From 7e2fee4899d9f351cfc9eb6f58d7ec0bd3152138 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 3 Jun 2024 19:13:40 +0100 Subject: [PATCH] JAL-4421 Also add DMG filename to python script. Necessitates DS_Store for x64 and aarch64 versions, with changes in build.gradle and install4j10_template.install4j. Ensure all x64 references are x64 and not the (more correct) x86 -- java uses x64. --- build.gradle | 51 ++++++++++++-- utils/install4j/install4j10_template.install4j | 40 ++++++----- utils/macos_dmg/jalview_customise_dsstore.py | 85 ++++++++++++++++-------- 3 files changed, 123 insertions(+), 53 deletions(-) diff --git a/build.gradle b/build.gradle index 044242c..f8a6a20 100644 --- a/build.gradle +++ b/build.gradle @@ -247,7 +247,8 @@ ext { install4jPngIconFile = string("${install4j_images_dir}/${install4j_png_icon_file}") install4jBackground = string("${install4j_images_dir}/${install4j_background}") install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}" - install4jDMGFixedDSStore = "${install4jBuildDir}/${install4j_dmg_ds_store}" + install4jDMGFixedDSStoreX64 = "build/macos_dmg/${install4j_dmg_ds_store}-x64" + install4jDMGFixedDSStoreAarch64 = "build/macos_dmg/${install4j_dmg_ds_store}-aarch64" install4jCheckSums = true applicationName = "${jalview_name}" @@ -438,7 +439,7 @@ ext { .replaceAll("_+", "_") // collapse __ .replaceAll("_*-_*", "-") // collapse _-_ .toLowerCase() - install4jmacOSArchiveX86Name = "${install4jmacOSArchiveName} (Intel)" + install4jmacOSArchiveX64Name = "${install4jmacOSArchiveName} (Intel)" install4jmacOSArchiveAarch64Name = "${install4jmacOSArchiveName} (Apple Silicon)" getdownWrapperLink = install4jUnixApplicationFolder // e.g. "jalview_local" @@ -537,6 +538,9 @@ ext { if (install4jHomeDir.startsWith("~/")) { install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1) } + install4jmacOSArchiveX64DMGFilename = "${install4jApplicationFolder}-${JALVIEW_VERSION}-macos-x64-java_${JAVA_INTEGER_VERSION}" + install4jmacOSArchiveAarch64DMGFilename = "${install4jApplicationFolder}-${JALVIEW_VERSION}-macos-aarch64-java_${JAVA_INTEGER_VERSION}" + resourceBuildDir = string("${buildDir}/resources") resourcesBuildDir = string("${resourceBuildDir}/resources_build") @@ -2840,13 +2844,43 @@ python { pip 'ds_store:1.3.1' } -task install4jCustomiseDS_Store(type: PythonTask) { +task install4jCustomiseDS_StoreX64(type: PythonTask) { inputs.file(install4jDMGDSStore) inputs.file(install4jDMGDSStoreJSON) - outputs.file(install4jDMGFixedDSStore) - command = [ jalview_customise_ds_store, '--input', install4jDMGDSStore, '--output', install4jDMGFixedDSStore, '--volumename', install4jmacOSArchiveName, '--background', install4j_dmg_background_filename, '--config', install4jDMGDSStoreJSON ] + outputs.file(install4jDMGFixedDSStoreX64) + def command_args = [ jalview_customise_ds_store, '--input', install4jDMGDSStore, '--output', install4jDMGFixedDSStoreX64, '--volumename', install4jmacOSArchiveX64Name, '--backgroundfile', install4j_dmg_background_filename, '--dmg', install4jmacOSArchiveX64DMGFilename + ".dmg" ] + if (file(install4jDMGDSStoreJSON).exists()) { + command_args += [ '--config', install4jDMGDSStoreJSON ] + } + command = command_args + doFirst { + println("Running command '${command_args.join(' ')}'") + } } +task install4jCustomiseDS_StoreAarch64(type: PythonTask) { + inputs.file(install4jDMGDSStore) + inputs.file(install4jDMGDSStoreJSON) + outputs.file(install4jDMGFixedDSStoreAarch64) + def command_args = [ jalview_customise_ds_store, '--input', install4jDMGDSStore, '--output', install4jDMGFixedDSStoreAarch64, '--volumename', install4jmacOSArchiveAarch64Name, '--backgroundfile', install4j_dmg_background_filename, '--dmg', install4jmacOSArchiveAarch64DMGFilename + ".dmg" ] + if (file(install4jDMGDSStoreJSON).exists()) { + command_args += [ '--config', install4jDMGDSStoreJSON ] + } + command = command_args + doFirst { + def print_args = [] + for (int i = 0; i < command_args.size(); i++) { + def arg = command_args[i] + print_args += (i > 0 && !arg.startsWith("-")) ? "\"${arg}\"" : arg + } + println("Running command '${print_args.join(' ')}'") + } +} + +task install4jCustomiseDS_Store { + dependsOn install4jCustomiseDS_StoreX64 + dependsOn install4jCustomiseDS_StoreAarch64 +} task install4jDMGProcesses { dependsOn install4jDMGBackgroundImageProcess @@ -2898,7 +2932,8 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'BUNDLE_ID': install4jBundleId, 'INTERNAL_ID': install4jInternalId, 'WINDOWS_APPLICATION_ID': install4jWinApplicationId, - 'MACOS_DMG_DS_STORE': install4jDMGFixedDSStore, + 'MACOS_X64_DMG_DS_STORE': install4jDMGFixedDSStoreX64, + 'MACOS_AARCH64_DMG_DS_STORE': install4jDMGFixedDSStoreAarch64, 'MACOS_DMG_BG_IMAGE': "${install4jDMGBackgroundImageBuildDir}/${install4jDMGBackgroundImageFile}", 'MACOS_DMG_BG_FILENAME': install4j_dmg_background_filename, 'WRAPPER_LINK': getdownWrapperLink, @@ -2906,7 +2941,7 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script, 'BATCH_WRAPPER_SCRIPT': getdown_batch_wrapper_script, 'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir, - 'MACOSARCHIVE_X86_NAME': install4jmacOSArchiveX86Name, + 'MACOSARCHIVE_X64_NAME': install4jmacOSArchiveX64Name, 'MACOSARCHIVE_AARCH64_NAME': install4jmacOSArchiveAarch64Name, 'INSTALL4J_UTILS_DIR': install4j_utils_dir, 'GETDOWN_CHANNEL_DIR': getdownChannelDir, @@ -2926,6 +2961,8 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'WINDOWS_ICONS_FILE': install4jWindowsIconsFile, 'PNG_ICON_FILE': install4jPngIconFile, 'BACKGROUND': install4jBackground, + 'MACOSARCHIVE_X64_DMG_FILENAME': install4jmacOSArchiveX64DMGFilename, + 'MACOSARCHIVE_AARCH64_DMG_FILENAME': install4jmacOSArchiveAarch64DMGFilename, ] def varNameMap = [ diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 39c0b48..b118189 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -23,27 +23,29 @@ - + - - + + - + - - + + + + - + @@ -66,6 +68,8 @@ + + @@ -96,7 +100,7 @@ - + @@ -117,7 +121,7 @@ - + @@ -1495,18 +1499,18 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + - + - + - + @@ -1514,7 +1518,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + @@ -1523,7 +1527,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + @@ -1544,7 +1548,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + @@ -1570,7 +1574,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + @@ -1581,7 +1585,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + diff --git a/utils/macos_dmg/jalview_customise_dsstore.py b/utils/macos_dmg/jalview_customise_dsstore.py index 8434b69..5360c49 100755 --- a/utils/macos_dmg/jalview_customise_dsstore.py +++ b/utils/macos_dmg/jalview_customise_dsstore.py @@ -3,8 +3,8 @@ # Copyright (c) 2013-2017 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from ds_store import DSStore -from pprint import pprint +import ds_store +import pprint import mac_alias import argparse import json @@ -16,9 +16,11 @@ parser = argparse.ArgumentParser( parser.add_argument("-i", "--input", help="The existing styled DS_Store file", dest="input") parser.add_argument("-o", "--output", help="The output DS_Store file", dest="output") parser.add_argument("-v", "--volumename", help="The name of the output DS_Store volume", dest="volumename") -parser.add_argument("-b", "--background", help="The background image filename to use", dest="background") +parser.add_argument("-b", "--backgroundfile", help="The background image filename to use", dest="backgroundfile", default="background.png") +parser.add_argument("-d", "--backgrounddir", help="The background image hidden dirname to use", dest="backgrounddir", default=".background") parser.add_argument("-c", "--config", help="YAML configuration for window and icon sizes and positions", dest="config") -parser.add_argument("-d", "--dump", help="Display contents of the input DS_Store to stdout", action="store_true", dest="dump") +parser.add_argument("-m", "--dmg", help="The filename of the DMG file", dest="dmg", default="Jalview_macos.dmg") +parser.add_argument("--dump", help="Display contents of the input DS_Store to stdout", action="store_true", dest="dump") parser.add_argument("-q", "--quiet", help="Don't print messages to stdout", action="store_true", dest="quiet") parser.add_argument("-f", "--filenames", help="List of comma-separated filenames to show information for --dump", dest="filenames", default="") @@ -30,30 +32,34 @@ def myprint(string): def mypprint(string): if (not args.quiet): - pprint(string) + pprint.pprint(string) if (args.dump and not args.input): exit("When --dump used, an --input must be given") if (args.dump): - with DSStore.open(args.input, 'r+') as d: + with ds_store.DSStore.open(args.input, 'r+') as d: + print(f"d=") + print(pprint.pformat(d['.']['bwsp'], width=1)) + for key in ["bwsp", "icvp","Iloc"]: try: - myprint(f"d['.']['{key}']=") - mypprint(str(d['.'][key])) + print(f"d['.']['{key}']=") + pprint.pprint(str(d['.'][key]), width=1) except: - myprint(f"No info for d['.']['{key}']") + print(f"No info for d['.']['{key}']") - alias = mac_alias.Alias.from_bytes( d['.']['icvp']['backgroundImageAlias'] ) - myprint("backgroundImageAlias=") - mypprint(alias) + a = mac_alias.Alias.from_bytes( d['.']['icvp']['backgroundImageAlias'] ) + print("backgroundImageAlias:") + print("alias.volume="+pprint.pformat(a.volume)) + print("alias.target="+pprint.pformat(a.target)) for data in d: try: data = str(data) - mypprint(f"d['{data}']=",d[data]) + pprint.pprint(f"d['{data}']="+d[data], width=1) except: - myprint(f"No info for d['{data}']") + print(f"No info for d['{data}']") # for filename in args.filenames.split(","): # if (filename): # for f in d.find(filename): @@ -71,16 +77,18 @@ if (not args.output): if (not args.volumename): exit("Provide a volume name with --volumename NAME") -if (not args.background): - exit("Provide a background image filename (just the file, no path) with --background FILENAME") +if (not args.backgroundfile): + exit("Provide a background image filename (just the file, no path) with --backgroundfile FILENAME") package_name_ns = args.volumename configfilename = args.config -configfile = open(configfilename, 'r') +config = None +if (configfilename): + configfile = open(configfilename, 'r') + config = json.load(configfile) -config = json.load(configfile) -inputds = DSStore.open(args.input) -outputds = DSStore.open(args.output, 'w+') +inputds = ds_store.DSStore.open(args.input) +outputds = ds_store.DSStore.open(args.output, 'w+') bwsp = {} @@ -93,13 +101,34 @@ outputds['.']['bwsp'] = bwsp icvp = {} +#alias = mac_alias.Alias.from_bytes(inputds['.']['icvp']['backgroundImageAlias']) +#alias.volume.name = args.volumename +#alias.volume.posix_path = '/Volumes/' + args.volumename +#alias.volume.disk_image_alias.target.filename = args.volumename + '.dmg' +#alias.volume.disk_image_alias.target.carbon_path = 'Macintosh HD:Users:\x00Jalview:\x00' + args.volumename + ':\x00' + args.volumename + '.dmg' +#alias.volume.disk_image_alias.target.posix_path = '/Users/Jalview/' + args.volumename + '.dmg' +#alias.target.carbon_path = args.volumename + ':' + args.backgrounddir + ':\x00' + args.backgroundfile +#alias.target.posix_path = '/Volumes/' + args.volumename + '/' + args.backgrounddir +#alias.target.filename = args.backgroundfile + + alias = mac_alias.Alias.from_bytes(inputds['.']['icvp']['backgroundImageAlias']) + alias.volume.name = args.volumename -alias.volume.posix_path = '/Volumes/' + args.volumename -alias.volume.disk_image_alias.target.filename = args.volumename + '.dmg' -alias.volume.disk_image_alias.target.carbon_path = 'Macintosh HD:Users:\x00Jalview:\x00' + args.volumename + ':\x00' + args.volumename + '.dmg' -alias.volume.disk_image_alias.target.posix_path = '/Users/Jalview/' + args.volumename + '.dmg' -alias.target.carbon_path = args.volumename + ':.background:\x00' + args.background +alias.volume.posix_path = "/Volumes/" + args.volumename + +alias.volume.disk_image_alias.volume.name = "Macintosh HD" +alias.volume.disk_image_alias.volume.posix_path = "/" + +alias.volume.disk_image_alias.target.filename = args.dmg +alias.volume.disk_image_alias.target.folder_name = "Downloads" +alias.volume.disk_image_alias.target.carbon_path = f'Macintosh HD:Users:Jalview:Downloads:{args.dmg}' +alias.volume.disk_image_alias.target.posix_path = f'/Users/jalview/Downloads/{args.dmg}' + +alias.target.filename = args.backgroundfile +alias.target.folder_name = args.backgrounddir +alias.target.carbon_path = f'{args.volumename}:{args.backgrounddir}:{args.backgroundfile}' +alias.target.posix_path = f'/{args.backgrounddir}/{args.backgroundfile}' icvp['backgroundImageAlias'] = alias.to_bytes() @@ -115,10 +144,10 @@ outputds['.']['icvp'] = icvp outputds['.']['vSrn'] = ('long', 1) -for fileinfo in config['files']: - outputds[fileinfo['name']]['Iloc'] = (fileinfo['xpos'], fileinfo['ypos']) +if config: + for fileinfo in config['files']: + outputds[fileinfo['name']]['Iloc'] = (fileinfo['xpos'], fileinfo['ypos']) outputds.flush() outputds.close() inputds.close() - -- 1.7.10.2