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  dd8d4374dd1f51c634b67ad629d7afe8a12fb18f (commit)
       via  bd3fbf36b4da6a160d13eac37732377a9b123c6f (commit)
      from  3155bf4537d145f0f06e679b16b0b6fca338fee6 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd8d4374dd1f51c634b67ad629d7afe8a12fb18f
commit dd8d4374dd1f51c634b67ad629d7afe8a12fb18f
Merge: 3155bf4 bd3fbf3
Author:     Clinton Stimpson <clin...@elemtech.com>
AuthorDate: Tue Oct 28 14:20:39 2014 -0400
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Tue Oct 28 14:20:39 2014 -0400

    Merge topic 'cpack-bundle-codesign' into next
    
    bd3fbf36 CPack: Add support for code signing of bundles on MacOS


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bd3fbf36b4da6a160d13eac37732377a9b123c6f
commit bd3fbf36b4da6a160d13eac37732377a9b123c6f
Author:     André Klitzing <aklitz...@gmail.com>
AuthorDate: Tue Oct 28 19:15:55 2014 +0100
Commit:     Clinton Stimpson <clin...@elemtech.com>
CommitDate: Tue Oct 28 12:20:05 2014 -0600

    CPack: Add support for code signing of bundles on MacOS

diff --git a/Modules/CPackBundle.cmake b/Modules/CPackBundle.cmake
index d8293c0..d26a0b3 100644
--- a/Modules/CPackBundle.cmake
+++ b/Modules/CPackBundle.cmake
@@ -33,6 +33,31 @@
 #  Path to a startup script. This is a path to an executable or script that
 #  will be run whenever an end-user double-clicks the generated bundle in the
 #  OSX Finder. Optional.
+#
+# .. variable:: CPACK_BUNDLE_APPLE_CERT_APP
+#
+#  The name of your Apple supplied code signing certificate for the 
application.
+#  The name usually takes the form "Developer ID Application: [Name]" or
+#  "3rd Party Mac Developer Application: [Name]". If this variable is not set
+#  the application will not be signed.
+#
+# .. variable:: CPACK_BUNDLE_APPLE_ENTITLEMENTS
+#
+#  The name of the plist file that contains your apple entitlements for 
sandboxing
+#  your application. This file is required for submission to the Mac App Store.
+#
+# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_FILES
+#
+#  A list of additional files that you wish to be signed. You do not need to
+#  list the main application folder, or the main executable. You should
+#  list any frameworks and plugins that are included in your app bundle.
+#
+# .. variable:: CPACK_COMMAND_CODESIGN
+#
+#  Path to the codesign(1) command used to sign applications with an
+#  Apple cert. This variable can be used to override the automatically
+#  detected command (or specify its location if the auto-detection fails
+#  to find it.)
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx 
b/Source/CPack/cmCPackBundleGenerator.cxx
index 6c994f1..fbd1d21 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -39,6 +39,21 @@ int cmCPackBundleGenerator::InitializeInternal()
     return 0;
     }
 
+  if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP"))
+    {
+    const std::string codesign_path = cmSystemTools::FindProgram("codesign",
+       std::vector<std::string>(), false);
+
+    if(codesign_path.empty())
+      {
+      cmCPackLogger(cmCPackLog::LOG_ERROR,
+        "Cannot locate codesign command"
+        << std::endl);
+      return 0;
+      }
+    this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
+    }
+
   return this->Superclass::InitializeInternal();
 }
 
@@ -53,7 +68,7 @@ const char* 
cmCPackBundleGenerator::GetPackagingInstallPrefix()
 }
 
 //----------------------------------------------------------------------
-int cmCPackBundleGenerator::PackageFiles()
+int cmCPackBundleGenerator::ConstructBundle()
 {
 
   // Get required arguments ...
@@ -165,6 +180,22 @@ int cmCPackBundleGenerator::PackageFiles()
     cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
     }
 
+  return 1;
+}
+
+//----------------------------------------------------------------------
+int cmCPackBundleGenerator::PackageFiles()
+{
+  if(!this->ConstructBundle())
+    {
+    return 0;
+    }
+
+  if(!this->SignBundle(toplevel))
+    {
+    return 0;
+    }
+
   return this->CreateDMG(toplevel, packageFileNames[0]);
 }
 
