summaryrefslogtreecommitdiff
path: root/Source/CPack/cmCPackDragNDropGenerator.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2009-04-03 13:12:53 -0400
committerDavid Cole <david.cole@kitware.com>2009-04-03 13:12:53 -0400
commit42c033ccd6653d61cd304e0c853f13cf90eb3924 (patch)
tree4ceef3ef75921ff7e46a8c48925d82d11ad111b8 /Source/CPack/cmCPackDragNDropGenerator.cxx
parent601764feed24c32ddbe83fa1b3937e925eea10bc (diff)
downloadcmake-42c033ccd6653d61cd304e0c853f13cf90eb3924.tar.gz
BUG: Fix issue #8759 - add support for setting dmg volume name and compression type by CPack variables. Also add custom .DS_Store and background image support. Thanks to Mike Arthur for the patches.
Diffstat (limited to 'Source/CPack/cmCPackDragNDropGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx80
1 files changed, 78 insertions, 2 deletions
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 32e2e15ca4..db0dcf8799 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -173,10 +173,28 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel,
const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON")
? this->GetOption("CPACK_PACKAGE_ICON") : "";
+ const std::string cpack_dmg_volume_name =
+ this->GetOption("CPACK_DMG_VOLUME_NAME")
+ ? this->GetOption("CPACK_DMG_VOLUME_NAME")
+ : this->GetOption("CPACK_PACKAGE_FILE_NAME");
+
+ const std::string cpack_dmg_format =
+ this->GetOption("CPACK_DMG_FORMAT")
+ ? this->GetOption("CPACK_DMG_FORMAT") : "UDZO";
+
// Get optional arguments ...
std::string cpack_license_file =
this->GetOption("CPACK_RESOURCE_FILE_LICENSE") ?
this->GetOption("CPACK_RESOURCE_FILE_LICENSE") : "";
+
+ const std::string cpack_dmg_background_image =
+ this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
+ ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE") : "";
+
+ const std::string cpack_dmg_ds_store =
+ this->GetOption("CPACK_DMG_DS_STORE")
+ ? this->GetOption("CPACK_DMG_DS_STORE") : "";
+
// only put license on dmg if is user provided
if(!cpack_license_file.empty() &&
cpack_license_file.find("CPack.GenericLicense.txt") != std::string::npos)
@@ -216,6 +234,63 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel,
}
}
+ // Optionally add a custom .DS_Store file
+ // (e.g. for setting background/layout) ...
+ if(!cpack_dmg_ds_store.empty())
+ {
+ cmOStringStream package_settings_source;
+ package_settings_source << cpack_dmg_ds_store;
+
+ cmOStringStream package_settings_destination;
+ package_settings_destination << staging.str() << "/.DS_Store";
+
+ if(!this->CopyFile(package_settings_source, package_settings_destination))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying disk volume settings file. "
+ "Check the value of CPACK_DMG_DS_STORE."
+ << std::endl);
+
+ return 0;
+ }
+ }
+
+ // Optionally add a custom background image ...
+ if(!cpack_dmg_background_image.empty())
+ {
+ cmOStringStream package_background_source;
+ package_background_source << cpack_dmg_background_image;
+
+ cmOStringStream package_background_destination;
+ package_background_destination << staging.str() << "/background.png";
+
+ if(!this->CopyFile(package_background_source,
+ package_background_destination))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying disk volume background image. "
+ "Check the value of CPACK_DMG_BACKGROUND_IMAGE."
+ << std::endl);
+
+ return 0;
+ }
+
+ cmOStringStream temp_background_hiding_command;
+ temp_background_hiding_command << this->GetOption("CPACK_COMMAND_SETFILE");
+ temp_background_hiding_command << " -a V \"";
+ temp_background_hiding_command << package_background_destination.str();
+ temp_background_hiding_command << "\"";
+
+ if(!this->RunCommand(temp_background_hiding_command))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error setting attributes on disk volume background image."
+ << std::endl);
+
+ return 0;
+ }
+ }
+
// Create a temporary read-write disk image ...
std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
temp_image += "/temp.dmg";
@@ -226,7 +301,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel,
temp_image_command << " -ov";
temp_image_command << " -srcfolder \"" << staging.str() << "\"";
temp_image_command << " -volname \""
- << this->GetOption("CPACK_PACKAGE_FILE_NAME") << "\"";
+ << cpack_dmg_volume_name << "\"";
temp_image_command << " -format UDRW";
temp_image_command << " \"" << temp_image << "\"";
@@ -394,7 +469,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel,
cmOStringStream final_image_command;
final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
final_image_command << " convert \"" << temp_image << "\"";
- final_image_command << " -format UDZO";
+ final_image_command << " -format ";
+ final_image_command << cpack_dmg_format;
final_image_command << " -imagekey";
final_image_command << " zlib-level=9";
final_image_command << " -o \"" << outFileName << "\"";