[Cmake-commits] CMake branch, next, updated. v3.4.0-rc3-1304-g9c7a715

Brad King brad.king at kitware.com
Tue Nov 10 11:05:35 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  9c7a7154ef26d6dbcb10b36b0a2e599daf79b5ba (commit)
       via  45a799f000067991147e32a56c331de858af2bfb (commit)
       via  aa32f715b0950ff1b81735a270962d803dfdd65c (commit)
       via  b05104419a750ca1039c40bfa0ef04aed908674b (commit)
       via  6d6d6d891dfc4950149ab9c0454b5315ef945803 (commit)
       via  487ce279b6a1a4a326b13c0056d405466eb38164 (commit)
       via  0f054a775aaaae2183d07b43a69a099d76613dda (commit)
       via  d6d873fbd7af072e10362e2a4767185117068c5b (commit)
       via  c43b4f8fdc9a2f1072509ed4eaa7d4cc1a6cf234 (commit)
      from  84351658ae6c344413382dd93830b0959b136ece (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c7a7154ef26d6dbcb10b36b0a2e599daf79b5ba
commit 9c7a7154ef26d6dbcb10b36b0a2e599daf79b5ba
Merge: 8435165 45a799f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 10 11:05:33 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Nov 10 11:05:33 2015 -0500

    Merge topic 'better_looking_mac_package' into next
    
    45a799f0 fixup! DragNDropGenerator Updated Documentation to include new variables.
    aa32f715 CMake DragNDrop release now uses a custom background and script
    b0510441 DragNDropGenerator Updated Documentation to include new variables.
    6d6d6d89 DragNDropGenerator now manually computes the size of the temp dmg image.
    487ce279 DragNDropGenerator copies the background image after the dmg is created.
    0f054a77 DragNDropGenerator now can run an apple script when making a package.
    d6d873fb DragNDropGenerator now places the background image file in a hidden folder.
    c43b4f8f DragNDropGenerator background image now uses source file extension.


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45a799f000067991147e32a56c331de858af2bfb
commit 45a799f000067991147e32a56c331de858af2bfb
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 10 11:04:05 2015 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Nov 10 11:04:05 2015 -0500

    fixup! DragNDropGenerator Updated Documentation to include new variables.

diff --git a/Help/release/dev/better-looking-mac-packages.rst b/Help/release/dev/better-looking-mac-packages.rst
index 7e845aa..ef1b8e8 100644
--- a/Help/release/dev/better-looking-mac-packages.rst
+++ b/Help/release/dev/better-looking-mac-packages.rst
@@ -2,7 +2,7 @@ better-looking-mac-packages
 ---------------------------
 
 * The :module:`CPackDMG` module learned new variable to specify AppleScript
-  file run to customize appearance of ``DragNDrop``` installer folder,
+  file run to customize appearance of ``DragNDrop`` installer folder,
   including background image setting using supplied PNG or multi-resolution
   TIFF file.  See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
   :variable:`CPACK_DMG_BACKGROUND_IMAGE` variables.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aa32f715b0950ff1b81735a270962d803dfdd65c
commit aa32f715b0950ff1b81735a270962d803dfdd65c
Author:     Adam Strzelecki <ono at java.pl>
AuthorDate: Mon Sep 29 08:42:49 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 22:27:47 2015 +0100

    CMake DragNDrop release now uses a custom background and script

diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in
index b6013ef..ae00653 100644
--- a/CMakeCPackOptions.cmake.in
+++ b/CMakeCPackOptions.cmake.in
@@ -183,6 +183,13 @@ if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
   endif()
 endif()
 
+if("${CPACK_GENERATOR}" STREQUAL "DragNDrop")
+  set(CPACK_DMG_BACKGROUND_IMAGE
+      "@CMake_SOURCE_DIR@/Packaging/CMakeDMGBackground.tif")
+  set(CPACK_DMG_DS_STORE_SETUP_SCRIPT
+      "@CMake_SOURCE_DIR@/Packaging/CMakeDMGSetup.scpt")
+endif()
+
 if("${CPACK_GENERATOR}" STREQUAL "WIX")
   # Reset CPACK_PACKAGE_VERSION to deal with WiX restriction.
   # But the file names still use the full CMake_VERSION value:
diff --git a/Packaging/CMakeDMGBackground.tif b/Packaging/CMakeDMGBackground.tif
new file mode 100644
index 0000000..91c4b13
Binary files /dev/null and b/Packaging/CMakeDMGBackground.tif differ
diff --git a/Packaging/CMakeDMGSetup.scpt b/Packaging/CMakeDMGSetup.scpt
new file mode 100644
index 0000000..c7ddcfb
--- /dev/null
+++ b/Packaging/CMakeDMGSetup.scpt
@@ -0,0 +1,42 @@
+on run argv
+  set image_name to item 1 of argv
+
+  tell application "Finder"
+  tell disk image_name
+
+    -- open the image the first time and save a DS_Store with just
+    -- background and icon setup
+    open
+      set current view of container window to icon view
+      set theViewOptions to the icon view options of container window
+      set background picture of theViewOptions to file ".background:background.tif"
+      set arrangement of theViewOptions to not arranged
+      set icon size of theViewOptions to 128
+      delay 1
+    close
+
+    -- next setup the position of the app and Applications symlink
+    -- plus hide all the window decoration
+    open
+      update without registering applications
+      tell container window
+        set sidebar width to 0
+        set statusbar visible to false
+        set toolbar visible to false
+        set the bounds to { 400, 100, 900, 465 }
+        set position of item "CMake.app" to { 133, 200 }
+        set position of item "Applications" to { 378, 200 }
+      end tell
+      update without registering applications
+      delay 1
+    close
+
+    -- one last open and close so you can see everything looks correct
+    open
+      delay 5
+    close
+
+  end tell
+  delay 1
+end tell
+end run

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b05104419a750ca1039c40bfa0ef04aed908674b
commit b05104419a750ca1039c40bfa0ef04aed908674b
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Thu Dec 18 14:56:37 2014 -0500
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 22:27:47 2015 +0100

    DragNDropGenerator Updated Documentation to include new variables.
    
    The DragNDropGenerator documentation now covers the new behavior of
    CPACK_DMG_BACKGROUND_IMAGE and what the purpose of
    CPACK_DMG_DS_STORE_SETUP_SCRIPT is.

diff --git a/Help/release/dev/better-looking-mac-packages.rst b/Help/release/dev/better-looking-mac-packages.rst
new file mode 100644
index 0000000..7e845aa
--- /dev/null
+++ b/Help/release/dev/better-looking-mac-packages.rst
@@ -0,0 +1,8 @@
+better-looking-mac-packages
+---------------------------
+
+* The :module:`CPackDMG` module learned new variable to specify AppleScript
+  file run to customize appearance of ``DragNDrop``` installer folder,
+  including background image setting using supplied PNG or multi-resolution
+  TIFF file.  See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
+  :variable:`CPACK_DMG_BACKGROUND_IMAGE` variables.
diff --git a/Modules/CPackDMG.cmake b/Modules/CPackDMG.cmake
index 37d7352..6b5af7e 100644
--- a/Modules/CPackDMG.cmake
+++ b/Modules/CPackDMG.cmake
@@ -26,15 +26,25 @@
 #  Path to a custom DS_Store file. This .DS_Store file e.g. can be used to
 #  specify the Finder window position/geometry and layout (such as hidden
 #  toolbars, placement of the icons etc.). This file has to be generated by
-#  the Finder (either manually or through OSA-script) using a normal folder
+#  the Finder (either manually or through AppleScript) using a normal folder
 #  from which the .DS_Store file can then be extracted.
 #
+# .. variable:: CPACK_DMG_DS_STORE_SETUP_SCRIPT
+#
+#  Path to a custom AppleScript file.  This AppleScript is used to generate
+#  a .DS_Store file which specifies the Finder window position/geometry and
+#  layout (such as hidden toolbars, placement of the icons etc.).
+#  By specifying a custom AppleScript there is no need to use
+#  CPACK_DMG_DS_STORE, as the .DS_Store that is generated by the AppleScript
+#  will be packaged.
+#
 # .. variable:: CPACK_DMG_BACKGROUND_IMAGE
 #
-#  Path to a background image file. This file will be used as the background
-#  for the Finder Window when the disk image is opened.  By default no
-#  background image is set. The background image is applied after applying the
-#  custom .DS_Store file.
+#  Path to an image file to be used as the background.  This file will be
+#  copied to .background/background.<ext>, where ext is the original image file
+#  extension.  The background image is installed into the image before
+#  CPACK_DMG_DS_STORE_SETUP_SCRIPT is executed or CPACK_DMG_DS_STORE is
+#  installed.  By default no background image is set.
 #
 # .. variable:: CPACK_DMG_SLA_DIR
 #

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d6d6d891dfc4950149ab9c0454b5315ef945803
commit 6d6d6d891dfc4950149ab9c0454b5315ef945803
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Oct 1 13:52:11 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 21:53:28 2015 +0100

    DragNDropGenerator now manually computes the size of the temp dmg image.
    
    When creating a DragNDrop bundle with a custom layout and background you need
    to make sure that the image size is large enough to store both the background
    and the custom .DS_Store.
    
    Now previously the DragNDropGenerator relied on the fact that both of these
    files would exist in the staging folder so it could let hdiutil compute an
    exact size. Now that we allow generation of the .DS_Store to happen after
    creation of the image we need to manually specify the size of the image
    to include room for the new .DS_Store and background.
    
    The size calculation must not take only file sizes into account, but also file
    system block padding and directory entry structure size, therefore we add
    additional 4K to each file size to provide more accurate final value.
    
    The whole reason why we have to delay the background image copy, is that
    if we let hdiutil package the background image it gets modified in such away
    that applescript aren't able to specify it as the background image.

diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 5e06b2d..9a75b25 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -15,8 +15,10 @@
 #include "cmSystemTools.h"
 #include "cmGeneratedFileStream.h"
 
-#include <cmsys/RegularExpression.hxx>
+#include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
+#include <cmsys/SystemTools.hxx>
 
 #include <iomanip>
 
@@ -67,6 +69,53 @@ static const char* SLASTREnglish =
 "};\n"
 "\n";
 
+
+namespace
+{
+  //computes the size of all items in a given folder.
+  //will not traverse symlinked folders
+  unsigned long compute_folder_content_size( const std::string& path )
+  {
+  unsigned long sum = 0; //total size in bytes
+  cmsys::Directory dir;
+  dir.Load(path.c_str());
+  for (unsigned long fileNum = 0; fileNum <  dir.GetNumberOfFiles(); ++fileNum)
+    {
+    const std::string fileName(dir.GetFile(fileNum));
+    const bool is_not_dot_file = fileName != std::string(".") &&
+                                 fileName != std::string("..");
+    if ( is_not_dot_file )
+      {
+      std::string fullPath = path;
+      fullPath += "/";
+      fullPath += fileName;
+
+      const bool is_folder =
+                    cmSystemTools::FileIsDirectory(fullPath.c_str());
+      const bool is_file =
+                    !is_folder;
+      const bool is_symlink =
+                    cmSystemTools::FileIsSymlink(fullPath.c_str());
+
+      //add extra 4K for each entry, simulating extra file-system space needed
+      //to hold entry.
+      sum += 4096;
+
+      if( is_folder && !is_symlink)
+        {
+        sum += cmSystemTools::FileLength(fullPath.c_str());
+        sum += compute_folder_content_size(fullPath);
+        }
+      else if( is_file )
+        {
+        sum += cmSystemTools::FileLength(fullPath.c_str());
+        }
+      }
+    }
+  return sum;
+  }
+}
+
 //----------------------------------------------------------------------
 cmCPackDragNDropGenerator::cmCPackDragNDropGenerator()
 {
@@ -381,7 +430,25 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
       }
     }
 
