From 28fdc3a5363cc8b7b141e9bc28d8e88ce99a431c Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 21 Mar 2022 13:36:48 +1100 Subject: productbuild: Simplify internal CPACK_PRODUCTBUILD_DOMAINS usage There's no benefit to storing the CPACK_PRODUCTBUILD_DOMAINS prefix in a variable and appending to it in the C++ code. It has the disadvantage of making it harder to find usages of the variables with a suffix appended to that string. Expand out the strings at the places they are used so that they are easier to spot. --- Source/CPack/cmCPackPKGGenerator.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index d8095cc..b2d8d9a 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -293,8 +293,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, void cmCPackPKGGenerator::CreateDomains(cmXMLWriter& xout) { - std::string opt = "CPACK_PRODUCTBUILD_DOMAINS"; - if (cmIsOff(this->GetOption(opt))) { + if (cmIsOff(this->GetOption("CPACK_PRODUCTBUILD_DOMAINS"))) { return; } @@ -302,19 +301,19 @@ void cmCPackPKGGenerator::CreateDomains(cmXMLWriter& xout) // Product can be installed at the root of any volume by default // unless specified - cmValue param = this->GetOption(cmStrCat(opt, "_ANYWHERE")); + cmValue param = this->GetOption("CPACK_PRODUCTBUILD_DOMAINS_ANYWHERE"); xout.Attribute("enable_anywhere", (param && cmIsOff(param)) ? "false" : "true"); // Product cannot be installed into the current user's home directory // by default unless specified - param = this->GetOption(cmStrCat(opt, "_USER")); + param = this->GetOption("CPACK_PRODUCTBUILD_DOMAINS_USER"); xout.Attribute("enable_currentUserHome", (param && cmIsOn(param)) ? "true" : "false"); // Product can be installed into the root directory by default // unless specified - param = this->GetOption(cmStrCat(opt, "_ROOT")); + param = this->GetOption("CPACK_PRODUCTBUILD_DOMAINS_ROOT"); xout.Attribute("enable_localSystem", (param && cmIsOff(param)) ? "false" : "true"); -- cgit v0.12 From 95eb8cbcfc0fc5ca4c784efa126b3aa3dafacefd Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 21 Mar 2022 14:28:15 +1100 Subject: CPack: Avoid space / tab mix in productbuild distribution.xml template --- Modules/Internal/CPack/CPack.distribution.dist.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Internal/CPack/CPack.distribution.dist.in b/Modules/Internal/CPack/CPack.distribution.dist.in index f20e66c..e04f7bf 100644 --- a/Modules/Internal/CPack/CPack.distribution.dist.in +++ b/Modules/Internal/CPack/CPack.distribution.dist.in @@ -1,9 +1,9 @@ - @CPACK_PACKAGE_NAME@ - - - - - @CPACK_PACKAGEMAKER_CHOICES@ + @CPACK_PACKAGE_NAME@ + + + + + @CPACK_PACKAGEMAKER_CHOICES@ -- cgit v0.12 From 2a8df7e7db2ecef9652ab27371c5dbfbc56b2617 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 21 Mar 2022 15:42:46 +1100 Subject: productbuild: Don't write rootVolumeOnly attribute if writing domains The rootVolumeOnly attribute is deprecated. Apple docs say to use domains instead. Fixes: #23343 --- Modules/Internal/CPack/CPack.distribution.dist.in | 3 +-- Source/CPack/cmCPackPKGGenerator.cxx | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Modules/Internal/CPack/CPack.distribution.dist.in b/Modules/Internal/CPack/CPack.distribution.dist.in index e04f7bf..291b24d 100644 --- a/Modules/Internal/CPack/CPack.distribution.dist.in +++ b/Modules/Internal/CPack/CPack.distribution.dist.in @@ -4,6 +4,5 @@ - - @CPACK_PACKAGEMAKER_CHOICES@ +@CPACK_APPLE_PKG_INSTALLER_CONTENT@ diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index b2d8d9a..2a14ccf 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -120,10 +120,20 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, std::string distributionFile = cmStrCat(metapackageFile, "/Contents/distribution.dist"); + std::ostringstream xContents; + cmXMLWriter xout(xContents, 1); + + // Installer-wide options + xout.StartElement("options"); + xout.Attribute("allow-external-scripts", "no"); + xout.Attribute("customize", "allow"); + if (cmIsOff(this->GetOption("CPACK_PRODUCTBUILD_DOMAINS"))) { + xout.Attribute("rootVolumeOnly", "false"); + } + xout.EndElement(); + // Create the choice outline, which provides a tree-based view of // the components in their groups. - std::ostringstream choiceOut; - cmXMLWriter xout(choiceOut, 1); xout.StartElement("choices-outline"); // Emit the outline for the groups @@ -169,7 +179,7 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, // Dark Aqua this->CreateBackground("darkAqua", metapackageFile, genName, xout); - this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str()); + this->SetOption("CPACK_APPLE_PKG_INSTALLER_CONTENT", xContents.str()); // Create the distribution.dist file in the metapackage to turn it // into a distribution package. -- cgit v0.12