BUG: Workaround PackageMaker 3.0 issue for new CPack components feature. Thanks again to Doug Gregor for the patch.

This commit is contained in:
David Cole 2008-06-18 07:08:33 -04:00
parent cb613406bc
commit e8825d320b
3 changed files with 95 additions and 50 deletions

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion="1.0"> <installer-gui-script minSpecVersion="1.0">
<title>@CPACK_PACKAGE_NAME@</title> <title>@CPACK_PACKAGE_NAME@</title>
<welcome file="@CPACK_RESOURCE_FILE_WELCOME_NOPATH@"/>
<readme file="@CPACK_RESOURCE_FILE_README_NOPATH@"/>
<license file="@CPACK_RESOURCE_FILE_LICENSE_NOPATH@"/>
<options allow-external-scripts="no" customize="allow" rootVolumeOnly="false"></options> <options allow-external-scripts="no" customize="allow" rootVolumeOnly="false"></options>
@CPACK_PACKAGEMAKER_CHOICES@ @CPACK_PACKAGEMAKER_CHOICES@
</installer-gui-script> </installer-gui-script>

View File

@ -69,9 +69,51 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
{ {
(void) files; // TODO: Fix api to not need files. (void) files; // TODO: Fix api to not need files.
(void) toplevel; // TODO: Use toplevel (void) toplevel; // TODO: Use toplevel
std::string resDir; // Where this package's resources will go.
std::string packageDirFileName
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
if (this->Components.empty())
{
packageDirFileName += ".pkg";
resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
resDir += "/Resources";
}
else
{
packageDirFileName += ".mpkg";
if ( !cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package directory "
<< packageDirFileName << std::endl);
return 0;
}
resDir = packageDirFileName;
resDir += "/Contents";
if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir
<< std::endl);
return 0;
}
resDir += "/Resources";
if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir
<< std::endl);
return 0;
}
resDir += "/en.lproj";
}
// Create directory structure // Create directory structure
std::string resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
resDir += "/Resources";
std::string preflightDirName = resDir + "/PreFlight"; std::string preflightDirName = resDir + "/PreFlight";
std::string postflightDirName = resDir + "/PostFlight"; std::string postflightDirName = resDir + "/PostFlight";
const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT"); const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
@ -124,8 +166,8 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
if (!this->Components.empty()) if (!this->Components.empty())
{ {
// Create the directory where component packages will be installed. // Create the directory where component packages will be installed.
std::string basePackageDir = toplevel; std::string basePackageDir = packageDirFileName;
basePackageDir += "/packages"; basePackageDir += "/Contents/Packages";
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str()))
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -157,59 +199,49 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
this->SetOption("CPACK_MODULE_VERSION_SUFFIX", ""); this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
// Copy or create all of the resource files we need. // Copy or create all of the resource files we need.
if ( !this->CopyCreateResourceFile("License") if ( !this->CopyCreateResourceFile("License", resDir.c_str())
|| !this->CopyCreateResourceFile("ReadMe") || !this->CopyCreateResourceFile("ReadMe", resDir.c_str())
|| !this->CopyCreateResourceFile("Welcome") || !this->CopyCreateResourceFile("Welcome", resDir.c_str())
|| !this->CopyResourcePlistFile("Info.plist") || !this->CopyResourcePlistFile("Info.plist")
|| !this->CopyResourcePlistFile("Description.plist") ) || !this->CopyResourcePlistFile("Description.plist") )
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl); << std::endl);
return 0; return 0;
} }
std::string packageDirFileName
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
if (this->Components.empty()) if (this->Components.empty())
{ {
packageDirFileName += ".pkg"; // Use PackageMaker to build the package.
} cmOStringStream pkgCmd;
else pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
{ << "\" -build -p \"" << packageDirFileName << "\"";
packageDirFileName += ".mpkg"; if (this->Components.empty())
if (this->PackageMakerVersion == 3.0)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY");
"PackageMaker 3.0 cannot build component-based installations."
<< std::endl << "Please use PackageMaker 2.5 instead." << std::endl);
} }
} else
{
cmOStringStream pkgCmd; pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") << "/packages/";
<< "\" -build -p \"" << packageDirFileName << "\""; }
if (this->Components.empty()) pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
{ << "/Resources\" -i \""
pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY"); << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Info.plist\" -d \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 )
{
pkgCmd << " -v";
}
if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
return 0;
} }
else else
{ {
pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY") // We have built the package in place. Generate the
<< "/packages/"; // distribution.dist file to describe it for the installer.
}
pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Resources\" -i \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Info.plist\" -d \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 )
{
pkgCmd << " -v";
}
if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
return 0;
if (!this->Components.empty())
{
WriteDistributionFile(packageDirFileName.c_str()); WriteDistributionFile(packageDirFileName.c_str());
} }
@ -331,7 +363,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name) bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
const char* dirName)
{ {
std::string uname = cmSystemTools::UpperCase(name); std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@ -361,10 +394,14 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name)
return false; return false;
} }
std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string destFileName = dirName;
destFileName += "/Resources/"; destFileName += '/';
destFileName += name + ext; 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: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< (inFileName ? inFileName : "(NULL)") << (inFileName ? inFileName : "(NULL)")
@ -509,9 +546,9 @@ GenerateComponentPackage(const char *packageFile,
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageFile << "\"" << "\" -build -p \"" << packageFile << "\""
<< " -f \"" << packageDir << "\"" << " -f \"" << packageDir << "\""
<< "-i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/" << infoFileName << "\"" << "/" << infoFileName << "\""
<< "-d \"" << descriptionFile << "\""; << " -d \"" << descriptionFile << "\"";
return RunPackageMaker(pkgCmd.str().c_str(), packageFile); return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
} }

View File

@ -52,7 +52,12 @@ protected:
virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputExtension() { return ".dmg"; }
virtual const char* GetOutputPostfix() { return "darwin"; } virtual const char* GetOutputPostfix() { return "darwin"; }
bool CopyCreateResourceFile(const char* name); // 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 char* name, const char *dirName);
bool CopyResourcePlistFile(const char* name, const char* outName = 0); bool CopyResourcePlistFile(const char* 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