Merge branch 'v1.5' into task_396

This commit is contained in:
Andrei Yankovich 2021-02-08 10:23:58 +03:00
commit 0b1b36d7c2
46 changed files with 601 additions and 120 deletions

View File

@ -19,7 +19,7 @@ TEMPLATE = lib
DEFINES += DEPLOY_LIBRARY
VERSION = 1.5.0.15
VERSION = 1.5.0.23
DEFINES += APP_VERSION='\\"$$VERSION\\"'
@ -63,6 +63,7 @@ SOURCES += \
extracter.cpp \
filemanager.cpp \
Distributions/idistribution.cpp \
generalfiles_type.cpp \
ignorerule.cpp \
metafilemanager.cpp \
packagecontrol.cpp \
@ -77,6 +78,7 @@ SOURCES += \
qml.cpp \
libinfo.cpp \
qtdir.cpp \
targetdata.cpp \
targetinfo.cpp \
zipcompresser.cpp
@ -100,6 +102,7 @@ HEADERS += \
extracter.h \
filemanager.h \
Distributions/idistribution.h \
generalfiles_type.h \
ignorerule.h \
metafilemanager.h \
packagecontrol.h \
@ -114,6 +117,7 @@ HEADERS += \
qml.h \
libinfo.h \
qtdir.h \
targetdata.h \
targetinfo.h \
zipcompresser.h

View File

