[gtk-mac-bundler] Add code signing to bundler.
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-mac-bundler] Add code signing to bundler.
- Date: Sat, 8 Sep 2012 22:12:30 +0000 (UTC)
commit a58ff7529c0f0a8f139fa7d90d306e252e736ecf
Author: John Ralls <jralls ceridwen us>
Date: Sat Sep 8 14:53:47 2012 -0700
Add code signing to bundler.
bundler/bundler.py | 37 ++++++++++++++++++++++++++++++++-----
bundler/project.py | 7 ++++++-
2 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/bundler/bundler.py b/bundler/bundler.py
index 15ce54a..6366a89 100644
--- a/bundler/bundler.py
+++ b/bundler/bundler.py
@@ -448,6 +448,25 @@ class Bundler:
os.system("strip -ur " + path + " 2>/dev/null")
os.chmod(path, 0555)
+#
+# If you want to sign your application, set $APPLICATION_CERT with the
+# appropriate certificate name in your default Keychain. This function
+# will sign every binary in the bundle with the certificate and the
+# bundle's id string.
+#
+ def sign_binaries(self):
+ if not os.environ.has_key("APPLICATION_CERT"):
+ return
+ cert = os.getenv("APPLICATION_CERT")
+ paths = self.list_copied_binaries()
+ ident = self.project.get_bundle_id()
+ for path in paths:
+ cmdargs = ['codesign', '-s', cert, '-i', ident, path]
+ result = os.spawnvp(os.P_WAIT, 'codesign', cmdargs)
+
+ if result:
+ raise OSError, '"' + " ".join(cmdargs) + '" failed %d' % result
+
def copy_icon_themes(self):
all_icons = set()
@@ -555,11 +574,6 @@ class Bundler:
# Note: could move this to xml file...
self.copy_path(Path("${prefix}/lib/charset.alias"))
- # Launcher script, if necessary.
- launcher_script = self.project.get_launcher_script()
- if launcher_script:
- self.copy_path(launcher_script)
-
# Main binary
path = self.project.get_main_binary()
source = self.project.evaluate_path(path.source)
@@ -598,6 +612,19 @@ class Bundler:
#self.strip_debugging()
+ self.sign_binaries()
+
+ # Launcher script, if necessary.
+ launcher_script = self.project.get_launcher_script()
+ if launcher_script:
+ path = self.copy_path(launcher_script)
+ if os.environ.has_key("APPLICATION_CERT"):
+ cert = os.environ["APPLICATION_CERT"]
+ ident = self.project.get_bundle_id()
+ cmdargs = ['codesign', '-s', cert, '-i', ident, "-f", path]
+ result = os.spawnvp(os.P_WAIT, 'codesign', cmdargs)
+ if result:
+ raise OSError, '"'+ " ".join(cmdargs) + '" failed %d' % result
if self.meta.overwrite:
self.recursive_rm(final_path)
shutil.move(self.project.get_bundle_path(), final_path)
diff --git a/bundler/project.py b/bundler/project.py
index a88535d..c98b65a 100644
--- a/bundler/project.py
+++ b/bundler/project.py
@@ -243,7 +243,9 @@ class Project:
self.bundle_name = plist.CFBundleName
else:
self.bundle_name = plist.CFBundleExecutable
-
+
+ self.bundle_id = plist.CFBundleIdentifier
+
"""
Replace ${env:?}, ${prefix}, ${prefix:?}, ${project}, ${gtk}, ${gtkdir},
${gtkversion}, ${pkg:?:?}, ${bundle}, and ${name} variables.
@@ -293,6 +295,9 @@ class Project:
def get_bundle_name(self):
return self.bundle_name
+ def get_bundle_id(self):
+ return self.bundle_id
+
def get_prefix(self, name="default"):
meta = self.get_meta()
return meta.prefixes[name]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]