[Cmake-commits] [cmake-commits] david.cole committed cmCPackDragNDropGenerator.cxx 1.5 1.6

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Apr 3 13:12:56 EDT 2009


Update of /cvsroot/CMake/CMake/Source/CPack
In directory public:/mounts/ram/cvs-serv20468/Source/CPack

Modified Files:
	cmCPackDragNDropGenerator.cxx 
Log Message:
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.


Index: cmCPackDragNDropGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackDragNDropGenerator.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -C 2 -d -r1.5 -r1.6
*** cmCPackDragNDropGenerator.cxx	24 Feb 2009 14:34:03 -0000	1.5
--- cmCPackDragNDropGenerator.cxx	3 Apr 2009 17:12:53 -0000	1.6
***************
*** 174,181 ****
--- 174,199 ----
      ? 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() &&
***************
*** 217,220 ****
--- 235,295 ----
      }
  
+   // 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");
***************
*** 227,231 ****
    temp_image_command << " -srcfolder \"" << staging.str() << "\"";
    temp_image_command << " -volname \""
!     << this->GetOption("CPACK_PACKAGE_FILE_NAME") << "\"";
    temp_image_command << " -format UDRW";
    temp_image_command << " \"" << temp_image << "\"";
--- 302,306 ----
    temp_image_command << " -srcfolder \"" << staging.str() << "\"";
    temp_image_command << " -volname \""
!     << cpack_dmg_volume_name << "\"";
    temp_image_command << " -format UDRW";
    temp_image_command << " \"" << temp_image << "\"";
***************
*** 395,399 ****
    final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
    final_image_command << " convert \"" << temp_image << "\"";
!   final_image_command << " -format UDZO";
    final_image_command << " -imagekey";
    final_image_command << " zlib-level=9";
--- 470,475 ----
    final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
    final_image_command << " convert \"" << temp_image << "\"";
!   final_image_command << " -format ";
!   final_image_command << cpack_dmg_format;
    final_image_command << " -imagekey";
    final_image_command << " zlib-level=9";



More information about the Cmake-commits mailing list