@@ -172,3 +203,96 @@ bool 
cmCPackBundleGenerator::SupportsComponentInstallation() const
 {
   return false;
 }
+
+
+int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
+{
+  const std::string cpack_apple_cert_app =
+    this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
+    ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : "";
+
+  // codesign the application.
+  if(!cpack_apple_cert_app.empty())
+    {
+    std::string bundle_path;
+    bundle_path = src_dir + "/";
+    bundle_path += this->GetOption("CPACK_BUNDLE_NAME");
+    bundle_path += ".app";
+
+    // A list of additional files to sign, ie. frameworks and plugins.
+    const std::string sign_files =
+      this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
+      ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : "";
+
+    std::vector<std::string> relFiles;
+    cmSystemTools::ExpandListArgument(sign_files, relFiles);
+
+    // sign the files supplied by the user, ie. frameworks.
+    for(std::vector<std::string>::iterator it = relFiles.begin();
+      it != relFiles.end(); ++it)
+      {
+      cmOStringStream temp_sign_file_cmd;
+      temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+      temp_sign_file_cmd << " --deep -f -s \"" << cpack_apple_cert_app;
+      temp_sign_file_cmd << "\" -i ";
+      temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID");
+      temp_sign_file_cmd << " \"";
+      temp_sign_file_cmd << bundle_path;
+      temp_sign_file_cmd << it->c_str() << "\"";
+
+      if(!this->RunCommand(temp_sign_file_cmd))
+        {
+        cmCPackLogger(cmCPackLog::LOG_ERROR,
+          "Error signing file:"
+          << bundle_path << it->c_str() << std::endl);
+
+        return 0;
+        }
+      }
+
+    // sign main binary
+    cmOStringStream temp_sign_binary_cmd;
+    temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+    temp_sign_binary_cmd << " --deep -f -s \"" << cpack_apple_cert_app;
+    temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
+
+    if(!this->RunCommand(temp_sign_binary_cmd))
+      {
+      cmCPackLogger(cmCPackLog::LOG_ERROR,
+        "Error signing the application binary."
+        << std::endl);
+
+      return 0;
+      }
+
+    // sign app bundle
+    cmOStringStream temp_codesign_cmd;
+    temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+    temp_codesign_cmd << " --deep -f -s \"" << cpack_apple_cert_app << "\"";
+    if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"))
+      {
+      temp_codesign_cmd << " --entitlements ";
+      temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
+      }
+    temp_codesign_cmd << " \"" << bundle_path << "\"";
+
+    if(!this->RunCommand(temp_codesign_cmd))
+      {
+      cmCPackLogger(cmCPackLog::LOG_ERROR,
+        "Error signing the application package."
+        << std::endl);
+
+      return 0;
+      }
+
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+      "- Application has been codesigned"
+      << std::endl);
+    cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+       (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
+         ? "with entitlement sandboxing" : "without entitlement sandboxing")
+       << std::endl);
+  }
+
+  return 1;
+}
diff --git a/Source/CPack/cmCPackBundleGenerator.h 
b/Source/CPack/cmCPackBundleGenerator.h
index ed0187d..9cb2f0a 100644
--- a/Source/CPack/cmCPackBundleGenerator.h
+++ b/Source/CPack/cmCPackBundleGenerator.h
@@ -31,6 +31,8 @@ public:
 protected:
   virtual int InitializeInternal();
   virtual const char* GetPackagingInstallPrefix();
+  int ConstructBundle();
+  int SignBundle(const std::string& src_dir);
   int PackageFiles();
   bool SupportsComponentInstallation() const;
 

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

Summary of changes:
 Modules/CPackBundle.cmake               |   25 ++++++
 Source/CPack/cmCPackBundleGenerator.cxx |  126 ++++++++++++++++++++++++++++++-
 Source/CPack/cmCPackBundleGenerator.h   |    2 +
 3 files changed, 152 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to