summaryrefslogtreecommitdiffstats
path: root/TOOLS/osxbundle.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:13:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:13:14 +0000
commit5a3b54c78ce63d899f76dbb3db72e4894b40bd53 (patch)
tree50693d13eeefc4d683bdf5417f0861b0ef274a0c /TOOLS/osxbundle.py
parentAdding debian version 0.37.0-1. (diff)
downloadmpv-5a3b54c78ce63d899f76dbb3db72e4894b40bd53.tar.xz
mpv-5a3b54c78ce63d899f76dbb3db72e4894b40bd53.zip
Merging upstream version 0.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'TOOLS/osxbundle.py')
-rwxr-xr-xTOOLS/osxbundle.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py
index 98699e4..0e156a0 100755
--- a/TOOLS/osxbundle.py
+++ b/TOOLS/osxbundle.py
@@ -1,13 +1,11 @@
#!/usr/bin/env python3
import os
import shutil
-import sys
import fileinput
+import dylib_unhell
+import subprocess
from optparse import OptionParser
-def sh(command):
- return os.popen(command).read().strip()
-
def bundle_path(binary_name):
return "%s.app" % binary_name
@@ -24,11 +22,11 @@ def target_binary(binary_name):
return os.path.join(target_directory(binary_name),
os.path.basename(binary_name))
-def copy_bundle(binary_name):
+def copy_bundle(binary_name, src_path):
if os.path.isdir(bundle_path(binary_name)):
shutil.rmtree(bundle_path(binary_name))
shutil.copytree(
- os.path.join('TOOLS', 'osxbundle', bundle_name(binary_name)),
+ os.path.join(src_path, 'TOOLS', 'osxbundle', bundle_name(binary_name)),
bundle_path(binary_name))
def copy_binary(binary_name):
@@ -39,20 +37,24 @@ def apply_plist_template(plist_file, version):
print(line.rstrip().replace('${VERSION}', version))
def sign_bundle(binary_name):
- sh('codesign --force --deep -s - ' + bundle_path(binary_name))
-
-def bundle_version():
- if os.path.exists('VERSION'):
- x = open('VERSION')
+ sign_directories = ['Contents/Frameworks', 'Contents/MacOS']
+ for dir in sign_directories:
+ resolved_dir = os.path.join(bundle_path(binary_name), dir)
+ for root, _dirs, files in os.walk(resolved_dir):
+ for f in files:
+ subprocess.run(['codesign', '--force', '-s', '-', os.path.join(root, f)])
+ subprocess.run(['codesign', '--force', '-s', '-', bundle_path(binary_name)])
+
+def bundle_version(src_path):
+ version = 'UNKNOWN'
+ version_path = os.path.join(src_path, 'VERSION')
+ if os.path.exists(version_path):
+ x = open(version_path)
version = x.read()
x.close()
- else:
- version = sh("./version.sh").strip()
return version
def main():
- version = bundle_version().rstrip()
-
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
parser.add_option("-s", "--skip-deps", action="store_false", dest="deps",
@@ -61,14 +63,17 @@ def main():
(options, args) = parser.parse_args()
- if len(args) != 1:
+ if len(args) < 1 or len(args) > 2:
parser.error("incorrect number of arguments")
else:
binary_name = args[0]
+ src_path = args[1] if len(args) > 1 else "."
+
+ version = bundle_version(src_path).rstrip()
- print("Creating Mac OS X application bundle (version: %s)..." % version)
+ print("Creating macOS application bundle (version: %s)..." % version)
print("> copying bundle skeleton")
- copy_bundle(binary_name)
+ copy_bundle(binary_name, src_path)
print("> copying binary")
copy_binary(binary_name)
print("> generating Info.plist")
@@ -76,7 +81,7 @@ def main():
if options.deps:
print("> bundling dependencies")
- print(sh(" ".join(["TOOLS/dylib-unhell.py", target_binary(binary_name)])))
+ dylib_unhell.process(target_binary(binary_name))
print("> signing bundle with ad-hoc pseudo identity")
sign_bundle(binary_name)