diff options
author | Craig Scott <craig.scott@crascit.com> | 2022-04-29 07:43:03 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2022-04-29 14:28:05 (GMT) |
commit | d099136addaf5e9672e892ad2cb1c43809f7174b (patch) | |
tree | 21fba5692c4e988cb27ef19e2086386ce73d0864 /Source/CPack/cmCPackPKGGenerator.cxx | |
parent | 74c4762a3884ac938106d412a5ea8ea7b248f9ca (diff) | |
download | CMake-d099136addaf5e9672e892ad2cb1c43809f7174b.zip CMake-d099136addaf5e9672e892ad2cb1c43809f7174b.tar.gz CMake-d099136addaf5e9672e892ad2cb1c43809f7174b.tar.bz2 |
productbuild: Restore CPACK_PACKAGEMAKER_CHOICES variable
In 2a8df7e7db (productbuild: Don't write rootVolumeOnly attribute if
writing domains, 2022-03-21), the variable holding the main contents
of the distribution.dist XML file was renamed from
CPACK_PACKAGEMAKER_CHOICES to CPACK_APPLE_PKG_INSTALLER_CONTENT.
This reflected the fact that the PackageMaker generator is deprecated.
The new variable also includes more details than the old one held.
Some projects were relying on the old variable name, so we need to still
set that to the same contents as it would have previously provided.
Neither of these variables were previously documented, but the older
variable was mentioned in enough semi-official places that it essentially
became semi-supported. Document both variables and highlight that the
older one is deprecated.
Fixes: #23467
Diffstat (limited to 'Source/CPack/cmCPackPKGGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 2a14ccf..7b9f6cf 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -123,7 +123,9 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, std::ostringstream xContents; cmXMLWriter xout(xContents, 1); - // Installer-wide options + // Installer-wide options and domains. These need to be separate from the + // choices and background elements added further below so that we can + // preserve backward compatibility. xout.StartElement("options"); xout.Attribute("allow-external-scripts", "no"); xout.Attribute("customize", "allow"); @@ -131,55 +133,69 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, xout.Attribute("rootVolumeOnly", "false"); } xout.EndElement(); + this->CreateDomains(xout); + + // In order to preserve backward compatibility, all elements added below + // here need to be made available in a variable named + // CPACK_PACKAGEMAKER_CHOICES. The above elements are new and only appear + // in the CPACK_APPLE_PKG_INSTALLER_CONTENT variable, which is a superset + // of what CPACK_PACKAGEMAKER_CHOICES used to provide. The renaming reflects + // the fact that CMake has deprecated the PackageMaker generator. // Create the choice outline, which provides a tree-based view of // the components in their groups. - xout.StartElement("choices-outline"); + std::ostringstream choiceOut; + cmXMLWriter xChoiceOut(choiceOut, 1); + xChoiceOut.StartElement("choices-outline"); // Emit the outline for the groups for (auto const& group : this->ComponentGroups) { if (group.second.ParentGroup == nullptr) { - CreateChoiceOutline(group.second, xout); + CreateChoiceOutline(group.second, xChoiceOut); } } // Emit the outline for the non-grouped components for (auto const& comp : this->Components) { if (!comp.second.Group) { - xout.StartElement("line"); - xout.Attribute("choice", comp.first + "Choice"); - xout.Content(""); // Avoid self-closing tag. - xout.EndElement(); + xChoiceOut.StartElement("line"); + xChoiceOut.Attribute("choice", comp.first + "Choice"); + xChoiceOut.Content(""); // Avoid self-closing tag. + xChoiceOut.EndElement(); } } if (!this->PostFlightComponent.Name.empty()) { - xout.StartElement("line"); - xout.Attribute("choice", PostFlightComponent.Name + "Choice"); - xout.Content(""); // Avoid self-closing tag. - xout.EndElement(); + xChoiceOut.StartElement("line"); + xChoiceOut.Attribute("choice", PostFlightComponent.Name + "Choice"); + xChoiceOut.Content(""); // Avoid self-closing tag. + xChoiceOut.EndElement(); } - xout.EndElement(); // choices-outline> + xChoiceOut.EndElement(); // choices-outline> // Create the actual choices for (auto const& group : this->ComponentGroups) { - CreateChoice(group.second, xout); + CreateChoice(group.second, xChoiceOut); } for (auto const& comp : this->Components) { - CreateChoice(comp.second, xout); + CreateChoice(comp.second, xChoiceOut); } if (!this->PostFlightComponent.Name.empty()) { - CreateChoice(PostFlightComponent, xout); + CreateChoice(PostFlightComponent, xChoiceOut); } - this->CreateDomains(xout); - - // default background - this->CreateBackground(nullptr, metapackageFile, genName, xout); + // default background. These are not strictly part of the choices, but they + // must be included in CPACK_PACKAGEMAKER_CHOICES to preserve backward + // compatibility. + this->CreateBackground(nullptr, metapackageFile, genName, xChoiceOut); // Dark Aqua - this->CreateBackground("darkAqua", metapackageFile, genName, xout); + this->CreateBackground("darkAqua", metapackageFile, genName, xChoiceOut); - this->SetOption("CPACK_APPLE_PKG_INSTALLER_CONTENT", xContents.str()); + // Provide the content for substitution into the template. Support both the + // old and new variables. + this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str()); + this->SetOption("CPACK_APPLE_PKG_INSTALLER_CONTENT", + cmStrCat(xContents.str(), " ", choiceOut.str())); // Create the distribution.dist file in the metapackage to turn it // into a distribution package. |