mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
43 lines
1.6 KiB
Python
Executable File
43 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os, sys, subprocess
|
|
|
|
def log_message(message):
|
|
sys.stderr.write(message + "\n")
|
|
|
|
def sanitize(argument):
|
|
return ('"' + argument + '"' if ' ' in argument else argument)
|
|
|
|
def codesign_service(identity, path, entitlements_path=None):
|
|
command = ["codesign", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path])
|
|
log_message(" ".join(map(sanitize, command)))
|
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE)
|
|
process.communicate()
|
|
if process.returncode != 0:
|
|
log_message("Error: Failed to codesign %s" % (path))
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 3:
|
|
log_message("Usage:\n\t%s <code-signing-identity> <xpc-services-directory>" % (sys.argv[0]))
|
|
log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices" % (sys.argv[0]))
|
|
sys.exit(1)
|
|
|
|
signing_identity = sys.argv[1]
|
|
xpc_services = sys.argv[2]
|
|
|
|
if os.path.islink(xpc_services) or not os.path.isdir(xpc_services):
|
|
log_message("Error: %s is not a directory" % (xpc_services))
|
|
sys.exit(1)
|
|
|
|
for filename in os.listdir(xpc_services):
|
|
if filename.startswith(".") or not os.path.splitext(filename)[1] == ".xpc":
|
|
continue
|
|
|
|
service_path = os.path.join(xpc_services, filename)
|
|
service_name = os.path.splitext(filename)[0]
|
|
entitlements_path = os.path.join(xpc_services, service_name + ".entitlements")
|
|
|
|
codesign_service(signing_identity, service_path, None if not os.path.exists(entitlements_path) else entitlements_path)
|