mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 18:54:33 +00:00
fix multipacking configuration
This commit is contained in:
parent
dabff2b2b1
commit
c182a1ebc9
@ -36,7 +36,7 @@ bool Deb::deployTemplate(PackageControl &pkg) {
|
||||
|
||||
TemplateInfo info;
|
||||
bool fDefaultPakcage;
|
||||
if (!collectInfo(it, cfg, info, fDefaultPakcage)) {
|
||||
if (!collectInfoWithDeployIcons(package, it.key(), cfg, info, fDefaultPakcage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,66 +140,71 @@ void iDistribution::registerOutFiles() const {
|
||||
}
|
||||
}
|
||||
|
||||
bool iDistribution::collectInfo(
|
||||
const QHash<QString, DistroModule>::const_iterator& it,
|
||||
const DeployConfig * cfg,
|
||||
TemplateInfo &info,
|
||||
bool &fDefaultPakcage) {
|
||||
bool iDistribution::collectInfoWithDeployIcons(const DistroModule &pkg,
|
||||
const QString &pkgKey,
|
||||
const DeployConfig *cfg,
|
||||
TemplateInfo &info,
|
||||
bool &fDefaultPakcage) {
|
||||
|
||||
auto package = it.value();
|
||||
if (!collectInfo(pkg, pkgKey, cfg, info, fDefaultPakcage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
info.Name = PathUtils::stripPath(it.key());
|
||||
return deployIcon(info, pkg);
|
||||
|
||||
}
|
||||
|
||||
bool iDistribution::collectInfo(const DistroModule& pkg,
|
||||
const QString &pkgKey,
|
||||
const DeployConfig * cfg,
|
||||
TemplateInfo &info,
|
||||
bool &fDefaultPakcage) {
|
||||
|
||||
info.Name = PathUtils::stripPath(pkgKey);
|
||||
fDefaultPakcage = cfg->getDefaultPackage() == info.Name;
|
||||
|
||||
if (fDefaultPakcage) {
|
||||
QFileInfo targetInfo(*package.targets().begin());
|
||||
auto targets = pkg.targets();
|
||||
if (fDefaultPakcage && targets.size()) {
|
||||
QFileInfo targetInfo(*pkg.targets().begin());
|
||||
info.Name = targetInfo.baseName();
|
||||
}
|
||||
|
||||
if (!package.name().isEmpty()) {
|
||||
info.Name = package.name();
|
||||
if (!pkg.name().isEmpty()) {
|
||||
info.Name = pkg.name();
|
||||
}
|
||||
|
||||
auto localData = dataLocation(info.Name);
|
||||
|
||||
info.Description = "This package contains the " + info.Name;
|
||||
if (!package.description().isEmpty())
|
||||
info.Description = package.description();
|
||||
if (!pkg.description().isEmpty())
|
||||
info.Description = pkg.description();
|
||||
|
||||
if (!package.homePage().isEmpty())
|
||||
info.Homepage = package.homePage();
|
||||
if (!pkg.homePage().isEmpty())
|
||||
info.Homepage = pkg.homePage();
|
||||
|
||||
info.Version = "1.0";
|
||||
if (!package.version().isEmpty())
|
||||
info.Version = package.version();
|
||||
if (!pkg.version().isEmpty())
|
||||
info.Version = pkg.version();
|
||||
|
||||
info.ReleaseData = QDate::currentDate().toString("yyyy-MM-dd");
|
||||
if (!package.releaseData().isEmpty())
|
||||
info.ReleaseData = package.releaseData();
|
||||
if (!pkg.releaseData().isEmpty())
|
||||
info.ReleaseData = pkg.releaseData();
|
||||
|
||||
info.Icon = "icons/Icon.png";
|
||||
if (package.icon().isEmpty()) {
|
||||
if (!copyFile(":/shared/Distributions/Templates/Icon.png",
|
||||
localData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QFileInfo iconInfo(package.icon());
|
||||
if (!pkg.icon().isEmpty()) {
|
||||
QFileInfo iconInfo(pkg.icon());
|
||||
info.Icon = info.Name + "/icons/" + iconInfo.fileName();
|
||||
if (!copyFile(package.icon(), localData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
info.Publisher = "Company";
|
||||
if (!package.publisher().isEmpty())
|
||||
info.Publisher = package.publisher();
|
||||
if (!pkg.publisher().isEmpty())
|
||||
info.Publisher = pkg.publisher();
|
||||
|
||||
QString cmdArray = "[";
|
||||
QString bashArray = "";
|
||||
|
||||
int initSize = cmdArray.size();
|
||||
for (const auto &target :package.targets()) {
|
||||
for (const auto &target :pkg.targets()) {
|
||||
auto fileinfo = QFileInfo(target);
|
||||
if (fileinfo.suffix().compare("exe", ONLY_WIN_CASE_INSENSIATIVE) == 0 || fileinfo.suffix().isEmpty()) {
|
||||
if (cmdArray.size() > initSize) {
|
||||
@ -225,4 +230,24 @@ bool iDistribution::collectInfo(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool iDistribution::deployIcon(TemplateInfo &info ,const DistroModule& pkg) {
|
||||
auto localData = dataLocation(info.Name);
|
||||
|
||||
info.Icon = "icons/Icon.png";
|
||||
if (pkg.icon().isEmpty()) {
|
||||
if (!copyFile(":/shared/Distributions/Templates/Icon.png",
|
||||
localData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QFileInfo iconInfo(pkg.icon());
|
||||
info.Icon = info.Name + "/icons/" + iconInfo.fileName();
|
||||
if (!copyFile(pkg.icon(), localData + "/icons/", false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,19 +57,47 @@ protected:
|
||||
void registerOutFiles() const;
|
||||
|
||||
/**
|
||||
* @brief collectInfo This method collect information about package.
|
||||
* @param it This is iterator of package.
|
||||
* @brief collectInfoWithDeployIcons This is wraper of the collectInfo and deployIcon methods.
|
||||
* @param pkg This is package object.
|
||||
* @param pkgKey This is package key value.
|
||||
* @param cfg This is pointer to config.
|
||||
* @param info This is return value (created template information)
|
||||
* @param fDefaultPakcage This is return value
|
||||
* (return true if package that collected information is a default package)
|
||||
* @return true if information collected successful.
|
||||
*/
|
||||
bool collectInfo(const QHash<QString, DistroModule>::const_iterator &it,
|
||||
bool collectInfoWithDeployIcons(const DistroModule &pkg,
|
||||
const QString& pkgKey,
|
||||
const DeployConfig *cfg,
|
||||
TemplateInfo& info,
|
||||
bool &fDefaultPakcage);
|
||||
|
||||
/**
|
||||
* @brief collectInfo This method collect information about package.
|
||||
* @param pkg This is package object.
|
||||
* @param pkgKey This is package key value.
|
||||
* @param cfg This is pointer to config.
|
||||
* @param info This is return value (created template information)
|
||||
* @param fDefaultPakcage This is return value
|
||||
* (return true if package that collected information is a default package)
|
||||
* @return true if information collected successful.
|
||||
*/
|
||||
bool collectInfo(const DistroModule &pkg,
|
||||
const QString& pkgKey,
|
||||
const DeployConfig *cfg,
|
||||
TemplateInfo& info,
|
||||
bool &fDefaultPakcage);
|
||||
|
||||
/**
|
||||
* @brief deployIcon This method copy default or custom icon to the package.
|
||||
* @param info This is information about package.
|
||||
* @note This method change the icon field of the info object.
|
||||
* If packages support the icons then you need to invocke this method after the collectInfo method.
|
||||
* @param pkg This is package info
|
||||
* @return true if this method finished successful.
|
||||
*/
|
||||
bool deployIcon(TemplateInfo &info, const DistroModule &pkg);
|
||||
|
||||
/**
|
||||
* @brief dataLocation This method should be retrun location of application or package files.
|
||||
* @param packageName This is name of package that request data location.
|
||||
|
@ -13,6 +13,7 @@ QIF::QIF(FileManager *fileManager)
|
||||
:iDistribution(fileManager){
|
||||
|
||||
setLocation("tmp QIF");
|
||||
|
||||
};
|
||||
|
||||
Envirement QIF::toolKitEnv() const {
|
||||
@ -82,6 +83,13 @@ QList<SystemCommandData> QIF::runCmd() {
|
||||
}
|
||||
|
||||
bool QIF::deployTemplate(PackageControl &pkg) {
|
||||
if (!initDefaultConfiguratuin()) {
|
||||
|
||||
QuasarAppUtils::Params::log("Fail to init rhe default configuration of the qif installer.",
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto customTemplate = QuasarAppUtils::Params::getStrArg("qif", "");
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
@ -165,6 +173,9 @@ QStringList QIF::outPutFiles() const {
|
||||
}
|
||||
|
||||
QString QIF::dataLocation(const QString &packageName) const {
|
||||
if (packageName.isEmpty())
|
||||
return "";
|
||||
|
||||
const DeployConfig* cfg = DeployCore::_config;
|
||||
|
||||
QString result = location(packageName) + "/data";
|
||||
@ -176,6 +187,10 @@ QString QIF::dataLocation(const QString &packageName) const {
|
||||
}
|
||||
|
||||
QString QIF::location(const QString &packageName) const {
|
||||
|
||||
if (packageName.isEmpty())
|
||||
return "";
|
||||
|
||||
const DeployConfig* cfg = DeployCore::_config;
|
||||
return cfg->getTargetDir() + "/" + getLocation() + "/packages/" + packageName;
|
||||
}
|
||||
@ -221,7 +236,7 @@ bool QIF::deployPackage(const QHash<QString, DistroModule>::const_iterator& it,
|
||||
|
||||
TemplateInfo info;
|
||||
bool fDefaultPakcage;
|
||||
if (!collectInfo(it, cfg, info, fDefaultPakcage)) {
|
||||
if (!collectInfoWithDeployIcons(it.value(), it.key(), cfg, info, fDefaultPakcage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -243,3 +258,11 @@ bool QIF::deployPackage(const QHash<QString, DistroModule>::const_iterator& it,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QIF::initDefaultConfiguratuin() {
|
||||
const DeployConfig *cfg = DeployCore::_config;
|
||||
|
||||
// init default configuration
|
||||
bool fDefaultPakcage;
|
||||
return collectInfo({}, cfg->getDefaultPackage(), cfg, generalInfo, fDefaultPakcage);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,12 @@ private:
|
||||
const QString &defaultPackageTempalte,
|
||||
PackageControl &pkg);
|
||||
|
||||
/**
|
||||
* @brief initDefaultConfiguratuin This method initialise the default configuration of installer.
|
||||
* @return true if functions finished successful.
|
||||
*/
|
||||
bool initDefaultConfiguratuin();
|
||||
|
||||
QString binarycreator;
|
||||
TemplateInfo generalInfo;
|
||||
|
||||
|
@ -16,6 +16,7 @@ struct DEPLOYSHARED_EXPORT TemplateInfo
|
||||
QString Homepage;
|
||||
|
||||
QHash<QString, QString> Custom;
|
||||
|
||||
};
|
||||
|
||||
#endif // TEMPLATEINFO_H
|
||||
|
@ -24,7 +24,7 @@ bool ZipArhive::deployTemplate(PackageControl &pkg) {
|
||||
|
||||
TemplateInfo info;
|
||||
bool fDefaultPakcage;
|
||||
if (!collectInfo(it, cfg, info, fDefaultPakcage)) {
|
||||
if (!collectInfo(package, it.key(), cfg, info, fDefaultPakcage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -483,22 +483,21 @@ bool ConfigParser::initPackages() {
|
||||
}
|
||||
|
||||
// init default packages
|
||||
bool fdefaultPackage = false;
|
||||
bool fDefaultPackage = false;
|
||||
for (auto it = _config.targetsEdit().begin(); it != _config.targetsEdit().end(); ++it) {
|
||||
if (!configuredTargets.contains(it.key())) {
|
||||
configuredTargets.insert(it.key());
|
||||
it.value().setPackage(defaultPackage);
|
||||
fdefaultPackage = true;
|
||||
fDefaultPackage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fdefaultPackage) {
|
||||
if (fDefaultPackage) {
|
||||
_config.packagesEdit().insert(defaultPackage, {});
|
||||
_config.setDefaultPackage(defaultPackage);
|
||||
} else {
|
||||
_config.setDefaultPackage(_config.packages().begin().key());
|
||||
}
|
||||
|
||||
_config.setDefaultPackage(defaultPackage);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -990,7 +990,8 @@ void deploytest::testQmlScaner() {
|
||||
}
|
||||
|
||||
void deploytest::customTest() {
|
||||
|
||||
runTestParams({"-confFile", "pass to tested configuration",
|
||||
"qifFromSystem"});
|
||||
}
|
||||
|
||||
void deploytest::testQmlExtrct() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user