On Thursday 05 February 2009 18:27:06 David Cole wrote:
> I agree with Clint. This belongs in the new cmCPackDragNDropGenerator.
Please find attached a new patch for the DND generator. Sorry about the delay!

-- 
Cheers,
Mike Arthur
http://mikearthur.co.uk/
--- Source/CPack/cmCPackDragNDropGenerator.cxx	24 Feb 2009 14:34:03 -0000	1.5
+++ Source/CPack/cmCPackDragNDropGenerator.cxx	18 Mar 2009 18:33:24 -0000
@@ -177,6 +177,15 @@
   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 +225,63 @@
       }
     }
 
+  // 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";
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to