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-12-03 20:00:14 +03:00
if (!collectInfo(package, info)) {
return false;
2020-11-09 16:33:50 +03:00
}
2020-08-14 17:47:34 +03:00
2020-12-03 20:00:14 +03:00
auto local = location(it.value());
auto dataLoc = dataLocation(it.value());
2020-08-14 17:47:34 +03:00
2020-12-03 20:00:14 +03:00
if (!pkg.movePackage(it.key(), dataLoc)) {
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;
}
2020-12-03 20:00:14 +03:00
QString ZipArhive::dataLocation(const DistroModule &module) const {
return location(module) + "/" + releativeLocation(module);
}
2020-12-03 20:00:14 +03:00
QString ZipArhive::location(const DistroModule &module) const {
const DeployConfig *cfg = DeployCore::_config;
2020-12-03 20:00:14 +03:00
return cfg->getTargetDir() + "/" + getLocation() + "/" + module.key();
}