-  // Create a temporary read-write disk image ...
+  // Create a temporary read-write disk image. If we are adding a DS_Store,
+  // Background or running a script we need to allocate some buffer space
+  // in the image, otherwise we won't have enough room
+
+  //first compute the size of the staging_path which requires us to
+  //iterate over
+  const std::string staging_path = staging.str();
+  unsigned long dmgSize = compute_folder_content_size( staging_path );
+  if (!cpack_dmg_background_image.empty())
+    {
+    dmgSize += cmSystemTools::FileLength(cpack_dmg_background_image.c_str());
+    }
+  dmgSize += 8388608; //add 8MB for the DS_Store and buffer
+
+  //now that we have computed the size of the disk image we need to convert
+  //it to kb. The reason for this is that the hdiutil doesn't have a byte
+  //size specifier.
+  const unsigned long dmgSizeAsKB = dmgSize / 1024;
+
   std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   temp_image += "/temp.dmg";
 
@@ -389,6 +456,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
   temp_image_command << " create";
   temp_image_command << " -ov";
+  temp_image_command << " -size " << dmgSizeAsKB << "k";
   temp_image_command << " -srcfolder \"" << staging.str() << "\"";
   temp_image_command << " -volname \""
     << cpack_dmg_volume_name << "\"";

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=487ce279b6a1a4a326b13c0056d405466eb38164
commit 487ce279b6a1a4a326b13c0056d405466eb38164
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Mon Sep 29 08:43:47 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 21:53:22 2015 +0100

    DragNDropGenerator copies the background image after the dmg is created.
    
    This is required so that the permissions on the image are correct so that
    an apple script can set the background.

diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 59b29a2..5e06b2d 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -380,73 +380,6 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
       return 0;
       }
     }
-  // Optionally add a custom background image ...
-  // Make sure the background file type is the same as the custom image
-  // and that the file is hidden so it doesn't show up.
-  if(!cpack_dmg_background_image.empty())
-    {
-    const std::string extension =
-        cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
-    std::ostringstream package_background_source;
-    package_background_source << cpack_dmg_background_image;
-
-    std::ostringstream package_background_destination;
-    package_background_destination << staging.str()
-                                   << "/.background/background" << extension;
-
-    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;
-      }
-    }
-
-  // Figure out if we have a .DS_Store to install or if we need to run
-  // an apple-script to generate a .DS_Store
-  if(!cpack_dmg_ds_store.empty())
-    {
-    // Optionally add a custom .DS_Store file
-    // (e.g. for setting background/layout) ...
-    std::ostringstream package_settings_source;
-    package_settings_source << cpack_dmg_ds_store;
-
-    std::ostringstream 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;
-      }
-    }
-  else if(!cpack_dmg_ds_store_setup_script.empty())
-    {
-    //If you don't have a custom .DS_Store file
-    //we can execute a custom apple script to generate the .DS_Store for
-    //the application
-    std::ostringstream setup_script_command;
-    setup_script_command << "osascript"
-                           << " \"" << cpack_dmg_ds_store_setup_script << "\"";
-    std::string error;
-    if(!this->RunCommand(setup_script_command, &error))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error executing custom script on disk image." << std::endl
-        << error
-        << std::endl);
-
-      return 0;
-      }
-    }
 
   // Create a temporary read-write disk image ...
   std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -471,10 +404,16 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     return 0;
     }
 