@ -8,7 +8,7 @@
Deb::Deb(FileManager *fileManager):
iDistribution(fileManager)
{
setLocation("tmp DEB");
setLocation("defaultDEBTemplate");
}
bool Deb::deployTemplate(PackageControl &pkg) {
@ -87,7 +87,7 @@ QProcessEnvironment Deb::processEnvirement() const {
QList<SystemCommandData> Deb::runCmd() {
QList<SystemCommandData> res;
for (const auto& dir: packageFolders) {
for (const auto& dir: qAsConst(packageFolders)) {
res.push_back({"dpkg-deb", QStringList{"--build", "--verbose"} << dir});
}

View File

@ -11,6 +11,7 @@
#include <QMap>
#include <deployconfig.h>
#include <distromodule.h>
#include <quasarapp.h>
iDistribution::~iDistribution() = default;
@ -46,11 +47,17 @@ bool iDistribution::unpackFile(const QFileInfo &resource,
QByteArray inputData = file.readAll();
file.close();
if (!QDir().mkpath(target))
if (!QDir().mkpath(target)) {
QuasarAppUtils::Params::log(QString("impossible to create path : %0 ").arg(target),
QuasarAppUtils::Error);
return false;
}
file.setFileName(target + "/" + resource.fileName());
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QuasarAppUtils::Params::log(QString("impossible to write in file: %0 ").arg(file.fileName()),
QuasarAppUtils::Error);
return false;
}
@ -195,8 +202,8 @@ bool iDistribution::collectInfo(const DistroModule& pkg,
cmdArray += ",";
bashArray += " ";
}
cmdArray += "\"" + releativeLocation(pkg) + "/" + fileinfo.fileName() + "\"";
bashArray += fileinfo.fileName();
cmdArray += "\"" + releativeLocation(pkg) + "/" + fileinfo.baseName() + "\"";
bashArray += fileinfo.baseName();
}
}
cmdArray += "]";
@ -242,6 +249,10 @@ bool iDistribution::deployIcon(TemplateInfo &info ,const DistroModule& pkg) {
QFileInfo iconInfo(pkg.icon());
info.Icon = releativeLocation(pkg) + "/icons/" + iconInfo.fileName();
if (!copyFile(pkg.icon(), localData + "/icons/", false)) {
QuasarAppUtils::Params::log(QString("fail to copy icon: %0 ").arg(pkg.icon()),
QuasarAppUtils::Error);
return false;
}
}

View File

@ -12,7 +12,7 @@
QIF::QIF(FileManager *fileManager)
:iDistribution(fileManager){
setLocation("tmp QIF");
setLocation("defaultQIFWTemplate");
};

View File

@ -10,10 +10,11 @@
ZipArhive::ZipArhive(FileManager *fileManager)
:iDistribution(fileManager) {
setLocation("tmp zip");
setLocation("defaultZIPTemplate");
}
bool ZipArhive::deployTemplate(PackageControl &pkg) {
// default template
const DeployConfig *cfg = DeployCore::_config;

View File

@ -45,20 +45,16 @@ bool parsePackagesPrivate(Container& mainContainer,
for (const auto& str: inputParamsList) {
auto paramsList = str.split(DeployCore::getSeparator(1));
auto first = paramsList.value(0, "");
auto second = paramsList.value(1, "");
if (paramsList.size() == 1)
(valueLink(mainContainer, defaultPackage, DistroModule{defaultPackage}).*adder)(first);
else {
bool skipError = QuasarAppUtils::Params::isEndable("allowEmptyPackages");
first = PathUtils::fullStripPath(first);
if (!skipError && !mainContainer.contains(first)) {
return false;
}
for (int i = 1; i < paramsList.size(); ++i) {
(valueLink(mainContainer, first, DistroModule{first}).*adder)(paramsList[i]);
}
@ -137,6 +133,20 @@ bool ConfigParser::parseParams() {
break;
}
case RunMode::Template: {
QuasarAppUtils::Params::log("Extract defaults Templates ...",
QuasarAppUtils::Info);
if (!parseDeployMode()) {
QuasarAppUtils::Params::log("Extract defaults Templates is failed!",
QuasarAppUtils::Error);
return false;
}
break;
}
}
DeployCore::_config = &_config;
@ -473,29 +483,32 @@ bool ConfigParser::initPackages() {
for (auto& str: tar_packages_array) {
auto pair = str.split(DeployCore::getSeparator(1));
auto package = PathUtils::fullStripPath(pair.value(0, ""));
auto paramsList = str.split(DeployCore::getSeparator(1));
auto package = PathUtils::fullStripPath(paramsList.value(0, ""));
auto list = _config.getTargetsListByFilter(pair.value(1, ""));
for (int i = 1; i < paramsList.size(); ++i) {
auto targetPattern = paramsList.value(i);
auto list = _config.getTargetsListByFilter(targetPattern);
if (!list.size()) {
auto warning = QString("You create the %0 package with the %1 pattern, "
"but no matches were found for this pattern. ").
arg(package, pair.value(1, ""));
QuasarAppUtils::Params::log(warning, QuasarAppUtils::Warning);
continue;
}
for (auto it = list.begin(); it != list.end(); ++it) {
if (!configuredTargets.contains(it.key())) {
configuredTargets.insert(it.key());
it.value()->setPackage(package);
if (!list.size()) {
auto warning = QString("You create the %0 package with the %1 pattern, "
"but no matches were found for this pattern. ").
arg(package, targetPattern);
QuasarAppUtils::Params::log(warning, QuasarAppUtils::Warning);
continue;
}
for (auto it = list.begin(); it != list.end(); ++it) {
if (!configuredTargets.contains(it.key())) {
configuredTargets.insert(it.key());
it.value()->setPackage(package);
}
}
_config.packagesEdit().insert(package, DistroModule{package});
}
_config.packagesEdit().insert(package, DistroModule{package});
if (pair.size() != 2) {
if (paramsList.size() < 2) {
defaultPackage = package;
}
}
@ -755,7 +768,10 @@ bool ConfigParser::setTargets(const QStringList &value) {
if (targetInfo.isFile()) {
_config.targetsEdit().unite(createTarget(QDir::fromNativeSeparators(i)));
auto target = createTarget(QDir::fromNativeSeparators(i));
if (!_config.targetsEdit().contains(target.target)) {
_config.targetsEdit().insert(target.target, target.targetInfo);
}
isfillList = true;
}
@ -807,7 +823,7 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
}
bool result = false;
for (const auto &file : list) {
for (const auto &file : qAsConst(list)) {
if (file.isDir()) {
result |= setTargetsInDir(file.absoluteFilePath(), recursive);
@ -820,9 +836,13 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
if (sufix.isEmpty() || name.contains(".dll", Qt::CaseInsensitive) ||
name.contains(".so", Qt::CaseInsensitive) || name.contains(".exe", Qt::CaseInsensitive)) {
result = true;
_config.targetsEdit().unite(createTarget(QDir::fromNativeSeparators(file.absoluteFilePath())));
auto target = createTarget(QDir::fromNativeSeparators(file.absoluteFilePath()));
if (!_config.targetsEdit().contains(target.target)) {
_config.targetsEdit().insert(target.target, target.targetInfo);
}
result = true;
}
@ -831,13 +851,13 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
return result;
}
QHash<QString, TargetInfo> ConfigParser::createTarget(const QString &target) {
TargetData ConfigParser::createTarget(const QString &target) {
TargetInfo libinfo;
auto key = target;
if (_scaner->fillLibInfo(libinfo, key)) {
return {{libinfo.fullPath(), libinfo}};
return {libinfo.fullPath(), libinfo};
}
return {{key, {}}};
return {key, {}};
}
QHash<QString, TargetInfo>
@ -884,6 +904,7 @@ void ConfigParser::initIgnoreList()
};
_config.ignoreList.addRule(addRuleUnix("libc"));
_config.ignoreList.addRule(addRuleUnix("libstdc++"));
_config.ignoreList.addRule(addRuleUnix("ld-"));
_config.ignoreList.addRule(addRuleUnix("libpthread"));
_config.ignoreList.addRule(addRuleUnix("libm"));
@ -897,7 +918,7 @@ void ConfigParser::initIgnoreList()
_config.ignoreList.addRule(addRuleUnix("libBrokenLocale"));
_config.ignoreList.addRule(addRuleUnix("libSegFault"));
_config.ignoreList.addRule(addRuleUnix("libanl"));
_config.ignoreList.addRule(addRuleUnix("libcrypt"));
_config.ignoreList.addRule(addRuleUnix("libcrypt.so"));
_config.ignoreList.addRule(addRuleUnix("/gconv/"));
_config.ignoreList.addRule(addRuleUnix("libnss"));
}
@ -1436,6 +1457,16 @@ bool ConfigParser::smartMoveTargets() {
bool result = true;
for (auto i = _config.targets().cbegin(); i != _config.targets().cend(); ++i) {
if (!i.value().isValid()) {
QuasarAppUtils::Params::log(QString("Internal error ocurred in %0. Target not inited.").arg(__FUNCTION__),
QuasarAppUtils::Error);
QuasarAppUtils::Params::log(QString("If you see this message please create a new issue"
" about this problem on the official github page"
" https://github.com/QuasarApp/CQtDeployer/issues/new/choose. "),
QuasarAppUtils::Error);
return false;
}
QFileInfo target(i.key());
QString targetPath = _config.getTargetDir() + "/" + i.value().getPackage();

View File

@ -11,6 +11,7 @@
#include "distrostruct.h"
#include "envirement.h"
#include "ignorerule.h"
#include "targetdata.h"
#include "targetinfo.h"
#include <QJsonObject>
@ -99,7 +100,7 @@ private:
void readKey(const QString &key, const QJsonObject &obj, const QString &confFileDir) const;
void readString(const QString &key, const QString &val, const QString &confFileDir) const;
QHash<QString, TargetInfo> createTarget(const QString &target);
TargetData createTarget(const QString &target);
QHash<QString, TargetInfo> moveTarget(TargetInfo target, const QString &newLocation);

View File

@ -9,7 +9,7 @@
#define DEFINES_H
#include <QtGlobal>
#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#define splitbehavior Qt::SkipEmptyParts
#else
#define splitbehavior QString::SkipEmptyParts

View File

@ -90,10 +90,13 @@ bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) const
case PrivateScaner::PE: {
return _peScaner.getLibInfo(file, info);
}
case PrivateScaner::ELF:
return _elfScaner.getLibInfo(file, info);
default: return false;
case PrivateScaner::ELF: {
return _elfScaner.getLibInfo(file, info);
}
default:
return _filesScaner.getLibInfo(file, info);
}
}

View File

@ -14,6 +14,7 @@
#include "pe_type.h"
#include "elf_type.h"
#include "libinfo.h"
#include "generalfiles_type.h"
enum class PrivateScaner: unsigned char {
@ -32,6 +33,7 @@ private:
PE _peScaner;
ELF _elfScaner;
GeneralFiles _filesScaner;
PrivateScaner getScaner(const QString& lib) const;

View File

@ -87,13 +87,13 @@ bool Deploy::prepare() {
bool Deploy::deploy() {
_extracter->clear();
switch (DeployCore::getMode() ) {
case RunMode::Deploy:
_extracter->deploy();
break;
case RunMode::Clear:
_extracter->clear();
if (!_extracter->deploy())
return false;
break;
default:
break;
@ -104,8 +104,17 @@ bool Deploy::deploy() {
bool Deploy::packing() {
if (DeployCore::getMode() != RunMode::Deploy)
return true;
switch (DeployCore::getMode() ) {
return _packing->create();
case RunMode::Deploy:
return _packing->create();
case RunMode::Template:
return _packing->extractTemplates();
default:
break;
}
return true;
}

View File

@ -18,6 +18,7 @@ class DependenciesScanner;
class PluginsParser;
class Packing;
enum exitCodes {
Good = 0x0,
PrepareError = 0x1,

View File

@ -52,7 +52,7 @@ DistroModule DeployConfig::getDistroFromPackage(const QString &package) const {
return _packages.value(package, DistroModule{package});
}
QMultiHash<QString, TargetInfo> &DeployConfig::targetsEdit() {
QHash<QString, TargetInfo> &DeployConfig::targetsEdit() {
return _targets;
}

View File

@ -95,7 +95,7 @@ public:
const QHash<QString, TargetInfo>& targets() const;
const QHash<QString, DistroModule>& packages() const;
QMultiHash<QString, TargetInfo> &targetsEdit();
QHash<QString, TargetInfo> &targetsEdit();
QHash<QString, DistroModule>& packagesEdit();
/**
@ -125,7 +125,7 @@ private:
* key - path
* value - create wrapper
*/
QMultiHash<QString, TargetInfo> _targets;
QHash<QString, TargetInfo> _targets;
/**
* @brief packages

View File

@ -159,6 +159,10 @@ RunMode DeployCore::getMode() {
return RunMode::Init;
}
if (C("getDefaultTemplate")) {
return RunMode::Template;
}
if (C("bin") || C("extraData")) {
return RunMode::Deploy;
}
@ -211,6 +215,11 @@ void DeployCore::help() {
"(on snap version you need to turn on permission)"},
{"noQt", "Ignors the error of initialize of a qmake. Use only if your application does not use the qt framework."},
{"allowEmptyPackages", "Allows configure the empty packages."},
{"getDefaultTemplate", "Extracts defaults deb or qif templates."
" All templates extract into targetDirectory."
" For change target directory use the targetDir option."
" Example: cqtdeployer -bin myExecutable getDefaultTemplate qif deb."},
}
},
@ -241,7 +250,7 @@ void DeployCore::help() {
}
},
{
"Part 3 Controll of packages options", {
"Part 3 Control of packages options", {
{"-targetPackage [package;tar1,package;tar2]", "Creates a new package and adds 'tar1 and tar2' to it."
"If you want configure the package that do not have any targets use the allowEmptyPackages option."},
{"-qmlOut [package;path,path]", "Sets path to qml out directory"},
@ -354,7 +363,8 @@ QStringList DeployCore::helpKeys() {
"prefix",
"deb",
"allowEmptyPackages",
"runScript"
"runScript",
"getDefaultTemplate"
};
}

View File

@ -108,7 +108,8 @@ enum class RunMode: int {
Info,
Deploy,
Clear,
Init
Init,
Template
};
class Extracter;

View File

@ -18,7 +18,7 @@ ELF::ELF()
QByteArrayList ELF::getDynamicString(ElfReader& reader) const {
auto headers = reader.readHeaders();
for (const auto &sectionHeader : headers.sectionHeaders) {
for (const auto &sectionHeader : qAsConst(headers.sectionHeaders)) {
if (sectionHeader.name == ".dynstr") {
auto arr = reader.readSection(sectionHeader.name).split(0);
return arr;

View File

@ -111,9 +111,8 @@ void Extracter::extractExtraDataTargets() {
auto cfg = DeployCore::_config;
for (auto i = cfg->packages().cbegin(); i != cfg->packages().cend(); ++i) {
auto &dep = _packageDependencyes[i.key()];
const auto extraDataList = i.value().extraData();
for (const auto &target : extraDataList) {
const auto extraData = i.value().extraData();
for (const auto &target : extraData) {
dep.addExtraData(target);
}
}
@ -137,9 +136,9 @@ void Extracter::copyExtraPlugins(const QString& package) {
auto cnf = DeployCore::_config;
auto targetPath = cnf->getTargetDir() + "/" + package;
auto distro = cnf->getDistroFromPackage(package);
const auto plugins = distro.extraPlugins();
auto extraPlugins = distro.extraPlugins();
for (const auto &extraPlugin : extraPlugins) {
for (const auto &extraPlugin : plugins) {
info.setFile(extraPlugin);
@ -268,11 +267,13 @@ void Extracter::copyTr() {
}
}
void Extracter::deploy() {
bool Extracter::deploy() {
QuasarAppUtils::Params::log("target deploy started!!",
QuasarAppUtils::Info);
clear();
_cqt->smartMoveTargets();
if (!_cqt->smartMoveTargets()) {
return false;
}
_scaner->setEnvironment(DeployCore::_config->envirement.environmentList());
extractAllTargets();
extractExtraDataTargets();
@ -290,6 +291,7 @@ void Extracter::deploy() {
if (!extractWebEngine()) {
QuasarAppUtils::Params::log("deploy webEngine failed", QuasarAppUtils::Error);
return false;
}
if (!deployMSVC()) {
@ -300,6 +302,8 @@ void Extracter::deploy() {
QuasarAppUtils::Params::log("deploy done!",
QuasarAppUtils::Info);
return true;
}
bool Extracter::copyTranslations(const QStringList &list, const QString& package) {
@ -405,10 +409,8 @@ bool Extracter::extractQml() {
QStringList plugins;
QStringList listItems;
const auto qmlImports = distro.qmlInput();
for (const auto &qmlInput: qmlImports) {
const auto qmlInput = distro.qmlInput();
for (const auto &qmlInput: qmlInput) {
QFileInfo info(qmlInput);
if (!info.isDir()) {

View File

@ -24,7 +24,7 @@ class DEPLOYSHARED_EXPORT Extracter {
public:
explicit Extracter(FileManager *fileManager, PluginsParser* pluginsParser, ConfigParser * cqt, DependenciesScanner *_scaner);
void deploy();
bool deploy();
void clear();
private:

View File

@ -352,6 +352,10 @@ bool FileManager::cp(const QString &from,
bool FileManager::moveFolder(const QString &from, const QString &to, const QString& ignore) {
QFileInfo info(from);
if (to.contains(from)) {
return false;
}
if (!info.exists())
return false;
@ -443,11 +447,7 @@ QString FileManager::changeDistanation(const QString& absalutePath,
QString basePath,
int depch) {
#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0)
auto prefixes = absalutePath.split(QRegExp("[\\/]"), Qt::SkipEmptyParts);
#else
auto prefixes = absalutePath.split(QRegExp("[\\/]"), QString::SkipEmptyParts);
#endif
auto prefixes = absalutePath.split(QRegExp("[\\/]"), splitbehavior);
depch = std::min(depch, prefixes.size());
while (depch) {
auto index = prefixes.size() - depch;

View File

@ -0,0 +1,24 @@
//#
//# Copyright (C) 2021-2021 QuasarApp.
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "generalfiles_type.h"
GeneralFiles::GeneralFiles()
{
}
bool GeneralFiles::getLibInfo(const QString &lib, LibInfo &info) const {
QFileInfo fileInfo(lib);
info.setPlatform(GeneralFile);
info.setName(fileInfo.fileName());
info.setPath(fileInfo.absolutePath());
return true;
}

View File

@ -0,0 +1,26 @@
//#
//# Copyright (C) 2021-2021 QuasarApp.
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef GENERALFILES_TYPE_H
#define GENERALFILES_TYPE_H
#include "igetlibinfo.h"
/**
* @brief The GeneralFiles class intendet for extract information of general files.
* This is defautl extracte for unknown files types.
*/
class GeneralFiles: public IGetLibInfo
{
public:
GeneralFiles();
// IGetLibInfo interface
bool getLibInfo(const QString &lib, LibInfo &info) const override;
};
#endif // GENERALFILES_TYPE_H

View File

@ -29,7 +29,7 @@ bool MetaFileManager::createRunScriptWindows(const QString &target) {
QString content;
auto runScript = cnf->getRunScript(targetInfo.fileName());
if (runScript.size()) {
auto script = QFile(runScript);
QFile script(runScript);
if (!script.open(QIODevice::ReadOnly)) {
return false;
}
@ -43,13 +43,18 @@ bool MetaFileManager::createRunScriptWindows(const QString &target) {
"@echo off \n"
"SET BASE_DIR=%~dp0\n"
"SET PATH=%BASE_DIR%" + distro.getLibOutDir() + ";%PATH%;" + systemLibsDir + "\n"
"%2\n"
"call \"%BASE_DIR%" + distro.getBinOutDir() + "%0\" %1 \n";
"SET CQT_PKG_ROOT=%BASE_DIR%\n"
"SET CQT_RUN_FILE=%BASE_DIR%%5\n"
content = content.arg(targetInfo.fileName()).arg("%*");
content = content.arg(generateCustoScriptBlok(true));
"%3\n"
"start \"%0\" %4 \"%BASE_DIR%" + distro.getBinOutDir() + "%1\" %2 \n";
content = content.arg(targetInfo.baseName(), targetInfo.fileName(), "%*",
generateCustoScriptBlok(true)); // %0 %1 %2 %3
content = QDir::toNativeSeparators(content);
content = content.arg("/B", targetInfo.baseName()+ ".bat"); // %4 %5
}
QString fname = DeployCore::_config->getTargetDir(target) + QDir::separator() + targetInfo.baseName()+ ".bat";
@ -85,7 +90,7 @@ bool MetaFileManager::createRunScriptLinux(const QString &target) {
QString content;
auto runScript = cnf->getRunScript(targetInfo.fileName());
if (runScript.size()) {
auto script = QFile(runScript);
QFile script(runScript);
if (!script.open(QIODevice::ReadOnly)) {
return false;
}
@ -107,14 +112,17 @@ bool MetaFileManager::createRunScriptLinux(const QString &target) {
"export QT_PLUGIN_PATH=\"$BASE_DIR\"" + distro.getPluginsOutDir() + ":$QT_PLUGIN_PATH\n"
"export QTWEBENGINEPROCESS_PATH=\"$BASE_DIR\"" + distro.getBinOutDir() + "QtWebEngineProcess\n"
"export QTDIR=\"$BASE_DIR\"\n"
"export CQT_PKG_ROOT=\"$BASE_DIR\"\n"
"export CQT_RUN_FILE=\"$BASE_DIR/%3\"\n"
"export "
"QT_QPA_PLATFORM_PLUGIN_PATH=\"$BASE_DIR\"" + distro.getPluginsOutDir() +
"platforms:$QT_QPA_PLATFORM_PLUGIN_PATH\n"
"%2"
"%3\n"
"\"$BASE_DIR" + distro.getBinOutDir() + "%1\" \"$@\"\n";
"%1"
"%2\n"
"\"$BASE_DIR" + distro.getBinOutDir() + "%0\" \"$@\"\n";
content = content.arg(targetInfo.fileName());
content = content.arg(targetInfo.fileName()); // %0
auto deployedFies = _fileManager->getDeployedFilesStringList();
int ld_index = DeployCore::find("ld-linux", deployedFies);
@ -124,9 +132,12 @@ bool MetaFileManager::createRunScriptLinux(const QString &target) {
arg(QFileInfo(deployedFies[ld_index]).fileName()));
} else {
content = content.arg("");
}
} // %1
content = content.arg(generateCustoScriptBlok(false),
targetInfo.baseName()+ ".sh"); // %2 %3
content = content.arg(generateCustoScriptBlok(false));
}

View File

@ -51,8 +51,12 @@ bool Packing::create() {
if (!package)
return false;
if (!package->deployTemplate(*this))
if (!package->deployTemplate(*this)) {
QuasarAppUtils::Params::log(QString("Deploy package template error ocured. Package: %0.").
arg(package->getClassName()),
QuasarAppUtils::Error);
return false;
}
auto commands = package->runCmd();
@ -121,6 +125,11 @@ bool Packing::create() {
bool Packing::movePackage(const QString &package,
const QString &newLocation) {
// Disable moving data for extracting defaults templates.
if (QuasarAppUtils::Params::isEndable("getDefaultTemplate")) {
return true;
}
if (moveData(_packagesLocations.value(package),
newLocation)) {
@ -135,6 +144,32 @@ bool Packing::copyPackage(const QString &package, const QString &newLocation) {
return _fileManager->copyFolder(_packagesLocations[package], newLocation, {}, nullptr, nullptr, true);
}
bool Packing::extractTemplates() {
const DeployConfig *cfg = DeployCore::_config;
QuasarAppUtils::Params::log("You use the getDefaultTemplate. All using templates will be extracted into " + cfg->getTargetDir(),
QuasarAppUtils::Info);
if (!prepareTemplatesForExtract()) {
return false;
}
for (auto package : qAsConst(_pakages)) {
if (!package)
return false;
if (!package->deployTemplate(*this))
return false;
delete package;
}
return true;
}
QStringList Packing::availablePackages() const {
return _packagesLocations.keys();
}
@ -160,6 +195,19 @@ bool Packing::collectPackages() {
return true;
}
bool Packing::prepareTemplatesForExtract() {
const DeployConfig *cfg = DeployCore::_config;
for (auto it = cfg->packages().begin(); it != cfg->packages().end(); ++it) {
_packagesLocations.insert(it.key(),
cfg->getTargetDir() + "/" + TMP_PACKAGE_DIR + "/" + it.key());
}
_defaultPackagesLocations = _packagesLocations;
return true;
}
bool Packing::moveData(const QString &from, const QString &to, const QString &ignore) const {
if (from == to )

View File

@ -34,12 +34,20 @@ public:
bool movePackage(const QString &package, const QString &newLocation) override;
bool copyPackage(const QString &package, const QString &newLocation) override;
/**
* @brief extractTemplates This method extract all default temlates. See the getDefaultTemplate for get more information.
* @return true if function finished successful.
*/
bool extractTemplates();
protected:
QStringList availablePackages() const override;
private:
bool collectPackages();
bool prepareTemplatesForExtract();
bool moveData(const QString& from, const QString& to,
const QString &ignore = "") const;

1
Deploy/targetdata.cpp Normal file
View File

@ -0,0 +1 @@
#include "targetdata.h"

22
Deploy/targetdata.h Normal file
View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2018-2021 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef TARGETDATA_H
#define TARGETDATA_H
#include "targetinfo.h"
/**
* @brief The TargetData struct simple info structo about target.
*/
struct TargetData {
QString target;
TargetInfo targetInfo;
};
#endif // TARGETDATA_H

View File

@ -3,7 +3,7 @@
<WizardDefaultWidth>640px</WizardDefaultWidth>
<WizardDefaultHeight>400px</WizardDefaultHeight>
<Name>CQtDeployer</Name>
<Version>1.5.0.15</Version>
<Version>1.5.0.23</Version>
<Title>CQtDeployer</Title>
<Publisher>QuasarApp</Publisher>
<StartMenuDir>CQtDeployer</StartMenuDir>

View File

@ -3,7 +3,7 @@
<WizardDefaultWidth>640px</WizardDefaultWidth>
<WizardDefaultHeight>400px</WizardDefaultHeight>
<Name>CQtDeployer</Name>
<Version>1.5.0.15</Version>
<Version>1.5.0.23</Version>
<Title>CQtDeployer</Title>
<Publisher>QuasarApp</Publisher>
<StartMenuDir>CQtDeployer</StartMenuDir>

View File

@ -2,11 +2,11 @@
<Package>
<DisplayName>CQtDeployer 1.5 Alpha</DisplayName>
<Description>CQtDeployer 1.5 Alpha. Do not use this version because it is unstable and may lead to unwanted bugs or consequences. Use this version exclusively for testing new functionality.</Description>
<Version>1.5.0.15</Version>
<Version>1.5.0.23</Version>
<Default>true</Default>
<ForcedInstallation>false</ForcedInstallation>
<Script>installscript.js</Script>
<ReleaseDate>2020-09-06</ReleaseDate>
<ReleaseDate>2021-02-06</ReleaseDate>
<SortingPriority>201</SortingPriority>
<Translations>
<Translation>ru.qm</Translation>

View File

@ -20,6 +20,8 @@ print("VERSION=" + VERSION)
# Command Example : aqt tool linux tools_ifw 4.0 qt.tools.ifw.40
command = ["aqt",
"tool",
"-b",
"https://mirrors.ocf.berkeley.edu/qt/",
"--outputdir",
PATHQIF,
PLATFORM,

View File

@ -6,6 +6,8 @@ export QML2_IMPORT_PATH="$BASE_DIR"/q/and/q/:$QML2_IMPORT_PATH
export QT_PLUGIN_PATH="$BASE_DIR"/plugins/:$QT_PLUGIN_PATH
export QTWEBENGINEPROCESS_PATH="$BASE_DIR"/bin/QtWebEngineProcess
export QTDIR="$BASE_DIR"
export CQT_PKG_ROOT="$BASE_DIR"
export CQT_RUN_FILE="$BASE_DIR/TestQMLWidgets.sh"
export QT_QPA_PLATFORM_PLUGIN_PATH="$BASE_DIR"/plugins/platforms:$QT_QPA_PLATFORM_PLUGIN_PATH
"$BASE_DIR/bin/TestQMLWidgets" "$@"

View File

@ -174,6 +174,8 @@ private slots:
void testEmptyPackages();
void testRunScripts();
void testGetDefaultTemplate();
void testDeployGeneralFiles();
void customTest();
};
@ -1100,6 +1102,71 @@ void deploytest::testRunScripts() {
}
void deploytest::testGetDefaultTemplate() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/defaultDEBTemplate/Application/DEBIAN/control",
"./" + DISTRO_DIR + "/defaultDEBTemplate/Application/DEBIAN/postinst",
"./" + DISTRO_DIR + "/defaultDEBTemplate/Application/DEBIAN/prerm",
"./" + DISTRO_DIR + "/defaultDEBTemplate/Application/opt/Application/icons/Icon.png",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/config/config.xml",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/config/controlScript.qs",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/data/icons/Icon.png",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/meta/installscript.qs",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/meta/package.xml"
});
runTestParams(
{"-bin", bin,
"force-clear",
"getDefaultTemplate",
"deb",
"qif"
}, &comapareTree);
#else
QString bin = TestBinDir + "TestOnlyC.exe";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/defaultQIFWTemplate/config/config.xml",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/config/controlScript.qs",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/data/icons/Icon.png",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/meta/installscript.qs",
"./" + DISTRO_DIR + "/defaultQIFWTemplate/packages/Application/meta/package.xml"
});
runTestParams(
{"-bin", bin,
"force-clear",
"getDefaultTemplate",
"qif"
}, &comapareTree);
#endif
}
void deploytest::testDeployGeneralFiles() {
TestUtils utils;
QString bin = TestBinDir + "/../../CMakeLists.txt";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/bin/CMakeLists.txt",
"./" + DISTRO_DIR + "/bin/qt.conf",
});
runTestParams(
{"-bin", bin,
"-binOut", "bin",
"force-clear"
}, &comapareTree);
}
void deploytest::customTest() {
// runTestParams({"-confFile", "path",
// "qifFromSystem"});
@ -2567,9 +2634,11 @@ void deploytest::testOutDirs() {
runScript = file.readAll();
file.close();
qDebug() << "runScript =" << runScript;
QVERIFY(runScript.contains("SET BASE_DIR=%~dp0"));
QVERIFY(runScript.contains("SET PATH=%BASE_DIR%\\lolLib\\;%PATH%"));
QVERIFY(runScript.contains("call \"%BASE_DIR%\\lol\\TestQMLWidgets.exe\" %*"));
QVERIFY(runScript.contains("start \"TestQMLWidgets\" /B \"%BASE_DIR%\\lol\\TestQMLWidgets.exe\" %*"));
#endif

View File

@ -0,0 +1,45 @@
# Environment variables of the CQtDeployer
This page contains information about environment variables of the default launcher script.
## Initialization
All environment variables initialized in the default launcher script. So if you use the runScript option then you must be reunited all needed variables manually.
## Variables list
| Variable name | Description |
|---|---|
| CQT_PKG_ROOT | This variable contains path to root of the current package.|
| CQT_RUN_FILE | This variable contains path to the run script of the using application.|
## Description of definitions
**Root of the current package** - This root is local root for any separate packages.
Example :
``` bash
.
├── pakcage1 << This is local root of the package1
│ ├── bin
│ ├── lib
│ ├── plugins
│ ├── qml
│ └── translations
├── package2 << This is local root of the package2
│ ├── bin
│ ├── lib
│ ├── plugins
│ ├── qml
│ └── translations
└── pakcage3 << This is local root of the package3
├── bin
├── lib
├── plugins
├── qml
└── translations
```

View File

@ -0,0 +1,48 @@
# Extracting default templates
Sometimes you need to create your own templates for installers or deb packages.
Fot this you can use the getDefaultTemplate option. This option extracts your distribution's default template to the target directory. This option will generate a template according to your settings. If you use the targetPackage option then a template will be generated for each package you configured.
### Example:
``` bash
cqtdeployer -bin myExecutable getDefaultTemplate qif
```
This command generate template for qt installer framework into DistributionKit folder for your "myExecutable" programm.
If you want change target location just add the targetDir option
``` bash
cqtdeployer -bin myExecutable getDefaultTemplate qif -targetDir "/distanation/Dir"
```
## Work With multipackage distribution.
This option support the configFile.json
### Example :
#### configFile.json
```json
{
"bin": [
"myClientExecutable",
"myServerExecutable"
],
"targetPackage" : [
["Client", "myClientExecutable"],
["Server", "myServerExecutable"]
],
}
```
```bash
cqtdeployer getDefaultTemplate qif -confFile "path/to/configFile.json"
```
## Note
This option support work with all packages except of zip.
If you want get more information about available packages see the packing [page](Package.md).

View File

@ -1,5 +1,4 @@
# How to deploy C++ Application
Hi my name is Yankovich Andrei and i an maintainer of the [CQtDeployer tool](https://github.com/QuasarApp/CQtDeployer).
In this article i describe deploy processes of c++/qt application with cqtdeployer.

View File

@ -5,17 +5,19 @@
# Main sections
* [Description CQtDeployer](Description)
* [Options](Options)
* [Guide](Guide)
* [Quick guide](QuickGuide)
* [Build and Install](Build-and-Install)
* [Deploy file](DeployConfigFile)
* [Packing](Packing)
* [Change log page](Changelog)
* [Reviews](ReleaseReviews)
* [Compare Features](CompareFeatures)
* [Description CQtDeployer](Description.md)
* [Options](Options.md)
* [Guide](Guide.md)
* [Quick guide](QuickGuide.md)
* [Build and Install](Build-and-Install.md)
* [Deploy file](DeployConfigFile.md)
* [Packing](Packing.md)
* [Change log page](Changelog.md)
* [Reviews](ReleaseReviews.md)
* [Compare Features](CompareFeatures.md)
* [Adding extra files](ExtraFiles.md)
* [Retrieving packaging templates](ExtractDefaultsTemplates.md)
* [Default Environment Variables](EnvironmentVariables.md)
## Support the project

View File

@ -51,6 +51,7 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
| deploySystem-with-libc | Deploys all libs include libc (only linux). Do not use this option for a gui application, for gui use the deploySystem option. (on snap version you need to turn on permission) |
| noQt | Ignors the error of initialize of a qmake. Use only if your application does not use the qt framework. |
| allowEmptyPackages | Allows configure the empty packages. |
| getDefaultTemplate | Extracts defaults deb or qif templates. For more information see the extracting default templates [page](ExtractDefaultsTemplates.md) |
### Deploy options

View File

@ -0,0 +1,43 @@
# Переменные окружения CQtDeployer
Эта страница содержит информацию о переменных содержащихся в скрипте запуска по умолчанию.
## Инициализация
Все переменные окружения инициализируются в скрипте запуска по умолчанию. Поэтому, если вы используете опцию runScript, вам необходимо вручную воссоздать все необходимые переменные.
## Список стандартных переменных
| Имя переменной | Описание |
| --- | --- |
| CQT_PKG_ROOT | Эта переменная содержит путь к корню текущего пакета.
| CQT_RUN_FILE | Эта переменная содержит путь к скрипту запуска используемого приложения. |
## Описания определений
**корень текущего пакета** - Этот корень является локальным корнем для любых отдельных пакетов.
Пример :
``` bash
.
├── pakcage1 << Это локальный корень пакета package1
│ ├── bin
│ ├── lib
│ ├── plugins
│ ├── qml
│ └── translations
├── package2 << Это локальный корень пакета package2
│ ├── bin
│ ├── lib
│ ├── plugins
│ ├── qml
│ └── translations
└── pakcage3 << Это локальный корень пакета package3
├── bin
├── lib
├── plugins
├── qml
└── translations
```

View File

@ -0,0 +1,52 @@
# Извлечение шаблонов по умолчанию
Иногда вам нужно создать свои собственные шаблоны для установщиков или пакетов deb.
Для этого вы можете использовать опцию getDefaultTemplate.
Эта опция извлекает шаблон вашего дистрибутива по умолчанию в целевой каталог.
Эта опция создаст шаблон в соответствии с вашими настройками. Если вы используете опцию targetPackage, то для каждого настроенного вами пакета будет создан шаблон.
### Пример:
```bash
cqtdeployer -bin myExecutable getDefaultTemplate qif
```
Эта команда создает шаблон для среды установки qt в папке DistributionKit для вашей программы "myExecutable".
Если вы хотите изменить целевое местоположение, просто добавьте параметр targetDir
```bash
cqtdeployer -bin myExecutable getDefaultTemplate qif -targetDir "/distanation/Dir"
```
## Работа с мультипакетной раздачей.
Эта опция поддерживает configFile.json
### Пример:
#### configFile.json
`` json
{
"корзина": [
"myClientExecutable",
"myServerExecutable"
],
"targetPackage": [
["Клиент", "myClientExecutable"],
["Сервер", "myServerExecutable"]
],
}
``
```bash
cqtdeployer getDefaultTemplate qif -confFile "path/to/configFile.json"
```
## Запись
Эта опция поддерживает работу со всеми пакетами, кроме zip.
Если вы хотите получить больше информации о доступных пакетах, смотрите упаковку [страница](Package.md).

View File

@ -1,5 +1,4 @@
# Как развернуть приложение C ++
Привет, меня зовут Янкович Андрей, я сопровождаю [инструмент CQtDeployer](https://github.com/QuasarApp/CQtDeployer).
В этой статье я описываю процессы развертывания приложения c++/qt с помощью cqtdeployer.
@ -92,4 +91,4 @@ cqtdeployer -bin myexecutable -libDir/PathToMyExtraLibs -recursiveDepth 5 -qmlDi
```
cqtdeployer -bin myexecutable -libDir / PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources qif -qmake/path/to/my/qmake
```
```

View File

@ -5,17 +5,19 @@
# Основные разделы
* [Описание CQtDeployer](Description)
* [Параметры](Options)
* [Руководство](Guide)
* [Краткое Руководство](QuickGuide)
* [Сборка и установка](Build-and-Install)
* [Файл развертывания](DeployConfigFile)
* [Упаковка](Packing)
* [Список изменений](Changelog)
* [Обзоры](ReleaseReviews)
* [Сравнение возможностей](CompareFeatures)
* [Описание CQtDeployer](Description.md)
* [Параметры](Options.md)
* [Руководство](Guide.md)
* [Краткое Руководство](QuickGuide.md)
* [Сборка и установка](Build-and-Install.md)
* [Файл развертывания](DeployConfigFile.md)
* [Упаковка](Packing.md)
* [Список изменений](Changelog.md)
* [Обзоры](ReleaseReviews.md)
* [Сравнение возможностей](CompareFeatures.md)
* [Добавление дополнительных файлов](ExtraFiles.md)
* [Получение шаблонов упаковки](ExtractDefaultsTemplates.md)
* [Стандартные переменные окружения](EnvironmentVariables.md)
## Поддержите проект

View File

@ -52,6 +52,7 @@ cqtdeployer -option1 value1 -option2 list,of,values flag1 flag2 flag3
| deploySystem-with-libc | Копирует все зависимости в том числе и libc, не рекомендуется использовать с gui приложения, в место этого используйте опцию deploySystem |
| noQt | Игнорирует ошибку инициализации qmake. Используйте только в том случае, если ваше приложение не использует платформу qt. |
| allowEmptyPackages | Разрешите настраивать пустые пакеты. |
| getDefaultTemplate | Извлекает deb или qif шаблоны по умолчанию. Для получения дополнительной информации см. [Страницу](ExtractDefaultsTemplates.md) извлечения шаблонов по умолчанию. |
### Параметры развертывания:

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Version=1.5.0.15
Version=1.5.0.23
Name=CQtDeployer
Comment=CQtDeployer Help.
Exec=cqtdeployer
@ -10,6 +10,6 @@ Categories=Application;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=CQtDeployer
X-GNOME-Bugzilla-Component=General
X-GNOME-Bugzilla-Version=1.5.0.15
X-GNOME-Bugzilla-Version=1.5.0.23
StartupNotify=true
Name[ru_RU]=CQtDeployer

View File

@ -6,7 +6,7 @@
#
name: cqtdeployer # you probably want to 'snapcraft register <name>'
version: '1.5.0.15' # just for humans, typically '1.2+git' or '1.3.2'
version: '1.5.0.23' # just for humans, typically '1.2+git' or '1.3.2'
summary: deploy your qt projects # 79 char long summary
description: |
Console app for deploy qt libs.

View File

@ -15,7 +15,7 @@ deployTest.commands = $$DEPLOYER -bin $$exec clear -qmake $$QMAKE_BIN -targetDir
!android:test.depends = deployTest
unix:!android:test.commands = $$PWD/deployTests/UnitTests.sh -maxwarnings 100000
win32:test.commands = $$PWD/deployTests/UnitTests.exe -maxwarnings 100000 -o $$PWD/buildLog.log
win32:test.commands = $$PWD/deployTests/UnitTests.exe -maxwarnings 100000 -o buildLog.log
contains(QMAKE_HOST.os, Linux):{
win32:test.commands =