cmake/Source/CPack/IFW/cmCPackIFWInstaller.cxx

564 lines
17 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2015-04-27 22:25:09 +02:00
#include "cmCPackIFWInstaller.h"
2020-02-01 23:06:01 +01:00
#include <cstddef>
#include <sstream>
#include <utility>
2017-07-20 19:35:53 +02:00
#include "cmCPackIFWCommon.h"
2015-04-27 22:25:09 +02:00
#include "cmCPackIFWGenerator.h"
2016-10-30 18:24:19 +01:00
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWRepository.h"
2017-07-20 19:35:53 +02:00
#include "cmCPackLog.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
#include "cmGeneratedFileStream.h"
2020-02-01 23:06:01 +01:00
#include "cmStringAlgorithms.h"
2016-10-30 18:24:19 +01:00
#include "cmSystemTools.h"
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
2015-04-27 22:25:09 +02:00
2019-11-11 23:01:05 +01:00
cmCPackIFWInstaller::cmCPackIFWInstaller() = default;
2015-08-17 11:37:30 +02:00
2017-04-14 19:02:05 +02:00
void cmCPackIFWInstaller::printSkippedOptionWarning(
const std::string& optionName, const std::string& optionValue)
{
2017-07-20 19:35:53 +02:00
cmCPackIFWLogger(
2018-08-09 18:06:22 +02:00
WARNING,
"Option "
2017-04-14 19:02:05 +02:00
<< optionName << " is set to \"" << optionValue
<< "\" but will be skipped because the specified file does not exist."
<< std::endl);
}
2015-04-27 22:25:09 +02:00
void cmCPackIFWInstaller::ConfigureFromOptions()
{
// Name;
if (const char* optIFW_PACKAGE_NAME =
2016-07-09 11:21:54 +02:00
this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
2017-07-20 19:35:53 +02:00
this->Name = optIFW_PACKAGE_NAME;
2016-07-09 11:21:54 +02:00
} else if (const char* optPACKAGE_NAME =
this->GetOption("CPACK_PACKAGE_NAME")) {
2017-07-20 19:35:53 +02:00
this->Name = optPACKAGE_NAME;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->Name = "Your package";
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Title;
if (const char* optIFW_PACKAGE_TITLE =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_IFW_PACKAGE_TITLE")) {
this->Title = optIFW_PACKAGE_TITLE;
2016-07-09 11:21:54 +02:00
} else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
this->Title = optPACKAGE_DESCRIPTION_SUMMARY;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->Title = "Your package description";
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Version;
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_PACKAGE_VERSION")) {
this->Version = option;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->Version = "1.0.0";
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Publisher
2016-07-09 11:21:54 +02:00
if (const char* optIFW_PACKAGE_PUBLISHER =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
this->Publisher = optIFW_PACKAGE_PUBLISHER;
2016-07-09 11:21:54 +02:00
} else if (const char* optPACKAGE_VENDOR =
2021-09-14 00:13:48 +02:00
this->GetOption("CPACK_PACKAGE_VENDOR")) {
2017-07-20 19:35:53 +02:00
this->Publisher = optPACKAGE_VENDOR;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// ProductUrl
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PRODUCT_URL")) {
this->ProductUrl = option;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// ApplicationIcon
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_ICON")) {
2016-07-09 11:21:54 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->InstallerApplicationIcon = option;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_ICON", option);
2015-04-27 22:25:09 +02:00
}
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// WindowIcon
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
2016-07-09 11:21:54 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->InstallerWindowIcon = option;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WINDOW_ICON", option);
2015-04-27 22:25:09 +02:00
}
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2018-04-23 21:13:27 +02:00
// RemoveTargetDir
if (this->IsSetToOff("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
this->RemoveTargetDir = "false";
} else if (this->IsOn("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
this->RemoveTargetDir = "true";
} else {
this->RemoveTargetDir.clear();
}
2015-04-27 22:25:09 +02:00
// Logo
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_LOGO")) {
2016-07-09 11:21:54 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->Logo = option;
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_LOGO", option);
2017-04-14 19:02:05 +02:00
}
}
// Watermark
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WATERMARK")) {
2017-04-14 19:02:05 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->Watermark = option;
2017-04-14 19:02:05 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WATERMARK", option);
2017-04-14 19:02:05 +02:00
}
}
// Banner
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_BANNER")) {
2017-04-14 19:02:05 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->Banner = option;
2017-04-14 19:02:05 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BANNER", option);
2017-04-14 19:02:05 +02:00
}
}
// Background
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_BACKGROUND")) {
2017-04-14 19:02:05 +02:00
if (cmSystemTools::FileExists(option)) {
2017-07-20 19:35:53 +02:00
this->Background = option;
2017-04-14 19:02:05 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BACKGROUND", option);
2017-04-14 19:02:05 +02:00
}
}
// WizardStyle
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WIZARD_STYLE")) {
// Setting the user value in any case
this->WizardStyle = option;
// Check known values
if (this->WizardStyle != "Modern" && this->WizardStyle != "Aero" &&
this->WizardStyle != "Mac" && this->WizardStyle != "Classic") {
cmCPackIFWLogger(
2018-08-09 18:06:22 +02:00
WARNING,
"Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \""
2017-04-14 19:02:05 +02:00
<< option << "\". Expected values are: Modern, Aero, Mac, Classic."
<< std::endl);
2015-04-27 22:25:09 +02:00
}
2017-04-14 19:02:05 +02:00
}
2019-11-11 23:01:05 +01:00
// StyleSheet
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) {
if (cmSystemTools::FileExists(option)) {
this->StyleSheet = option;
} else {
this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_STYLE_SHEET", option);
}
}
2017-04-14 19:02:05 +02:00
// WizardDefaultWidth
if (const char* option =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) {
this->WizardDefaultWidth = option;
2017-04-14 19:02:05 +02:00
}
// WizardDefaultHeight
if (const char* option =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT")) {
this->WizardDefaultHeight = option;
2017-04-14 19:02:05 +02:00
}
2021-09-14 00:13:48 +02:00
// WizardShowPageList
if (const char* option =
this->GetOption("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
if (!this->IsVersionLess("4.0")) {
if (this->IsSetToOff("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
this->WizardShowPageList = "false";
} else if (this->IsOn("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
this->WizardShowPageList = "true";
} else {
this->WizardShowPageList.clear();
}
} else {
std::string currentVersionMsg;
if (this->Generator) {
currentVersionMsg =
"QtIFW version " + this->Generator->FrameworkVersion;
} else {
currentVersionMsg = "an older QtIFW version";
}
cmCPackIFWLogger(
WARNING,
"Option CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST is set to \""
<< option
<< "\", but it is only supported with QtIFW version 4.0 or later. "
"It is being ignored because you are using "
<< currentVersionMsg << std::endl);
}
}
2017-04-14 19:02:05 +02:00
// TitleColor
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_TITLE_COLOR")) {
this->TitleColor = option;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2015-08-17 11:37:30 +02:00
// Start menu
if (const char* optIFW_START_MENU_DIR =
2016-07-09 11:21:54 +02:00
this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
2017-07-20 19:35:53 +02:00
this->StartMenuDir = optIFW_START_MENU_DIR;
2016-07-09 11:21:54 +02:00
} else {
2021-09-14 00:13:48 +02:00
this->StartMenuDir = this->Name;
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
2015-04-27 22:25:09 +02:00
// Default target directory for installation
if (const char* optIFW_TARGET_DIRECTORY =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
this->TargetDir = optIFW_TARGET_DIRECTORY;
2016-07-09 11:21:54 +02:00
} else if (const char* optPACKAGE_INSTALL_DIRECTORY =
2017-07-20 19:35:53 +02:00
this->GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
2020-02-01 23:06:01 +01:00
this->TargetDir =
cmStrCat("@ApplicationsDir@/", optPACKAGE_INSTALL_DIRECTORY);
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->TargetDir = "@RootDir@/usr/local";
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Default target directory for installation with administrator rights
2017-07-20 19:35:53 +02:00
if (const char* option =
this->GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
this->AdminTargetDir = option;
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Maintenance tool
2016-07-09 11:21:54 +02:00
if (const char* optIFW_MAINTENANCE_TOOL =
this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
2017-07-20 19:35:53 +02:00
this->MaintenanceToolName = optIFW_MAINTENANCE_TOOL;
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Maintenance tool ini file
2016-07-09 11:21:54 +02:00
if (const char* optIFW_MAINTENANCE_TOOL_INI =
this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
2017-07-20 19:35:53 +02:00
this->MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI;
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Allow non-ASCII characters
2016-07-09 11:21:54 +02:00
if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
2017-07-20 19:35:53 +02:00
if (this->IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
this->AllowNonAsciiCharacters = "true";
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->AllowNonAsciiCharacters = "false";
2015-08-17 11:37:30 +02:00
}
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Space in path
2016-07-09 11:21:54 +02:00
if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
2017-07-20 19:35:53 +02:00
if (this->IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
this->AllowSpaceInPath = "true";
2016-07-09 11:21:54 +02:00
} else {
2017-07-20 19:35:53 +02:00
this->AllowSpaceInPath = "false";
2015-08-17 11:37:30 +02:00
}
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Control script
2016-07-09 11:21:54 +02:00
if (const char* optIFW_CONTROL_SCRIPT =
this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
2017-07-20 19:35:53 +02:00
this->ControlScript = optIFW_CONTROL_SCRIPT;
2016-07-09 11:21:54 +02:00
}
2016-10-30 18:24:19 +01:00
// Resources
if (const char* optIFW_PACKAGE_RESOURCES =
this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) {
2017-07-20 19:35:53 +02:00
this->Resources.clear();
2020-02-01 23:06:01 +01:00
cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources);
2016-10-30 18:24:19 +01:00
}
2015-04-27 22:25:09 +02:00
}
2016-10-30 18:24:19 +01:00
/** \class cmCPackIFWResourcesParser
* \brief Helper class that parse resources form .qrc (Qt)
*/
class cmCPackIFWResourcesParser : public cmXMLParser
{
public:
2021-09-14 00:13:48 +02:00
explicit cmCPackIFWResourcesParser(cmCPackIFWInstaller* i)
2016-10-30 18:24:19 +01:00
: installer(i)
{
2017-07-20 19:35:53 +02:00
this->path = i->Directory + "/resources";
2016-10-30 18:24:19 +01:00
}
bool ParseResource(size_t r)
{
2017-07-20 19:35:53 +02:00
this->hasFiles = false;
this->hasErrors = false;
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
this->basePath =
cmSystemTools::GetFilenamePath(this->installer->Resources[r]);
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
this->ParseFile(this->installer->Resources[r].data());
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
return this->hasFiles && !this->hasErrors;
2016-10-30 18:24:19 +01:00
}
cmCPackIFWInstaller* installer;
2021-09-14 00:13:48 +02:00
bool file = false;
bool hasFiles = false;
bool hasErrors = false;
2016-10-30 18:24:19 +01:00
std::string path, basePath;
protected:
2018-01-26 17:06:56 +01:00
void StartElement(const std::string& name, const char** /*atts*/) override
2016-10-30 18:24:19 +01:00
{
2017-07-20 19:35:53 +02:00
this->file = name == "file";
2021-09-14 00:13:48 +02:00
if (this->file) {
2017-07-20 19:35:53 +02:00
this->hasFiles = true;
2016-10-30 18:24:19 +01:00
}
}
2018-01-26 17:06:56 +01:00
void CharacterDataHandler(const char* data, int length) override
2016-10-30 18:24:19 +01:00
{
2017-07-20 19:35:53 +02:00
if (this->file) {
2016-10-30 18:24:19 +01:00
std::string content(data, data + length);
2020-02-01 23:06:01 +01:00
content = cmTrimWhitespace(content);
2017-07-20 19:35:53 +02:00
std::string source = this->basePath + "/" + content;
std::string destination = this->path + "/" + content;
2019-11-11 23:01:05 +01:00
if (!cmSystemTools::CopyFileIfDifferent(source, destination)) {
2017-07-20 19:35:53 +02:00
this->hasErrors = true;
2016-10-30 18:24:19 +01:00
}
}
}
2018-01-26 17:06:56 +01:00
void EndElement(const std::string& /*name*/) override {}
2016-10-30 18:24:19 +01:00
};
2015-04-27 22:25:09 +02:00
void cmCPackIFWInstaller::GenerateInstallerFile()
{
// Lazy directory initialization
2017-07-20 19:35:53 +02:00
if (this->Directory.empty() && this->Generator) {
this->Directory = this->Generator->toplevel;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Output stream
2018-10-28 12:09:07 +01:00
cmGeneratedFileStream fout(this->Directory + "/config/config.xml");
2016-07-09 11:21:54 +02:00
cmXMLWriter xout(fout);
2015-04-27 22:25:09 +02:00
2016-07-09 11:21:54 +02:00
xout.StartDocument();
2015-08-17 11:37:30 +02:00
2021-09-14 00:13:48 +02:00
this->WriteGeneratedByToStrim(xout);
2015-08-17 11:37:30 +02:00
2016-07-09 11:21:54 +02:00
xout.StartElement("Installer");
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
xout.Element("Name", this->Name);
xout.Element("Version", this->Version);
xout.Element("Title", this->Title);
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
if (!this->Publisher.empty()) {
xout.Element("Publisher", this->Publisher);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
if (!this->ProductUrl.empty()) {
xout.Element("ProductUrl", this->ProductUrl);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// ApplicationIcon
2017-07-20 19:35:53 +02:00
if (!this->InstallerApplicationIcon.empty()) {
2015-04-27 22:25:09 +02:00
std::string name =
2017-07-20 19:35:53 +02:00
cmSystemTools::GetFilenameName(this->InstallerApplicationIcon);
std::string path = this->Directory + "/config/" + name;
2015-04-27 22:25:09 +02:00
name = cmSystemTools::GetFilenameWithoutExtension(name);
2017-07-20 19:35:53 +02:00
cmsys::SystemTools::CopyFileIfDifferent(this->InstallerApplicationIcon,
path);
2016-07-09 11:21:54 +02:00
xout.Element("InstallerApplicationIcon", name);
}
2015-04-27 22:25:09 +02:00
// WindowIcon
2017-07-20 19:35:53 +02:00
if (!this->InstallerWindowIcon.empty()) {
std::string name =
cmSystemTools::GetFilenameName(this->InstallerWindowIcon);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->InstallerWindowIcon, path);
2016-07-09 11:21:54 +02:00
xout.Element("InstallerWindowIcon", name);
}
2015-04-27 22:25:09 +02:00
// Logo
2017-07-20 19:35:53 +02:00
if (!this->Logo.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->Logo);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Logo, path);
2016-07-09 11:21:54 +02:00
xout.Element("Logo", name);
}
2015-04-27 22:25:09 +02:00
2017-04-14 19:02:05 +02:00
// Banner
2017-07-20 19:35:53 +02:00
if (!this->Banner.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->Banner);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Banner, path);
2017-04-14 19:02:05 +02:00
xout.Element("Banner", name);
}
// Watermark
2017-07-20 19:35:53 +02:00
if (!this->Watermark.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->Watermark);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Watermark, path);
2017-04-14 19:02:05 +02:00
xout.Element("Watermark", name);
}
// Background
2017-07-20 19:35:53 +02:00
if (!this->Background.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->Background);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Background, path);
2017-04-14 19:02:05 +02:00
xout.Element("Background", name);
}
// WizardStyle
2017-07-20 19:35:53 +02:00
if (!this->WizardStyle.empty()) {
xout.Element("WizardStyle", this->WizardStyle);
2017-04-14 19:02:05 +02:00
}
2019-11-11 23:01:05 +01:00
// Stylesheet
if (!this->StyleSheet.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->StyleSheet);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->StyleSheet, path);
xout.Element("StyleSheet", name);
}
2017-04-14 19:02:05 +02:00
// WizardDefaultWidth
2017-07-20 19:35:53 +02:00
if (!this->WizardDefaultWidth.empty()) {
xout.Element("WizardDefaultWidth", this->WizardDefaultWidth);
2017-04-14 19:02:05 +02:00
}
// WizardDefaultHeight
2017-07-20 19:35:53 +02:00
if (!this->WizardDefaultHeight.empty()) {
xout.Element("WizardDefaultHeight", this->WizardDefaultHeight);
2017-04-14 19:02:05 +02:00
}
2021-09-14 00:13:48 +02:00
// WizardShowPageList
if (!this->IsVersionLess("4.0") && !this->WizardShowPageList.empty()) {
xout.Element("WizardShowPageList", this->WizardShowPageList);
}
2017-04-14 19:02:05 +02:00
// TitleColor
2017-07-20 19:35:53 +02:00
if (!this->TitleColor.empty()) {
xout.Element("TitleColor", this->TitleColor);
2017-04-14 19:02:05 +02:00
}
2015-08-17 11:37:30 +02:00
// Start menu
2017-07-20 19:35:53 +02:00
if (!this->IsVersionLess("2.0")) {
xout.Element("StartMenuDir", this->StartMenuDir);
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Target dir
2017-07-20 19:35:53 +02:00
if (!this->TargetDir.empty()) {
xout.Element("TargetDir", this->TargetDir);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2015-08-17 11:37:30 +02:00
// Admin target dir
2017-07-20 19:35:53 +02:00
if (!this->AdminTargetDir.empty()) {
xout.Element("AdminTargetDir", this->AdminTargetDir);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Remote repositories
2017-07-20 19:35:53 +02:00
if (!this->RemoteRepositories.empty()) {
2016-07-09 11:21:54 +02:00
xout.StartElement("RemoteRepositories");
2018-01-26 17:06:56 +01:00
for (cmCPackIFWRepository* r : this->RemoteRepositories) {
r->WriteRepositoryConfig(xout);
2015-04-27 22:25:09 +02:00
}
2016-07-09 11:21:54 +02:00
xout.EndElement();
}
2015-04-27 22:25:09 +02:00
2015-08-17 11:37:30 +02:00
// Maintenance tool
2017-07-20 19:35:53 +02:00
if (!this->IsVersionLess("2.0") && !this->MaintenanceToolName.empty()) {
xout.Element("MaintenanceToolName", this->MaintenanceToolName);
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Maintenance tool ini file
2017-07-20 19:35:53 +02:00
if (!this->IsVersionLess("2.0") && !this->MaintenanceToolIniFile.empty()) {
xout.Element("MaintenanceToolIniFile", this->MaintenanceToolIniFile);
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
2018-04-23 21:13:27 +02:00
if (!this->RemoveTargetDir.empty()) {
xout.Element("RemoveTargetDir", this->RemoveTargetDir);
}
2015-08-17 11:37:30 +02:00
// Different allows
2017-07-20 19:35:53 +02:00
if (this->IsVersionLess("2.0")) {
2015-08-17 11:37:30 +02:00
// CPack IFW default policy
2016-07-09 11:21:54 +02:00
xout.Comment("CPack IFW default policy for QtIFW less 2.0");
xout.Element("AllowNonAsciiCharacters", "true");
xout.Element("AllowSpaceInPath", "true");
} else {
2017-07-20 19:35:53 +02:00
if (!this->AllowNonAsciiCharacters.empty()) {
xout.Element("AllowNonAsciiCharacters", this->AllowNonAsciiCharacters);
2015-08-17 11:37:30 +02:00
}
2017-07-20 19:35:53 +02:00
if (!this->AllowSpaceInPath.empty()) {
xout.Element("AllowSpaceInPath", this->AllowSpaceInPath);
2015-08-17 11:37:30 +02:00
}
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
// Control script (copy to config dir)
2017-07-20 19:35:53 +02:00
if (!this->IsVersionLess("2.0") && !this->ControlScript.empty()) {
std::string name = cmSystemTools::GetFilenameName(this->ControlScript);
std::string path = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->ControlScript, path);
2016-07-09 11:21:54 +02:00
xout.Element("ControlScript", name);
}
2015-04-27 22:25:09 +02:00
2016-10-30 18:24:19 +01:00
// Resources (copy to resources dir)
2017-07-20 19:35:53 +02:00
if (!this->Resources.empty()) {
2016-10-30 18:24:19 +01:00
std::vector<std::string> resources;
cmCPackIFWResourcesParser parser(this);
2017-07-20 19:35:53 +02:00
for (size_t i = 0; i < this->Resources.size(); i++) {
2016-10-30 18:24:19 +01:00
if (parser.ParseResource(i)) {
2017-07-20 19:35:53 +02:00
std::string name = cmSystemTools::GetFilenameName(this->Resources[i]);
std::string path = this->Directory + "/resources/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Resources[i], path);
2018-04-23 21:13:27 +02:00
resources.push_back(std::move(name));
2016-10-30 18:24:19 +01:00
} else {
2018-08-09 18:06:22 +02:00
cmCPackIFWLogger(WARNING,
"Can't copy resources from \""
2017-07-20 19:35:53 +02:00
<< this->Resources[i]
<< "\". Resource will be skipped." << std::endl);
2016-10-30 18:24:19 +01:00
}
}
2017-07-20 19:35:53 +02:00
this->Resources = resources;
2016-10-30 18:24:19 +01:00
}
2016-07-09 11:21:54 +02:00
xout.EndElement();
xout.EndDocument();
2015-04-27 22:25:09 +02:00
}
void cmCPackIFWInstaller::GeneratePackageFiles()
{
2017-07-20 19:35:53 +02:00
if (this->Packages.empty() || this->Generator->IsOnePackage()) {
2015-04-27 22:25:09 +02:00
// Generate default package
cmCPackIFWPackage package;
2017-07-20 19:35:53 +02:00
package.Generator = this->Generator;
2015-04-27 22:25:09 +02:00
package.Installer = this;
// Check package group
2017-07-20 19:35:53 +02:00
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
2015-04-27 22:25:09 +02:00
package.ConfigureFromGroup(option);
2017-04-14 19:02:05 +02:00
std::string forcedOption = "CPACK_IFW_COMPONENT_GROUP_" +
cmsys::SystemTools::UpperCase(option) + "_FORCED_INSTALLATION";
2021-09-14 00:13:48 +02:00
if (!this->GetOption(forcedOption)) {
2017-04-14 19:02:05 +02:00
package.ForcedInstallation = "true";
}
2016-07-09 11:21:54 +02:00
} else {
2015-04-27 22:25:09 +02:00
package.ConfigureFromOptions();
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
package.GeneratePackageFile();
return;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
// Generate packages meta information
2018-01-26 17:06:56 +01:00
for (auto& p : this->Packages) {
cmCPackIFWPackage* package = p.second;
2015-04-27 22:25:09 +02:00
package->GeneratePackageFile();
2015-08-17 11:37:30 +02:00
}
}