-  // Optionally set the custom icon flag for the image ...
-  if(!cpack_package_icon.empty())
+  //mount the image and set the ds_store or custom icon flag
+  const bool remount_image =  !cpack_dmg_background_image.empty() ||
+                              !cpack_dmg_ds_store.empty() ||
+                              !cpack_dmg_ds_store_setup_script.empty() ||
+                              !cpack_package_icon.empty();
+  if(remount_image)
     {
-    std::ostringstream temp_mount;
+    //store that we have a failure so that we always unmount the image
+    //before we exit
+    bool had_error = false;
 
     std::ostringstream attach_command;
     attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
@@ -490,25 +429,103 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
       return 0;
       }
-
     cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*");
     mountpoint_regex.find(attach_output.c_str());
+
+    std::ostringstream temp_mount;
     temp_mount << mountpoint_regex.match(1);
 
-    std::ostringstream setfile_command;
-    setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
-    setfile_command << " -a C";
-    setfile_command << " \"" << temp_mount.str() << "\"";
+    // Optionally add a custom background image ...
+    // Make sure the background file type is the same as the custom image
+    // and that the file is hidden so it doesn't show up.
+    if(!cpack_dmg_background_image.empty())
+      {
+      const std::string extension =
+          cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
+      std::ostringstream package_background_source;
+      package_background_source << cpack_dmg_background_image;
 
-    if(!this->RunCommand(setfile_command))
+      std::ostringstream package_background_destination;
+      package_background_destination << temp_mount.str()
+                                     << "/.background/background" << extension;
+
+      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);
+
+        had_error = true;
+        }
+      }
+
+    // Figure out if we have a .DS_Store to install or if we need to run
+    // an apple-script to generate a .DS_Store
+    if(!cpack_dmg_ds_store.empty())
       {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error assigning custom icon to temporary disk image."
-        << std::endl);
+      // Optionally add a custom .DS_Store file
+      // (e.g. for setting background/layout) ...
+      std::ostringstream package_settings_source;
+      package_settings_source << cpack_dmg_ds_store;
 
