Merge topic 'productbuild'
63e5eb5f
Help: Add notes for 'productbuild' topic2e3c67d1
productbuild: Add new productbuild cpack generator.50a3d340
PackageMaker: factor out common code for creating pkg files.
This commit is contained in:
commit
d546456765
|
@ -60,6 +60,7 @@ All Modules
|
||||||
/module/CPackIFW
|
/module/CPackIFW
|
||||||
/module/CPackNSIS
|
/module/CPackNSIS
|
||||||
/module/CPackPackageMaker
|
/module/CPackPackageMaker
|
||||||
|
/module/CPackProductBuild
|
||||||
/module/CPackRPM
|
/module/CPackRPM
|
||||||
/module/CPack
|
/module/CPack
|
||||||
/module/CPackWIX
|
/module/CPackWIX
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
.. cmake-module:: ../../Modules/CPackProductBuild.cmake
|
|
@ -0,0 +1,5 @@
|
||||||
|
productbuild
|
||||||
|
------------
|
||||||
|
|
||||||
|
* CPack gained a ``productbuild`` generator on OS X, configured by
|
||||||
|
the :module:`CPackProductBuild` module.
|
|
@ -455,6 +455,7 @@ if(NOT CPACK_GENERATOR)
|
||||||
option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
|
option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
|
||||||
option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
|
option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
|
||||||
option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
|
option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
|
||||||
|
option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF)
|
||||||
else()
|
else()
|
||||||
option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
|
option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
|
||||||
endif()
|
endif()
|
||||||
|
@ -483,6 +484,7 @@ if(NOT CPACK_GENERATOR)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
|
||||||
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
|
||||||
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
|
||||||
|
@ -531,6 +533,7 @@ mark_as_advanced(
|
||||||
CPACK_BINARY_NSIS
|
CPACK_BINARY_NSIS
|
||||||
CPACK_BINARY_OSXX11
|
CPACK_BINARY_OSXX11
|
||||||
CPACK_BINARY_PACKAGEMAKER
|
CPACK_BINARY_PACKAGEMAKER
|
||||||
|
CPACK_BINARY_PRODUCTBUILD
|
||||||
CPACK_BINARY_RPM
|
CPACK_BINARY_RPM
|
||||||
CPACK_BINARY_STGZ
|
CPACK_BINARY_STGZ
|
||||||
CPACK_BINARY_TBZ2
|
CPACK_BINARY_TBZ2
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#.rst:
|
||||||
|
# CPackProductBuild
|
||||||
|
# -----------------
|
||||||
|
#
|
||||||
|
# productbuild CPack generator (Mac OS X).
|
||||||
|
#
|
||||||
|
# Variables specific to CPack productbuild generator
|
||||||
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
#
|
||||||
|
# The following variable is specific to installers built on Mac
|
||||||
|
# OS X using productbuild:
|
||||||
|
#
|
||||||
|
# .. variable:: CPACK_COMMAND_PRODUCTBUILD
|
||||||
|
#
|
||||||
|
# Path to the productbuild(1) command used to generate a product archive for
|
||||||
|
# the OS X Installer or Mac App Store. This variable can be used to override
|
||||||
|
# the automatically detected command (or specify its location if the
|
||||||
|
# auto-detection fails to find it.)
|
||||||
|
#
|
||||||
|
# .. variable:: CPACK_COMMAND_PKGBUILD
|
||||||
|
#
|
||||||
|
# Path to the pkgbuild(1) command used to generate an OS X component package
|
||||||
|
# on OS X. This variable can be used to override the automatically detected
|
||||||
|
# command (or specify its location if the auto-detection fails to find it.)
|
||||||
|
#
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2006-2012 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
|
@ -717,7 +717,9 @@ if(APPLE)
|
||||||
CPack/cmCPackBundleGenerator.cxx
|
CPack/cmCPackBundleGenerator.cxx
|
||||||
CPack/cmCPackDragNDropGenerator.cxx
|
CPack/cmCPackDragNDropGenerator.cxx
|
||||||
CPack/cmCPackOSXX11Generator.cxx
|
CPack/cmCPackOSXX11Generator.cxx
|
||||||
|
CPack/cmCPackPKGGenerator.cxx
|
||||||
CPack/cmCPackPackageMakerGenerator.cxx
|
CPack/cmCPackPackageMakerGenerator.cxx
|
||||||
|
CPack/cmCPackProductBuildGenerator.cxx
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "cmCPackDragNDropGenerator.h"
|
#include "cmCPackDragNDropGenerator.h"
|
||||||
#include "cmCPackOSXX11Generator.h"
|
#include "cmCPackOSXX11Generator.h"
|
||||||
#include "cmCPackPackageMakerGenerator.h"
|
#include "cmCPackPackageMakerGenerator.h"
|
||||||
|
#include "cmCPackProductBuildGenerator.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
|
@ -122,6 +123,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
|
||||||
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
|
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
|
||||||
cmCPackOSXX11Generator::CreateGenerator);
|
cmCPackOSXX11Generator::CreateGenerator);
|
||||||
}
|
}
|
||||||
|
if (cmCPackProductBuildGenerator::CanGenerate()) {
|
||||||
|
this->RegisterGenerator("productbuild", "Mac OSX pkg",
|
||||||
|
cmCPackProductBuildGenerator::CreateGenerator);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
|
#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
|
||||||
!defined(__HAIKU__)
|
!defined(__HAIKU__)
|
||||||
|
|
|
@ -0,0 +1,367 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
#include "cmCPackPKGGenerator.h"
|
||||||
|
|
||||||
|
#include "cmake.h"
|
||||||
|
#include "cmGlobalGenerator.h"
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
|
#include "cmSystemTools.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
#include "cmCPackComponentGroup.h"
|
||||||
|
#include "cmCPackLog.h"
|
||||||
|
|
||||||
|
#include <cmsys/SystemTools.hxx>
|
||||||
|
#include <cmsys/Glob.hxx>
|
||||||
|
|
||||||
|
cmCPackPKGGenerator::cmCPackPKGGenerator()
|
||||||
|
{
|
||||||
|
this->componentPackageMethod = ONE_PACKAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmCPackPKGGenerator::~cmCPackPKGGenerator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmCPackPKGGenerator::SupportsComponentInstallation() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmCPackPKGGenerator::InitializeInternal()
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
||||||
|
"cmCPackPKGGenerator::Initialize()" << std::endl);
|
||||||
|
|
||||||
|
return this->Superclass::InitializeInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string cmCPackPKGGenerator::GetPackageName(
|
||||||
|
const cmCPackComponent& component)
|
||||||
|
{
|
||||||
|
if (component.ArchiveFile.empty()) {
|
||||||
|
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
||||||
|
packagesDir += ".dummy";
|
||||||
|
std::ostringstream out;
|
||||||
|
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
|
||||||
|
<< "-" << component.Name << ".pkg";
|
||||||
|
return out.str();
|
||||||
|
} else {
|
||||||
|
return component.ArchiveFile + ".pkg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::WriteDistributionFile(
|
||||||
|
const char* metapackageFile)
|
||||||
|
{
|
||||||
|
std::string distributionTemplate =
|
||||||
|
this->FindTemplate("CPack.distribution.dist.in");
|
||||||
|
if (distributionTemplate.empty()) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
|
||||||
|
<< distributionTemplate << std::endl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string distributionFile = metapackageFile;
|
||||||
|
distributionFile += "/Contents/distribution.dist";
|
||||||
|
|
||||||
|
// Create the choice outline, which provides a tree-based view of
|
||||||
|
// the components in their groups.
|
||||||
|
std::ostringstream choiceOut;
|
||||||
|
choiceOut << "<choices-outline>" << std::endl;
|
||||||
|
|
||||||
|
// Emit the outline for the groups
|
||||||
|
std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
|
||||||
|
for (groupIt = this->ComponentGroups.begin();
|
||||||
|
groupIt != this->ComponentGroups.end(); ++groupIt) {
|
||||||
|
if (groupIt->second.ParentGroup == 0) {
|
||||||
|
CreateChoiceOutline(groupIt->second, choiceOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit the outline for the non-grouped components
|
||||||
|
std::map<std::string, cmCPackComponent>::iterator compIt;
|
||||||
|
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
||||||
|
++compIt) {
|
||||||
|
if (!compIt->second.Group) {
|
||||||
|
choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this->PostFlightComponent.Name.empty()) {
|
||||||
|
choiceOut << "<line choice=\"" << PostFlightComponent.Name
|
||||||
|
<< "Choice\"></line>" << std::endl;
|
||||||
|
}
|
||||||
|
choiceOut << "</choices-outline>" << std::endl;
|
||||||
|
|
||||||
|
// Create the actual choices
|
||||||
|
for (groupIt = this->ComponentGroups.begin();
|
||||||
|
groupIt != this->ComponentGroups.end(); ++groupIt) {
|
||||||
|
CreateChoice(groupIt->second, choiceOut);
|
||||||
|
}
|
||||||
|
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
||||||
|
++compIt) {
|
||||||
|
CreateChoice(compIt->second, choiceOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->PostFlightComponent.Name.empty()) {
|
||||||
|
CreateChoice(PostFlightComponent, choiceOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
|
||||||
|
|
||||||
|
// Create the distribution.dist file in the metapackage to turn it
|
||||||
|
// into a distribution package.
|
||||||
|
this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::CreateChoiceOutline(
|
||||||
|
const cmCPackComponentGroup& group, std::ostringstream& out)
|
||||||
|
{
|
||||||
|
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
|
||||||
|
std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
|
||||||
|
for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
|
||||||
|
++groupIt) {
|
||||||
|
CreateChoiceOutline(**groupIt, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<cmCPackComponent*>::const_iterator compIt;
|
||||||
|
for (compIt = group.Components.begin(); compIt != group.Components.end();
|
||||||
|
++compIt) {
|
||||||
|
out << " <line choice=\"" << (*compIt)->Name << "Choice\"></line>"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
out << "</line>" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::CreateChoice(
|
||||||
|
const cmCPackComponentGroup& group, std::ostringstream& out)
|
||||||
|
{
|
||||||
|
out << "<choice id=\"" << group.Name << "Choice\" "
|
||||||
|
<< "title=\"" << group.DisplayName << "\" "
|
||||||
|
<< "start_selected=\"true\" "
|
||||||
|
<< "start_enabled=\"true\" "
|
||||||
|
<< "start_visible=\"true\" ";
|
||||||
|
if (!group.Description.empty()) {
|
||||||
|
out << "description=\"" << EscapeForXML(group.Description) << "\"";
|
||||||
|
}
|
||||||
|
out << "></choice>" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::CreateChoice(
|
||||||
|
const cmCPackComponent& component, std::ostringstream& out)
|
||||||
|
{
|
||||||
|
std::string packageId = "com.";
|
||||||
|
packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
|
||||||
|
packageId += '.';
|
||||||
|
packageId += this->GetOption("CPACK_PACKAGE_NAME");
|
||||||
|
packageId += '.';
|
||||||
|
packageId += component.Name;
|
||||||
|
|
||||||
|
out << "<choice id=\"" << component.Name << "Choice\" "
|
||||||
|
<< "title=\"" << component.DisplayName << "\" "
|
||||||
|
<< "start_selected=\""
|
||||||
|
<< (component.IsDisabledByDefault && !component.IsRequired ? "false"
|
||||||
|
: "true")
|
||||||
|
<< "\" "
|
||||||
|
<< "start_enabled=\"" << (component.IsRequired ? "false" : "true")
|
||||||
|
<< "\" "
|
||||||
|
<< "start_visible=\"" << (component.IsHidden ? "false" : "true")
|
||||||
|
<< "\" ";
|
||||||
|
if (!component.Description.empty()) {
|
||||||
|
out << "description=\"" << EscapeForXML(component.Description) << "\" ";
|
||||||
|
}
|
||||||
|
if (!component.Dependencies.empty() ||
|
||||||
|
!component.ReverseDependencies.empty()) {
|
||||||
|
// The "selected" expression is evaluated each time any choice is
|
||||||
|
// selected, for all choices *except* the one that the user
|
||||||
|
// selected. A component is marked selected if it has been
|
||||||
|
// selected (my.choice.selected in Javascript) and all of the
|
||||||
|
// components it depends on have been selected (transitively) or
|
||||||
|
// if any of the components that depend on it have been selected
|
||||||
|
// (transitively). Assume that we have components A, B, C, D, and
|
||||||
|
// E, where each component depends on the previous component (B
|
||||||
|
// depends on A, C depends on B, D depends on C, and E depends on
|
||||||
|
// D). The expression we build for the component C will be
|
||||||
|
// my.choice.selected && B && A || D || E
|
||||||
|
// This way, selecting C will automatically select everything it depends
|
||||||
|
// on (B and A), while selecting something that depends on C--either D
|
||||||
|
// or E--will automatically cause C to get selected.
|
||||||
|
out << "selected=\"my.choice.selected";
|
||||||
|
std::set<const cmCPackComponent*> visited;
|
||||||
|
AddDependencyAttributes(component, visited, out);
|
||||||
|
visited.clear();
|
||||||
|
AddReverseDependencyAttributes(component, visited, out);
|
||||||
|
out << "\"";
|
||||||
|
}
|
||||||
|
out << ">" << std::endl;
|
||||||
|
out << " <pkg-ref id=\"" << packageId << "\"></pkg-ref>" << std::endl;
|
||||||
|
out << "</choice>" << std::endl;
|
||||||
|
|
||||||
|
// Create a description of the package associated with this
|
||||||
|
// component.
|
||||||
|
std::string relativePackageLocation = "Contents/Packages/";
|
||||||
|
relativePackageLocation += this->GetPackageName(component);
|
||||||
|
|
||||||
|
// Determine the installed size of the package.
|
||||||
|
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
||||||
|
dirName += '/';
|
||||||
|
dirName += component.Name;
|
||||||
|
dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
|
||||||
|
unsigned long installedSize =
|
||||||
|
component.GetInstalledSizeInKbytes(dirName.c_str());
|
||||||
|
|
||||||
|
out << "<pkg-ref id=\"" << packageId << "\" "
|
||||||
|
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
|
||||||
|
<< "installKBytes=\"" << installedSize << "\" "
|
||||||
|
<< ">";
|
||||||
|
if (component.IsDownloaded) {
|
||||||
|
out << this->GetOption("CPACK_DOWNLOAD_SITE")
|
||||||
|
<< this->GetPackageName(component);
|
||||||
|
} else {
|
||||||
|
out << "file:./" << relativePackageLocation;
|
||||||
|
}
|
||||||
|
out << "</pkg-ref>" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::AddDependencyAttributes(
|
||||||
|
const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
|
||||||
|
{
|
||||||
|
if (visited.find(&component) != visited.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visited.insert(&component);
|
||||||
|
|
||||||
|
std::vector<cmCPackComponent*>::const_iterator dependIt;
|
||||||
|
for (dependIt = component.Dependencies.begin();
|
||||||
|
dependIt != component.Dependencies.end(); ++dependIt) {
|
||||||
|
out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
|
||||||
|
AddDependencyAttributes(**dependIt, visited, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCPackPKGGenerator::AddReverseDependencyAttributes(
|
||||||
|
const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
|
||||||
|
{
|
||||||
|
if (visited.find(&component) != visited.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visited.insert(&component);
|
||||||
|
|
||||||
|
std::vector<cmCPackComponent*>::const_iterator dependIt;
|
||||||
|
for (dependIt = component.ReverseDependencies.begin();
|
||||||
|
dependIt != component.ReverseDependencies.end(); ++dependIt) {
|
||||||
|
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
|
||||||
|
AddReverseDependencyAttributes(**dependIt, visited, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmCPackPKGGenerator::EscapeForXML(std::string str)
|
||||||
|
{
|
||||||
|
cmSystemTools::ReplaceString(str, "&", "&");
|
||||||
|
cmSystemTools::ReplaceString(str, "<", "<");
|
||||||
|
cmSystemTools::ReplaceString(str, ">", ">");
|
||||||
|
cmSystemTools::ReplaceString(str, "\"", """);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmCPackPKGGenerator::CopyCreateResourceFile(
|
||||||
|
const std::string& name, const std::string& dirName)
|
||||||
|
{
|
||||||
|
std::string uname = cmSystemTools::UpperCase(name);
|
||||||
|
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
|
||||||
|
const char* inFileName = this->GetOption(cpackVar.c_str());
|
||||||
|
if (!inFileName) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
|
||||||
|
<< cpackVar.c_str()
|
||||||
|
<< " not specified. It should point to "
|
||||||
|
<< (!name.empty() ? name : "<empty>") << ".rtf, " << name
|
||||||
|
<< ".html, or " << name << ".txt file" << std::endl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!cmSystemTools::FileExists(inFileName)) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
|
||||||
|
<< (!name.empty() ? name : "<empty>")
|
||||||
|
<< " resource file: " << inFileName << std::endl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
|
||||||
|
if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
|
||||||
|
cmCPackLogger(
|
||||||
|
cmCPackLog::LOG_ERROR, "Bad file extension specified: "
|
||||||
|
<< ext
|
||||||
|
<< ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
|
||||||
|
<< std::endl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string destFileName = dirName;
|
||||||
|
destFileName += '/';
|
||||||
|
destFileName += name + ext;
|
||||||
|
|
||||||
|
// Set this so that distribution.dist gets the right name (without
|
||||||
|
// the path).
|
||||||
|
this->SetOption(("CPACK_RESOURCE_FILE_" + uname + "_NOPATH").c_str(),
|
||||||
|
(name + ext).c_str());
|
||||||
|
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
|
||||||
|
<< (inFileName ? inFileName : "(NULL)") << " to "
|
||||||
|
<< destFileName.c_str() << std::endl);
|
||||||
|
this->ConfigureFile(inFileName, destFileName.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmCPackPKGGenerator::CopyResourcePlistFile(
|
||||||
|
const std::string& name, const char* outName)
|
||||||
|
{
|
||||||
|
if (!outName) {
|
||||||
|
outName = name.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string inFName = "CPack.";
|
||||||
|
inFName += name;
|
||||||
|
inFName += ".in";
|
||||||
|
std::string inFileName = this->FindTemplate(inFName.c_str());
|
||||||
|
if (inFileName.empty()) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Cannot find input file: " << inFName << std::endl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
destFileName += "/";
|
||||||
|
destFileName += outName;
|
||||||
|
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
||||||
|
"Configure file: " << inFileName.c_str() << " to "
|
||||||
|
<< destFileName.c_str() << std::endl);
|
||||||
|
this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir,
|
||||||
|
const std::string& script,
|
||||||
|
const std::string& name)
|
||||||
|
{
|
||||||
|
std::string dst = resdir;
|
||||||
|
dst += "/";
|
||||||
|
dst += name;
|
||||||
|
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
|
||||||
|
cmSystemTools::SetPermissions(dst.c_str(), 0777);
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : "
|
||||||
|
<< script << "\ninto " << dst.c_str() << std::endl);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2000-2009 Kitware, Inc.
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
|
||||||
|
#ifndef cmCPackPKGGenerator_h
|
||||||
|
#define cmCPackPKGGenerator_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "cmCPackGenerator.h"
|
||||||
|
|
||||||
|
class cmCPackComponent;
|
||||||
|
|
||||||
|
/** \class cmCPackPKGGenerator
|
||||||
|
* \brief A generator for pkg files
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class cmCPackPKGGenerator : public cmCPackGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cmCPackTypeMacro(cmCPackPKGGenerator, cmCPackGenerator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct generator
|
||||||
|
*/
|
||||||
|
cmCPackPKGGenerator();
|
||||||
|
virtual ~cmCPackPKGGenerator();
|
||||||
|
|
||||||
|
virtual bool SupportsComponentInstallation() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int InitializeInternal();
|
||||||
|
virtual const char* GetOutputPostfix() { return "darwin"; }
|
||||||
|
|
||||||
|
// Copies or creates the resource file with the given name to the
|
||||||
|
// package or package staging directory dirName. The variable
|
||||||
|
// CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
|
||||||
|
// version of name) specifies the input file to use for this file,
|
||||||
|
// which will be configured via ConfigureFile.
|
||||||
|
bool CopyCreateResourceFile(const std::string& name,
|
||||||
|
const std::string& dirName);
|
||||||
|
bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
|
||||||
|
|
||||||
|
int CopyInstallScript(const std::string& resdir, const std::string& script,
|
||||||
|
const std::string& name);
|
||||||
|
|
||||||
|
// Retrieve the name of package file that will be generated for this
|
||||||
|
// component. The name is just the file name with extension, and
|
||||||
|
// does not include the subdirectory.
|
||||||
|
std::string GetPackageName(const cmCPackComponent& component);
|
||||||
|
|
||||||
|
// Writes a distribution.dist file, which turns a metapackage into a
|
||||||
|
// full-fledged distribution. This file is used to describe
|
||||||
|
// inter-component dependencies. metapackageFile is the name of the
|
||||||
|
// metapackage for the distribution. Only valid for a
|
||||||
|
// component-based install.
|
||||||
|
void WriteDistributionFile(const char* metapackageFile);
|
||||||
|
|
||||||
|
// Subroutine of WriteDistributionFile that writes out the
|
||||||
|
// dependency attributes for inter-component dependencies.
|
||||||
|
void AddDependencyAttributes(const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent*>& visited,
|
||||||
|
std::ostringstream& out);
|
||||||
|
|
||||||
|
// Subroutine of WriteDistributionFile that writes out the
|
||||||
|
// reverse dependency attributes for inter-component dependencies.
|
||||||
|
void AddReverseDependencyAttributes(
|
||||||
|
const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
|
||||||
|
|
||||||
|
// Generates XML that encodes the hierarchy of component groups and
|
||||||
|
// their components in a form that can be used by distribution
|
||||||
|
// metapackages.
|
||||||
|
void CreateChoiceOutline(const cmCPackComponentGroup& group,
|
||||||
|
std::ostringstream& out);
|
||||||
|
|
||||||
|
/// Create the "choice" XML element to describe a component group
|
||||||
|
/// for the installer GUI.
|
||||||
|
void CreateChoice(const cmCPackComponentGroup& group,
|
||||||
|
std::ostringstream& out);
|
||||||
|
|
||||||
|
/// Create the "choice" XML element to describe a component for the
|
||||||
|
/// installer GUI.
|
||||||
|
void CreateChoice(const cmCPackComponent& component,
|
||||||
|
std::ostringstream& out);
|
||||||
|
|
||||||
|
// Escape the given string to make it usable as an XML attribute
|
||||||
|
// value.
|
||||||
|
std::string EscapeForXML(std::string str);
|
||||||
|
|
||||||
|
// The PostFlight component when creating a metapackage
|
||||||
|
cmCPackComponent PostFlightComponent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -46,21 +46,6 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
|
||||||
return this->PackageCompatibilityVersion >= getVersion(10, 4);
|
return this->PackageCompatibilityVersion >= getVersion(10, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
|
|
||||||
const std::string& script,
|
|
||||||
const std::string& name)
|
|
||||||
{
|
|
||||||
std::string dst = resdir;
|
|
||||||
dst += "/";
|
|
||||||
dst += name;
|
|
||||||
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
|
|
||||||
cmSystemTools::SetPermissions(dst.c_str(), 0777);
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : "
|
|
||||||
<< script << "\ninto " << dst.c_str() << std::endl);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cmCPackPackageMakerGenerator::PackageFiles()
|
int cmCPackPackageMakerGenerator::PackageFiles()
|
||||||
{
|
{
|
||||||
// TODO: Use toplevel
|
// TODO: Use toplevel
|
||||||
|
@ -344,8 +329,6 @@ int cmCPackPackageMakerGenerator::PackageFiles()
|
||||||
|
|
||||||
int cmCPackPackageMakerGenerator::InitializeInternal()
|
int cmCPackPackageMakerGenerator::InitializeInternal()
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
|
||||||
"cmCPackPackageMakerGenerator::Initialize()" << std::endl);
|
|
||||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
||||||
|
|
||||||
// Starting with Xcode 4.3, PackageMaker is a separate app, and you
|
// Starting with Xcode 4.3, PackageMaker is a separate app, and you
|
||||||
|
@ -481,80 +464,6 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
|
|
||||||
const std::string& name, const std::string& dirName)
|
|
||||||
{
|
|
||||||
std::string uname = cmSystemTools::UpperCase(name);
|
|
||||||
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
|
|
||||||
const char* inFileName = this->GetOption(cpackVar.c_str());
|
|
||||||
if (!inFileName) {
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
|
|
||||||
<< cpackVar.c_str()
|
|
||||||
<< " not specified. It should point to "
|
|
||||||
<< (!name.empty() ? name : "<empty>") << ".rtf, " << name
|
|
||||||
<< ".html, or " << name << ".txt file" << std::endl);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!cmSystemTools::FileExists(inFileName)) {
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
|
|
||||||
<< (!name.empty() ? name : "<empty>")
|
|
||||||
<< " resource file: " << inFileName << std::endl);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
|
|
||||||
if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
|
|
||||||
cmCPackLogger(
|
|
||||||
cmCPackLog::LOG_ERROR, "Bad file extension specified: "
|
|
||||||
<< ext
|
|
||||||
<< ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
|
|
||||||
<< std::endl);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string destFileName = dirName;
|
|
||||||
destFileName += '/';
|
|
||||||
destFileName += name + ext;
|
|
||||||
|
|
||||||
// Set this so that distribution.dist gets the right name (without
|
|
||||||
// the path).
|
|
||||||
this->SetOption(("CPACK_RESOURCE_FILE_" + uname + "_NOPATH").c_str(),
|
|
||||||
(name + ext).c_str());
|
|
||||||
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
|
|
||||||
<< (inFileName ? inFileName : "(NULL)") << " to "
|
|
||||||
<< destFileName.c_str() << std::endl);
|
|
||||||
this->ConfigureFile(inFileName, destFileName.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
|
|
||||||
const std::string& name, const char* outName)
|
|
||||||
{
|
|
||||||
if (!outName) {
|
|
||||||
outName = name.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string inFName = "CPack.";
|
|
||||||
inFName += name;
|
|
||||||
inFName += ".in";
|
|
||||||
std::string inFileName = this->FindTemplate(inFName.c_str());
|
|
||||||
if (inFileName.empty()) {
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
||||||
"Cannot find input file: " << inFName << std::endl);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
||||||
destFileName += "/";
|
|
||||||
destFileName += outName;
|
|
||||||
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
|
||||||
"Configure file: " << inFileName.c_str() << " to "
|
|
||||||
<< destFileName.c_str() << std::endl);
|
|
||||||
this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
|
bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
|
||||||
const char* packageFile)
|
const char* packageFile)
|
||||||
{
|
{
|
||||||
|
@ -597,21 +506,6 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmCPackPackageMakerGenerator::GetPackageName(
|
|
||||||
const cmCPackComponent& component)
|
|
||||||
{
|
|
||||||
if (component.ArchiveFile.empty()) {
|
|
||||||
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
|
||||||
packagesDir += ".dummy";
|
|
||||||
std::ostringstream out;
|
|
||||||
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
|
|
||||||
<< component.Name << ".pkg";
|
|
||||||
return out.str();
|
|
||||||
} else {
|
|
||||||
return component.ArchiveFile + ".pkg";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
|
bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
|
||||||
const char* packageFile, const char* packageDir,
|
const char* packageFile, const char* packageDir,
|
||||||
const cmCPackComponent& component)
|
const cmCPackComponent& component)
|
||||||
|
@ -686,219 +580,3 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
|
||||||
// Run PackageMaker
|
// Run PackageMaker
|
||||||
return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
|
return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::WriteDistributionFile(
|
|
||||||
const char* metapackageFile)
|
|
||||||
{
|
|
||||||
std::string distributionTemplate =
|
|
||||||
this->FindTemplate("CPack.distribution.dist.in");
|
|
||||||
if (distributionTemplate.empty()) {
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
|
|
||||||
<< distributionTemplate << std::endl);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string distributionFile = metapackageFile;
|
|
||||||
distributionFile += "/Contents/distribution.dist";
|
|
||||||
|
|
||||||
// Create the choice outline, which provides a tree-based view of
|
|
||||||
// the components in their groups.
|
|
||||||
std::ostringstream choiceOut;
|
|
||||||
choiceOut << "<choices-outline>" << std::endl;
|
|
||||||
|
|
||||||
// Emit the outline for the groups
|
|
||||||
std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
|
|
||||||
for (groupIt = this->ComponentGroups.begin();
|
|
||||||
groupIt != this->ComponentGroups.end(); ++groupIt) {
|
|
||||||
if (groupIt->second.ParentGroup == 0) {
|
|
||||||
CreateChoiceOutline(groupIt->second, choiceOut);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit the outline for the non-grouped components
|
|
||||||
std::map<std::string, cmCPackComponent>::iterator compIt;
|
|
||||||
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
|
||||||
++compIt) {
|
|
||||||
if (!compIt->second.Group) {
|
|
||||||
choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this->PostFlightComponent.Name.empty()) {
|
|
||||||
choiceOut << "<line choice=\"" << PostFlightComponent.Name
|
|
||||||
<< "Choice\"></line>" << std::endl;
|
|
||||||
}
|
|
||||||
choiceOut << "</choices-outline>" << std::endl;
|
|
||||||
|
|
||||||
// Create the actual choices
|
|
||||||
for (groupIt = this->ComponentGroups.begin();
|
|
||||||
groupIt != this->ComponentGroups.end(); ++groupIt) {
|
|
||||||
CreateChoice(groupIt->second, choiceOut);
|
|
||||||
}
|
|
||||||
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
|
||||||
++compIt) {
|
|
||||||
CreateChoice(compIt->second, choiceOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this->PostFlightComponent.Name.empty()) {
|
|
||||||
CreateChoice(PostFlightComponent, choiceOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
|
|
||||||
|
|
||||||
// Create the distribution.dist file in the metapackage to turn it
|
|
||||||
// into a distribution package.
|
|
||||||
this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::CreateChoiceOutline(
|
|
||||||
const cmCPackComponentGroup& group, std::ostringstream& out)
|
|
||||||
{
|
|
||||||
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
|
|
||||||
std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
|
|
||||||
for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
|
|
||||||
++groupIt) {
|
|
||||||
CreateChoiceOutline(**groupIt, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<cmCPackComponent*>::const_iterator compIt;
|
|
||||||
for (compIt = group.Components.begin(); compIt != group.Components.end();
|
|
||||||
++compIt) {
|
|
||||||
out << " <line choice=\"" << (*compIt)->Name << "Choice\"></line>"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
out << "</line>" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::CreateChoice(
|
|
||||||
const cmCPackComponentGroup& group, std::ostringstream& out)
|
|
||||||
{
|
|
||||||
out << "<choice id=\"" << group.Name << "Choice\" "
|
|
||||||
<< "title=\"" << group.DisplayName << "\" "
|
|
||||||
<< "start_selected=\"true\" "
|
|
||||||
<< "start_enabled=\"true\" "
|
|
||||||
<< "start_visible=\"true\" ";
|
|
||||||
if (!group.Description.empty()) {
|
|
||||||
out << "description=\"" << EscapeForXML(group.Description) << "\"";
|
|
||||||
}
|
|
||||||
out << "></choice>" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::CreateChoice(
|
|
||||||
const cmCPackComponent& component, std::ostringstream& out)
|
|
||||||
{
|
|
||||||
std::string packageId = "com.";
|
|
||||||
packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
|
|
||||||
packageId += '.';
|
|
||||||
packageId += this->GetOption("CPACK_PACKAGE_NAME");
|
|
||||||
packageId += '.';
|
|
||||||
packageId += component.Name;
|
|
||||||
|
|
||||||
out << "<choice id=\"" << component.Name << "Choice\" "
|
|
||||||
<< "title=\"" << component.DisplayName << "\" "
|
|
||||||
<< "start_selected=\""
|
|
||||||
<< (component.IsDisabledByDefault && !component.IsRequired ? "false"
|
|
||||||
: "true")
|
|
||||||
<< "\" "
|
|
||||||
<< "start_enabled=\"" << (component.IsRequired ? "false" : "true")
|
|
||||||
<< "\" "
|
|
||||||
<< "start_visible=\"" << (component.IsHidden ? "false" : "true")
|
|
||||||
<< "\" ";
|
|
||||||
if (!component.Description.empty()) {
|
|
||||||
out << "description=\"" << EscapeForXML(component.Description) << "\" ";
|
|
||||||
}
|
|
||||||
if (!component.Dependencies.empty() ||
|
|
||||||
!component.ReverseDependencies.empty()) {
|
|
||||||
// The "selected" expression is evaluated each time any choice is
|
|
||||||
// selected, for all choices *except* the one that the user
|
|
||||||
// selected. A component is marked selected if it has been
|
|
||||||
// selected (my.choice.selected in Javascript) and all of the
|
|
||||||
// components it depends on have been selected (transitively) or
|
|
||||||
// if any of the components that depend on it have been selected
|
|
||||||
// (transitively). Assume that we have components A, B, C, D, and
|
|
||||||
// E, where each component depends on the previous component (B
|
|
||||||
// depends on A, C depends on B, D depends on C, and E depends on
|
|
||||||
// D). The expression we build for the component C will be
|
|
||||||
// my.choice.selected && B && A || D || E
|
|
||||||
// This way, selecting C will automatically select everything it depends
|
|
||||||
// on (B and A), while selecting something that depends on C--either D
|
|
||||||
// or E--will automatically cause C to get selected.
|
|
||||||
out << "selected=\"my.choice.selected";
|
|
||||||
std::set<const cmCPackComponent*> visited;
|
|
||||||
AddDependencyAttributes(component, visited, out);
|
|
||||||
visited.clear();
|
|
||||||
AddReverseDependencyAttributes(component, visited, out);
|
|
||||||
out << "\"";
|
|
||||||
}
|
|
||||||
out << ">" << std::endl;
|
|
||||||
out << " <pkg-ref id=\"" << packageId << "\"></pkg-ref>" << std::endl;
|
|
||||||
out << "</choice>" << std::endl;
|
|
||||||
|
|
||||||
// Create a description of the package associated with this
|
|
||||||
// component.
|
|
||||||
std::string relativePackageLocation = "Contents/Packages/";
|
|
||||||
relativePackageLocation += this->GetPackageName(component);
|
|
||||||
|
|
||||||
// Determine the installed size of the package.
|
|
||||||
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
|
||||||
dirName += '/';
|
|
||||||
dirName += component.Name;
|
|
||||||
dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
|
|
||||||
unsigned long installedSize =
|
|
||||||
component.GetInstalledSizeInKbytes(dirName.c_str());
|
|
||||||
|
|
||||||
out << "<pkg-ref id=\"" << packageId << "\" "
|
|
||||||
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
|
|
||||||
<< "installKBytes=\"" << installedSize << "\" "
|
|
||||||
<< "auth=\"Admin\" onConclusion=\"None\">";
|
|
||||||
if (component.IsDownloaded) {
|
|
||||||
out << this->GetOption("CPACK_DOWNLOAD_SITE")
|
|
||||||
<< this->GetPackageName(component);
|
|
||||||
} else {
|
|
||||||
out << "file:./" << relativePackageLocation;
|
|
||||||
}
|
|
||||||
out << "</pkg-ref>" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::AddDependencyAttributes(
|
|
||||||
const cmCPackComponent& component,
|
|
||||||
std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
|
|
||||||
{
|
|
||||||
if (visited.find(&component) != visited.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
visited.insert(&component);
|
|
||||||
|
|
||||||
std::vector<cmCPackComponent*>::const_iterator dependIt;
|
|
||||||
for (dependIt = component.Dependencies.begin();
|
|
||||||
dependIt != component.Dependencies.end(); ++dependIt) {
|
|
||||||
out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
|
|
||||||
AddDependencyAttributes(**dependIt, visited, out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmCPackPackageMakerGenerator::AddReverseDependencyAttributes(
|
|
||||||
const cmCPackComponent& component,
|
|
||||||
std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
|
|
||||||
{
|
|
||||||
if (visited.find(&component) != visited.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
visited.insert(&component);
|
|
||||||
|
|
||||||
std::vector<cmCPackComponent*>::const_iterator dependIt;
|
|
||||||
for (dependIt = component.ReverseDependencies.begin();
|
|
||||||
dependIt != component.ReverseDependencies.end(); ++dependIt) {
|
|
||||||
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
|
|
||||||
AddReverseDependencyAttributes(**dependIt, visited, out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string cmCPackPackageMakerGenerator::EscapeForXML(std::string str)
|
|
||||||
{
|
|
||||||
cmSystemTools::ReplaceString(str, "&", "&");
|
|
||||||
cmSystemTools::ReplaceString(str, "<", "<");
|
|
||||||
cmSystemTools::ReplaceString(str, ">", ">");
|
|
||||||
cmSystemTools::ReplaceString(str, "\"", """);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifndef cmCPackPackageMakerGenerator_h
|
#ifndef cmCPackPackageMakerGenerator_h
|
||||||
#define cmCPackPackageMakerGenerator_h
|
#define cmCPackPackageMakerGenerator_h
|
||||||
|
|
||||||
#include "cmCPackGenerator.h"
|
#include "cmCPackPKGGenerator.h"
|
||||||
|
|
||||||
class cmCPackComponent;
|
class cmCPackComponent;
|
||||||
|
|
||||||
|
@ -23,46 +23,28 @@ class cmCPackComponent;
|
||||||
* http://developer.apple.com/documentation/Darwin
|
* http://developer.apple.com/documentation/Darwin
|
||||||
* /Reference/ManPages/man1/packagemaker.1.html
|
* /Reference/ManPages/man1/packagemaker.1.html
|
||||||
*/
|
*/
|
||||||
class cmCPackPackageMakerGenerator : public cmCPackGenerator
|
class cmCPackPackageMakerGenerator : public cmCPackPKGGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenerator);
|
cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackPKGGenerator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct generator
|
* Construct generator
|
||||||
*/
|
*/
|
||||||
cmCPackPackageMakerGenerator();
|
cmCPackPackageMakerGenerator();
|
||||||
virtual ~cmCPackPackageMakerGenerator();
|
virtual ~cmCPackPackageMakerGenerator();
|
||||||
|
bool SupportsComponentInstallation() const;
|
||||||
virtual bool SupportsComponentInstallation() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int CopyInstallScript(const std::string& resdir, const std::string& script,
|
|
||||||
const std::string& name);
|
|
||||||
virtual int InitializeInternal();
|
virtual int InitializeInternal();
|
||||||
int PackageFiles();
|
int PackageFiles();
|
||||||
virtual const char* GetOutputExtension() { return ".dmg"; }
|
virtual const char* GetOutputExtension() { return ".dmg"; }
|
||||||
virtual const char* GetOutputPostfix() { return "darwin"; }
|
|
||||||
|
|
||||||
// Copies or creates the resource file with the given name to the
|
|
||||||
// package or package staging directory dirName. The variable
|
|
||||||
// CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
|
|
||||||
// version of name) specifies the input file to use for this file,
|
|
||||||
// which will be configured via ConfigureFile.
|
|
||||||
bool CopyCreateResourceFile(const std::string& name,
|
|
||||||
const std::string& dirName);
|
|
||||||
bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
|
|
||||||
|
|
||||||
// Run PackageMaker with the given command line, which will (if
|
// Run PackageMaker with the given command line, which will (if
|
||||||
// successful) produce the given package file. Returns true if
|
// successful) produce the given package file. Returns true if
|
||||||
// PackageMaker succeeds, false otherwise.
|
// PackageMaker succeeds, false otherwise.
|
||||||
bool RunPackageMaker(const char* command, const char* packageFile);
|
bool RunPackageMaker(const char* command, const char* packageFile);
|
||||||
|
|
||||||
// Retrieve the name of package file that will be generated for this
|
|
||||||
// component. The name is just the file name with extension, and
|
|
||||||
// does not include the subdirectory.
|
|
||||||
std::string GetPackageName(const cmCPackComponent& component);
|
|
||||||
|
|
||||||
// Generate a package in the file packageFile for the given
|
// Generate a package in the file packageFile for the given
|
||||||
// component. All of the files within this component are stored in
|
// component. All of the files within this component are stored in
|
||||||
// the directory packageDir. Returns true if successful, false
|
// the directory packageDir. Returns true if successful, false
|
||||||
|
@ -71,48 +53,6 @@ protected:
|
||||||
const char* packageDir,
|
const char* packageDir,
|
||||||
const cmCPackComponent& component);
|
const cmCPackComponent& component);
|
||||||
|
|
||||||
// Writes a distribution.dist file, which turns a metapackage into a
|
|
||||||
// full-fledged distribution. This file is used to describe
|
|
||||||
// inter-component dependencies. metapackageFile is the name of the
|
|
||||||
// metapackage for the distribution. Only valid for a
|
|
||||||
// component-based install.
|
|
||||||
void WriteDistributionFile(const char* metapackageFile);
|
|
||||||
|
|
||||||
// Subroutine of WriteDistributionFile that writes out the
|
|
||||||
// dependency attributes for inter-component dependencies.
|
|
||||||
void AddDependencyAttributes(const cmCPackComponent& component,
|
|
||||||
std::set<const cmCPackComponent*>& visited,
|
|
||||||
std::ostringstream& out);
|
|
||||||
|
|
||||||
// Subroutine of WriteDistributionFile that writes out the
|
|
||||||
// reverse dependency attributes for inter-component dependencies.
|
|
||||||
void AddReverseDependencyAttributes(
|
|
||||||
const cmCPackComponent& component,
|
|
||||||
std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
|
|
||||||
|
|
||||||
// Generates XML that encodes the hierarchy of component groups and
|
|
||||||
// their components in a form that can be used by distribution
|
|
||||||
// metapackages.
|
|
||||||
void CreateChoiceOutline(const cmCPackComponentGroup& group,
|
|
||||||
std::ostringstream& out);
|
|
||||||
|
|
||||||
/// Create the "choice" XML element to describe a component group
|
|
||||||
/// for the installer GUI.
|
|
||||||
void CreateChoice(const cmCPackComponentGroup& group,
|
|
||||||
std::ostringstream& out);
|
|
||||||
|
|
||||||
/// Create the "choice" XML element to describe a component for the
|
|
||||||
/// installer GUI.
|
|
||||||
void CreateChoice(const cmCPackComponent& component,
|
|
||||||
std::ostringstream& out);
|
|
||||||
|
|
||||||
// Escape the given string to make it usable as an XML attribute
|
|
||||||
// value.
|
|
||||||
std::string EscapeForXML(std::string str);
|
|
||||||
|
|
||||||
// The PostFlight component when creating a metapackage
|
|
||||||
cmCPackComponent PostFlightComponent;
|
|
||||||
|
|
||||||
double PackageMakerVersion;
|
double PackageMakerVersion;
|
||||||
unsigned int PackageCompatibilityVersion;
|
unsigned int PackageCompatibilityVersion;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,260 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
#include "cmCPackProductBuildGenerator.h"
|
||||||
|
|
||||||
|
#include "cmake.h"
|
||||||
|
#include "cmGlobalGenerator.h"
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
|
#include "cmSystemTools.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
#include "cmCPackComponentGroup.h"
|
||||||
|
#include "cmCPackLog.h"
|
||||||
|
|
||||||
|
#include <cmsys/SystemTools.hxx>
|
||||||
|
#include <cmsys/Glob.hxx>
|
||||||
|
|
||||||
|
cmCPackProductBuildGenerator::cmCPackProductBuildGenerator()
|
||||||
|
{
|
||||||
|
this->componentPackageMethod = ONE_PACKAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmCPackProductBuildGenerator::~cmCPackProductBuildGenerator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmCPackProductBuildGenerator::PackageFiles()
|
||||||
|
{
|
||||||
|
// TODO: Use toplevel
|
||||||
|
// It is used! Is this an obsolete comment?
|
||||||
|
|
||||||
|
std::string packageDirFileName
|
||||||
|
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
||||||
|
|
||||||
|
// Create the directory where component packages will be built.
|
||||||
|
std::string basePackageDir = packageDirFileName;
|
||||||
|
basePackageDir += "/Contents/Packages";
|
||||||
|
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str()))
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Problem creating component packages directory: "
|
||||||
|
<< basePackageDir.c_str() << std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->Components.empty())
|
||||||
|
{
|
||||||
|
std::map<std::string, cmCPackComponent>::iterator compIt;
|
||||||
|
for (compIt = this->Components.begin(); compIt != this->Components.end();
|
||||||
|
++compIt)
|
||||||
|
{
|
||||||
|
std::string packageDir = toplevel;
|
||||||
|
packageDir += '/';
|
||||||
|
packageDir += compIt->first;
|
||||||
|
if (!this->GenerateComponentPackage(basePackageDir,
|
||||||
|
GetPackageName(compIt->second),
|
||||||
|
packageDir,
|
||||||
|
&compIt->second))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!this->GenerateComponentPackage(basePackageDir,
|
||||||
|
this->GetOption("CPACK_PACKAGE_NAME"),
|
||||||
|
toplevel, NULL))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy or create all of the resource files we need.
|
||||||
|
std::string resDir = packageDirFileName + "/Contents";
|
||||||
|
if ( !this->CopyCreateResourceFile("License", resDir.c_str())
|
||||||
|
|| !this->CopyCreateResourceFile("ReadMe", resDir.c_str())
|
||||||
|
|| !this->CopyCreateResourceFile("Welcome", resDir.c_str()))
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// combine package(s) into a distribution
|
||||||
|
WriteDistributionFile(packageDirFileName.c_str());
|
||||||
|
std::ostringstream pkgCmd;
|
||||||
|
|
||||||
|
std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
|
||||||
|
std::string productbuild = this->GetOption("CPACK_COMMAND_PRODUCTBUILD");
|
||||||
|
|
||||||
|
pkgCmd << productbuild
|
||||||
|
<< " --distribution \"" << packageDirFileName
|
||||||
|
<< "/Contents/distribution.dist\""
|
||||||
|
<< " --package-path \"" << packageDirFileName << "/Contents/Packages" << "\""
|
||||||
|
<< " --resources \"" << resDir << "\""
|
||||||
|
<< " --version \"" << version << "\""
|
||||||
|
<< " \"" << packageFileNames[0] << "\"";
|
||||||
|
|
||||||
|
// Run ProductBuild
|
||||||
|
return RunProductBuild(pkgCmd.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmCPackProductBuildGenerator::InitializeInternal()
|
||||||
|
{
|
||||||
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/Applications");
|
||||||
|
|
||||||
|
std::vector<std::string> no_paths;
|
||||||
|
std::string program =
|
||||||
|
cmSystemTools::FindProgram("pkgbuild", no_paths, false);
|
||||||
|
if (program.empty()) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find pkgbuild executable"
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
program = cmSystemTools::FindProgram("productbuild", no_paths, false);
|
||||||
|
if (program.empty()) {
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable"
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
this->SetOptionIfNotSet("CPACK_COMMAND_PRODUCTBUILD", program.c_str());
|
||||||
|
|
||||||
|
return this->Superclass::InitializeInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool cmCPackProductBuildGenerator::RunProductBuild(
|
||||||
|
const std::string& command)
|
||||||
|
{
|
||||||
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
tmpFile += "/ProductBuildOutput.log";
|
||||||
|
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
|
||||||
|
std::string output, error_output;
|
||||||
|
int retVal = 1;
|
||||||
|
bool res = cmSystemTools::RunSingleCommand(command.c_str(),
|
||||||
|
&output, &error_output, &retVal, 0, this->GeneratorVerbose, 0);
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command"
|
||||||
|
<< std::endl);
|
||||||
|
if ( !res || retVal )
|
||||||
|
{
|
||||||
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
||||||
|
ofs << "# Run command: " << command << std::endl
|
||||||
|
<< "# Output:" << std::endl
|
||||||
|
<< output.c_str() << std::endl;
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Problem running command: " << command
|
||||||
|
<< std::endl << "Please check " << tmpFile.c_str() << " for errors"
|
||||||
|
<< std::endl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmCPackProductBuildGenerator::GenerateComponentPackage(
|
||||||
|
const std::string& packageFileDir,
|
||||||
|
const std::string& packageFileName,
|
||||||
|
const std::string& packageDir,
|
||||||
|
const cmCPackComponent* component)
|
||||||
|
{
|
||||||
|
std::string packageFile = packageFileDir;
|
||||||
|
packageFile += '/';
|
||||||
|
packageFile += packageFileName;
|
||||||
|
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
||||||
|
"- Building component package: " <<
|
||||||
|
packageFile << std::endl);
|
||||||
|
|
||||||
|
const char* comp_name = component ? component->Name.c_str() : NULL;
|
||||||
|
|
||||||
|
const char* preflight = this->GetComponentScript("PREFLIGHT", comp_name);
|
||||||
|
const char* postflight = this->GetComponentScript("POSTFLIGHT", comp_name);
|
||||||
|
|
||||||
|
std::string resDir = packageFileDir;
|
||||||
|
if(component)
|
||||||
|
{
|
||||||
|
resDir += "/";
|
||||||
|
resDir += component->Name;
|
||||||
|
}
|
||||||
|
std::string scriptDir = resDir + "/scripts";
|
||||||
|
|
||||||
|
if ( !cmsys::SystemTools::MakeDirectory(scriptDir.c_str()))
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Problem creating installer directory: "
|
||||||
|
<< scriptDir.c_str() << std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if preflight, postflight, or postupgrade are set
|
||||||
|
// then copy them into the script directory and make
|
||||||
|
// them executable
|
||||||
|
if(preflight)
|
||||||
|
{
|
||||||
|
this->CopyInstallScript(scriptDir.c_str(),
|
||||||
|
preflight,
|
||||||
|
"preinstall");
|
||||||
|
}
|
||||||
|
if(postflight)
|
||||||
|
{
|
||||||
|
this->CopyInstallScript(scriptDir.c_str(),
|
||||||
|
postflight,
|
||||||
|
"postinstall");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The command that will be used to run ProductBuild
|
||||||
|
std::ostringstream pkgCmd;
|
||||||
|
|
||||||
|
std::string pkgId = "com.";
|
||||||
|
pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
|
||||||
|
pkgId += '.';
|
||||||
|
pkgId += this->GetOption("CPACK_PACKAGE_NAME");
|
||||||
|
if(component)
|
||||||
|
{
|
||||||
|
pkgId += '.';
|
||||||
|
pkgId += component->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
|
||||||
|
std::string pkgbuild = this->GetOption("CPACK_COMMAND_PKGBUILD");
|
||||||
|
|
||||||
|
pkgCmd << pkgbuild
|
||||||
|
<< " --root \"" << packageDir << "\""
|
||||||
|
<< " --identifier \"" << pkgId << "\""
|
||||||
|
<< " --scripts \"" << scriptDir << "\""
|
||||||
|
<< " --version \"" << version << "\""
|
||||||
|
<< " --install-location \"/\""
|
||||||
|
<< " \"" << packageFile << "\"";
|
||||||
|
|
||||||
|
// Run ProductBuild
|
||||||
|
return RunProductBuild(pkgCmd.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* cmCPackProductBuildGenerator::GetComponentScript(
|
||||||
|
const char* script,
|
||||||
|
const char* component_name)
|
||||||
|
{
|
||||||
|
std::string scriptname = std::string("CPACK_") + script + "_";
|
||||||
|
if(component_name)
|
||||||
|
{
|
||||||
|
scriptname += cmSystemTools::UpperCase(component_name);
|
||||||
|
scriptname += "_";
|
||||||
|
}
|
||||||
|
scriptname += "SCRIPT";
|
||||||
|
|
||||||
|
return this->GetOption(scriptname);
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2000-2009 Kitware, Inc.
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
|
||||||
|
#ifndef cmCPackProductBuildGenerator_h
|
||||||
|
#define cmCPackProductBuildGenerator_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "cmCPackPKGGenerator.h"
|
||||||
|
|
||||||
|
class cmCPackComponent;
|
||||||
|
|
||||||
|
/** \class cmCPackProductBuildGenerator
|
||||||
|
* \brief A generator for ProductBuild files
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class cmCPackProductBuildGenerator : public cmCPackPKGGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cmCPackTypeMacro(cmCPackProductBuildGenerator, cmCPackPKGGenerator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct generator
|
||||||
|
*/
|
||||||
|
cmCPackProductBuildGenerator();
|
||||||
|
virtual ~cmCPackProductBuildGenerator();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int InitializeInternal();
|
||||||
|
int PackageFiles();
|
||||||
|
virtual const char* GetOutputExtension() { return ".pkg"; }
|
||||||
|
|
||||||
|
// Run ProductBuild with the given command line, which will (if
|
||||||
|
// successful) produce the given package file. Returns true if
|
||||||
|
// ProductBuild succeeds, false otherwise.
|
||||||
|
bool RunProductBuild(const std::string& command);
|
||||||
|
|
||||||
|
// Generate a package in the file packageFile for the given
|
||||||
|
// component. All of the files within this component are stored in
|
||||||
|
// the directory packageDir. Returns true if successful, false
|
||||||
|
// otherwise.
|
||||||
|
bool GenerateComponentPackage(const std::string& packageFileDir,
|
||||||
|
const std::string& packageFileName,
|
||||||
|
const std::string& packageDir,
|
||||||
|
const cmCPackComponent* component);
|
||||||
|
|
||||||
|
const char* GetComponentScript(const char* script,
|
||||||
|
const char* script_component);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -951,6 +951,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||||
set(CPackComponents_BUILD_OPTIONS)
|
set(CPackComponents_BUILD_OPTIONS)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
|
set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
|
||||||
|
if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
|
||||||
|
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
||||||
|
-DCPACK_BINARY_PRODUCTBUILD:BOOL=ON)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NSIS_MAKENSIS_EXECUTABLE)
|
if(NSIS_MAKENSIS_EXECUTABLE)
|
||||||
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
||||||
|
@ -995,6 +999,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||||
list(APPEND ACTIVE_CPACK_GENERATORS "ZIP")
|
list(APPEND ACTIVE_CPACK_GENERATORS "ZIP")
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
list(APPEND ACTIVE_CPACK_GENERATORS "DragNDrop")
|
list(APPEND ACTIVE_CPACK_GENERATORS "DragNDrop")
|
||||||
|
if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
|
||||||
|
list(APPEND ACTIVE_CPACK_GENERATORS "productbuild")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# set up list of component packaging ways
|
# set up list of component packaging ways
|
||||||
|
@ -1105,6 +1112,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||||
set(CPackComponents_BUILD_OPTIONS)
|
set(CPackComponents_BUILD_OPTIONS)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
|
set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
|
||||||
|
if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
|
||||||
|
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
||||||
|
-DCPACK_BINARY_PRODUCTBUILD:BOOL=ON)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT NSIS_MAKENSIS_EXECUTABLE)
|
if(NOT NSIS_MAKENSIS_EXECUTABLE)
|
||||||
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
|
||||||
|
|
Loading…
Reference in New Issue