summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackOSXX11Generator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CPack/cmCPackOSXX11Generator.cxx')
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.cxx193
1 files changed, 91 insertions, 102 deletions
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 42b8c62..d5691be 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -36,41 +36,38 @@ int cmCPackOSXX11Generator::PackageFiles()
// TODO: Use toplevel ?
// It is used! Is this an obsolete comment?
- const char* cpackPackageExecutables
- = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
- if ( cpackPackageExecutables )
- {
+ const char* cpackPackageExecutables =
+ this->GetOption("CPACK_PACKAGE_EXECUTABLES");
+ if (cpackPackageExecutables) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
- << cpackPackageExecutables << "." << std::endl);
+ << cpackPackageExecutables << "." << std::endl);
std::ostringstream str;
std::ostringstream deleteStr;
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesVector);
- if ( cpackPackageExecutablesVector.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ cpackPackageExecutablesVector);
+ if (cpackPackageExecutablesVector.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
- "<icon name>." << std::endl);
+ "<icon name>."
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string>::iterator it;
- for ( it = cpackPackageExecutablesVector.begin();
- it != cpackPackageExecutablesVector.end();
- ++it )
- {
+ for (it = cpackPackageExecutablesVector.begin();
+ it != cpackPackageExecutablesVector.end(); ++it) {
std::string cpackExecutableName = *it;
- ++ it;
+ ++it;
this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME",
- cpackExecutableName.c_str());
- }
+ cpackExecutableName.c_str());
}
+ }
// Disk image directories
std::string diskImageDirectory = toplevel;
- std::string diskImageBackgroundImageDir
- = diskImageDirectory + "/.background";
-
+ std::string diskImageBackgroundImageDir =
+ diskImageDirectory + "/.background";
// App bundle directories
std::string packageDirFileName = toplevel;
@@ -90,48 +87,45 @@ int cmCPackOSXX11Generator::PackageFiles()
const char* contDir = contentsDirectory.c_str();
const char* rsrcFile = resourceFileName.c_str();
const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
- if ( iconFile )
- {
- std::string iconFileName = cmsys::SystemTools::GetFilenameName(
- iconFile);
- if ( !cmSystemTools::FileExists(iconFile) )
- {
+ if (iconFile) {
+ std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
+ if (!cmSystemTools::FileExists(iconFile)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
- << iconFile << ". Please check CPACK_PACKAGE_ICON setting."
- << std::endl);
+ << iconFile
+ << ". Please check CPACK_PACKAGE_ICON setting."
+ << std::endl);
return 0;
- }
+ }
std::string destFileName = resourcesDirectory + "/" + iconFileName;
this->ConfigureFile(iconFile, destFileName.c_str(), true);
this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
- }
+ }
std::string applicationsLinkName = diskImageDirectory + "/Applications";
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
- if (
- !this->CopyResourcePlistFile("VolumeIcon.icns",
- diskImageDirectory.c_str(),
- ".VolumeIcon.icns", true ) ||
- !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
- ".DS_Store", true ) ||
- !this->CopyResourcePlistFile("background.png",
- diskImageBackgroundImageDir.c_str(), "background.png", true ) ||
- !this->CopyResourcePlistFile("RuntimeScript", dir) ||
- !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
- "Info.plist" ) ||
- !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir,
- "main.scpt", true ) ||
- !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir,
- rsrcFile, true) ||
- !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
- this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
- )
- {
+ if (!this->CopyResourcePlistFile("VolumeIcon.icns",
+ diskImageDirectory.c_str(),
+ ".VolumeIcon.icns", true) ||
+ !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
+ ".DS_Store", true) ||
+ !this->CopyResourcePlistFile("background.png",
+ diskImageBackgroundImageDir.c_str(),
+ "background.png", true) ||
+ !this->CopyResourcePlistFile("RuntimeScript", dir) ||
+ !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
+ "Info.plist") ||
+ !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, "main.scpt",
+ true) ||
+ !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, rsrcFile,
+ true) ||
+ !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ true)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
// Two of the files need to have execute permission, so ensure they do:
std::string runTimeScript = dir;
@@ -143,21 +137,21 @@ int cmCPackOSXX11Generator::PackageFiles()
appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
mode_t mode;
- if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode))
- {
+ if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) {
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript
- << " to permission: " << mode << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "Setting: " << runTimeScript << " to permission: " << mode
+ << std::endl);
+ }
- if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode))
- {
+ if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) {
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << appScriptName
- << " to permission: " << mode << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "Setting: " << appScriptName << " to permission: " << mode
+ << std::endl);
+ }
std::string output;
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -165,56 +159,52 @@ int cmCPackOSXX11Generator::PackageFiles()
std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \""
- << diskImageDirectory.c_str()
- << "\" \"" << packageFileNames[0] << "\"";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Compress disk image using command: "
- << dmgCmd.str().c_str() << std::endl);
+ << diskImageDirectory.c_str() << "\" \"" << packageFileNames[0]
+ << "\"";
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: "
+ << dmgCmd.str().c_str() << std::endl);
// since we get random dashboard failures with this one
// try running it more than once
int retVal = 1;
int numTries = 10;
bool res = false;
- while(numTries > 0)
- {
- res = cmSystemTools::RunSingleCommand(
- dmgCmd.str().c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( res && !retVal )
- {
+ while (numTries > 0) {
+ res =
+ cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
+ &retVal, 0, this->GeneratorVerbose, 0);
+ if (res && !retVal) {
numTries = -1;
break;
- }
+ }
cmSystemTools::Delay(500);
numTries--;
- }
- if ( !res || retVal )
- {
+ }
+ if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
- << "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
- << dmgCmd.str().c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << dmgCmd.str().c_str() << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors"
+ << std::endl);
return 0;
- }
+ }
return 1;
}
int cmCPackOSXX11Generator::InitializeInternal()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "cmCPackOSXX11Generator::Initialize()" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()"
+ << std::endl);
std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
- if ( pkgPath.empty() )
- {
+ if (pkgPath.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
pkgPath.c_str());
@@ -265,32 +255,31 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
}
*/
-bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
- const std::string& dir, const char* outputFileName /* = 0 */,
- bool copyOnly /* = false */)
+bool cmCPackOSXX11Generator::CopyResourcePlistFile(
+ const std::string& name, const std::string& dir,
+ const char* outputFileName /* = 0 */, bool copyOnly /* = false */)
{
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);
+ if (inFileName.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find input file: " << inFName << std::endl);
return false;
- }
+ }
- if ( !outputFileName )
- {
+ if (!outputFileName) {
outputFileName = name.c_str();
- }
+ }
std::string destFileName = dir;
destFileName += "/";
destFileName += outputFileName;
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << inFileName.c_str() << " to "
+ << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
return true;
}