mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-29 11:14:33 +00:00
fix build
This commit is contained in:
parent
25a04c2974
commit
60980c4967
@ -29,6 +29,8 @@ CONFIG(release, debug|release): {
|
||||
|
||||
include('$$PWD/../QuasarAppLib/QuasarLib.pri')
|
||||
include('$$PWD/../Deploy/Deploy.pri')
|
||||
include('$$PWD/../zip/zip.pri')
|
||||
|
||||
include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri')
|
||||
|
||||
|
||||
|
@ -63,6 +63,7 @@ SOURCES += \
|
||||
Distributions/idistribution.cpp \
|
||||
ignorerule.cpp \
|
||||
metafilemanager.cpp \
|
||||
packagecontrol.cpp \
|
||||
packing.cpp \
|
||||
pathutils.cpp \
|
||||
pe.cpp \
|
||||
@ -97,6 +98,7 @@ HEADERS += \
|
||||
Distributions/idistribution.h \
|
||||
ignorerule.h \
|
||||
metafilemanager.h \
|
||||
packagecontrol.h \
|
||||
packing.h \
|
||||
pathutils.h \
|
||||
pe.h \
|
||||
|
@ -8,7 +8,7 @@ DefaultDistro::DefaultDistro(FileManager *fileManager)
|
||||
|
||||
};
|
||||
|
||||
bool DefaultDistro::deployTemplate() {
|
||||
bool DefaultDistro::deployTemplate(PackageControl &pkg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
// iDistribution interface
|
||||
public:
|
||||
QString getConfig() const ;
|
||||
bool deployTemplate() override;
|
||||
bool deployTemplate(PackageControl &pkg) override;
|
||||
Envirement toolKitEnv() const override;
|
||||
QString runCmd() override;
|
||||
QStringList runArg() const override;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QFileInfo>
|
||||
class FileManager;
|
||||
class DistroModule;
|
||||
class PackageControl;
|
||||
|
||||
class DEPLOYSHARED_EXPORT iDistribution
|
||||
{
|
||||
@ -16,7 +17,7 @@ public:
|
||||
iDistribution(FileManager * fileManager);
|
||||
virtual ~iDistribution();
|
||||
|
||||
virtual bool deployTemplate() = 0;
|
||||
virtual bool deployTemplate(PackageControl& pkgCtrl) = 0;
|
||||
virtual bool removeTemplate() const = 0;
|
||||
virtual Envirement toolKitEnv() const = 0;
|
||||
virtual QProcessEnvironment processEnvirement() const = 0;
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QProcess>
|
||||
#include <packagecontrol.h>
|
||||
#include <pathutils.h>
|
||||
|
||||
QIF::QIF(FileManager *fileManager)
|
||||
@ -63,7 +64,7 @@ QString QIF::runCmd() {
|
||||
return binarycreator;
|
||||
}
|
||||
|
||||
bool QIF::deployTemplate() {
|
||||
bool QIF::deployTemplate(PackageControl &pkg) {
|
||||
auto customTemplate = QuasarAppUtils::Params::getStrArg("qif", "");
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
@ -74,61 +75,60 @@ bool QIF::deployTemplate() {
|
||||
if (customTemplate.isEmpty()) {
|
||||
// default template
|
||||
|
||||
auto sortedMap = sortPackages(cfg->packages());
|
||||
|
||||
for (auto &it : sortedMap) {
|
||||
auto package = it.second;
|
||||
for (auto it = cfg->packages().begin();
|
||||
it != cfg->packages().end(); ++it) {
|
||||
auto package = it.value();
|
||||
|
||||
TemplateInfo info;
|
||||
info.Name = PathUtils::stripPath(it.first);
|
||||
info.Name = PathUtils::stripPath(it.key());
|
||||
|
||||
if (info.Name.isEmpty()) {
|
||||
QFileInfo targetInfo(*package->targets().begin());
|
||||
QFileInfo targetInfo(*package.targets().begin());
|
||||
info.Name = targetInfo.baseName();
|
||||
}
|
||||
|
||||
if (!package->name().isEmpty()) {
|
||||
info.Name = package->name();
|
||||
if (!package.name().isEmpty()) {
|
||||
info.Name = package.name();
|
||||
}
|
||||
|
||||
auto location = cfg->getTargetDir() + "/" + getLocation() + "/packages/" +
|
||||
((it.first.isEmpty())? "Application": info.Name);
|
||||
((it.key().isEmpty())? "Application": info.Name);
|
||||
|
||||
auto locationData = location + "/data/" + info.Name;
|
||||
|
||||
info.Description = "This package contains the " + info.Name;
|
||||
if (!package->description().isEmpty())
|
||||
info.Description = package->description();
|
||||
if (!package.description().isEmpty())
|
||||
info.Description = package.description();
|
||||
|
||||
info.Version = "1.0";
|
||||
if (!package->version().isEmpty())
|
||||
info.Version = package->version();
|
||||
if (!package.version().isEmpty())
|
||||
info.Version = package.version();
|
||||
|
||||
info.ReleaseData = QDate::currentDate().toString("yyyy-MM-dd");
|
||||
if (!package->releaseData().isEmpty())
|
||||
info.ReleaseData = package->releaseData();
|
||||
if (!package.releaseData().isEmpty())
|
||||
info.ReleaseData = package.releaseData();
|
||||
|
||||
info.Icon = "icons/Icon.png";
|
||||
if (package->icon().isEmpty()) {
|
||||
if (package.icon().isEmpty()) {
|
||||
if (!copyFile(":/Templates/QIF/Distributions/Templates/qif/Icon.png",
|
||||
locationData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QFileInfo iconInfo(package->icon());
|
||||
QFileInfo iconInfo(package.icon());
|
||||
info.Icon = info.Name + "/icons/" + iconInfo.fileName();
|
||||
if (!copyFile(package->icon(), locationData + "/icons/", false)) {
|
||||
if (!copyFile(package.icon(), locationData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
info.Publisher = "Company";
|
||||
if (!package->publisher().isEmpty())
|
||||
info.Publisher = package->publisher();
|
||||
if (!package.publisher().isEmpty())
|
||||
info.Publisher = package.publisher();
|
||||
|
||||
QString cmdArray = "[";
|
||||
int initSize = cmdArray.size();
|
||||
for (const auto &target :it.second->targets()) {
|
||||
for (const auto &target :package.targets()) {
|
||||
auto fileinfo = QFileInfo(target);
|
||||
if (fileinfo.suffix().compare("exe", ONLY_WIN_CASE_INSENSIATIVE) == 0 || fileinfo.suffix().isEmpty()) {
|
||||
if (cmdArray.size() > initSize) {
|
||||
@ -152,7 +152,7 @@ bool QIF::deployTemplate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.first, locationData, getLocation())) {
|
||||
if (!pkg.movePackage(it.key(), locationData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "idistribution.h"
|
||||
|
||||
|
||||
class PackageControl;
|
||||
/**
|
||||
* @brief The QIF class provides interface betvin deployment targets and Qt Installer Framework
|
||||
*/
|
||||
@ -13,7 +13,7 @@ public:
|
||||
QIF(FileManager *fileManager);
|
||||
Envirement toolKitEnv() const override;
|
||||
QString runCmd() override;
|
||||
bool deployTemplate() override;
|
||||
bool deployTemplate(PackageControl &pkg) override;
|
||||
QStringList runArg() const override;
|
||||
bool removeTemplate() const override;
|
||||
QProcessEnvironment processEnvirement() const override;
|
||||
|
@ -12,32 +12,31 @@ ZipArhive::ZipArhive(FileManager *fileManager)
|
||||
setLocation("tmp zip");
|
||||
}
|
||||
|
||||
bool ZipArhive::deployTemplate() {
|
||||
bool ZipArhive::deployTemplate(PackageControl &pkg) {
|
||||
// default template
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
auto sortedMap = sortPackages(cfg->packages());
|
||||
|
||||
ZipCompresser zipWorker;
|
||||
for (auto &it : sortedMap) {
|
||||
auto package = it.second;
|
||||
for (auto it = cfg->packages().begin();
|
||||
it != cfg->packages().end(); ++it) {
|
||||
auto package = it.value();
|
||||
|
||||
TemplateInfo info;
|
||||
info.Name = PathUtils::stripPath(it.first);
|
||||
info.Name = PathUtils::stripPath(it.key());
|
||||
|
||||
if (info.Name.isEmpty()) {
|
||||
QFileInfo targetInfo(*package->targets().begin());
|
||||
QFileInfo targetInfo(*package.targets().begin());
|
||||
info.Name = targetInfo.baseName();
|
||||
}
|
||||
|
||||
if (!package->name().isEmpty()) {
|
||||
info.Name = package->name();
|
||||
if (!package.name().isEmpty()) {
|
||||
info.Name = package.name();
|
||||
}
|
||||
|
||||
auto location = cfg->getTargetDir() + "/" + getLocation() + "/" +
|
||||
((it.first.isEmpty())? "Application": info.Name);
|
||||
((it.key().isEmpty())? "Application": info.Name);
|
||||
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.first, location, getLocation())) {
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.key(), location, getLocation())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@ public:
|
||||
|
||||
// iDistribution interface
|
||||
public:
|
||||
bool deployTemplate();
|
||||
bool removeTemplate() const;
|
||||
Envirement toolKitEnv() const;
|
||||
QProcessEnvironment processEnvirement() const;
|
||||
QString runCmd();
|
||||
QStringList runArg() const;
|
||||
QStringList outPutFiles() const;
|
||||
bool deployTemplate(PackageControl &pkg) override;
|
||||
bool removeTemplate() const override;
|
||||
Envirement toolKitEnv() const override;
|
||||
QProcessEnvironment processEnvirement() const override;
|
||||
QString runCmd() override;
|
||||
QStringList runArg() const override;
|
||||
QStringList outPutFiles() const override;
|
||||
private:
|
||||
QStringList outFiles;
|
||||
};
|
||||
|
@ -1173,16 +1173,19 @@ QString ConfigParser::findWindowsPath(const QString& path) const {
|
||||
return "C:/" + win_magic;
|
||||
}
|
||||
|
||||
iDistribution *ConfigParser::getDistribution() {
|
||||
QList<iDistribution *> ConfigParser::getDistribution() {
|
||||
QList<iDistribution *> distros;
|
||||
if (QuasarAppUtils::Params::isEndable("zip")) {
|
||||
return new ZipArhive(_fileManager);
|
||||
distros.push_back(new ZipArhive(_fileManager));
|
||||
}
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("qif")) {
|
||||
return new QIF(_fileManager);
|
||||
distros.push_back(new QIF(_fileManager));
|
||||
}
|
||||
|
||||
return new DefaultDistro(_fileManager);
|
||||
distros.push_back(new DefaultDistro(_fileManager));
|
||||
|
||||
return distros;
|
||||
}
|
||||
|
||||
void ConfigParser::initEnvirement() {
|
||||
|
@ -100,7 +100,7 @@ private:
|
||||
QJsonValue writeKeyArray(int separatorLvl, const QString ¶meter, const QString &confFileDir) const;
|
||||
QString findWindowsPath(const QString &path) const;
|
||||
|
||||
iDistribution* getDistribution();
|
||||
QList<iDistribution *> getDistribution();
|
||||
|
||||
bool isNeededQt() const;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
Deploy::Deploy() {
|
||||
_fileManager = new FileManager();
|
||||
_scaner = new DependenciesScanner();
|
||||
_packing = new Packing();
|
||||
_packing = new Packing(_fileManager);
|
||||
_pluginParser = new PluginsParser();
|
||||
|
||||
_paramsParser = new ConfigParser(_fileManager, _pluginParser, _scaner, _packing);
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
QStringList *listOfCopiedItems = nullptr,
|
||||
QStringList *mask = nullptr);
|
||||
|
||||
bool moveFolder(const QString &from, const QString &to, const QString &ignore);
|
||||
bool moveFolder(const QString &from, const QString &to, const QString &ignore = "");
|
||||
|
||||
void clear(const QString& targetDir, bool force);
|
||||
|
||||
|
6
Deploy/packagecontrol.cpp
Normal file
6
Deploy/packagecontrol.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "packagecontrol.h"
|
||||
|
||||
PackageControl::PackageControl()
|
||||
{
|
||||
|
||||
}
|
19
Deploy/packagecontrol.h
Normal file
19
Deploy/packagecontrol.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef PACKAGECONTROL_H
|
||||
#define PACKAGECONTROL_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
/**
|
||||
* @brief The PackageControl class - this is interface for move files for package
|
||||
*/
|
||||
class PackageControl
|
||||
{
|
||||
public:
|
||||
PackageControl();
|
||||
virtual bool movePackage(const QString& package,
|
||||
const QString& newLocation) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PACKAGECONTROL_H
|
@ -1,5 +1,6 @@
|
||||
#include "Distributions/idistribution.h"
|
||||
#include "deployconfig.h"
|
||||
#include "filemanager.h"
|
||||
#include "packing.h"
|
||||
#include "pathutils.h"
|
||||
#include "quasarapp.h"
|
||||
@ -7,7 +8,10 @@
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
|
||||
Packing::Packing() {
|
||||
Packing::Packing(FileManager *fileManager) {
|
||||
assert(fileManager);
|
||||
|
||||
_fileManager = fileManager;
|
||||
_proc = new QProcess(this);
|
||||
|
||||
connect(_proc, SIGNAL(readyReadStandardError()),
|
||||
@ -28,27 +32,31 @@ void Packing::setDistribution(const QList<iDistribution*> &pakages) {
|
||||
|
||||
bool Packing::create() {
|
||||
|
||||
if (!collectPackages()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto package : _pakage) {
|
||||
|
||||
if (!package)
|
||||
return false;
|
||||
|
||||
if (!package->deployTemplate())
|
||||
if (!package->deployTemplate(*this))
|
||||
return false;
|
||||
|
||||
if (package->runCmd().size()) {
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
QFileInfo cmdInfo(_pakage->runCmd());
|
||||
QFileInfo cmdInfo(package->runCmd());
|
||||
|
||||
auto allExecRight = QFile::ExeUser | QFile::ExeGroup | QFile::ExeOwner;
|
||||
if (!cmdInfo.permission(allExecRight)) {
|
||||
QFile::setPermissions(cmdInfo.absoluteFilePath(), cmdInfo.permissions() | allExecRight);
|
||||
}
|
||||
|
||||
_proc->setProgram(_pakage->runCmd());
|
||||
_proc->setProgram(package->runCmd());
|
||||
_proc->setProcessEnvironment(_proc->processEnvironment());
|
||||
_proc->setArguments(_pakage->runArg());
|
||||
_proc->setArguments(package->runArg());
|
||||
_proc->setWorkingDirectory(cfg->getTargetDir());
|
||||
|
||||
_proc->start();
|
||||
@ -74,9 +82,27 @@ bool Packing::create() {
|
||||
}
|
||||
}
|
||||
|
||||
_pakage->removeTemplate();
|
||||
if (!restorePackagesLocations()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
package->removeTemplate();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Packing::movePackage(const QString &package,
|
||||
const QString &newLocation) {
|
||||
|
||||
if (moveData(_packagesLocations.value(package),
|
||||
newLocation)) {
|
||||
|
||||
_packagesLocations[package] = newLocation;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QMultiMap<int ,QPair<QString, const DistroModule*>>
|
||||
@ -89,7 +115,7 @@ sortPackages(const QHash<QString, DistroModule> &input) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Packing::collectPackages() {
|
||||
bool Packing::collectPackages() {
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
auto sortedMap = sortPackages(cfg->packages());
|
||||
@ -113,12 +139,29 @@ void Packing::collectPackages() {
|
||||
((it.first.isEmpty())? "Application": Name);
|
||||
|
||||
|
||||
_packages.insert(it.first, location);
|
||||
_packagesLocations.insert(it.first, location);
|
||||
|
||||
if (!moveData(cfg->getTargetDir() + "/" + it.first, location, tmpPakcageLocation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_defaultPackagesLocations = _packagesLocations;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Packing::moveData(const QString &from, const QString &to, const QString &ignore) const {
|
||||
return _fileManager->moveFolder(from, to, ignore);
|
||||
}
|
||||
|
||||
bool Packing::restorePackagesLocations() {
|
||||
for (auto it = _packagesLocations.begin(); it != _packagesLocations.end(); ++it) {
|
||||
if (!moveData(it.value(), _defaultPackagesLocations.value(it.key()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Packing::handleOutputUpdate() {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include "deploy_global.h"
|
||||
#include "packagecontrol.h"
|
||||
|
||||
/**
|
||||
* @brief The Packing class - this class have interface for configure package and
|
||||
@ -12,27 +13,38 @@
|
||||
|
||||
class ConfigParser;
|
||||
class iDistribution;
|
||||
class FileManager;
|
||||
|
||||
class DEPLOYSHARED_EXPORT Packing : public QObject
|
||||
|
||||
class DEPLOYSHARED_EXPORT Packing : public QObject, public PackageControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Packing();
|
||||
Packing(FileManager *fileManager);
|
||||
~Packing();
|
||||
void setDistribution(const QList<iDistribution*> &pakages);
|
||||
bool create();
|
||||
|
||||
bool movePackage(const QString &package, const QString &newLocation);
|
||||
|
||||
private:
|
||||
|
||||
void collectPackages();
|
||||
bool collectPackages();
|
||||
bool moveData(const QString& from, const QString& to,
|
||||
const QString &ignore = "") const;
|
||||
|
||||
bool restorePackagesLocations();
|
||||
|
||||
QList<iDistribution*> _pakage;
|
||||
QProcess *_proc = nullptr;
|
||||
QHash<QString, QString> _packages;
|
||||
QHash<QString, QString> _packagesLocations;
|
||||
QHash<QString, QString> _defaultPackagesLocations;
|
||||
|
||||
FileManager* _fileManager = nullptr;
|
||||
|
||||
private slots:
|
||||
void handleOutputUpdate();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // PACKING_H
|
||||
|
@ -354,7 +354,7 @@ void deploytest::testDeployTarget() {
|
||||
|
||||
FileManager file;
|
||||
DependenciesScanner scan;
|
||||
Packing pac;
|
||||
Packing pac(&file);
|
||||
PluginsParser _pluginParser;
|
||||
|
||||
ConfigParser *deploy = new ConfigParser(&file, &_pluginParser, &scan, &pac);
|
||||
@ -922,7 +922,7 @@ void deploytest::testSetTargetDir() {
|
||||
|
||||
FileManager file;
|
||||
DependenciesScanner scan;
|
||||
Packing pac;
|
||||
Packing pac(&file);
|
||||
PluginsParser _plugins;
|
||||
ConfigParser dep(&file, &_plugins, &scan, &pac);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user