scripts: add ignore-codesign-paths feature

QtDesignStudio packages Qt into the dmg
which is already codesigned.

Change-Id: I8d0f0d6df1e8792e44ef93ab6f871e6eecad7183
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenssen
2023-03-01 11:08:22 +01:00
parent 3425b55352
commit cc4914ff83
2 changed files with 15 additions and 4 deletions

View File

@@ -228,16 +228,22 @@ def conditional_sign_recursive(path, filter):
if is_mac_platform():
os_walk(path, filter, lambda fp: codesign_executable(fp))
def codesign(app_path):
def is_filtered(path, ignore_paths):
for ignore_path in ignore_paths:
if path.startswith(ignore_path):
return True
return False
def codesign(app_path, filter_paths):
codesign = codesign_call()
if not codesign or not is_mac_platform():
return
# sign all executables in Resources
conditional_sign_recursive(os.path.join(app_path, 'Contents', 'Resources'),
lambda ff: os.access(ff, os.X_OK))
lambda ff: os.access(ff, os.X_OK) and not is_filtered(ff, filter_paths))
# sign all libraries in Imports
conditional_sign_recursive(os.path.join(app_path, 'Contents', 'Imports'),
lambda ff: ff.endswith('.dylib'))
lambda ff: ff.endswith('.dylib') and not is_filtered(ff, filter_paths))
# sign the whole bundle
entitlements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dist',

View File

@@ -19,6 +19,8 @@ def parse_arguments():
parser.add_argument('source_directory', help='directory with the Qt Creator sources')
parser.add_argument('binary_directory', help='directory that contains the Qt Creator.app')
parser.add_argument('--dmg-size', default='1500m', required=False)
parser.add_argument('--ignore-codesign-paths', default=None, required=False, help='A list of paths separated by "," relative from the binary_directory. ' +
'example ignore-codesign-paths for content that is already signed: "installed/Qt DesignStudio.app/Resources/qt6_design_studio_reduced_version"')
return parser.parse_args()
def main():
@@ -29,7 +31,10 @@ def main():
common.copytree(arguments.binary_directory, tempdir, symlinks=True, ignore=common.is_debug)
if common.is_mac_platform():
app_path = [app for app in os.listdir(tempdir) if app.endswith('.app')][0]
common.codesign(os.path.join(tempdir, app_path))
if arguments.ignore_codesign_paths:
ignore_codesign_paths = arguments.ignore_codesign_paths.split(',')
ignore_codesign_paths = [os.path.join(tempdir_base, path) for path in ignore_codesign_paths]
common.codesign(os.path.join(tempdir, app_path), ignore_codesign_paths)
os.symlink('/Applications', os.path.join(tempdir, 'Applications'))
shutil.copy(os.path.join(arguments.source_directory, 'LICENSE.GPL3-EXCEPT'), tempdir)
dmg_cmd = ['hdiutil', 'create', '-srcfolder', tempdir, '-volname', arguments.dmg_volumename,