diff --git a/src/Deploy/src/configparser.cpp b/src/Deploy/src/configparser.cpp index 258ea18..a41d262 100644 --- a/src/Deploy/src/configparser.cpp +++ b/src/Deploy/src/configparser.cpp @@ -23,6 +23,7 @@ #include #include #include +#include /** @@ -740,7 +741,7 @@ bool ConfigParser::parseDeployMode(bool checkBin) { if (!initQmake()) { - if (DeployCore::isSnap()) { + if (QuasarAppUtils::PlatformUtils::isSnap()) { QuasarAppUtils::Params::log("If you are using qmake from the system repository," " then you must use the classic version of CQtDeployer instead of the snap version." " This is due to the fact that the snap version" @@ -1024,9 +1025,11 @@ void ConfigParser::initIgnoreList() envUnix.addEnv(Envirement::recursiveInvairement("/lib", 3)); envUnix.addEnv(Envirement::recursiveInvairement("/usr/lib", 3)); - if (DeployCore::isSnap()) { - envUnix.addEnv(Envirement::recursiveInvairement(DeployCore::transportPathToSnapRoot("/lib"), 3)); - envUnix.addEnv(Envirement::recursiveInvairement(DeployCore::transportPathToSnapRoot("/usr/lib"), 3)); + if (QuasarAppUtils::PlatformUtils::isSnap()) { + envUnix.addEnv(Envirement::recursiveInvairement( + QuasarAppUtils::PlatformUtils::transportPathToSnapRoot("/lib"), 3)); + envUnix.addEnv(Envirement::recursiveInvairement( + QuasarAppUtils::PlatformUtils::transportPathToSnapRoot("/usr/lib"), 3)); } ruleUnix.prority = SystemLib; @@ -1113,7 +1116,7 @@ void ConfigParser::initIgnoreEnvList() { } // forbid pathes of the snap container - if (DeployCore::isSnap()) { + if (QuasarAppUtils::PlatformUtils::isSnap()) { ignoreEnvList.push_back("/lib"); ignoreEnvList.push_back("/usr/lib"); } @@ -1134,7 +1137,7 @@ QString ConfigParser::getPathFrmoQmakeLine(const QString &in) const { auto list = in.split(':'); if (list.size() > 1) { list.removeAt(0); - return DeployCore::transportPathToSnapRoot( + return QuasarAppUtils::PlatformUtils::transportPathToSnapRoot( QFileInfo(list.join(':')).absoluteFilePath().remove('\r')); } @@ -1151,7 +1154,7 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) { // Invoke qmake executable only when qmake paths exclude snapRootFS path. // Because files in snapRootFS is not executable ... - if (!qmake.contains(DeployCore::snapRootFS()) && setQmake(qmake)) { + if (!qmake.contains(QuasarAppUtils::PlatformUtils::snapRootFS()) && setQmake(qmake)) { return true; } @@ -1167,8 +1170,8 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) { QString debianQtRoot = QString("/usr/lib/%0/qt%1"). arg(neededPlatform).arg(qtVersion); - if (DeployCore::isSnap()) { - debianQtRoot = DeployCore::snapRootFS() + debianQtRoot; + if (QuasarAppUtils::PlatformUtils::isSnap()) { + debianQtRoot = QuasarAppUtils::PlatformUtils::snapRootFS() + debianQtRoot; } if (!setQtDir(debianQtRoot)) { @@ -1189,7 +1192,7 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) { } // For snap package of cqtdeplyer it is normal behavior - if (!DeployCore::isSnap()) { + if (!QuasarAppUtils::PlatformUtils::isSnap()) { QuasarAppUtils::Params::log("Failed to execute the qmake process!" " Trying to initialize Qt directories from path: " + dir.absolutePath(), QuasarAppUtils::Warning); @@ -1214,7 +1217,8 @@ bool ConfigParser::initQmake() { return true; } - auto qmake = DeployCore::transportPathToSnapRoot(QuasarAppUtils::Params::getArg("qmake")); + auto qmake = QuasarAppUtils::PlatformUtils::transportPathToSnapRoot( + QuasarAppUtils::Params::getArg("qmake")); QFileInfo info(qmake); @@ -1409,7 +1413,7 @@ bool ConfigParser::initExtraPath() { QDir dir; for (const auto &i : listLibDir) { - QFileInfo info(DeployCore::transportPathToSnapRoot(i)); + QFileInfo info(QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(i)); if (info.isDir()) { if (_config.targets().contains(info.absoluteFilePath())) { QuasarAppUtils::Params::log("Skip the extra library path because it is target!", @@ -1563,7 +1567,7 @@ void ConfigParser::initEnvirement() { QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); auto path = env.value("PATH"); - if (!DeployCore::isSnap()) { + if (!QuasarAppUtils::PlatformUtils::isSnap()) { _config.envirement.addEnv(env.value("LD_LIBRARY_PATH")); _config.envirement.addEnv(path); @@ -1572,8 +1576,8 @@ void ConfigParser::initEnvirement() { QStringList dirs; #ifdef Q_OS_LINUX - dirs.append(getDirsRecursive(DeployCore::transportPathToSnapRoot("/lib"), 5)); - dirs.append(getDirsRecursive(DeployCore::transportPathToSnapRoot("/usr/lib"), 5)); + dirs.append(getDirsRecursive(QuasarAppUtils::PlatformUtils::transportPathToSnapRoot("/lib"), 5)); + dirs.append(getDirsRecursive(QuasarAppUtils::PlatformUtils::transportPathToSnapRoot("/usr/lib"), 5)); #else auto winPath = findWindowsPath(path); @@ -1592,14 +1596,14 @@ void ConfigParser::initEnvirement() { bool ConfigParser::checkSnapPermisions() { - if (!DeployCore::isSnap()) + if (!QuasarAppUtils::PlatformUtils::isSnap()) return true; bool system = QuasarAppUtils::Params::isEndable("deploySystem") || QuasarAppUtils::Params::isEndable("extraLibs"); - if (system && !DeployCore::checkSystemBakupSnapInterface()) { + if (system && !QuasarAppUtils::PlatformUtils::checkSystemBakupSnapInterface()) { QuasarAppUtils::Params::log("You use a deploySystem or extraLibs options," " but not added permision system-backup for cqtdeployer." diff --git a/src/Deploy/src/deploycore.cpp b/src/Deploy/src/deploycore.cpp index 73db8df..c28b381 100644 --- a/src/Deploy/src/deploycore.cpp +++ b/src/Deploy/src/deploycore.cpp @@ -16,6 +16,7 @@ #include #include #include +#include //QString DeployCore::qtDir = ""; //QStringList DeployCore::extraPaths = QStringList(); @@ -609,7 +610,7 @@ QString DeployCore::getAppVersion() { } QString DeployCore::getAppVersionName() { - if (isSnap()) { + if (QuasarAppUtils::PlatformUtils::isSnap()) { return "*** Cool Core (snap) ***"; } return "*** Cool Core ***"; @@ -661,9 +662,10 @@ QString DeployCore::findProcess(const QString &env, const QString& proc, bool ig } // working only for the snap version of cqtdeployer ... - if (isSnap()) { + if (QuasarAppUtils::PlatformUtils::isSnap()) { for (const auto& path : list) { - auto files = QDir(transportPathToSnapRoot(path)).entryInfoList(findEntries); + auto files = QDir(QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(path)). + entryInfoList(findEntries); for (const auto& bin : files) { if (bin.baseName().compare(proc, DeployCore::getCaseSensitivity()) == 0) { @@ -1006,40 +1008,6 @@ char DeployCore::getEnvSeparator() { #endif } -bool DeployCore::isSnap() { - return QProcessEnvironment::systemEnvironment().value("SNAP").size(); -} - -QString DeployCore::snapRootFS() { - return "/var/lib/snapd/hostfs"; -} - -QString DeployCore::transportPathToSnapRoot(const QString &path) { - if (isSnap() && checkSystemBakupSnapInterface()) { - - if(QFileInfo(path).isWritable()) { - return path; - } - - if (path.size() && path[0] != QString("/")) { - auto absalutPath = QProcessEnvironment::systemEnvironment().value("PWD") + "/" + path; - if (!absalutPath.contains(DeployCore::snapRootFS())) { - return snapRootFS() + "/" + absalutPath; - } - } - - if (!path.contains(DeployCore::snapRootFS())) { - return snapRootFS() + "/" + path; - } - } - - return path; -} - -bool DeployCore::checkSystemBakupSnapInterface() { - return QDir(DeployCore::snapRootFS()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).size(); -} - void DeployCore::printInternalError(const char * function, const char* file, int line ) { QuasarAppUtils::Params::log(QString("Internal error ocurred in %0 (%1:%2).").arg(function, file).arg(line), QuasarAppUtils::Error); diff --git a/src/Deploy/src/deploycore.h b/src/Deploy/src/deploycore.h index 41f843d..edc300e 100644 --- a/src/Deploy/src/deploycore.h +++ b/src/Deploy/src/deploycore.h @@ -283,11 +283,6 @@ public: static QStringList debugExtensions(); static bool isDebugFile(const QString& file); - static bool isSnap(); - static QString snapRootFS(); - static QString transportPathToSnapRoot(const QString &path); - static bool checkSystemBakupSnapInterface(); - /** * @brief getLibCoreName This method remove platfomr specificly prefixes and sufixes of the librarry. * Example : getLibCoreName(libTest.so) return Test diff --git a/src/Deploy/src/distromodule.cpp b/src/Deploy/src/distromodule.cpp index 37e54ea..a0c3554 100644 --- a/src/Deploy/src/distromodule.cpp +++ b/src/Deploy/src/distromodule.cpp @@ -8,6 +8,7 @@ #include "deployconfig.h" #include "deploycore.h" #include "distromodule.h" +#include DistroModule::DistroModule(const QString& key) { setKey(key); @@ -34,7 +35,7 @@ void DistroModule::setQmlInput(const QSet &qmlInput) { } void DistroModule::addQmlInput(const QString &target) { - _qmlInput.insert(DeployCore::transportPathToSnapRoot(target)); + _qmlInput.insert(QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(target)); } QString DistroModule::name() const { @@ -110,7 +111,7 @@ void DistroModule::setExtraPlugins(const QSet &extraPlugins) { } void DistroModule::addExtraPlugins(const QString &extraPlugin) { - _extraPlugins += DeployCore::transportPathToSnapRoot(extraPlugin); + _extraPlugins += QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(extraPlugin); } diff --git a/src/Deploy/src/elf_type.cpp b/src/Deploy/src/elf_type.cpp index 95a08aa..67c6b44 100644 --- a/src/Deploy/src/elf_type.cpp +++ b/src/Deploy/src/elf_type.cpp @@ -66,9 +66,10 @@ QString ELF::extractRPath(ElfReader& reader) const { for (const auto &path: pathes) { if (path.contains("/")) { if (result.size()) { - result += DeployCore::getEnvSeparator() + DeployCore::transportPathToSnapRoot(path); + result += DeployCore::getEnvSeparator() + + QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(path); } else { - result += DeployCore::transportPathToSnapRoot(path); + result += QuasarAppUtils::PlatformUtils::transportPathToSnapRoot(path); } } } diff --git a/submodules/QuasarAppLib b/submodules/QuasarAppLib index 37fe8a0..00b80d9 160000 --- a/submodules/QuasarAppLib +++ b/submodules/QuasarAppLib @@ -1 +1 @@ -Subproject commit 37fe8a069b88a1b389868b6556e078e1310e9e95 +Subproject commit 00b80d94547f2bfe96c675950a4e68619b49f4fd