Created
May 14, 2014 13:26
-
-
Save koenbok/f044ac3ea8a3ec756a2c to your computer and use it in GitHub Desktop.
Mac Desktop Code Sign Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import shutil | |
import subprocess | |
if len(sys.argv) < 3: | |
sys.exit("Usage: python sign.py <identity> <myApp.app>") | |
SCRIPT, IDENTITY, APP_PATH = sys.argv | |
def run(command): | |
return subprocess.check_output(command, shell=True) | |
def listIdentities(): | |
run("certtool y | grep Developer\ ID") | |
run("security find-identity") | |
def sign(path): | |
run("codesign --verbose --force --sign '%s' '%s'" % (IDENTITY, path)) | |
def signDir(path): | |
if not os.path.exists(path): | |
return | |
for name in os.listdir(path): | |
sign(os.path.join(path, name)) | |
def signCheck(path): | |
run("codesign --verify --verbose=100 '%s'" % (path)) | |
run("spctl -vvvvvv --assess --type execute '%s'" % (path)) | |
applicationPath = os.path.abspath(APP_PATH) | |
signedApplicationPath = applicationPath | |
# Extract specific paths from the application | |
signedApplicationFrameworksPath = os.path.join(signedApplicationPath, "Contents", "Frameworks") | |
signedApplicationLibrariesPath = os.path.join(signedApplicationPath, "Contents", "Libraries") | |
# Sign all the frameworks | |
signDir(signedApplicationFrameworksPath) | |
# Sign all the libraries | |
signDir(signedApplicationLibrariesPath) | |
# Sign the application bundle | |
sign(signedApplicationPath) | |
signCheck(signedApplicationPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment