2018-08-19 11:00:13 +03:00
|
|
|
/*
|
2019-12-08 13:57:20 +03:00
|
|
|
* Copyright (C) 2018-2020 QuasarApp.
|
2018-08-19 11:00:13 +03:00
|
|
|
* Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
2018-10-24 17:26:42 +03:00
|
|
|
*/
|
2018-08-19 11:00:13 +03:00
|
|
|
|
2019-09-14 13:59:11 +03:00
|
|
|
#include "configparser.h"
|
2018-08-17 20:47:49 +03:00
|
|
|
#include "deploy.h"
|
2019-09-08 13:37:33 +03:00
|
|
|
#include "extracter.h"
|
|
|
|
#include "filemanager.h"
|
2020-01-04 16:39:25 +03:00
|
|
|
#include "packing.h"
|
2018-10-24 17:26:42 +03:00
|
|
|
#include <quasarapp.h>
|
2019-08-24 01:04:36 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
Deploy::Deploy() {
|
|
|
|
_fileManager = new FileManager();
|
2019-11-13 18:18:44 +03:00
|
|
|
_scaner = new DependenciesScanner();
|
2020-01-04 16:39:25 +03:00
|
|
|
_packing = new Packing();
|
|
|
|
_paramsParser = new ConfigParser(_fileManager, _scaner, _packing);
|
2019-11-13 18:18:44 +03:00
|
|
|
|
2020-01-20 13:24:01 +03:00
|
|
|
connect(this, &Deploy::sigStart, this, &Deploy::handleStart, Qt::QueuedConnection);
|
2019-09-09 18:12:39 +03:00
|
|
|
}
|
|
|
|
|
2020-01-20 13:24:01 +03:00
|
|
|
int Deploy::run(bool async) {
|
|
|
|
if (async) {
|
|
|
|
emit sigStart();
|
2020-01-20 14:29:06 +03:00
|
|
|
return Good;
|
2020-01-04 16:39:25 +03:00
|
|
|
}
|
|
|
|
|
2020-01-20 13:24:01 +03:00
|
|
|
return runPrivate();
|
2019-09-09 18:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Deploy::~Deploy() {
|
|
|
|
|
|
|
|
if (_extracter) {
|
|
|
|
delete _extracter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_paramsParser) {
|
|
|
|
delete _paramsParser;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_fileManager) {
|
|
|
|
delete _fileManager;
|
|
|
|
}
|
2019-11-13 18:18:44 +03:00
|
|
|
|
|
|
|
if (_scaner) {
|
|
|
|
delete _scaner;
|
|
|
|
}
|
2018-08-18 22:36:28 +03:00
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
bool Deploy::prepare() {
|
2020-01-04 16:39:25 +03:00
|
|
|
|
|
|
|
|
2019-09-09 18:12:39 +03:00
|
|
|
if ( !_paramsParser->parseParams()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-11-13 18:18:44 +03:00
|
|
|
_extracter = new Extracter(_fileManager, _paramsParser, _scaner);
|
2019-09-09 18:12:39 +03:00
|
|
|
|
|
|
|
return true;
|
2019-06-19 22:48:19 +03:00
|
|
|
}
|
|
|
|
|
2020-01-04 16:39:25 +03:00
|
|
|
bool Deploy::deploy() {
|
2019-09-10 18:22:49 +03:00
|
|
|
|
2019-12-12 22:50:04 +03:00
|
|
|
_fileManager->loadDeployemendFiles(_paramsParser->config()->getTargetDir());
|
2019-09-16 10:56:22 +03:00
|
|
|
|
|
|
|
switch (DeployCore::getMode() ) {
|
|
|
|
case RunMode::Deploy:
|
|
|
|
_extracter->deploy();
|
|
|
|
break;
|
|
|
|
case RunMode::Clear:
|
|
|
|
_extracter->clear();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-12-12 22:50:04 +03:00
|
|
|
_fileManager->saveDeploymendFiles(_paramsParser->config()->getTargetDir());
|
2019-05-25 19:09:43 +03:00
|
|
|
|
2020-01-04 16:39:25 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:24:01 +03:00
|
|
|
bool Deploy::packing(bool async) {
|
|
|
|
if (async) {
|
|
|
|
connect(_packing, &Packing::sigFinished, this, &Deploy::sigFinish, Qt::QueuedConnection);
|
|
|
|
}
|
2020-01-04 16:39:25 +03:00
|
|
|
|
2020-01-20 13:24:01 +03:00
|
|
|
return _packing->create(async);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Deploy::runPrivate(bool async) {
|
|
|
|
if (!prepare()) {
|
2020-01-20 14:29:06 +03:00
|
|
|
return PrepareError;
|
2020-01-20 13:24:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!deploy()) {
|
2020-01-20 14:29:06 +03:00
|
|
|
return DeployError;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (async) {
|
|
|
|
if (!packing(async))
|
|
|
|
return PackingError;
|
|
|
|
|
|
|
|
return ASyncGood;
|
2020-01-20 13:24:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!packing(async))
|
2020-01-20 14:29:06 +03:00
|
|
|
return PackingError;
|
2020-01-20 13:24:01 +03:00
|
|
|
|
2020-01-20 14:29:06 +03:00
|
|
|
return Good;
|
2020-01-20 13:24:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::handleStart() {
|
2020-01-20 15:43:00 +03:00
|
|
|
int exit = runPrivate(true);
|
|
|
|
if (exit == ASyncGood) {
|
|
|
|
return;
|
2020-01-20 13:24:01 +03:00
|
|
|
}
|
2020-01-20 15:43:00 +03:00
|
|
|
|
|
|
|
emit sigFinish(exit);
|
2019-01-16 22:17:49 +03:00
|
|
|
}
|