mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 02:34:34 +00:00
added multipaccking support
This commit is contained in:
parent
60980c4967
commit
ca36d2dc5f
Binary file not shown.
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 108 KiB |
@ -2,13 +2,35 @@
|
||||
|
||||
#include <deployconfig.h>
|
||||
#include <deploycore.h>
|
||||
#include <packagecontrol.h>
|
||||
#include <pathutils.h>
|
||||
|
||||
DefaultDistro::DefaultDistro(FileManager *fileManager)
|
||||
:iDistribution(fileManager){
|
||||
|
||||
};
|
||||
|
||||
bool DefaultDistro::deployTemplate(PackageControl &pkg) {
|
||||
bool DefaultDistro::deployTemplate(PackageControl & ctrl) {
|
||||
// default template
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
for (auto it = cfg->packages().begin();
|
||||
it != cfg->packages().end(); ++it) {
|
||||
auto package = it.value();
|
||||
QString Name = PathUtils::stripPath(it.key());
|
||||
|
||||
QString targetLocation;
|
||||
if (cfg->getDefaultPackage() == Name) {
|
||||
targetLocation = cfg->getTargetDir();
|
||||
} else {
|
||||
targetLocation = cfg->getTargetDir() + "/" + it.key();
|
||||
}
|
||||
|
||||
if (!ctrl.copyPackage(it.key(), targetLocation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,12 @@ bool iDistribution::unpackDir(const QString &resource,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool iDistribution::copyDir(const QString &resource,
|
||||
const QString &target) const {
|
||||
|
||||
return _fileManager->copyFolder(resource, target, {}, nullptr, nullptr, true);
|
||||
}
|
||||
|
||||
bool iDistribution::moveData(const QString &from,
|
||||
const QString &to,
|
||||
const QString& ignore) const {
|
||||
|
@ -43,6 +43,7 @@ protected:
|
||||
|
||||
bool moveData(const QString& from, const QString& to, const QString &ignore) const;
|
||||
bool copyFile(const QString& from, const QString& to, bool isFileTarget) const;
|
||||
bool copyDir(const QString &resource, const QString &target) const;
|
||||
|
||||
void registerOutFiles() const;
|
||||
|
||||
|
@ -20,7 +20,7 @@ Envirement QIF::toolKitEnv() const {
|
||||
if (QuasarAppUtils::Params::isEndable("qifFromSystem")) {
|
||||
result.addEnv(QProcessEnvironment::systemEnvironment().value("PATH"));
|
||||
|
||||
// BASE
|
||||
// BASE
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
auto basePATH = cfg->qtDir.getBins() + "/../../../Tools/QtInstallerFramework/";
|
||||
QDir QifDir(basePATH);
|
||||
@ -41,12 +41,12 @@ Envirement QIF::toolKitEnv() const {
|
||||
|
||||
|
||||
|
||||
// SNAP
|
||||
// SNAP
|
||||
|
||||
QString AppPath = QuasarAppUtils::Params::getStrArg("appPath", "");
|
||||
result.addEnv(AppPath + "/../QIF/");
|
||||
|
||||
//Installer
|
||||
//Installer
|
||||
result.addEnvRec(AppPath + "/../../QIF/", 2);
|
||||
|
||||
return result;
|
||||
@ -79,10 +79,12 @@ bool QIF::deployTemplate(PackageControl &pkg) {
|
||||
it != cfg->packages().end(); ++it) {
|
||||
auto package = it.value();
|
||||
|
||||
|
||||
TemplateInfo info;
|
||||
info.Name = PathUtils::stripPath(it.key());
|
||||
bool fDefaultPakcage = cfg->getDefaultPackage() == info.Name;
|
||||
|
||||
if (info.Name.isEmpty()) {
|
||||
if (fDefaultPakcage) {
|
||||
QFileInfo targetInfo(*package.targets().begin());
|
||||
info.Name = targetInfo.baseName();
|
||||
}
|
||||
@ -91,10 +93,11 @@ bool QIF::deployTemplate(PackageControl &pkg) {
|
||||
info.Name = package.name();
|
||||
}
|
||||
|
||||
auto location = cfg->getTargetDir() + "/" + getLocation() + "/packages/" +
|
||||
((it.key().isEmpty())? "Application": info.Name);
|
||||
|
||||
auto locationData = location + "/data/" + info.Name;
|
||||
auto location = cfg->getTargetDir() + "/" + getLocation() + "/packages/" + info.Name;
|
||||
auto locationData = location + "/data";
|
||||
if (cfg->getDefaultPackage() != info.Name) {
|
||||
locationData += "/" + info.Name;
|
||||
}
|
||||
|
||||
info.Description = "This package contains the " + info.Name;
|
||||
if (!package.description().isEmpty())
|
||||
@ -156,7 +159,8 @@ bool QIF::deployTemplate(PackageControl &pkg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
generalInfo = info;
|
||||
if (fDefaultPakcage)
|
||||
generalInfo = info;
|
||||
|
||||
}
|
||||
|
||||
@ -202,9 +206,9 @@ QStringList QIF::runArg() const {
|
||||
|
||||
return {
|
||||
"-c", location + "/config/config.xml",
|
||||
"-p", location + "/packages/",
|
||||
"-v",
|
||||
installerFile()
|
||||
"-p", location + "/packages/",
|
||||
"-v",
|
||||
installerFile()
|
||||
};
|
||||
}
|
||||
|
||||
@ -244,7 +248,7 @@ QString QIF::getStyle(const QString& input) const {
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log(input + " not exits",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ziparhive.h"
|
||||
|
||||
#include <deploycore.h>
|
||||
#include <packagecontrol.h>
|
||||
#include <pathutils.h>
|
||||
#include <zipcompresser.h>
|
||||
#include "deployconfig.h"
|
||||
@ -36,7 +37,7 @@ bool ZipArhive::deployTemplate(PackageControl &pkg) {
|
||||
auto location = cfg->getTargetDir() + "/" + getLocation() + "/" +
|
||||
((it.key().isEmpty())? "Application": info.Name);
|
||||
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.key(), location, getLocation())) {
|
||||
if (!pkg.movePackage(it.key(), location)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
* important : package in inputParamsList must be second.
|
||||
*/
|
||||
|
||||
static QString defaultPackage = "";
|
||||
static QString defaultPackage;
|
||||
|
||||
template<typename Container, typename Adder>
|
||||
bool parsePackagesPrivate(Container& mainContainer,
|
||||
@ -74,7 +74,7 @@ bool ConfigParser::parseParams() {
|
||||
if (QFile::exists(path)) {
|
||||
if (!loadFromFile(path)) {
|
||||
QuasarAppUtils::Params::log("failed to parse " + path,
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -85,22 +85,22 @@ bool ConfigParser::parseParams() {
|
||||
switch (DeployCore::getMode()) {
|
||||
case RunMode::Info: {
|
||||
QuasarAppUtils::Params::log("Print info ...",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
if (!parseInfoMode()) {
|
||||
QuasarAppUtils::Params::log("show info is failed!",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RunMode::Clear: {
|
||||
QuasarAppUtils::Params::log("clear ...",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
if (!parseClearMode()) {
|
||||
QuasarAppUtils::Params::log("clear is failed!",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -108,10 +108,10 @@ bool ConfigParser::parseParams() {
|
||||
|
||||
case RunMode::Init: {
|
||||
QuasarAppUtils::Params::log("Init ...",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
if (!parseInitMode()) {
|
||||
QuasarAppUtils::Params::log("init is failed!",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -119,11 +119,11 @@ bool ConfigParser::parseParams() {
|
||||
|
||||
case RunMode::Deploy: {
|
||||
QuasarAppUtils::Params::log("Deploy ...",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
if (!parseDeployMode()) {
|
||||
QuasarAppUtils::Params::log("deploy is failed!",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -135,7 +135,7 @@ bool ConfigParser::parseParams() {
|
||||
|
||||
if (createFile && !createFromDeploy(path)) {
|
||||
QuasarAppUtils::Params::log("Do not create a deploy config file in " + path,
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -147,7 +147,7 @@ const DeployConfig *ConfigParser::config() const {
|
||||
|
||||
// FIX ME. if package contains the path separators then package rewrite to RelativeLink of configFile location
|
||||
QJsonValue ConfigParser::writeKeyArray(int separatorLvl, const QString ¶meter,
|
||||
const QString &confFileDir) const {
|
||||
const QString &confFileDir) const {
|
||||
|
||||
auto list = parameter.split(DeployCore::getSeparator(separatorLvl));
|
||||
|
||||
@ -187,7 +187,7 @@ void ConfigParser::writeKey(const QString& key, QJsonObject& obj,
|
||||
}
|
||||
|
||||
QString ConfigParser::readKeyArray(int separatorLvl, const QJsonArray &array,
|
||||
const QString& confFileDir) const {
|
||||
const QString& confFileDir) const {
|
||||
|
||||
QStringList list;
|
||||
|
||||
@ -359,12 +359,12 @@ bool ConfigParser::initDistroStruct() {
|
||||
split(DeployCore::getSeparator(0), Qt::SkipEmptyParts);
|
||||
|
||||
auto erroLog = [](const QString &flag){
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
|
||||
// init distro stucts for all targets
|
||||
// init distro stucts for all targets
|
||||
if (binOut.size() && !parsePackagesPrivate(mainDistro, binOut, &DistroModule::setBinOutDir)) {
|
||||
erroLog("binOut");
|
||||
return false;
|
||||
@ -429,15 +429,15 @@ bool ConfigParser::initDistroStruct() {
|
||||
}
|
||||
|
||||
bool ConfigParser::initPackages() {
|
||||
defaultPackage = "Application";
|
||||
|
||||
defaultPackage = "";
|
||||
QSet<QString> configuredTargets;
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("targetPackage")) {
|
||||
auto tar_packages_array = QuasarAppUtils::Params::getStrArg("targetPackage", "").
|
||||
split(DeployCore::getSeparator(0));
|
||||
|
||||
|
||||
QSet<QString> configuredTargets;
|
||||
for (auto& str: tar_packages_array) {
|
||||
auto pair = str.split(DeployCore::getSeparator(1));
|
||||
auto package = PathUtils::fullStripPath(pair.value(0, ""));
|
||||
@ -460,9 +460,19 @@ bool ConfigParser::initPackages() {
|
||||
|
||||
QuasarAppUtils::Params::log(
|
||||
"Set Default Package to " + defaultPackage,
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
}
|
||||
|
||||
// init default packages
|
||||
for (auto it = _config.targetsEdit().begin(); it != _config.targetsEdit().end(); ++it) {
|
||||
if (!configuredTargets.contains(it.key())) {
|
||||
configuredTargets.insert(it.key());
|
||||
it.value().setPackage(defaultPackage);
|
||||
}
|
||||
}
|
||||
_config.packagesEdit().insert(defaultPackage, {});
|
||||
_config.setDefaultPackage(defaultPackage);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -477,12 +487,12 @@ bool ConfigParser::initQmlInput() {
|
||||
}
|
||||
|
||||
auto erroLog = [](const QString &flag){
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
|
||||
// init distro stucts for all targets
|
||||
// init distro stucts for all targets
|
||||
_config.deployQml = qmlDir.size();
|
||||
|
||||
if (qmlDir.size() && !parsePackagesPrivate(_config.packagesEdit(), qmlDir, &DistroModule::addQmlInput)) {
|
||||
@ -511,7 +521,7 @@ bool ConfigParser::parseDeployMode() {
|
||||
auto binDir = QuasarAppUtils::Params::getStrArg("binDir");
|
||||
if (!setTargetsRecursive(binDir)) {
|
||||
QuasarAppUtils::Params::log("setTargetDir fail!",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -524,7 +534,7 @@ bool ConfigParser::parseDeployMode() {
|
||||
if (!ok) {
|
||||
_config.depchLimit = 0;
|
||||
QuasarAppUtils::Params::log("recursiveDepth is invalid! use default value 0",
|
||||
QuasarAppUtils::Warning);
|
||||
QuasarAppUtils::Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,7 +570,7 @@ bool ConfigParser::parseDeployMode() {
|
||||
|
||||
bool ConfigParser::parseInfoMode() {
|
||||
if ((QuasarAppUtils::Params::isEndable("v") ||
|
||||
QuasarAppUtils::Params::isEndable("version"))) {
|
||||
QuasarAppUtils::Params::isEndable("version"))) {
|
||||
DeployCore::printVersion();
|
||||
return true;
|
||||
}
|
||||
@ -635,7 +645,7 @@ void ConfigParser::setTargetDir(const QString &target) {
|
||||
|
||||
_config.setTargetDir(QFileInfo("./" + DISTRO_DIR).absoluteFilePath());
|
||||
QuasarAppUtils::Params::log("flag targetDir not used. use default target dir :" + _config.getTargetDir(),
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,14 +668,14 @@ bool ConfigParser::setTargets(const QStringList &value) {
|
||||
else if (targetInfo.isDir()) {
|
||||
if (!setBinDir(i)) {
|
||||
QuasarAppUtils::Params::log(i + " du not contains executable binaries!",
|
||||
QuasarAppUtils::Debug);
|
||||
QuasarAppUtils::Debug);
|
||||
continue;
|
||||
}
|
||||
isfillList = true;
|
||||
|
||||
} else {
|
||||
QuasarAppUtils::Params::log(targetInfo.absoluteFilePath() + " not exits!",
|
||||
QuasarAppUtils::Debug);
|
||||
QuasarAppUtils::Debug);
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,7 +690,7 @@ bool ConfigParser::setTargets(const QStringList &value) {
|
||||
bool ConfigParser::setTargetsRecursive(const QString &dir) {
|
||||
if (!setBinDir(dir, true)) {
|
||||
QuasarAppUtils::Params::log("setBinDir failed!",
|
||||
QuasarAppUtils::Warning);
|
||||
QuasarAppUtils::Warning);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -693,11 +703,11 @@ bool ConfigParser::setBinDir(const QString &dir, bool recursive) {
|
||||
QDir d(dir);
|
||||
if (dir.isEmpty() || !d.exists()) {
|
||||
QuasarAppUtils::Params::log(dir + " dir not exits!",
|
||||
QuasarAppUtils::Debug);
|
||||
QuasarAppUtils::Debug);
|
||||
return false;
|
||||
}
|
||||
QuasarAppUtils::Params::log("setBinDir check path: " + dir,
|
||||
QuasarAppUtils::Debug);
|
||||
QuasarAppUtils::Debug);
|
||||
QFileInfoList list;
|
||||
|
||||
if (recursive) {
|
||||
@ -718,7 +728,7 @@ bool ConfigParser::setBinDir(const QString &dir, bool recursive) {
|
||||
auto sufix = file.completeSuffix();
|
||||
|
||||
if (sufix.isEmpty() || name.contains(".dll", Qt::CaseInsensitive) ||
|
||||
name.contains(".so", Qt::CaseInsensitive) || name.contains(".exe", Qt::CaseInsensitive)) {
|
||||
name.contains(".so", Qt::CaseInsensitive) || name.contains(".exe", Qt::CaseInsensitive)) {
|
||||
|
||||
result = true;
|
||||
|
||||
@ -726,7 +736,7 @@ bool ConfigParser::setBinDir(const QString &dir, bool recursive) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -885,16 +895,16 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) {
|
||||
|
||||
if (!dir.cdUp()) {
|
||||
QuasarAppUtils::Params::log("fail init qmake",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log("exec qmake fail!, try init qtDir from path:" + dir.absolutePath(),
|
||||
QuasarAppUtils::Warning);
|
||||
QuasarAppUtils::Warning);
|
||||
|
||||
if (!setQtDir(dir.absolutePath())){
|
||||
QuasarAppUtils::Params::log("fail ini qmake",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -920,22 +930,22 @@ bool ConfigParser::initQmake() {
|
||||
auto proc = DeployCore::findProcess(env.value("PATH"), "qmake");
|
||||
if (proc.isEmpty()) {
|
||||
QuasarAppUtils::Params::log("The deployment target requir Qt libs, but init qmake is failed.",
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return initQmakePrivate(proc);
|
||||
}
|
||||
QuasarAppUtils::Params::log("deploy only C libs because qmake is not found",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (qtList.size() > 1) {
|
||||
QuasarAppUtils::Params::log("Your deployment targets were compiled by different qmake,"
|
||||
"qt auto-capture is not possible. Use the -qmake flag to solve this problem.",
|
||||
QuasarAppUtils::Error);
|
||||
"qt auto-capture is not possible. Use the -qmake flag to solve this problem.",
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -955,7 +965,7 @@ bool ConfigParser::setQmake(const QString &value) {
|
||||
auto qmakeInfo = QFileInfo(QDir::fromNativeSeparators(value));
|
||||
|
||||
if (!(qmakeInfo.fileName().compare("qmake", Qt::CaseInsensitive) ||
|
||||
qmakeInfo.fileName().compare("qmake.exe", Qt::CaseInsensitive))) {
|
||||
qmakeInfo.fileName().compare("qmake.exe", Qt::CaseInsensitive))) {
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1078,7 +1088,7 @@ void ConfigParser::setExtraPath(const QStringList &value) {
|
||||
if (info.isDir()) {
|
||||
if (_config.targets().contains(info.absoluteFilePath())) {
|
||||
QuasarAppUtils::Params::log("skip the extra lib path because it is target!",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1092,11 +1102,11 @@ void ConfigParser::setExtraPath(const QStringList &value) {
|
||||
_config.extraPaths.addExtraPathsMasks({i});
|
||||
|
||||
QuasarAppUtils::Params::log(i + " added like a path mask",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
} else {
|
||||
QuasarAppUtils::Params::log(i + " not added in path mask because"
|
||||
" the path mask must be large 2 characters",
|
||||
QuasarAppUtils::Warning);
|
||||
" the path mask must be large 2 characters",
|
||||
QuasarAppUtils::Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1107,11 +1117,11 @@ void ConfigParser::setExtraNames(const QStringList &value) {
|
||||
_config.extraPaths.addtExtraNamesMasks({i});
|
||||
|
||||
QuasarAppUtils::Params::log(i + " added like a file name mask",
|
||||
QuasarAppUtils::Info);
|
||||
QuasarAppUtils::Info);
|
||||
} else {
|
||||
QuasarAppUtils::Params::log(i + " not added in file mask because"
|
||||
" the file mask must be large 2 characters",
|
||||
QuasarAppUtils::Warning);
|
||||
" the file mask must be large 2 characters",
|
||||
QuasarAppUtils::Warning);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1129,10 +1139,10 @@ bool ConfigParser::initPlugins() {
|
||||
split(DeployCore::getSeparator(0), Qt::SkipEmptyParts);
|
||||
|
||||
auto erroLog = [](const QString &flag){
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
QuasarAppUtils::Params::log(QString("Set %0 fail, because you try set %0 for not inited package."
|
||||
" Use 'targetPackage' flag for init the packages").arg(flag),
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
|
||||
|
||||
if (listExtraPlugin.size() && !parsePackagesPrivate(_config.packagesEdit(),
|
||||
@ -1183,9 +1193,11 @@ QList<iDistribution *> ConfigParser::getDistribution() {
|
||||
distros.push_back(new QIF(_fileManager));
|
||||
}
|
||||
|
||||
distros.push_back(new DefaultDistro(_fileManager));
|
||||
if (distros.isEmpty()) {
|
||||
distros.push_back(new DefaultDistro(_fileManager));
|
||||
}
|
||||
|
||||
return distros;
|
||||
return distros;
|
||||
}
|
||||
|
||||
void ConfigParser::initEnvirement() {
|
||||
@ -1215,7 +1227,7 @@ void ConfigParser::initEnvirement() {
|
||||
|
||||
if (_config.envirement.size() < 2) {
|
||||
QuasarAppUtils::Params::log("system environment is empty",
|
||||
QuasarAppUtils::Warning);
|
||||
QuasarAppUtils::Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1237,13 +1249,13 @@ bool ConfigParser::checkSnapPermisions() {
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
QuasarAppUtils::Params::log(
|
||||
"'snap connect cqtdeployer:system-backup :system-backup'",
|
||||
QuasarAppUtils::Info);
|
||||
"'snap connect cqtdeployer:system-backup :system-backup'",
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
QuasarAppUtils::Params::log(
|
||||
"GUI: Open the gnome system setting >> Applications >> CQtDeployer. "
|
||||
"in menu rights and permisions enable system-backup.",
|
||||
QuasarAppUtils::Info);
|
||||
"GUI: Open the gnome system setting >> Applications >> CQtDeployer. "
|
||||
"in menu rights and permisions enable system-backup.",
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -104,5 +104,8 @@ bool Deploy::deploy() {
|
||||
|
||||
bool Deploy::packing() {
|
||||
|
||||
if (DeployCore::getMode() != RunMode::Deploy)
|
||||
return true;
|
||||
|
||||
return _packing->create();
|
||||
}
|
||||
|
@ -79,6 +79,15 @@ Platform DeployConfig::getPlatform(const QString& package) const {
|
||||
|
||||
}
|
||||
|
||||
QString DeployConfig::getDefaultPackage() const {
|
||||
return defaultPackage;
|
||||
}
|
||||
|
||||
void DeployConfig::setDefaultPackage(const QString &value)
|
||||
{
|
||||
defaultPackage = value;
|
||||
}
|
||||
|
||||
const QHash<QString, TargetInfo> &DeployConfig::targets() const {
|
||||
return _targets;
|
||||
}
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
|
||||
Platform getPlatform(const QString& package) const;
|
||||
|
||||
QString getDefaultPackage() const;
|
||||
void setDefaultPackage(const QString &value);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -109,6 +112,8 @@ private:
|
||||
* @brief targetDir - targe directory (this folder conteins all files of distrebution kit)
|
||||
*/
|
||||
QString targetDir = "";
|
||||
QString defaultPackage = "";
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -282,7 +282,7 @@ bool FileManager::moveFile(const QString &file, const QString &target, QStringLi
|
||||
}
|
||||
|
||||
bool FileManager::copyFolder(const QString &from, const QString &to, const QStringList &filter,
|
||||
QStringList *listOfCopiedItems, QStringList *mask) {
|
||||
QStringList *listOfCopiedItems, QStringList *mask, bool force) {
|
||||
|
||||
QDir fromDir(from);
|
||||
|
||||
@ -291,37 +291,39 @@ bool FileManager::copyFolder(const QString &from, const QString &to, const QStri
|
||||
for (const auto &item : list) {
|
||||
if (QFileInfo(item).isDir()) {
|
||||
|
||||
copyFolder(item.absoluteFilePath(), to + "/" + item.fileName(), filter, listOfCopiedItems, mask);
|
||||
copyFolder(item.absoluteFilePath(), to + "/" + item.fileName(), filter, listOfCopiedItems, mask, force);
|
||||
} else {
|
||||
|
||||
QString skipFilter = "";
|
||||
for (const auto &i: filter) {
|
||||
if (item.fileName().contains(i, ONLY_WIN_CASE_INSENSIATIVE)) {
|
||||
skipFilter = i;
|
||||
break;
|
||||
if (!force) {
|
||||
QString skipFilter = "";
|
||||
for (const auto &i: filter) {
|
||||
if (item.fileName().contains(i, ONLY_WIN_CASE_INSENSIATIVE)) {
|
||||
skipFilter = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipFilter.isEmpty()) {
|
||||
QuasarAppUtils::Params::log(
|
||||
item.absoluteFilePath() + " ignored by filter " + skipFilter,
|
||||
QuasarAppUtils::VerboseLvl::Debug);
|
||||
continue;
|
||||
}
|
||||
auto config = DeployCore::_config;
|
||||
|
||||
LibInfo info;
|
||||
info.setName(item.fileName());
|
||||
info.setPath(item.absolutePath());
|
||||
info.setPlatform(GeneralFile);
|
||||
|
||||
if (config)
|
||||
if (auto rule = config->ignoreList.isIgnore(info)) {
|
||||
if (!skipFilter.isEmpty()) {
|
||||
QuasarAppUtils::Params::log(
|
||||
item.absoluteFilePath() + " ignored by rule " + rule->label,
|
||||
item.absoluteFilePath() + " ignored by filter " + skipFilter,
|
||||
QuasarAppUtils::VerboseLvl::Debug);
|
||||
continue;
|
||||
}
|
||||
auto config = DeployCore::_config;
|
||||
|
||||
LibInfo info;
|
||||
info.setName(item.fileName());
|
||||
info.setPath(item.absolutePath());
|
||||
info.setPlatform(GeneralFile);
|
||||
|
||||
if (config)
|
||||
if (auto rule = config->ignoreList.isIgnore(info)) {
|
||||
QuasarAppUtils::Params::log(
|
||||
item.absoluteFilePath() + " ignored by rule " + rule->label,
|
||||
QuasarAppUtils::VerboseLvl::Debug);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!copyFile(item.absoluteFilePath(), to , mask)) {
|
||||
QuasarAppUtils::Params::log(
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
bool copyFolder(const QString &from, const QString &to,
|
||||
const QStringList &filter = QStringList(),
|
||||
QStringList *listOfCopiedItems = nullptr,
|
||||
QStringList *mask = nullptr);
|
||||
QStringList *mask = nullptr, bool force = false);
|
||||
|
||||
bool moveFolder(const QString &from, const QString &to, const QString &ignore = "");
|
||||
|
||||
|
@ -13,6 +13,8 @@ public:
|
||||
PackageControl();
|
||||
virtual bool movePackage(const QString& package,
|
||||
const QString& newLocation) = 0;
|
||||
virtual bool copyPackage(const QString& package,
|
||||
const QString& newLocation) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
|
||||
#define TMP_PACKAGE_DIR "tmp_data"
|
||||
|
||||
Packing::Packing(FileManager *fileManager) {
|
||||
assert(fileManager);
|
||||
|
||||
@ -27,7 +29,7 @@ Packing::~Packing() {
|
||||
}
|
||||
|
||||
void Packing::setDistribution(const QList<iDistribution*> &pakages) {
|
||||
_pakage = pakages;
|
||||
_pakages = pakages;
|
||||
}
|
||||
|
||||
bool Packing::create() {
|
||||
@ -36,7 +38,7 @@ bool Packing::create() {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto package : _pakage) {
|
||||
for (auto package : _pakages) {
|
||||
|
||||
if (!package)
|
||||
return false;
|
||||
@ -87,9 +89,11 @@ bool Packing::create() {
|
||||
}
|
||||
|
||||
package->removeTemplate();
|
||||
delete package;
|
||||
}
|
||||
|
||||
return true;
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
return QDir(cfg->getTargetDir() + "/" + TMP_PACKAGE_DIR).removeRecursively();
|
||||
}
|
||||
|
||||
bool Packing::movePackage(const QString &package,
|
||||
@ -105,45 +109,18 @@ bool Packing::movePackage(const QString &package,
|
||||
return false;
|
||||
}
|
||||
|
||||
QMultiMap<int ,QPair<QString, const DistroModule*>>
|
||||
sortPackages(const QHash<QString, DistroModule> &input) {
|
||||
QMultiMap<int, QPair<QString, const DistroModule *>> result;
|
||||
for (auto it = input.cbegin(); it != input.cend(); ++it ) {
|
||||
result.insert(0xFFFF - it.key().size(), {it.key(), &it.value()});
|
||||
}
|
||||
|
||||
return result;
|
||||
bool Packing::copyPackage(const QString &package, const QString &newLocation) {
|
||||
return _fileManager->copyFolder(_packagesLocations[package], newLocation, {}, nullptr, nullptr, true);
|
||||
}
|
||||
|
||||
bool Packing::collectPackages() {
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
auto sortedMap = sortPackages(cfg->packages());
|
||||
|
||||
for (auto &it : sortedMap) {
|
||||
auto package = it.second;
|
||||
|
||||
QString Name = PathUtils::stripPath(it.first);
|
||||
|
||||
if (Name.isEmpty()) {
|
||||
QFileInfo targetInfo(*package->targets().begin());
|
||||
Name = targetInfo.baseName();
|
||||
}
|
||||
|
||||
if (!package->name().isEmpty()) {
|
||||
Name = package->name();
|
||||
}
|
||||
|
||||
QString tmpPakcageLocation = "tmp_data";
|
||||
auto location = cfg->getTargetDir() + "/" + tmpPakcageLocation + "/" +
|
||||
((it.first.isEmpty())? "Application": Name);
|
||||
|
||||
|
||||
_packagesLocations.insert(it.first, location);
|
||||
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.first, location, tmpPakcageLocation)) {
|
||||
for (auto it = cfg->packages().begin(); it != cfg->packages().end(); ++it) {
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.key(), cfg->getTargetDir() + "/" + TMP_PACKAGE_DIR + "/" + it.key()))
|
||||
return false;
|
||||
}
|
||||
|
||||
_packagesLocations.insert(it.key(), cfg->getTargetDir() + "/" + TMP_PACKAGE_DIR + "/" + it.key());
|
||||
}
|
||||
|
||||
_defaultPackagesLocations = _packagesLocations;
|
||||
@ -151,7 +128,14 @@ bool Packing::collectPackages() {
|
||||
}
|
||||
|
||||
bool Packing::moveData(const QString &from, const QString &to, const QString &ignore) const {
|
||||
return _fileManager->moveFolder(from, to, ignore);
|
||||
|
||||
if (from == to )
|
||||
return true;
|
||||
|
||||
if (!_fileManager->moveFolder(from, to, ignore)) {
|
||||
return false;
|
||||
}
|
||||
return QDir(from).removeRecursively();
|
||||
}
|
||||
|
||||
bool Packing::restorePackagesLocations() {
|
||||
@ -160,6 +144,7 @@ bool Packing::restorePackagesLocations() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_packagesLocations = _defaultPackagesLocations;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
bool create();
|
||||
|
||||
bool movePackage(const QString &package, const QString &newLocation);
|
||||
bool copyPackage(const QString &package, const QString &newLocation);
|
||||
|
||||
private:
|
||||
|
||||
@ -34,7 +35,7 @@ private:
|
||||
|
||||
bool restorePackagesLocations();
|
||||
|
||||
QList<iDistribution*> _pakage;
|
||||
QList<iDistribution*> _pakages;
|
||||
QProcess *_proc = nullptr;
|
||||
QHash<QString, QString> _packagesLocations;
|
||||
QHash<QString, QString> _defaultPackagesLocations;
|
||||
|
@ -637,8 +637,8 @@ void deploytest::testQIF() {
|
||||
"-qmlDir", TestBinDir + "/../TestQMLWidgets",
|
||||
"qif", "qifFromSystem",
|
||||
"-qifStyle", "quasar",
|
||||
"-qifBanner", TestBinDir + "/../../res/cqtdeployer banner.png",
|
||||
"-qifLogo", TestBinDir + "/../../res/icon.png",
|
||||
"-qifBanner", TestBinDir + "/../../res/CQtDeployer_banner_web.png",
|
||||
"-qifLogo", TestBinDir + "/../../res/CQtDeployer defaultIcon_web.png",
|
||||
"verbose"}, &comapareTree, {}, true);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user