[Cmake-commits] [cmake-commits] david.cole committed cmCPackBundleGenerator.cxx 1.2 1.3
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Jul 18 16:12:38 EDT 2008
Update of /cvsroot/CMake/CMake/Source/CPack
In directory public:/mounts/ram/cvs-serv12458/Source/CPack
Modified Files:
cmCPackBundleGenerator.cxx
Log Message:
ENH: Improvements to the bundle cpack generator from second patch attached to feature request #7170. Thanks to Tim Shead.
Index: cmCPackBundleGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackBundleGenerator.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmCPackBundleGenerator.cxx 19 Jun 2008 10:17:01 -0000 1.2
--- cmCPackBundleGenerator.cxx 18 Jul 2008 20:12:36 -0000 1.3
***************
*** 37,41 ****
if(hdiutil_path.empty())
{
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
<< std::endl);
return 0;
--- 37,42 ----
if(hdiutil_path.empty())
{
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Cannot locate hdiutil command"
<< std::endl);
return 0;
***************
*** 47,51 ****
if(setfile_path.empty())
{
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
<< std::endl);
return 0;
--- 48,53 ----
if(setfile_path.empty())
{
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Cannot locate SetFile command"
<< std::endl);
return 0;
***************
*** 78,81 ****
--- 80,127 ----
(void) files;
+ // Get required arguments ...
+ const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") ? this->GetOption("CPACK_BUNDLE_NAME") : "";
+ if(cpack_bundle_name.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_NAME must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST") ? this->GetOption("CPACK_BUNDLE_PLIST") : "";
+ if(cpack_bundle_plist.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_PLIST must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON") ? this->GetOption("CPACK_BUNDLE_ICON") : "";
+ if(cpack_bundle_icon.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_ICON must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ const std::string cpack_bundle_startup_command = this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : "";
+ if(cpack_bundle_startup_command.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_STARTUP_COMMAND must be set."
+ << std::endl);
+
+ return 0;
+ }
+
+ // Get optional arguments ...
+ const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") ? this->GetOption("CPACK_PACKAGE_ICON") : "";
+
// The staging directory contains everything that will end-up inside the
// final disk image ...
***************
*** 84,88 ****
cmOStringStream contents;
! contents << staging.str() << "/" << this->GetOption("CPACK_BUNDLE_NAME")
<< ".app/" << "Contents";
--- 130,134 ----
cmOStringStream contents;
! contents << staging.str() << "/" << cpack_bundle_name
<< ".app/" << "Contents";
***************
*** 93,146 ****
resources << contents.str() << "/" << "Resources";
! // Install a user-provided bundle metadata file ...
! if(this->GetOption("CPACK_BUNDLE_PLIST"))
! {
! cmOStringStream plist_source;
! plist_source << this->GetOption("CPACK_BUNDLE_PLIST");
! cmOStringStream plist_target;
! plist_target << contents.str() << "/" << "Info.plist";
! if(!this->CopyFile(plist_source, plist_target))
! {
! return 0;
! }
}
// Install a user-provided bundle icon ...
! if(this->GetOption("CPACK_BUNDLE_ICON"))
! {
! cmOStringStream icon_source;
! icon_source << this->GetOption("CPACK_BUNDLE_ICON");
! cmOStringStream icon_target;
! icon_target << resources.str() << "/"
! << this->GetOption("CPACK_BUNDLE_NAME") << ".icns";
! if(!this->CopyFile(icon_source, icon_target))
! {
! return 0;
! }
}
// Install a user-provided startup command (could be an executable or a
// script) ...
! if(this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND"))
! {
! cmOStringStream command_source;
! command_source << this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND");
! cmOStringStream command_target;
! command_target << application.str() << "/"
! << this->GetOption("CPACK_BUNDLE_NAME");
! if(!this->CopyFile(command_source, command_target))
! {
! return 0;
! }
! cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
}
// Add a symlink to /Applications so users can drag-and-drop the bundle
// into it
--- 139,193 ----
resources << contents.str() << "/" << "Resources";
! // Install a required, user-provided bundle metadata file ...
! cmOStringStream plist_source;
! plist_source << cpack_bundle_plist;
! cmOStringStream plist_target;
! plist_target << contents.str() << "/" << "Info.plist";
! if(!this->CopyFile(plist_source, plist_target))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error copying plist. Check the value of CPACK_BUNDLE_PLIST."
! << std::endl);
!
! return 0;
}
// Install a user-provided bundle icon ...
! cmOStringStream icon_source;
! icon_source << cpack_bundle_icon;
! cmOStringStream icon_target;
! icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
! if(!this->CopyFile(icon_source, icon_target))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON."
! << std::endl);
!
! return 0;
}
// Install a user-provided startup command (could be an executable or a
// script) ...
! cmOStringStream command_source;
! command_source << cpack_bundle_startup_command;
! cmOStringStream command_target;
! command_target << application.str() << "/" << cpack_bundle_name;
! if(!this->CopyFile(command_source, command_target))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error copying startup command. Check the value of CPACK_BUNDLE_STARTUP_COMMAND."
! << std::endl);
! return 0;
}
+ cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
+
// Add a symlink to /Applications so users can drag-and-drop the bundle
// into it
***************
*** 151,158 ****
// Optionally add a custom volume icon ...
! if(this->GetOption("CPACK_PACKAGE_ICON"))
{
cmOStringStream package_icon_source;
! package_icon_source << this->GetOption("CPACK_PACKAGE_ICON");
cmOStringStream package_icon_destination;
--- 198,205 ----
// Optionally add a custom volume icon ...
! if(!cpack_package_icon.empty())
{
cmOStringStream package_icon_source;
! package_icon_source << cpack_package_icon;
cmOStringStream package_icon_destination;
***************
*** 161,164 ****
--- 208,215 ----
if(!this->CopyFile(package_icon_source, package_icon_destination))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying disk volume icon. Check the value of CPACK_PACKAGE_ICON."
+ << std::endl);
+
return 0;
}
***************
*** 181,189 ****
if(!this->RunCommand(temp_image_command))
{
return 0;
}
// Optionally set the custom icon flag for the image ...
! if(this->GetOption("CPACK_PACKAGE_ICON"))
{
cmOStringStream temp_mount;
--- 232,244 ----
if(!this->RunCommand(temp_image_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error generating temporary disk image."
+ << std::endl);
+
return 0;
}
// Optionally set the custom icon flag for the image ...
! if(!cpack_package_icon.empty())
{
cmOStringStream temp_mount;
***************
*** 199,202 ****
--- 254,261 ----
if(!this->RunCommand(attach_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error attaching temporary disk image."
+ << std::endl);
+
return 0;
}
***************
*** 209,212 ****
--- 268,275 ----
if(!this->RunCommand(setfile_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error assigning custom icon to temporary disk image."
+ << std::endl);
+
return 0;
}
***************
*** 219,222 ****
--- 282,289 ----
if(!this->RunCommand(detach_command))
{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error detaching temporary disk image."
+ << std::endl);
+
return 0;
}
***************
*** 234,294 ****
if(!this->RunCommand(final_image_command))
{
! return 0;
! }
!
! /*
! // Disk image directories
! std::string diskImageDirectory = toplevel;
! std::string diskImageBackgroundImageDir = diskImageDirectory
! + "/.background";
!
! // App bundle directories
! std::string packageDirFileName = toplevel;
! packageDirFileName += "/";
! packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
! packageDirFileName += ".app";
! std::string contentsDirectory = packageDirFileName + "/Contents";
! std::string resourcesDirectory = contentsDirectory + "/Resources";
! std::string appDirectory = contentsDirectory + "/MacOS";
!
! const char* dir = resourcesDirectory.c_str();
! const char* appdir = appDirectory.c_str();
! const char* contDir = contentsDirectory.c_str();
! const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
! 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);
! return 0;
! }
! std::string destFileName = resourcesDirectory + "/" + iconFileName;
! this->ConfigureFile(iconFile, destFileName.c_str(), true);
! this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.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("Bundle.Info.plist", contDir,
! "Info.plist" ) ||
! !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
! this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
! )
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl);
return 0;
}
- */
return 1;
--- 301,310 ----
if(!this->RunCommand(final_image_command))
{
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error compressing disk image."
<< std::endl);
+
return 0;
}
return 1;
***************
*** 299,304 ****
cmOStringStream& target)
{
! return cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
! target.str().c_str());
}
--- 315,333 ----
cmOStringStream& target)
{
! if(!cmSystemTools::CopyFileIfDifferent(
! source.str().c_str(),
! target.str().c_str()))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error copying "
! << source.str()
! << " to "
! << target.str()
! << std::endl);
!
! return false;
! }
!
! return true;
}
***************
*** 309,318 ****
int exit_code = 1;
! bool result = cmSystemTools::RunSingleCommand(command.str().c_str(),
! &output, &exit_code, 0, this->GeneratorVerbose, 0);
if(!result || exit_code)
{
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running command: "
! << command.str().c_str() << std::endl);
return false;
}
--- 338,356 ----
int exit_code = 1;
! bool result = cmSystemTools::RunSingleCommand(
! command.str().c_str(),
! &output,
! &exit_code,
! 0,
! this->GeneratorVerbose,
! 0);
!
if(!result || exit_code)
{
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Error executing: "
! << command.str()
! << std::endl);
!
return false;
}
More information about the Cmake-commits
mailing list