82 lines
1.8 KiB
C++
Raw Normal View History

2020-08-14 17:47:34 +03:00
#include "ziparhive.h"
#include <deploycore.h>
2020-08-15 19:29:17 +03:00
#include <packagecontrol.h>
2020-08-14 17:47:34 +03:00
#include <pathutils.h>
#include <zipcompresser.h>
#include "deployconfig.h"
#include "quasarapp.h"
ZipArhive::ZipArhive(FileManager *fileManager)
:iDistribution(fileManager) {
setLocation("tmp zip");
}
2020-08-15 14:38:03 +03:00
bool ZipArhive::deployTemplate(PackageControl &pkg) {
2020-08-14 17:47:34 +03:00
// default template
const DeployConfig *cfg = DeployCore::_config;
ZipCompresser zipWorker;
2020-08-15 14:38:03 +03:00
for (auto it = cfg->packages().begin();
it != cfg->packages().end(); ++it) {
auto package = it.value();
2020-08-14 17:47:34 +03:00
TemplateInfo info;
2020-08-15 14:38:03 +03:00
info.Name = PathUtils::stripPath(it.key());
2020-08-14 17:47:34 +03:00
if (info.Name.isEmpty()) {
2020-08-15 14:38:03 +03:00
QFileInfo targetInfo(*package.targets().begin());
2020-08-14 17:47:34 +03:00
info.Name = targetInfo.baseName();
}
2020-08-15 14:38:03 +03:00
if (!package.name().isEmpty()) {
info.Name = package.name();
2020-08-14 17:47:34 +03:00
}
auto location = cfg->getTargetDir() + "/" + getLocation() + "/" +
2020-08-15 14:38:03 +03:00
((it.key().isEmpty())? "Application": info.Name);
2020-08-14 17:47:34 +03:00
2020-08-15 19:29:17 +03:00
if (!pkg.movePackage(it.key(), location)) {
2020-08-14 17:47:34 +03:00
return false;
}
auto arr = cfg->getTargetDir() + info.Name + ".zip";
zipWorker.compress(location, arr);
outFiles.push_back(arr);
}
return true;
}
bool ZipArhive::removeTemplate() const {
const DeployConfig *cfg = DeployCore::_config;
registerOutFiles();
return QDir(cfg->getTargetDir() + "/" + getLocation()).removeRecursively();
return true;
}
Envirement ZipArhive::toolKitEnv() const {
return {};
}
QProcessEnvironment ZipArhive::processEnvirement() const {
return QProcessEnvironment::systemEnvironment();
}
QString ZipArhive::runCmd() {
return "";
}
QStringList ZipArhive::runArg() const {
return {};
}
QStringList ZipArhive::outPutFiles() const {
return outFiles;
}