-      return 0;
+      std::ostringstream package_settings_destination;
+      package_settings_destination << temp_mount.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);
+
+        had_error = true;
+        }
+      }
+    else if(!cpack_dmg_ds_store_setup_script.empty())
+      {
+      //If you don't have a custom .DS_Store file
+      //we can execute a custom apple script to generate the .DS_Store for
+      //the application. We pass in as arguments to the apple script
+      //the location of the disk image
+      std::ostringstream setup_script_command;
+
+      setup_script_command << "osascript"
+                           << " \"" << cpack_dmg_ds_store_setup_script << "\""
+                           << " \"" << cpack_dmg_volume_name << "\"";
+
+      std::string error;
+      if(!this->RunCommand(setup_script_command, &error))
+        {
+        cmCPackLogger(cmCPackLog::LOG_ERROR,
+          "Error executing custom script on disk image." << std::endl
+          << error
+          << std::endl);
+
+        had_error = true;
+        }
+      }
+
+    if(!cpack_package_icon.empty())
+      {
+      std::ostringstream setfile_command;
+      setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
+      setfile_command << " -a C";
+      setfile_command << " \"" << temp_mount.str() << "\"";
+
+      if(!this->RunCommand(setfile_command))
+        {
+        cmCPackLogger(cmCPackLog::LOG_ERROR,
+          "Error assigning custom icon to temporary disk image."
+          << std::endl);
+
+        had_error = true;
+        }
       }
 
+    //finish by detaching the package
     std::ostringstream detach_command;
     detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
     detach_command << " detach";
@@ -520,6 +537,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
         "Error detaching temporary disk image."
         << std::endl);
 
+      had_error = true;
+      }
+
+    if(had_error)
+      {
       return 0;
       }
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f054a775aaaae2183d07b43a69a099d76613dda
commit 0f054a775aaaae2183d07b43a69a099d76613dda
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Sep 26 14:38:38 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 21:52:00 2015 +0100

    DragNDropGenerator now can run an apple script when making a package.
    
    While the DragNDropGenerator supports custom DS_Store and backgrounds, it is
    still very hard to automatically setup nice looking packages. The primary
    issue is that the DS_Store embeds the name of the volume in the path
    to backgrounds, which means that if a package embeds the version in its
    volume name a new DS_Store must generated for each release.
    
    Instead you now can use applescript to setup your DS_Store.

diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index eff302c..59b29a2 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -331,6 +331,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     this->GetOption("CPACK_DMG_LANGUAGES")
       ? this->GetOption("CPACK_DMG_LANGUAGES") : "";
 
+  const std::string cpack_dmg_ds_store_setup_script =
+    this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
+    ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT") : "";
+
   // only put license on dmg if is user provided
   if(!cpack_license_file.empty() &&
       cpack_license_file.find("CPack.GenericLicense.txt") != std::string::npos)
@@ -376,11 +380,38 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
       return 0;
       }
     }
+  // Optionally add a custom background image ...
+  // Make sure the background file type is the same as the custom image
+  // and that the file is hidden so it doesn't show up.
+  if(!cpack_dmg_background_image.empty())
+    {
+    const std::string extension =
+        cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
+    std::ostringstream package_background_source;
+    package_background_source << cpack_dmg_background_image;
+
+    std::ostringstream package_background_destination;
+    package_background_destination << staging.str()
+                                   << "/.background/background" << extension;
+
+    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;
+      }
+    }
 
-  // Optionally add a custom .DS_Store file
-  // (e.g. for setting background/layout) ...
+  // Figure out if we have a .DS_Store to install or if we need to run
+  // an apple-script to generate a .DS_Store
   if(!cpack_dmg_ds_store.empty())
     {
+    // Optionally add a custom .DS_Store file
+    // (e.g. for setting background/layout) ...
     std::ostringstream package_settings_source;
     package_settings_source << cpack_dmg_ds_store;
 
@@ -397,27 +428,20 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
       return 0;
       }
     }
