Changeset View
Changeset View
Standalone View
Standalone View
contrib/macdeploy/macdeployqtplus
#!/usr/bin/env python | #!/usr/bin/env python3 | ||||
from __future__ import division, print_function, unicode_literals | |||||
# | # | ||||
# Copyright (C) 2011 Patrick "p2k" Schneider <me@p2k-network.org> | # Copyright (C) 2011 Patrick "p2k" Schneider <me@p2k-network.org> | ||||
# | # | ||||
# This program is free software: you can redistribute it and/or modify | # This program is free software: you can redistribute it and/or modify | ||||
# it under the terms of the GNU General Public License as published by | # it under the terms of the GNU General Public License as published by | ||||
# the Free Software Foundation, either version 3 of the License, or | # the Free Software Foundation, either version 3 of the License, or | ||||
# (at your option) any later version. | # (at your option) any later version. | ||||
# | # | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | def usesFramework(self, name): | ||||
if framework.startswith(libNameDot): | if framework.startswith(libNameDot): | ||||
return True | return True | ||||
return False | return False | ||||
def getFrameworks(binaryPath, verbose): | def getFrameworks(binaryPath, verbose): | ||||
if verbose >= 3: | if verbose >= 3: | ||||
print("Inspecting with otool: " + binaryPath) | print("Inspecting with otool: " + binaryPath) | ||||
otoolbin=os.getenv("OTOOL", "otool") | otoolbin=os.getenv("OTOOL", "otool") | ||||
otool = subprocess.Popen([otoolbin, "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | otool = subprocess.Popen([otoolbin, "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | ||||
o_stdout, o_stderr = otool.communicate() | o_stdout, o_stderr = otool.communicate() | ||||
if otool.returncode != 0: | if otool.returncode != 0: | ||||
if verbose >= 1: | if verbose >= 1: | ||||
sys.stderr.write(o_stderr) | sys.stderr.write(o_stderr) | ||||
sys.stderr.flush() | sys.stderr.flush() | ||||
raise RuntimeError("otool failed with return code %d" % otool.returncode) | raise RuntimeError("otool failed with return code %d" % otool.returncode) | ||||
otoolLines = o_stdout.decode().split("\n") | otoolLines = o_stdout.split("\n") | ||||
otoolLines.pop(0) # First line is the inspected binary | otoolLines.pop(0) # First line is the inspected binary | ||||
if ".framework" in binaryPath or binaryPath.endswith(".dylib"): | if ".framework" in binaryPath or binaryPath.endswith(".dylib"): | ||||
otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency. | otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency. | ||||
libraries = [] | libraries = [] | ||||
for line in otoolLines: | for line in otoolLines: | ||||
line = line.replace("@loader_path", os.path.dirname(binaryPath)) | line = line.replace("@loader_path", os.path.dirname(binaryPath)) | ||||
info = FrameworkInfo.fromOtoolLibraryLine(line.strip()) | info = FrameworkInfo.fromOtoolLibraryLine(line.strip()) | ||||
▲ Show 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | elif config.sign: | ||||
if verbose >= 1: | if verbose >= 1: | ||||
print("Code-signing app bundle %s"%(target,)) | print("Code-signing app bundle %s"%(target,)) | ||||
subprocess.check_call("codesign --force %s %s"%(os.environ['CODESIGNARGS'], target), shell=True) | subprocess.check_call("codesign --force %s %s"%(os.environ['CODESIGNARGS'], target), shell=True) | ||||
# ------------------------------------------------ | # ------------------------------------------------ | ||||
if config.dmg is not None: | if config.dmg is not None: | ||||
#Patch in check_output for Python 2.6 | |||||
if "check_output" not in dir( subprocess ): | |||||
def f(*popenargs, **kwargs): | |||||
if 'stdout' in kwargs: | |||||
raise ValueError('stdout argument not allowed, it will be overridden.') | |||||
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) | |||||
output, unused_err = process.communicate() | |||||
retcode = process.poll() | |||||
if retcode: | |||||
cmd = kwargs.get("args") | |||||
if cmd is None: | |||||
cmd = popenargs[0] | |||||
raise CalledProcessError(retcode, cmd) | |||||
return output | |||||
subprocess.check_output = f | |||||
def runHDIUtil(verb, image_basename, **kwargs): | def runHDIUtil(verb, image_basename, **kwargs): | ||||
hdiutil_args = ["hdiutil", verb, image_basename + ".dmg"] | hdiutil_args = ["hdiutil", verb, image_basename + ".dmg"] | ||||
if "capture_stdout" in kwargs: | if "capture_stdout" in kwargs: | ||||
del kwargs["capture_stdout"] | del kwargs["capture_stdout"] | ||||
run = subprocess.check_output | run = subprocess.check_output | ||||
else: | else: | ||||
if verbose < 2: | if verbose < 2: | ||||
hdiutil_args.append("-quiet") | hdiutil_args.append("-quiet") | ||||
elif verbose >= 3: | elif verbose >= 3: | ||||
hdiutil_args.append("-verbose") | hdiutil_args.append("-verbose") | ||||
run = subprocess.check_call | run = subprocess.check_call | ||||
for key, value in kwargs.items(): | for key, value in kwargs.items(): | ||||
hdiutil_args.append("-" + key) | hdiutil_args.append("-" + key) | ||||
if not value is True: | if not value is True: | ||||
hdiutil_args.append(str(value)) | hdiutil_args.append(str(value)) | ||||
return run(hdiutil_args) | return run(hdiutil_args, universal_newlines=True) | ||||
if verbose >= 2: | if verbose >= 2: | ||||
if fancy is None: | if fancy is None: | ||||
print("+ Creating .dmg disk image +") | print("+ Creating .dmg disk image +") | ||||
else: | else: | ||||
print("+ Preparing .dmg disk image +") | print("+ Preparing .dmg disk image +") | ||||
if config.dmg != "": | if config.dmg != "": | ||||
Show All 25 Lines | else: | ||||
if verbose >= 3: | if verbose >= 3: | ||||
print("Attaching temp image...") | print("Attaching temp image...") | ||||
try: | try: | ||||
output = runHDIUtil("attach", dmg_name + ".temp", readwrite=True, noverify=True, noautoopen=True, capture_stdout=True) | output = runHDIUtil("attach", dmg_name + ".temp", readwrite=True, noverify=True, noautoopen=True, capture_stdout=True) | ||||
except subprocess.CalledProcessError as e: | except subprocess.CalledProcessError as e: | ||||
sys.exit(e.returncode) | sys.exit(e.returncode) | ||||
m = re.search("/Volumes/(.+$)", output.decode()) | m = re.search("/Volumes/(.+$)", output) | ||||
disk_root = m.group(0) | disk_root = m.group(0) | ||||
disk_name = m.group(1) | disk_name = m.group(1) | ||||
if verbose >= 2: | if verbose >= 2: | ||||
print("+ Applying fancy settings +") | print("+ Applying fancy settings +") | ||||
if "background_picture" in fancy: | if "background_picture" in fancy: | ||||
bg_path = os.path.join(disk_root, ".background", os.path.basename(fancy["background_picture"])) | bg_path = os.path.join(disk_root, ".background", os.path.basename(fancy["background_picture"])) | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |