81 lines
1.9 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-11-10 14:07:54 +03:00
bool fDefaultPakcage;
2020-12-02 17:53:14 +03:00
if (!collectInfo(package, it.key(), cfg, info, fDefaultPakcage)) {
return false;
2020-11-09 16:33:50 +03:00
}
2020-08-14 17:47:34 +03:00
auto local = location(info.Name);
2020-08-14 17:47:34 +03:00
if (!pkg.movePackage(it.key(), local)) {
2020-08-14 17:47:34 +03:00
return false;
}
auto arr = cfg->getTargetDir() + "/" + info.Name + ".zip";
if (!zipWorker.compress(local, arr)) {
return false;
}
2020-08-14 17:47:34 +03:00
outFiles.push_back(arr);
}
return true;
}
bool ZipArhive::removeTemplate() const {
const DeployConfig *cfg = DeployCore::_config;
registerOutFiles();
return QDir(cfg->getTargetDir() + "/" + getLocation()).removeRecursively();
}
Envirement ZipArhive::toolKitEnv() const {
return {};
}
QProcessEnvironment ZipArhive::processEnvirement() const {
return QProcessEnvironment::systemEnvironment();
}
QList<SystemCommandData> ZipArhive::runCmd() {
2020-08-14 17:47:34 +03:00
return {};
}
QStringList ZipArhive::outPutFiles() const {
return outFiles;
}
QString ZipArhive::dataLocation(const QString &packageName) const {
return location(packageName);
}
QString ZipArhive::location(const QString &packageName) const {
const DeployConfig *cfg = DeployCore::_config;
return cfg->getTargetDir() + "/" + getLocation() + "/" + packageName;
}