-
-  // Optionally add a custom background image ...
-  // Make sure the background file type is the same as the custom image
-  // and that the file is hidden so it doesn't show up.
-  if(!cpack_dmg_background_image.empty())
+  else if(!cpack_dmg_ds_store_setup_script.empty())
     {
-    const std::string extension =
-        cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
-    std::ostringstream package_background_source;
-    package_background_source << cpack_dmg_background_image;
-
-    std::ostringstream package_background_destination;
-    package_background_destination << staging.str()
-                                   << "/.background/background" << extension;
-
-    if(!this->CopyFile(package_background_source,
-        package_background_destination))
+    //If you don't have a custom .DS_Store file
+    //we can execute a custom apple script to generate the .DS_Store for
+    //the application
+    std::ostringstream setup_script_command;
+    setup_script_command << "osascript"
+                           << " \"" << cpack_dmg_ds_store_setup_script << "\"";
+    std::string error;
+    if(!this->RunCommand(setup_script_command, &error))
       {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error copying disk volume background image.  "
-                    "Check the value of CPACK_DMG_BACKGROUND_IMAGE."
+        "Error executing custom script on disk image." << std::endl
+        << error
         << std::endl);
 
       return 0;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d6d873fbd7af072e10362e2a4767185117068c5b
commit d6d873fbd7af072e10362e2a4767185117068c5b
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Thu Sep 18 13:59:57 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 16:21:53 2015 +0100

    DragNDropGenerator now places the background image file in a hidden folder.
    
    by using a hidden folder we avoid the need to mark the file as hidden from
    finder, and it makes it easier for future work to refer to the background
    image file.

diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 3d1e4ea..eff302c 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -400,6 +400,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
   // Optionally add a custom background image ...
   // Make sure the background file type is the same as the custom image
+  // and that the file is hidden so it doesn't show up.
   if(!cpack_dmg_background_image.empty())
     {
     const std::string extension =
@@ -409,7 +410,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
     std::ostringstream package_background_destination;
     package_background_destination << staging.str()
-                                   << "/background" << extension;
+                                   << "/.background/background" << extension;
 
     if(!this->CopyFile(package_background_source,
         package_background_destination))
@@ -421,21 +422,6 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
       return 0;
       }
-
-    std::ostringstream 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 ...

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c43b4f8fdc9a2f1072509ed4eaa7d4cc1a6cf234
commit c43b4f8fdc9a2f1072509ed4eaa7d4cc1a6cf234
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Thu Sep 18 13:59:40 2014 -0400
Commit:     Adam Strzelecki <ono at java.pl>
CommitDate: Mon Nov 9 16:21:53 2015 +0100

    DragNDropGenerator background image now uses source file extension.
    
    Instead of blindly copying the CPACK_DMG_BACKGROUND_IMAGE file to
    background.png, we instead use the same file extension as the source image.
    This is needed for proper support of multi resolution tif backgrounds.

diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 208a64c..3d1e4ea 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -399,13 +399,17 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     }
 
   // Optionally add a custom background image ...
+  // Make sure the background file type is the same as the custom image
   if(!cpack_dmg_background_image.empty())
     {
+    const std::string extension =
+        cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
     std::ostringstream package_background_source;
     package_background_source << cpack_dmg_background_image;
 
     std::ostringstream package_background_destination;
-    package_background_destination << staging.str() << "/background.png";
+    package_background_destination << staging.str()
+                                   << "/background" << extension;
 
     if(!this->CopyFile(package_background_source,
         package_background_destination))

-----------------------------------------------------------------------

Summary of changes:
 CMakeCPackOptions.cmake.in                       |    7 +
 Help/release/dev/better-looking-mac-packages.rst |    8 +
 Modules/CPackDMG.cmake                           |   20 +-
 Packaging/CMakeDMGBackground.tif                 |  Bin 0 -> 95690 bytes
 Packaging/CMakeDMGSetup.scpt                     |   42 ++++
 Source/CPack/cmCPackDragNDropGenerator.cxx       |  240 ++++++++++++++++------
 6 files changed, 244 insertions(+), 73 deletions(-)
 create mode 100644 Help/release/dev/better-looking-mac-packages.rst
 create mode 100644 Packaging/CMakeDMGBackground.tif
 create mode 100644 Packaging/CMakeDMGSetup.scpt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list