|
|
@@ -46,7 +46,66 @@ std::string cmCPackPKGGenerator::GetPackageName(
|
|
|
return component.ArchiveFile + ".pkg";
|
|
|
}
|
|
|
|
|
|
-void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
|
|
|
+void cmCPackPKGGenerator::CreateBackground(const char* themeName,
|
|
|
+ const char* metapackageFile,
|
|
|
+ cm::string_view genName,
|
|
|
+ cmXMLWriter& xout)
|
|
|
+{
|
|
|
+ std::string paramSuffix =
|
|
|
+ (themeName == nullptr) ? "" : cmSystemTools::UpperCase(themeName);
|
|
|
+ std::string opt = (themeName == nullptr)
|
|
|
+ ? cmStrCat("CPACK_", genName, "_BACKGROUND")
|
|
|
+ : cmStrCat("CPACK_", genName, "_BACKGROUND_", paramSuffix);
|
|
|
+ const char* bgFileName = this->GetOption(opt);
|
|
|
+ if (bgFileName == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string bgFilePath = cmStrCat(metapackageFile, "/Contents/", bgFileName);
|
|
|
+
|
|
|
+ if (!cmSystemTools::FileExists(bgFilePath)) {
|
|
|
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
+ "Background image doesn't exist in the resource directory: "
|
|
|
+ << bgFileName << std::endl);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (themeName == nullptr) {
|
|
|
+ xout.StartElement("background");
|
|
|
+ } else {
|
|
|
+ xout.StartElement(cmStrCat("background-", themeName));
|
|
|
+ }
|
|
|
+
|
|
|
+ xout.Attribute("file", bgFileName);
|
|
|
+
|
|
|
+ const char* param = this->GetOption(cmStrCat(opt, "_ALIGNMENT"));
|
|
|
+ if (param != nullptr) {
|
|
|
+ xout.Attribute("alignment", param);
|
|
|
+ }
|
|
|
+
|
|
|
+ param = this->GetOption(cmStrCat(opt, "_SCALING"));
|
|
|
+ if (param != nullptr) {
|
|
|
+ xout.Attribute("scaling", param);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Apple docs say that you must provide either mime-type or uti
|
|
|
+ // attribute for the background, but I've seen examples that
|
|
|
+ // doesn't have them, so don't make them mandatory.
|
|
|
+ param = this->GetOption(cmStrCat(opt, "_MIME_TYPE"));
|
|
|
+ if (param != nullptr) {
|
|
|
+ xout.Attribute("mime-type", param);
|
|
|
+ }
|
|
|
+
|
|
|
+ param = this->GetOption(cmStrCat(opt, "_UTI"));
|
|
|
+ if (param != nullptr) {
|
|
|
+ xout.Attribute("uti", param);
|
|
|
+ }
|
|
|
+
|
|
|
+ xout.EndElement();
|
|
|
+}
|
|
|
+
|
|
|
+void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile,
|
|
|
+ const char* genName)
|
|
|
{
|
|
|
std::string distributionTemplate =
|
|
|
this->FindTemplate("Internal/CPack/CPack.distribution.dist.in");
|
|
|
@@ -102,6 +161,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
|
|
|
CreateChoice(PostFlightComponent, xout);
|
|
|
}
|
|
|
|
|
|
+ // default background
|
|
|
+ this->CreateBackground(nullptr, metapackageFile, genName, xout);
|
|
|
+ // Dark Aqua
|
|
|
+ this->CreateBackground("darkAqua", metapackageFile, genName, xout);
|
|
|
+
|
|
|
this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
|
|
|
|
|
|
// Create the distribution.dist file in the metapackage to turn it
|