2020-01-04 16:39:25 +03:00
|
|
|
#include "qif.h"
|
2020-01-05 14:55:57 +03:00
|
|
|
#include "quasarapp.h"
|
2020-01-13 18:25:03 +03:00
|
|
|
#include "deploycore.h"
|
|
|
|
#include "deployconfig.h"
|
2020-01-04 16:39:25 +03:00
|
|
|
|
2020-01-14 15:48:35 +03:00
|
|
|
#include <QDateTime>
|
2020-01-15 18:31:09 +03:00
|
|
|
#include <QProcess>
|
2020-01-14 15:48:35 +03:00
|
|
|
|
2020-01-15 18:31:09 +03:00
|
|
|
QIF::QIF(FileManager *fileManager)
|
|
|
|
:iDistribution(fileManager){
|
|
|
|
|
|
|
|
};
|
2020-01-04 16:39:25 +03:00
|
|
|
|
2020-01-05 13:58:38 +03:00
|
|
|
Envirement QIF::toolKitLocation() const {
|
2020-01-05 14:55:57 +03:00
|
|
|
Envirement result;
|
2020-01-15 18:31:09 +03:00
|
|
|
result.addEnv(QProcessEnvironment::systemEnvironment().value("PATH"));
|
|
|
|
|
|
|
|
// BASE
|
|
|
|
const DeployConfig *cfg = DeployCore::_config;
|
|
|
|
auto basePATH = cfg->qtDir.getBins() + "/../../../Tools/QtInstallerFramework/";
|
|
|
|
QDir QifDir(basePATH);
|
|
|
|
auto list = QifDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
|
|
|
|
|
|
QMap<double, QString> sortedItems;
|
|
|
|
for (const auto& i : list) {
|
|
|
|
sortedItems.insert(i.toDouble(), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sortedItems.size()) {
|
|
|
|
basePATH += ("/" + sortedItems.last() + "/bin");
|
|
|
|
result.addEnv(basePATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SNAP
|
2020-01-04 16:39:25 +03:00
|
|
|
|
2020-01-05 14:55:57 +03:00
|
|
|
QString AppPath = QuasarAppUtils::Params::getStrArg("appPath", "");
|
|
|
|
result.addEnv(AppPath);
|
|
|
|
|
|
|
|
//Installer
|
|
|
|
result.addEnvRec(AppPath + "../../QIF/", 2);
|
|
|
|
|
|
|
|
return result;
|
2020-01-04 16:39:25 +03:00
|
|
|
}
|
|
|
|
|
2020-01-05 13:58:38 +03:00
|
|
|
QString QIF::getConfig() const {
|
2020-01-05 14:55:57 +03:00
|
|
|
return ":/Distro/Distributions/configures/QIF.json";
|
2020-01-04 16:39:25 +03:00
|
|
|
}
|
|
|
|
|
2020-01-05 13:58:38 +03:00
|
|
|
QString QIF::runCmd() const {
|
2020-01-04 16:39:25 +03:00
|
|
|
return "binarycreator";
|
|
|
|
}
|
|
|
|
|
2020-01-14 15:48:35 +03:00
|
|
|
bool QIF::deployTemplate() const {
|
2020-01-05 14:55:57 +03:00
|
|
|
auto customTemplate = QuasarAppUtils::Params::getStrArg("qif", "");
|
2020-01-13 18:25:03 +03:00
|
|
|
const DeployConfig *cfg = DeployCore::_config;
|
|
|
|
|
|
|
|
if (customTemplate.isEmpty()) {
|
|
|
|
// default template
|
|
|
|
|
2020-01-15 11:50:30 +03:00
|
|
|
TemplateInfo generalInfo;
|
|
|
|
|
2020-01-15 18:31:09 +03:00
|
|
|
int number = 0;
|
2020-01-13 18:25:03 +03:00
|
|
|
for (auto it = cfg->prefixes().cbegin(); it != cfg->prefixes().cend(); ++it) {
|
2020-01-14 15:48:35 +03:00
|
|
|
auto package = it.value();
|
2020-01-13 18:25:03 +03:00
|
|
|
|
2020-01-14 15:48:35 +03:00
|
|
|
TemplateInfo info;
|
2020-01-15 18:31:09 +03:00
|
|
|
info.Name = (it.key().isEmpty())? "Application" + QString::number(number) : it.key();
|
|
|
|
if (!package.name().isEmpty()) {
|
2020-01-14 15:48:35 +03:00
|
|
|
info.Name = package.name();
|
2020-01-15 18:31:09 +03:00
|
|
|
}
|
2020-01-14 15:48:35 +03:00
|
|
|
|
|
|
|
info.Description = "This package contains the " + info.Name;
|
|
|
|
if (!package.description().isEmpty())
|
|
|
|
info.Description = package.description();
|
|
|
|
|
|
|
|
info.Version = "1.0";
|
|
|
|
if (!package.version().isEmpty())
|
|
|
|
info.Version = package.version();
|
|
|
|
|
|
|
|
info.ReleaseData = QDate::currentDate().toString();
|
|
|
|
if (!package.releaseData().isEmpty())
|
|
|
|
info.ReleaseData = package.releaseData();
|
2020-01-05 14:55:57 +03:00
|
|
|
|
2020-01-14 15:48:35 +03:00
|
|
|
info.Icon = "";
|
|
|
|
if (!package.icon().isEmpty())
|
|
|
|
info.Icon = package.icon();
|
2020-01-05 13:58:38 +03:00
|
|
|
|
2020-01-15 18:31:09 +03:00
|
|
|
info.Publisher = "Company";
|
2020-01-15 11:50:30 +03:00
|
|
|
if (!package.publisher().isEmpty())
|
|
|
|
info.Publisher = package.publisher();
|
|
|
|
|
2020-01-15 18:31:09 +03:00
|
|
|
auto location = cfg->getTargetDir() + "/" + getLocation() + "/packages/" + info.Name;
|
|
|
|
|
2020-01-15 11:50:30 +03:00
|
|
|
if (!unpackDir(":/Templates/QIF/Distributions/Templates/qif/packages/default", location, info)) {
|
2020-01-14 15:48:35 +03:00
|
|
|
return false;
|
|
|
|
}
|
2020-01-05 14:55:57 +03:00
|
|
|
|
2020-01-15 18:31:09 +03:00
|
|
|
if (!moveData(cfg->getTargetDir() + "/" + info.Name, location + "/data/")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-15 11:50:30 +03:00
|
|
|
generalInfo = info;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
auto configLocation = cfg->getTargetDir() + "/" + getLocation() + "/config/";
|
|
|
|
|
|
|
|
if (!unpackDir(":/Templates/QIF/Distributions/Templates/qif/config/",
|
|
|
|
configLocation, generalInfo)) {
|
|
|
|
return false;
|
2020-01-14 15:48:35 +03:00
|
|
|
}
|
|
|
|
|
2020-01-15 11:50:30 +03:00
|
|
|
|
2020-01-14 15:48:35 +03:00
|
|
|
return true;
|
2020-01-05 14:55:57 +03:00
|
|
|
}
|
2020-01-14 15:48:35 +03:00
|
|
|
|
|
|
|
// custom template
|
|
|
|
|
|
|
|
return true;
|
2020-01-05 13:58:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QIF::runArg() const {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-01-15 11:50:30 +03:00
|
|
|
bool QIF::removeTemplate() const {
|
|
|
|
auto customTemplate = QuasarAppUtils::Params::getStrArg("qif", "");
|
|
|
|
const DeployConfig *cfg = DeployCore::_config;
|
|
|
|
|
|
|
|
if (customTemplate.isEmpty()) {
|
|
|
|
return QDir(cfg->getTargetDir() + "/" + getLocation()).removeRecursively();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|