Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
macos: update packaging scripts
Ivan Yossi5d726e65f76c
diff --git a/packaging/macos/macos_notarize.py b/packaging/macos/macos_notarize.pynew file mode 100644index 0000000000..efe008dfb7--- /dev/null+++ b/packaging/macos/macos_notarize.py@@ -0,0 +1,154 @@+#!/usr/bin/env python3++import argparse+import pathlib+import subprocess+++class NotarizationHandler:++ def __init__(self+ , account: str=None+ , password: str=None+ , provider: str=None+ , store_credentials_key: str="KritaNotarizeAccount"+ ):+ self.account = account+ self.provider = provider+ self.password = password+ self.store_credentials_key = store_credentials_key+ self.__can_notarize = False+ self.__cmd_login = list()++ def can_notarize(self):+ return self.__can_notarize++ def notarize(self, target: pathlib.Path) -> bool:+ self.__check_notarization()++ if not self.__can_notarize:+ print("## ERROR: notarization credentials failed!")+ return False++ notarized_success = True+ target_intermediate = pathlib.Path(f'{target.stem}.zip')+ cmd = ['ditto', '-c', '-k', '--sequesterRsrc', '--keepParent', target, target_intermediate]+ subprocess.run(cmd)++ submit_id = 0+ cmd = ['xcrun', 'notarytool', 'submit', target_intermediate, '--wait']+ cmd.extend(self.__cmd_login)+ try:+ proc = subprocess.Popen(cmd, text=True, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)+ for line in proc.stdout:+ if 'id:' in line:+ submit_id = line.split(':')[-1].strip()++ if 'status: Invalid' in line:+ proc.returncode = 1;+ print(f'{line}', end='')++ proc.stdout.close()+ proc.wait()++ if proc.returncode != 0:+ raise subprocess.CalledProcessError(+ returncode=proc.returncode,+ cmd=cmd,+ output=proc.stdout,+ stderr=proc.stderr+ )+ # subprocess.run(cmd, check=True)+ except subprocess.CalledProcessError as ex:+ print(f"## ERROR: Notarization failed!\n{ex.stderr}")+ print(f'Fetching submit id {submit_id} log')+ cmd = ['xcrun', 'notarytool', 'log', submit_id]+ cmd.extend(self.__cmd_login)+ cmd_log = subprocess.run(cmd, capture_output=True, text=True).stdout+ print(cmd_log)++ notarized_success = False++ else:+ print('## Notarization success!')++ # clean up+ target_intermediate.unlink()+++ return notarized_success+++ def __check_notarization(self):+ cmd = ['xcrun', 'notarytool', 'history']+ if self.account and self.password and self.provider:+ login_ops = f"--apple-id {self.account} --password {self.password} --team-id {self.provider}".split()+ cmd.extend(login_ops)+ else:+ login_ops = ['--keychain-profile', self.store_credentials_key]+ cmd.extend(login_ops)++ print(f'## RUNNING: {' '.join(map(str,cmd))}')+ error_notarize = subprocess.run(cmd, capture_output=True, text=True).stderr++ if not error_notarize:+ self.__can_notarize = True+ self.__cmd_login.extend(login_ops)+ print("## Notarization checks complete, This build will be notarized")+ else:+ print("WARNING: Account information missing, Notarization will not be performed")++++def main_notarize():+ parser = argparse.ArgumentParser(prog='macos notarize krita.app',+ description='Utility that receives krita.app and sends for notarization',+ )+ parser.add_argument('target', type=pathlib.Path+ , help='signed krita.app for notarization')+ parser.add_argument('--apple-id', dest="appleid", help='apple id email')+ parser.add_argument('--password', dest='password', help='application password for appleid')+ parser.add_argument('--team-id', dest='teamid', help='apple developer team id')+ parser.add_argument('--stored-credentials', dest="cred_key"+ , help='stored credentials name as set when notarytool --store-credentials was run')+ args = parser.parse_args()++ target: pathlib.Path = args.target++ #### NOTARIZE BUNDLE+ # NOTE: it is enough to notarize the outer container+ notarizer = NotarizationHandler()++ if args.appleid:+ print("### WARNING: it is prefered to store-credentials to notarytool!")+ print(""" xcrun notarytool store-credentials+ --apple-id <apple-id> --password <app-pass> --team-id <team-id> <key>]""")+ print(" By default this script searches for 'KritaNotarizeAccount' key")+ notarizer.account = args.appleid++ if not (args.password and args.teamid):+ print('## ERROR: if apple-id is provided, --password and --team-id must be present')+ exit(1)++ if args.teamid:+ notarizer.provider = args.teamid+ if args.password:+ notarizer.password = args.password++ else:+ if args.cred_key:+ notarizer.account = args.cred_key+++ if notarizer.notarize(target):+ # Notarization success+ stapler = ['xcrun', 'stapler']+ subprocess.run(stapler + ['staple',target])+ subprocess.run(stapler + ['validate', '-v',target])++ return++++if __name__ == '__main__':+ main_notarize()diff --git a/packaging/macos/macos_signdmg.py b/packaging/macos/macos_signdmg.pynew file mode 100644index 0000000000..68e4689c38--- /dev/null+++ b/packaging/macos/macos_signdmg.py@@ -0,0 +1,375 @@+#!/usr/bin/env python3++import argparse+import pathlib+import shutil+import subprocess+import os+import stat+import concurrent.futures++from dataclasses import dataclass+++def main_signdmg():+ parser = argparse.ArgumentParser(prog='macos signdmg',+ description='Utility that receives krita.dmg and signs it')+ parser.add_argument('krita_dmg', metavar='krita.dmg', type=dmgpath,+ help='krita.dmg to sign')+ parser.add_argument('-s','--sign-identity',dest='sign_identity', metavar='<identity>',+ help='Apple certificate name to use for signing', required=True)+ parser.add_argument('--store', action='store_true', help="Sign app for store submission")+ parser.add_argument('--bundle-version',dest='bundle_version', metavar='<bversion>'+ , help="Store submission requires a unique bundle version (see appstoreconnect Testflight pane)")+ parser.add_argument('--entitlements-dir', dest='entitlements_dir', metavar='<entitlements-dir>'+ , help="Location of entitlements.plist, macStore-entitlements.plist, sandboxdev_sub-entitlements.plist and kis-thumbnail.entitlements"+ , type=pathlib.Path)+ args = parser.parse_args()++ if args.store:+ if not args.bundle_version:+ print("## ERROR: if --store is provided, bundle_version is mandatory")+ exit(1)+ print(f"## Signing {args.krita_dmg.stem} for store submission")++ krita_dmg: pathlib.Path = args.krita_dmg+ print(f'{krita_dmg} - {args.sign_identity}')++ #### Mount dmg to extract krita.app+ krita_app = pathlib.Path.cwd().joinpath('krita.app')+ if krita_app.exists():+ shutil.rmtree(krita_app)+ cmd = f"hdiutil attach {krita_dmg} -mountpoint {krita_dmg.stem}".split()+ subprocess.run(cmd)+ cmd = f"rsync -prult --delete {krita_dmg.stem + os.sep + krita_app.name + os.sep} krita.app".split()+ subprocess.run(cmd)+ subprocess.run(f"hdiutil detach {krita_dmg.stem}".split())++ #### FIX BUNDLE+ print("## Fixing bundle files permissions...")+ fix_bundle(krita_app, args.bundle_version, args.store)++ #### SIGN BUNDLE+ print("## Starting bundle signning...")+ # we do not check if the sign certificate identity is valid+ signer = Codesigner(args.sign_identity)+ if args.entitlements_dir:+ entitlements_path = args.entitlements_dir+ else:+ entitlements_path = pathlib.Path('bundle_root', '..', '..', 'krita', 'packaging', 'macos').resolve()++ sign_bundle(krita_app, signer, entitlements_path, args.store)++ #### VERIFY BUNDLE+ print("## Verifying all binary files signatures...")+ if not verify_bundle(krita_app):+ print('Codesign errors!')+ exit(1)++ print('## Could not detect codesign problems, app is ready for notarization')+ print(f"## {krita_app.name} signed")++ return++++@dataclass+class Entitlements:+ """Structure to hold all entitlement paths"""+ general: pathlib.Path | str = ""+ subprocess: pathlib.Path | str = ""+ plugins: pathlib.Path | str = ""++++class DeployCmd:+ # achmod appends the mod to file+ achmod = lambda target, mode: os.lchmod(target, stat.S_IMODE(os.stat(target).st_mode) | mode)+ # xchmod removes the bit flags from file+ xchmod = lambda target, mode: os.lchmod(target, stat.S_IMODE(os.stat(target).st_mode) & ~mode)++++class Codesigner:+ def __init__(self, signature: str):+ self.cores = os.cpu_count()+ self.signature = signature+ self.__targets: list[tuple[pathlib.Path, str]] = []++ @property+ def targets(self):+ return self.__targets++ def add(self, targets: list[pathlib.Path] | pathlib.Path, entitlement: str):+ if type(targets) is list:+ self.__targets.extend([(target, entitlement) for target in targets])+ else:+ self.__targets.append((targets, entitlement))++ def codesign(self, target_data: tuple[pathlib.Path,str]):+ target, entitlements = target_data+ cmd = ['codesign', '--options', 'runtime', '--timestamp', '-f']+ cmd.extend(['-s', self.signature])+ cmd.extend(['--entitlements', entitlements])+ cmd.append(target)++ result = subprocess.run(cmd,capture_output=True, text=True).stderr+ return target, result++ def signtargets(self):+ with concurrent.futures.ThreadPoolExecutor(max_workers=self.cores) as executor:+ result = executor.map(lambda target: self.codesign(target), self.__targets)++ self.__targets.clear()+ return result++++class PlistBuddyModifier:+ def __init__(self, plist: pathlib.Path):+ self.__plist = plist+ self.__plistbuddy = pathlib.Path(os.sep, 'usr', 'libexec', 'PlistBuddy')+ self.__cmd = [self.__plistbuddy, plist, '-c']++ @property+ def plist(self):+ return self.__plist++ @plist.setter+ def plist(self, plist: pathlib.Path):+ self.__plist = plist+ self.__cmd = [self.__plistbuddy, plist]++ def set(self, key: str, value: str):+ cmd = self.__cmd + [f'Set :{key} {value}']+ self.__execute(cmd)++ def delete(self, key: str):+ cmd = self.__cmd + [f'Delete :{key}']+ self.__execute(cmd)++ def add(self, key: str, value: str):+ cmd = self.__cmd + [f'Add :{key} {value}']+ self.__execute(cmd)++ @staticmethod+ def __execute(cmd: list[str]):+ print(f'- {' '.join(map(str, cmd))}')+ subprocess.run(cmd)++++# security find-identity -v -p codesigning+# check if path points to dmg file+def dmgpath(path: [str]) -> pathlib.Path:+ dmgfile = pathlib.Path(path)+ if dmgfile.suffix != '.dmg' or not dmgfile.exists():+ raise argparse.ArgumentTypeError(f'{path} is not a dmg file or does not exist')++ return dmgfile+++def fix_bundle(bundle_root: pathlib.Path, bundle_version: str="", for_store: bool=False):+ # All files in bundle must have read permissions+ bundle_files = [f for f in bundle_root.rglob('*') if f.is_file(follow_symlinks=False)]++ files_tofix = [f for f in bundle_files if (stat.S_IMODE(f.stat().st_mode) & 0o044) == 0]+ for file in files_tofix:+ DeployCmd.achmod(file, 0o444)++ # Fixing permissions of dynamic libraries+ files_tofix = [f for f in bundle_files if (f.suffix == '.dylib') and (stat.S_IMODE(f.stat().st_mode) & 0o111) == 0]+ for file in files_tofix:+ DeployCmd.achmod(file, 0o111)++ # any file owned by root is an ERROR+ files_tofix = [f for f in bundle_files if f.owner() == 'root']+ if len(files_tofix) > 0:+ print(f'files {files_tofix}\n cannot be read by non-root users!')+ print('submission will fail, please fix and relaunch script')+ exit(1)++ # remove Qt*debug as normal and debug versions can't be signed at the same time+ files_tofix = [f for f in bundle_files if f.name.endswith('_debug') and f.name.startswith('Qt')]+ for file in files_tofix:+ file.unlink()++ # NOT_PORTED: remove from Python.framework all *.so files++ if for_store:+ print("## Modifying bundle for store distribution...")+ # TODO: store move embedded.provisionprofile to krita.app/Contents/++ # get info from the packaged krita+ # krita_version_full = subprocess.run([bundle_root.joinpath('Contents', 'MacOS', 'krita_version'), 'v']+ # , capture_output=True, text=True).stdout+ krita_version_full = subprocess.run([pathlib.Path(os.sep,'usr', 'libexec', 'PListBuddy')+ , bundle_root.joinpath('Contents','Info.plist')+ , '-c', f'Print :CFBundleLongVersionString']+ , capture_output=True, text=True).stdout+ krita_version = krita_version_full.replace("-", " ").split()[0]++ # modify InfoPlist (krita_version, macosx_deployment_target)+ fix_krita_plists(bundle_root, 'org.kde.krita', krita_version, bundle_version)++ # clean dmg: removes krita_version, kritarunner fom MacOS+ bundle_macos = bundle_root.joinpath('Contents', 'MacOS')+ bundle_macos.joinpath('krita_version').unlink()+ bundle_macos.joinpath('kritarunner').unlink()++ return+++def fix_krita_plists(krita_app: pathlib.Path, bundle_id: str, version: str, build_version: str):++ macosx_deployment_target = '10.14' if version.startswith('5') else '12'+ appex_plugins_deployment_target = '10.15' # if user is in 10.14 the old thumbnailer will be used.++ kritaspotlight = pathlib.Path(krita_app, 'Contents', 'Library','Spotlight', 'kritaspotlight.mdimporter', 'Contents')+ kritaquicklook = pathlib.Path(krita_app, 'Contents', 'Library', 'Quicklook', 'kritaquicklook.qlgenerator', 'Contents')+ krita_thumbnailer = pathlib.Path(krita_app, 'Contents', 'Plugins', 'krita-thumbnailer.appex', 'Contents')+ krita_preview = pathlib.Path(krita_app, 'Contents', 'Plugins', 'krita-preview.appex', 'Contents')++ plists = dict()+ plists['krita'] = PlistBuddyModifier(pathlib.Path(krita_app, 'Contents', 'Info.plist'))+ plists['spotlight'] = PlistBuddyModifier(pathlib.Path(kritaspotlight, 'Info.plist'))+ plists['quicklook'] = PlistBuddyModifier(pathlib.Path(kritaquicklook, 'Info.plist'))+ plists['thumbnailer'] = PlistBuddyModifier(pathlib.Path(krita_thumbnailer, 'Info.plist'))+ plists['preview'] = PlistBuddyModifier(pathlib.Path(krita_preview, 'Info.plist'))++ # modify plist contents+ plists['krita'].set('CFBundleIdentifier', bundle_id)+ plists['krita'].set('CFBundleLongVersionString', version)+ plists['krita'].set('LSMinimumSystemVersion', macosx_deployment_target)++ plists['spotlight'].set('CFBundleIdentifier', bundle_id + '.spotlight')+ plists['quicklook'].set('CFBundleIdentifier', bundle_id + '.kritaquicklook')+ plists['thumbnailer'].set('CFBundleIdentifier', bundle_id + '.krita-thumbnailer')+ plists['preview'].set('CFBundleIdentifier', bundle_id + '.krita-preview')++ plists['spotlight'].set('LSMinimumSystemVersion', macosx_deployment_target)+ plists['quicklook'].set('LSMinimumSystemVersion', macosx_deployment_target)+ plists['thumbnailer'].set('LSMinimumSystemVersion', appex_plugins_deployment_target)+ plists['preview'].set('LSMinimumSystemVersion', appex_plugins_deployment_target)++ # common keys+ for plist in plists.values():+ plist.set('CFBundleVersion', build_version)+ plist.set('CFBundleShortVersionString', version)+++def sign_bundle(bundle_root: pathlib.Path, signer: Codesigner, entitlements_path: pathlib.Path, for_store: bool=False):++ entitlements = Entitlements()+ if for_store:+ entitlements.general = entitlements_path.joinpath('macStore-entitlements.plist')+ else:+ entitlements.general = entitlements_path.joinpath('entitlements.plist')++ entitlements.subprocess = entitlements_path.joinpath('sandboxdev_sub-entitlements.plist')+ entitlements.plugins = entitlements_path.joinpath('kis-thumbnail.entitlements')++ content_root = bundle_root.joinpath('Contents')++ # Start signing process, as codesigner signs in parallel, to ensure+ # some order, we must process them in chunks.+ python_targets = [f for f in content_root.joinpath('Frameworks','Python.framework').rglob('*') if+ f.is_file() and f.suffix.endswith('o')+ or (stat.S_IMODE(f.stat().st_mode) & 0o111 > 0)+ and not (f.is_symlink() or f.is_dir())+ ]+ signer.add(python_targets, entitlements.general)+ signer.signtargets()++ # Sign every lib and framework in toplevel Frameworks+ targets = [f for f in content_root.joinpath('Frameworks').glob('*') if not f.is_symlink()]+ # explicitly sign framework/Version/Current+ # TODO: check if this condition is necessary+ # testing showed first find skipped frameworks on the previous script+ targets.extend([f'{f}/Versions/Current' for f in content_root.joinpath('Frameworks').glob('*.framework')])++ # sign krita-python-libs+ # TODO: test,this should not be necessary as they are signed in the frameworks step+ # targets.extend([f for f in content_root.joinpath('Frameworks').glob('krita-python-libs')++ plugins_root = content_root.joinpath('PlugIns')+ targets.extend([f for f in plugins_root.rglob('*') if f.is_file()])++ resources_root = content_root.joinpath('Resources')+ targets.extend([f for f in resources_root.rglob('*') if f.is_file() and (stat.S_IMODE(f.stat().st_mode) & 0o111 > 0)])++ targets.append(content_root.joinpath('Library', 'QuickLook', 'kritaquicklook.qlgenerator'))+ targets.append(content_root.joinpath('Library', 'Spotlight', 'kritaspotlight.mdimporter'))++ signer.add(targets, entitlements.general)+ signer.signtargets()++ plugin_targets = [+ plugins_root.joinpath('krita-thumbnailer.appex')+ ,plugins_root.joinpath('krita-preview.appex')+ ]+ signer.add(plugin_targets, entitlements.plugins)++ bundle_macos_root = content_root.joinpath('MacOS')+ binary_helper_targets = [+ bundle_macos_root.joinpath('ffmpeg')+ ,bundle_macos_root.joinpath('ffprobe')+ ]+ signer.add(binary_helper_targets, entitlements.subprocess)++ if not for_store:+ binary_targets = [+ bundle_macos_root.joinpath('kritarunner')+ , bundle_macos_root.joinpath('krita_version')+ ]+ signer.add(binary_targets, entitlements.general)++ signer.signtargets()++ # Finally sign krita and krita.app+ krita_targets = [+ bundle_macos_root.joinpath('krita')+ , bundle_root+ ]+ signer.add(krita_targets, entitlements.general)+ signer.signtargets()++ return+++def verify_bundle(bundle: pathlib.Path) -> bool:+ is_binary = lambda fpath: b'Mach-O' in subprocess.run(['file',fpath], capture_output=True).stdout+ is_signed = lambda fpath: 'is not signed at all' not in subprocess.run(['codesign', '-vvv', '--strict', fpath], capture_output=True, text=True).stderr++ # missing_sign = [f for f in bundle.rglob('*') if is_binary(f) and not is_signed(f)]+ with concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count()) as executor:+ results = executor.map(lambda f: f if (f.is_file() and is_binary(f) and not is_signed(f)) else None, bundle.rglob('*'))++ missing_signature = [f for f in results if f is not None]+ for element in missing_signature:+ print(f'missing signature: {element}')++ check_pkg = [f for f in bundle.rglob('*.framework')]+ check_pkg.append(bundle.joinpath('Contents', 'Library', 'Quicklook', 'kritaquicklook.qlgenerator'))+ check_pkg.append(bundle.joinpath('Contents', 'Library', 'Spotlight', 'kritaspotlight.mdimporter'))+ check_pkg.append(bundle.joinpath('Contents', 'PlugIns', 'krita-thumbnailer.appex'))+ check_pkg.append(bundle.joinpath('Contents', 'PlugIns', 'krita-preview.appex'))+ check_pkg.append(bundle)++ pkg_error = list()+ for pkg in check_pkg:+ error = subprocess.run(['pkgutil', '--check-signature', pkg], capture_output=True).returncode+ if error:+ pkg_error.append(pkg)++ for pkg in pkg_error:+ print(f'pkgutil error: {pkg}')++ success = len(missing_signature) + len(pkg_error) == 0++ return success++++if __name__ == '__main__':+ main_signdmg()diff --git a/packaging/macos/macos_signeapp2pkg.py b/packaging/macos/macos_signeapp2pkg.pynew file mode 100644index 0000000000..1ffa9fc0e1--- /dev/null+++ b/packaging/macos/macos_signeapp2pkg.py@@ -0,0 +1,49 @@++import argparse+import pathlib+import subprocess+import os++def main_app2pkg():+ parser = argparse.ArgumentParser(prog='macos app to pkg'+ ,description="create a pkg from krita.app to store submission")+ parser.add_argument('krita_app', metavar="krita.app", type=pathlib.Path+ , help="krita.app to make pkg")+ parser.add_argument('-s','--sign-identity', dest='sign_identity', metavar='<identity>'+ , required=True+ , help='3rd Party Mac Developer Installer identity')+ args = parser.parse_args()+++ krita_app: pathlib.Path = args.krita_app+ krita_infoplist: pathlib.Path = krita_app.joinpath('Contents', 'Info.plist')++ plistbuddy = pathlib.Path(os.sep, 'usr', 'libexec', 'PListBuddy')+ kis_bundle_version = subprocess.run([plistbuddy, krita_infoplist, '-c', 'Print :CFBundleVersion']+ , capture_output=True, text=True).stdout.strip()+ kis_version_full = subprocess.run([plistbuddy, krita_infoplist, '-c', 'Print :CFBundleLongVersionString']+ , capture_output=True, text=True).stdout.strip()+ kis_bundle_id = subprocess.run([plistbuddy, krita_infoplist, '-c', 'Print :CFBundleIdentifier']+ , capture_output=True, text=True).stdout.strip()+++ krita_pkg: pathlib.Path = pathlib.Path(f'{krita_app.stem}-{kis_version_full}_bv-{kis_bundle_version}.pkg')+ print(f'creating {krita_pkg}')++ cmd = ['productbuild', '--component', krita_app, '/Applications', krita_pkg+ , '--sign', args.sign_identity]+ subprocess.run(cmd)+++ print(f"""+this script does not submit {krita_pkg} yo the store, to do so you may run altool as:+ xcrun altool --upload-package {krita_pkg} --bundle-id {kis_bundle_id} -t macos -u <appleid-account> --bundle-version {kis_bundle_version} --bundle-short-version-string {kis_version_full} --apple-id <app-id from store>++ You may also need to add a teamID if you belong to more than one team+ --asc-provider <apple-teamid>++ Alternative the resulting pkg can be submitted using Transporter.app"""+)++if __name__ == '__main__':+ main_app2pkg()diff --git a/packaging/macos/macstoreprep.sh b/packaging/macos/macstoreprep.shdeleted file mode 100755index 8148530ae7..0000000000--- a/packaging/macos/macstoreprep.sh+++ /dev/null@@ -1,390 +0,0 @@-#!/usr/bin/env zsh-#-# SPDX-License-Identifier: GPL-3.0-or-later-#--# macstoreprep-#-# Script to prepare a dmg for mac Store submission format-#--if [[ -n "$ZSH_VERSION" ]]; then- emulate -L ksh;-fi--if [[ -z $BUILDROOT ]]; then- echo "ERROR: BUILDROOT env not set!"- echo "\t Must point to the root of the buildfiles as stated in 3rdparty Readme"- echo "exiting..."- exit 1-fi--# receives a path without filename-get_absolute_path() {- local origLoc="$(pwd)"-- local filename="${1}"- local location="${filename}"-- if [[ -e "${filename}" && ! -d "${filename}" ]]; then- location="$(dirname "${filename}")"- fi-- local absolute="$(cd "${location}"; pwd)"- cd "${origLoc}"-- echo ${absolute}-}--# make sure BUILDROOT is always an absolute path-BUILDROOT=$(get_absolute_path "${BUILDROOT}")--KRITADMG_WDIR="${BUILDROOT}/kritadmg_store"-KRITADMG_MOUNT="kritadmg"-if [[ -z "${KIS_SRC_DIR}" ]]; then- KIS_SRC_DIR=${BUILDROOT}/krita-fi-if [[ -z "${KIS_BUILD_DIR}" ]]; then- KIS_BUILD_DIR=${BUILDROOT}/kisbuild-fi-KIS_ENTITLEMENTS_DIR="${KIS_SRC_DIR}/packaging/macos/"-# we look for the provisioning file in the script the directory was called-KIS_PROVISION="$(get_absolute_path ".")/embedded.provisionprofile"--KIS_BUNDLE_ID="org.kde.krita"--# print status messages-print_msg() {- printf "\e[32m${1}\e[0m\n" "${@:2}"- # printf "%s\n" "${1}" >> ${OUTPUT_LOG}-}--# print error-print_error() {- printf "\e[31m%s %s\e[0m\n" "Error:" "${1}"-}--get_script_dir() {- if [[ -n "$ZSH_VERSION" ]]; then- script_source="${(%):-%x}"- else- # transitional, macos should use ZSH- script_source="${BASH_SOURCE[0]}"- fi- # go to target until finding root.- while [ -L "${script_source}" ]; do- script_target="$(readlink ${script_source})"- if [[ "${script_source}" = /* ]]; then- script_source="$script_target"- else- script_dir="$(dirname "${script_source}")"- script_source="${script_dir}/${script_target}"- fi- done- echo "$(dirname ${script_source})"-}--findEntitlementsFile() {- if [[ -e ${KIS_ENTITLEMENTS} ]]; then- return- fi-- local fileName="macStore-entitlements.plist"- local subEntitlementsFile="sandboxdev_sub-entitlements.plist"-- if [[ -f "${DIR_CURRENT}/${fileName}" ]]; then- KIS_ENTITLEMENTS="${DIR_CURRENT}/${fileName}"- KIS_SUB_ENTITLEMENTS="${DIR_CURRENT}/${subEntitlementsFile}"- elif [[ -f "${KIS_ENTITLEMENTS_DIR}/${fileName}" ]]; then- KIS_ENTITLEMENTS="${KIS_ENTITLEMENTS_DIR}/${fileName}"- KIS_SUB_ENTITLEMENTS="${KIS_ENTITLEMENTS_DIR}/${subEntitlementsFile}"- fi-}--# calls /usr/libexec/PlistBuddy with basic args-# $1 file.plist to modify-# $2 -c command-# $3 plist key to modify-# $4 plist value for key-plistbuddy() {- local plistbuddy="/usr/libexec/PlistBuddy"- local filename="${1}"- local cmd="${2}"- local key="${3}"- local value="${4}"-- ${plistbuddy} "${filename}" -c "${cmd}:${key} ${value}"-}--modifyInfoPlistContents() {- local plistbuddy="/usr/libexec/PlistBuddy"- local PLIST_LOC="${KRITADMG_WDIR}/krita.app/Contents"-- plistbuddy "${PLIST_LOC}/Info.plist" Set CFBundleIdentifier ${KIS_BUNDLE_ID}- plistbuddy "${PLIST_LOC}/Info.plist" Set CFBundleVersion ${KIS_BUILD_VERSION}- plistbuddy "${PLIST_LOC}/Info.plist" Set CFBundleShortVersionString ${KIS_VERSION}- plistbuddy "${PLIST_LOC}/Info.plist" CFBundleLongVersionString ${KIS_VERSION}-- plistbuddy "${PLIST_LOC}/Library/QuickLook/kritaquicklook.qlgenerator/Contents/Info.plist" CFBundleIdentifier ${KIS_BUNDLE_ID}.quicklook- plistbuddy "${PLIST_LOC}/Library/Spotlight/kritaspotlight.mdimporter/Contents/Info.plist" CFBundleIdentifier ${KIS_BUNDLE_ID}.spotlight-}---clean_dmg() {- cd "${KRITADMG_WDIR}/krita.app/Contents/MacOS"- rm krita_version- rm kritarunner-}--batch_codesign() {- local entitlements="${1}"- if [[ -z "${1}" ]]; then- entitlements="${KIS_ENTITLEMENTS}"- fi- xargs -P4 -I FILE codesign --options runtime --timestamp -f -s "${CODE_SIGNATURE}" --entitlements "${entitlements}" FILE-}-# Code sign must be done as recommended by apple "sign code inside out in individual stages"-signBundle() {- cd ${KRITADMG_WDIR}-- # sign Frameworks and libs- cd ${KRITADMG_WDIR}/krita.app/Contents/Frameworks- # remove debug version as both versions can't be signed.- rm ${KRITADMG_WDIR}/krita.app/Contents/Frameworks/QtScript.framework/Versions/Current/QtScript_debug- # Do not sign binaries inside frameworks except for Python's- find . -type d -path "*.framework" -prune -false -o -perm +111 -not -type d | batch_codesign- find Python.framework -type f -name "*.o" -or -name "*.so" -or -perm +111 -not -type d -not -type l | batch_codesign- find . -type d -name "*.framework" | xargs printf "%s/Versions/Current\n" | batch_codesign-- # Sign all other files in Framework (needed)- # there are many files in python do we need to sign them all?- find krita-python-libs -type f | batch_codesign- # find python -type f | batch_codesign-- # Sign only libraries and plugins- cd ${KRITADMG_WDIR}/krita.app/Contents/PlugIns- find . -type f | batch_codesign-- cd ${KRITADMG_WDIR}/krita.app/Contents/Library/QuickLook- printf "kritaquicklook.qlgenerator" | batch_codesign-- cd ${KRITADMG_WDIR}/krita.app/Contents/Library/Spotlight- printf "kritaspotlight.mdimporter" | batch_codesign-- # It is necessary to sign every binary Resource file- cd ${KRITADMG_WDIR}/krita.app/Contents/Resources- find . -perm +111 -type f | batch_codesign-- printf "${KRITADMG_WDIR}/krita.app/Contents/MacOS/ffmpeg" | batch_codesign "${KIS_SUB_ENTITLEMENTS}"- printf "${KRITADMG_WDIR}/krita.app/Contents/MacOS/ffprobe" | batch_codesign "${KIS_SUB_ENTITLEMENTS}"- #Finally sign krita and krita.app- printf "${KRITADMG_WDIR}/krita.app/Contents/MacOS/krita" | batch_codesign- printf "${KRITADMG_WDIR}/krita.app" | batch_codesign-- cd ${KRITADMG_WDIR}-}--sign_hasError() {- local CODESIGN_STATUS=0- for f in $(find "${KRITADMG_WDIR}/krita.app" -type f); do- if [[ -z $(file ${f} | grep "Mach-O") ]]; then- continue- fi-- CODESIGN_RESULT=$(codesign -vvv --strict ${f} 2>&1 | grep "not signed")-- if [[ -n "${CODESIGN_RESULT}" ]]; then- CODESIGN_STATUS=1- printf "${f} not signed\n" >&2- fi- done- echo ${CODESIGN_STATUS}-}---print_usage () {- printf "USAGE:- macstoreprep.sh -f=<krita.dmg> [-s=<identity>] [-notarize-ac=<apple-account>]-- -bv \t\t bundle version: mac store needs to identify each submission as unique. for this- \t\t we do not bump the krita version but the bundle version. The format is [M.m.p] and- \t\t is totally independent from krita release version.-- -s \t\t\t Sign Identity for 3rd party application-- -sins \t\t Sign Identity for 3rd party Dev installer-- -notarize-ac \t Apple account name for notarization purposes- \t\t script will attempt to get password from keychain, if fails provide one with- \t\t the -notarize-pass option: To add a password run-- \t\t security add-generic-password -a \"AC_USERNAME\" -w <secret_password> -s \"AC_PASSWORD\"-- -notarize-pass \t If given, the Apple account password. Otherwise an attempt will be macdeployqt_exists- \t\t to get the password from keychain using the account given in <notarize-ac> option.-- -asc-provider \t some AppleIds might need this option pass the <shortname>-- -f \t\t\t input dmg-"-}---### Script starts-SCRIPT_SOURCE_DIR="$(get_script_dir)"--DIR_CURRENT="$(pwd)"-cd "$(get_script_dir)"-SCRIPT_SOURCE_DIR="$(pwd)"-cd "${DIR_CURRENT}"--# Attempt to detach previous mouted DMG-# if [[ -d "/Volumes/${DMG_title}" ]]; then-# echo "WARNING: Another Krita DMG is mounted!"-# echo "Attempting eject…"-# hdiutil detach "/Volumes/${DMG_title}"-# if [ $? -ne 0 ]; then-# exit 1-# fi-# echo "Success!"-# fi---# -- Parse input args-for arg in "${@}"; do- # If string starts with -sign-# if [[ ${arg} = -v=* ]]; then-# KIS_VERSION="${arg#*=}"-# fi-- if [[ ${arg} = -bv=* ]]; then- KIS_BUILD_VERSION="${arg#*=}"- fi-- if [[ ${arg} = -s=* ]]; then- CODE_SIGNATURE="${arg#*=}"- fi-- if [[ ${arg} = -sins=* ]]; then- SIGN_DEV_INSTALL="${arg#*=}"- fi-- if [[ ${arg} = -f=* ]]; then- INPUT_STR="${arg#*=}"- INPUT_DIR="$(cd $(dirname ${INPUT_STR}); pwd -P)"- INPUT_DMG="${INPUT_DIR}/$(basename ${INPUT_STR})"- fi-- if [[ ${arg} = -notarize-ac=* ]]; then- NOTARIZE_ACC="${arg#*=}"- fi-- if [[ ${arg} = -notarize-pass=* ]]; then- NOTARIZE_PASS="${arg#*=}"- fi-- if [[ ${arg} = -asc-provider=* ]]; then- APPLE_TEAMID="${arg#*=}"- fi-- if [[ ${arg} = "-h" || ${arg} = "--help" ]]; then- print_usage- exit 1- fi-done--### Code Signature & NOTARIZATION-NOTARIZE="false"-if [[ -n "${CODE_SIGNATURE}" ]]; then- print_msg "Code will be signed with %s" "${CODE_SIGNATURE}"-fi--if [[ -z "${KIS_BUILD_VERSION}" ]]; then- print_error "option -bv is not set!"- echo "run with --help for assistance"- exit-fi--# mount dmg--if [[ ! -d "${KRITADMG_WDIR}" ]]; then- mkdir "${KRITADMG_WDIR}"-fi--cd "${KRITADMG_WDIR}"-echo "cleaning last run..."-rm -rf "${KRITADMG_WDIR}/krita.app"--echo "mounting ${INPUT_DMG} ..."-hdiutil attach "${INPUT_DMG}" -mountpoint "${KRITADMG_MOUNT}"-rsync -prult --delete "${KRITADMG_MOUNT}/krita.app/" "krita.app"--hdiutil detach "${KRITADMG_MOUNT}"--# attach provisioning profile-cp -X "${KIS_PROVISION}" "${KRITADMG_WDIR}/krita.app/Contents/"-chmod 644 "${KRITADMG_WDIR}/krita.app/Contents/${KIS_PROVISION}"--# clean krita version string (app store format does not allow dashes-KIS_VERSION="$(${KRITADMG_WDIR}/krita.app/Contents/MacOS/krita_version 2> /dev/null | awk '{print $1}')"-KIS_VERSION=${KIS_VERSION%%-*}--# try to fix permissions-for f in $(find ${KRITADMG_WDIR} -not -perm +044); do- chmod +r ${f}-done--rootfiles="$(find ${KRITADMG_WDIR} -user root -perm +400 -and -not -perm +044)"-if [[ -n ${rootfiles} ]]; then- echo "files \n ${rootfiles} \n cannot be read by non-root users!"- echo "submission will fail, please fix and relaunch script"-fi--# replace signature-findEntitlementsFile-if [[ -z ${KIS_ENTITLEMENTS} ]]; then- echo "Could not find entitlements file use for codesign"- exit-else- echo "using ${KIS_ENTITLEMENTS}"-fi--modifyInfoPlistContents--clean_dmg--# Code sign krita.app if signature given-if [[ -n "${CODE_SIGNATURE}" ]]; then- signBundle- if [[ $(sign_hasError) -eq 1 ]]; then- print_error "CodeSign errors!"- echo "stopping...."- exit 1- fi- echo "no codesign errors"- echo "preparing pkg"-fi--if [[ -z ${APPLE_TEAMID} ]]; then- APPLE_TEAMID="<team_identifier>"-fi--KRITA_DMG_BASENAME="$(basename ${INPUT_STR})"-KRITA_PKG_NAME="${KRITA_DMG_BASENAME%.*}.pkg"-# productbuild --component ${KIS_APPLOC}/krita.app /Applications krita5_submit.pkg --sign \"3rd Party Mac Developer Installer: ...\"-if [[ -n "${SIGN_DEV_INSTALL}" ]]; then- echo "creating krita5_submit.pkg ..."- productbuild --component "${KRITADMG_WDIR}/krita.app" "/Applications" "${KRITADMG_WDIR}/${KRITA_PKG_NAME}" --sign "${SIGN_DEV_INSTALL}"-fi--echo "done"--print_msg "-Use altool to submit the Pkg:-- \t xcrun altool --upload-package "${KRITADMG_WDIR}/${KRITA_PKG_NAME}" --bundle-id ${KIS_BUNDLE_ID} -t macos -u "${NOTARIZE_ACC}" --password <pass> [--asc-provider "${APPLE_TEAMID}"] --bundle-version ${KIS_BUILD_VERSION} --bundle-short-version-string ${KIS_VERSION} --apple-id <app-id_fromStore>--To get <app-id_fromStore> from store go to: https://appstoreconnect.apple.com/apps ,select the app you wish to upload to,-click on App information on the left side, and search for 'Apple ID' field.--\n"diff --git a/packaging/macos/osxdeploy.sh b/packaging/macos/osxdeploy.shdeleted file mode 100755index d300f0adf4..0000000000--- a/packaging/macos/osxdeploy.sh+++ /dev/null@@ -1,1010 +0,0 @@-#!/usr/bin/env zsh-#-# SPDX-License-Identifier: GPL-3.0-or-later-#--# Krita tool to create dmg from installed source-# Copies all files to a folder to be converted into the final dmg--# osxdeploy.sh automates the creation of the release DMG.-# default background and style are used if none provided--# A short explanation of what it does:--# - Copies krita.app contents to kritadmg folder-# - Copies i/share to Contents/Resources excluding unnecessary files-# - Copies translations, qml and quicklook PlugIns-# - Copies i/plugins and i/lib/plugins to Contents/PlugIns--# - Runs macdeployqt: macdeployqt is not built by default in ext_qt-# build by:-# cd ${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src-# make sub-macdeployqt-all-# make sub-macdeployqt-install_subtargets-# make install--# the script changes dir to installation/bin to run macdeployqt as it can be buggy-# if not run from the same folder as the binary is on.--# - Fix rpath from krita bin-# - Find missing libraries from plugins and copy to Frameworks or plugins.-# This uses oTool iterative to find all unique libraries, then it searches each-# library fond in <kritadmg> folder, and if not found attempts to copy contents-# to the appropriate folder, either Frameworks (if frameworks is in namefile, or-# library has plugin is not in path), or plugin if otherwise.--# - Builds DMG-# Building DMG creates a new dmg with the contents of <kritadmg>-# mounts the dmg and sets the style for dmg.-# unmount-# Compress resulting dmg into krita_nightly-<gitsha>.dmg-# deletes temporary files.--if [[ -n "$ZSH_VERSION" ]]; then- emulate -L ksh;-fi--if [[ -z $BUILDROOT ]]; then- echo "ERROR: BUILDROOT env not set!"- echo "\t Must point to the root of the buildfiles as stated in 3rdparty Readme"- echo "exiting..."- exit 1-fi--BUILDROOT="${BUILDROOT%/}"--# print status messages-print_msg() {- printf "\e[32m${1}\e[0m\n" "${@:2}"- # printf "%s\n" "${1}" >> ${OUTPUT_LOG}-}--# print error-print_error() {- printf "\e[31m%s %s\e[0m\n" "Error:" "${1}"-}--# Debug helper function-debug_script() {- echo "## running subcmd: ${@}"- ${@}-}--if [[ -z ${DEBUG} ]]; then- RUN_CMD="debug_script"-fi--DMG_title="krita" #if changed krita.temp.dmg must be deleted manually--# There is some duplication between build and deploy scripts-# a config env file could would be a nice idea.-if [[ -z "${KIS_SRC_DIR}" ]]; then- KIS_SRC_DIR=${BUILDROOT}/-fi-if [[ -z "${KIS_BUILD_DIR}" ]]; then- KIS_BUILD_DIR=${BUILDROOT}/_build-fi-KIS_INSTALL_DIR=${BUILDROOT}/_install-KRITA_DMG=${BUILDROOT}/_dmg-KRITA_DMG_TEMPLATE=${BUILDROOT}/_kritadmg-template--export PATH=${KIS_INSTALL_DIR}/bin:$PATH--# flags for OSX environment-echo "Trying to guess Qt version..."-if [[ -e "${KIS_INSTALL_DIR}/lib/QtCore.framework/Versions/A/QtCore" ]]; then- echo " Found Qt6"- # We only support from 12 up- export MACOSX_DEPLOYMENT_TARGET=12- export QMAKE_MACOSX_DEPLOYMENT_TARGET=12-else- echo " Assuming Qt5"- # We only support from 10.14 up- export MACOSX_DEPLOYMENT_TARGET=10.14- export QMAKE_MACOSX_DEPLOYMENT_TARGET=10.14-fi--KRITA_VERSION="$(${KIS_INSTALL_DIR}/bin/krita_version -v)"--if [[ -n $KRITACI_RELEASE_PACKAGE_NAMING ]]; then- # remove git-sha1, which is split with the space char- KRITA_VERSION=${KRITA_VERSION% [a-f0-9]*}-else- # merge version and git-sha1 for non-release versions- KRITA_VERSION=${KRITA_VERSION// /-}-fi--print_usage () {- printf "USAGE:- osxdeploy.sh [-s=<identity>] [-notarize-ac=<apple-account>] [-style=<style.txt>] [-bg=<background-image>]-- -s \t\t\t Code sign identity for codesign-- -notarize-ac \t Apple account name for notarization purposes-\t\t\t script will attempt to get password from keychain, if fails provide one with-\t\t\t the -notarize-pass option: To add a password run--\t\t\t security add-generic-password -a \"AC_USERNAME\" -w <secret_password> -s \"AC_PASSWORD\"-- -notarize-pass \t If given, the Apple account password. Otherwise an attempt will be macdeployqt_exists-\t\t\t to get the password from keychain using the account given in <notarize-ac> option.-- -asc-provider \t some AppleIds might need this option pass the <shortname>-- -style \t\t Style file defined from 'dmgstyle.sh' output-- -bg \t\t Set a background image for dmg folder.-- -name \t\t Set the DMG name output.--\t\t\t osxdeploy needs an input image to attach to the dmg background-\t\t\t image recommended size is at least 950x500-"-}--# Attempt to detach previous mounted DMG-if [[ -d "/Volumes/${DMG_title}" ]]; then- echo "WARNING: Another Krita DMG is mounted!"- echo "Attempting eject…"- hdiutil detach "/Volumes/${DMG_title}"- if [ $? -ne 0 ]; then- exit 1- fi- echo "Success!"-fi--# -- Parse input args-for arg in "${@}"; do- if [ "${arg}" = -bg=* -a -f "${arg#*=}" ]; then- DMG_validBG=0- bg_filename=${arg#*=}- echo "attempting to check background is valid jpg or png..."- BG_FORMAT=$(sips --getProperty format ${bg_filename} | awk '{printf $2}')-- if [[ "png" = ${BG_FORMAT} || "jpeg" = ${BG_FORMAT} ]];then- echo "valid image file"- DMG_background=$(cd "$(dirname "${bg_filename}")"; pwd -P)/$(basename "${bg_filename}")- DMG_validBG=1- # check imageDPI- BG_DPI=$(sips --getProperty dpiWidth ${DMG_background} | grep dpi | awk '{print $2}')- if [[ $(echo "${BG_DPI} > 150" | bc -l) -eq 1 ]]; then- printf "WARNING: image dpi has an effect on apparent size!- Check dpi is adequate for screen display if image appears very small- Current dpi is: %s\n" ${BG_DPI}- fi- fi- fi- # If string starts with -sign- if [[ ${arg} = -s=* ]]; then- CODE_SIGNATURE="${arg#*=}"- fi-- if [[ ${arg} = -name=* ]]; then- DMG_NAME="${arg#*=}"- fi-- if [[ ${arg} = -notarize-ac=* ]]; then- NOTARIZE_ACC="${arg#*=}"- fi-- if [[ ${arg} = -notarize-pass=* ]]; then- NOTARIZE_PASS="${arg#*=}"- fi-- if [[ ${arg} = -style=* ]]; then- style_filename="${arg#*=}"- if [[ -f "${style_filename}" ]]; then- DMG_STYLE="${style_filename}"- fi- fi-- if [[ ${arg} = -asc-provider=* ]]; then- APPLE_TEAMID="${arg#*=}"- fi-- if [[ ${arg} = "-h" || ${arg} = "--help" ]]; then- print_usage- exit 1- fi-done--# -- Checks and messages--### PYTHONAttempt to find python_version-local_PY_MAYOR_VERSION=$(python -c "import sys; print(sys.version_info[0])")-local_PY_MINOR_VERSION=$(python -c "import sys; print(sys.version_info[1])")-PY_VERSION="${local_PY_MAYOR_VERSION}.${local_PY_MINOR_VERSION}"--print_msg "Detected Python %s" "${PY_VERSION}"--### Code Signature & NOTARIZATION-NOTARIZE="false"-if [[ -z "${CODE_SIGNATURE}" ]]; then- echo "WARNING: No code signature provided, Code will not be signed"-else- print_msg "Code will be signed with %s" "${CODE_SIGNATURE}"- ### NOTARIZATION- # check if we can perform notarization using notarytool- xcrun notarytool history --keychain-profile KritaNotarizeAccount 1> /dev/null- if [[ ${?} -eq 0 ]]; then- NOTARYTOOL="short"- NOTARIZE="true"- fi-- if [[ ${NOTARIZE} = "false" && -n "${NOTARIZE_ACC}" ]]; then- NOTARIZE="true"- ASC_PROVIDER_OP=""-- if [[ -z ${APPLE_TEAMID} ]]; then- echo "No team id provided, extracting from signature"- APPLE_TEAMID=${CODE_SIGNATURE[-11,-2]}- fi-- if [[ -n "${APPLE_TEAMID}" ]]; then- ASC_PROVIDER_OP="--asc-provider ${APPLE_TEAMID}"- fi-- if [[ -z "${NOTARIZE_PASS}" ]]; then- NOTARIZE_PASS="@keychain:AC_PASSWORD"- KEYCHAIN_PASS="true"- fi-- # check if we can perform notarization-- xcrun notarytool history --apple-id "${NOTARIZE_ACC}" --password "${NOTARIZE_PASS}" --team-id "${APPLE_TEAMID}" 1> /dev/null- if [[ ${?} -ne 0 ]]; then- echo "Unable to use notarytool: not setup/missing password, trying altool"- ALTOOL="true"- xcrun altool --notarization-history 0 --username "${NOTARIZE_ACC}" --password "${NOTARIZE_PASS}" ${ASC_PROVIDER_OP} 1> /dev/null-- if [[ ${?} -ne 0 ]]; then- NOTARIZE="false"- echo "No password given for notarization or AC_PASSWORD missing in keychain"- fi- else- NOTARYTOOL="long"- fi- fi-fi--if [[ ${NOTARIZE} = "true" ]]; then- print_msg "Notarization checks complete, This build will be notarized"-else- echo "WARNING: Account information missing, Notarization will not be performed"-fi---### STYLE for DMG-if [[ ! ${DMG_STYLE} ]]; then- DMG_STYLE="${KIS_SRC_DIR}/packaging/macos/default.style"-fi--print_msg "Using style from: %s" "${DMG_STYLE}"--### Background for DMG-if [[ ${DMG_validBG} -eq 0 ]]; then- echo "No jpg or png valid file detected!!"- echo "Using default style"- DMG_background="${KIS_SRC_DIR}/packaging/macos/krita_dmgBG.png"-fi----# Helper functions-countArgs () {- echo "${#}"-}--stringContains () {- echo "$(grep "${2}" <<< "${1}")"-}--waiting_fixed() {- local message="${1}"- local waitTime=${2}-- for i in $(seq ${waitTime}); do- sleep 1- printf -v dots '%*s' ${i}- printf -v spaces '%*s' $((${waitTime} - $i))- printf "\r%s [%s%s]" "${message}" "${dots// /.}" "${spaces}"- done- printf "\n"-}--add_lib_to_list() {- local llist=${2}- local libPathTail="${1##*/}"- local lib=${libPathTail}-- # we add a special case if the lib is a framework- if [[ -n "$(grep ${libPathTail}.framework <<< ${1})" ]]; then- lib="${libPathTail}.framework"- fi-- if [[ -z "$(grep ${lib} <<< ${llist})" ]]; then- local llist="${llist} ${lib} "- fi- echo "${llist}"-}--# Find all @rpath and Absolute to buildroot path libs-# Add to libs_used-# converts absolute buildroot path to @rpath-find_needed_libs () {- # echo "Analyzing libraries with oTool..." >&2- local libs_used="" # input lib_lists founded-- for libFile in ${@}; do- if [[ -z "$(file ${libFile} | grep 'Mach-O')" ]]; then- # echo "skipping ${libFile}" >&2- continue- fi-- resultArray=($(otool -L ${libFile} | awk '{print $1","substr($2,2)}'))-- for entry in ${resultArray[@]:1}; do- # skip fat-bin file markers- if [[ "${entry##*,}" = "architecture" ]]; then- continue- fi-- lib="${entry%%,*}"- printf "checking %s\n" "${lib}" >&2-- if [[ "${lib:0:1}" = "@" ]]; then- printf "Fixing %s from %s\n" "${lib}" "${libFile}" >&2- local libs_used=$(add_lib_to_list "${lib}" "${libs_used}")- fi-- if [[ "${lib:0:${#BUILDROOT}}" = "${BUILDROOT}" ]]; then- printf "\t%s\n" "${lib}" >&2- if [[ "${lib##*/}" = "${libFile##*/}" ]]; then- install_name_tool -id ${lib##*/} "${libFile}"- else- install_name_tool -change ${lib} "@rpath/${lib##*/i/lib/}" "${libFile}"- local libs_used=$(add_lib_to_list "${lib}" "${libs_used}")- fi- fi- done- done- echo "${libs_used}" # return updated list-}--find_missing_libs (){- # echo "Searching for missing libs on deployment folders…" >&2- local libs_missing=""- for lib in ${@}; do- printf "looking for %s\n" "${lib}" >&2- if [[ -z "$(find ${KRITA_DMG}/krita.app/Contents/ -name ${lib})" ]]; then- echo "Adding ${lib} to missing libraries." >&2- libs_missing="${libs_missing} ${lib}"- fi- done- echo "${libs_missing}"-}--copy_missing_lib_wlink() {- local inlibfile=${1}- local dst=${2}-- local sourceLibDir=$(dirname ${inlibfile})- local libfile=$(basename ${inlibfile})-- while [[ true ]]; do- local lib="${sourceLibDir}/${libfile}"- ${RUN_CMD} cp -av ${lib} ${dst}- libfile=$(readlink ${lib})- if [[ -z ${libfile} ]]; then break; fi- done-}--copy_missing_libs () {- for lib in ${@}; do- result=$(find -L "${KIS_INSTALL_DIR}" -name "${lib}")-- # check if missing lib is a framework- if [[ ${lib} = ${lib%.framework} ]]; then- if [ "$(stringContains "${result}" "plugin")" ]; then- copy_missing_lib_wlink ${result} ${KRITA_DMG}/krita.app/Contents/PlugIns/- krita_findmissinglibs "${KRITA_DMG}/krita.app/Contents/PlugIns/${result##*/}"- else- copy_missing_lib_wlink ${result} ${KRITA_DMG}/krita.app/Contents/Frameworks/- krita_findmissinglibs "${KRITA_DMG}/krita.app/Contents/Frameworks/${result##*/}"- fi- else- echo "copying missing framework ${lib}"- rsync -priul ${KIS_INSTALL_DIR}/lib/${lib} ${KRITA_DMG}/krita.app/Contents/Frameworks/- krita_findmissinglibs "$(find "${KRITA_DMG}/krita.app/Contents/Frameworks/${lib}/" -type f -perm 755)"- fi- done-}--krita_findmissinglibs() {- neededLibs=$(find_needed_libs ${@})- missingLibs=$(find_missing_libs ${neededLibs})-- if [[ $(countArgs ${missingLibs}) -gt 0 ]]; then- printf "Found missing libs: %s\n" "${missingLibs}"- copy_missing_libs ${missingLibs}- fi-}--strip_python_dmginstall() {- # reduce size of framework python- # Removes tests, installers, pyenv, distutils- echo "Removing unnecessary files from Python.Framework to be packaged..."- PythonFrameworkBase="${KRITA_DMG}/krita.app/Contents/Frameworks/Python.framework"-- cd "${PythonFrameworkBase}"- find . -name "test*" -type d | xargs rm -rf- find "${PythonFrameworkBase}/Versions/${PY_VERSION}/bin" -not -name "python*" \( -type f -or -type l \) | xargs rm -f- cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/lib/python${PY_VERSION}"- rm -rf distutils tkinter ensurepip venv lib2to3 idlelib turtledemo- # remove tkinter module- rm "./lib-dynload/_tkinter.cpython-${local_PY_MAYOR_VERSION}${local_PY_MINOR_VERSION}-darwin.so"-- cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/lib/python${PY_VERSION}/site-packages"- rm -rf pip* PyQt_builder* setuptools* sip* easy-install.pth-- cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/Resources"- rm -rf Python.app-}--# Remove any missing rpath pointing to BUILDROOT-libs_clean_rpath () {- for libFile in ${@}; do- rpath=($(otool -l "${libFile}" | grep "path ${BUILDROOT}" | awk '{$1=$1;print $2}'))- for lpath in "${rpath[@]}"; do- echo "removed rpath _${lpath}_ from ${libFile}"- install_name_tool -delete_rpath "${lpath}" "${libFile}" 2> /dev/null- done- done-}--# Multithreaded version-# of libs_clean_rpath, but makes assumptions-delete_install_rpath() {- xargs -P4 -I FILE install_name_tool -delete_rpath "${KIS_INSTALL_DIR}/lib" FILE 2> "${BUILDROOT}/deploy_error.log"-}--fix_python_framework() {- # Fix python.framework rpath and slims down installation- PythonFrameworkBase="${KRITA_DMG}/krita.app/Contents/Frameworks/Python.framework"-- # Fix permissions- find "${PythonFrameworkBase}" -name "*.so" | xargs -P4 -I FILE chmod a+x FILE 2> "${BUILDROOT}/deploy_error.log"- cd "${PythonFrameworkBase}/Versions/${PY_VERSION}/lib/python${PY_VERSION}"- chmod a+x pydoc.py-- # Fix main library- pythonLib="${PythonFrameworkBase}/Python"- install_name_tool -id "${pythonLib##*/}" "${pythonLib}"- install_name_tool -add_rpath @loader_path/../../../ "${pythonLib}" 2> /dev/null- install_name_tool -change @loader_path/../../../../libintl.9.dylib @loader_path/../../../libintl.9.dylib "${pythonLib}"-- # Fix all executables- install_name_tool -add_rpath @executable_path/../../../../../../../ "${PythonFrameworkBase}/Versions/Current/Resources/Python.app/Contents/MacOS/Python"- install_name_tool -change "${KIS_INSTALL_DIR}/lib/Python.framework/Versions/${PY_VERSION}/Python" @executable_path/../../../../../../Python "${PythonFrameworkBase}/Versions/Current/Resources/Python.app/Contents/MacOS/Python"- install_name_tool -add_rpath @executable_path/../../../../ "${PythonFrameworkBase}/Versions/Current/bin/python${PY_VERSION}"-- # Fix rpaths from Python.Framework- find "${PythonFrameworkBase}" -type f -perm 755 | delete_install_rpath- find "${PythonFrameworkBase}/Versions/Current/lib/python${PY_VERSION}/site-packages/PyQt5" -type f -name "*.so" | delete_install_rpath-}--plistbuddy_add() {- local plistbuddy="/usr/libexec/PlistBuddy"- local filename="${1}"- local key="${2}"- local type="${3}"- local value="${4}"-- ${plistbuddy} "${filename}" -c "Add:${key} ${type} ${value}"-}--krita_create_PyKrita() {- local plistbuddy="/usr/libexec/PlistBuddy"- local fmwk_name="PyKrita"- local fmwk_version=${KRITA_VERSION%%-*}-- # assume we are not in frameworks- local old_pwd=$(pwd)- cd ${KRITA_DMG}/krita.app/Contents/Frameworks/-- mkdir ${fmwk_name}.framework- mkdir ${fmwk_name}.framework/Versions-- cd ${fmwk_name}.framework/Versions- mkdir ${fmwk_version}- ln -s ${fmwk_version} Current-- cd ${fmwk_version}- mkdir Resources lib-- rsync -priul ${KIS_INSTALL_DIR}/lib/krita-python-libs/ lib-- mv lib/PyKrita/krita.so ${fmwk_name}- ln -s ../../${fmwk_name} lib/PyKrita/krita.so-- cd Resources- plistbuddy_add Info.plist CFBundleExecutable string ${fmwk_name}- plistbuddy_add Info.plist CFBundleIdentifier string org.krita.${fmwk_name}- plistbuddy_add Info.plist CFBundlePackageType string FMWK- plistbuddy_add Info.plist CFBundleShortVersionString string ${fmwk_version}- plistbuddy_add Info.plist CFBundleVersion string ${fmwk_version}-- cd ../../..- ln -s Versions/Current/${fmwk_name} ${fmwk_name}- ln -s Versions/Current/Resources Resources-- cd ../- ln -s ./${fmwk_name}.framework/Versions/Current/lib/ krita-python-libs-- cd ${old_pwd}-}--# Checks for macdeployqt-# If not present attempts to install-# If it fails shows an informative message-# (For now, macdeployqt is fundamental to deploy)-macdeployqt_exists() {- printf "Checking for macdeployqt... "-- if [[ ! -e "${KIS_INSTALL_DIR}/bin/macdeployqt" ]]; then- printf "Not Found!\n"- printf "Attempting to install macdeployqt\n"-- cd "${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src"- make sub-macdeployqt-all- make sub-macdeployqt-install_subtargets- make install-- if [[ ! -e "${KIS_INSTALL_DIR}/bin/macdeployqt" ]]; then- printf "-ERROR: Failed to install macdeployqt!-- Compile and install from qt source directory- Source code to build could be located in qttools/src in qt source dir:-- ${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src-- From the source dir, build and install:-- make sub-macdeployqt-all- make sub-macdeployqt-install_subtargets- make install-"- printf "\nexiting...\n"- exit 1- else- echo "Done!"- fi- else- echo "Found!"- fi-}--run_macdeployqt() {- # To avoid errors macdeployqt must be run from bin location- # ext_qt will not build macdeployqt by default so it must be build manually- # cd ${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src- # make sub-macdeployqt-all- # make sub-macdeployqt-install_subtargets- # make install- echo "Running macdeployqt..."- cd ${KIS_INSTALL_DIR}/bin- ./macdeployqt ${KRITA_DMG}/krita.app \- -verbose=0 \- -executable=${KRITA_DMG}/krita.app/Contents/MacOS/krita \- -libpath=${KIS_INSTALL_DIR}/lib \- -qmldir=${KIS_SRC_DIR}/plugins/dockers/textproperties \- -appstore-compliant- # -extra-plugins=${KIS_INSTALL_DIR}/lib/kritaplugins \- # -extra-plugins=${KIS_INSTALL_DIR}/lib/plugins \- # -extra-plugins=${KIS_INSTALL_DIR}/plugins-- cd ${BUILDROOT}- echo "macdeployqt done!"-}--krita_deploy () {- # check for macdeployqt- macdeployqt_exists-- cd ${BUILDROOT}- # Update files in krita.app- echo "Deleting previous kritadmg run..."- rm -rf ./krita.dmg ${KRITA_DMG}- # Copy new builtFiles- echo "Preparing ${KRITA_DMG} for deployment..."-- echo "Copying krita.app..."- mkdir "${KRITA_DMG}"-- rsync -prul ${KIS_INSTALL_DIR}/bin/krita.app ${KRITA_DMG}- cp ${KIS_INSTALL_DIR}/bin/kritarunner ${KRITA_DMG}/krita.app/Contents/MacOS- cp ${KIS_INSTALL_DIR}/bin/krita_version ${KRITA_DMG}/krita.app/Contents/MacOS-- mkdir -p ${KRITA_DMG}/krita.app/Contents/PlugIns- mkdir -p ${KRITA_DMG}/krita.app/Contents/Frameworks-- echo "Copying share..."- # Deletes old copies of translation and qml to be recreated- cd ${KIS_INSTALL_DIR}/share/- rsync -prul --delete ./ \- --exclude krita.icns \- --exclude krita-krz.icns \- --exclude krita-kra.icns \- --exclude Assets.car \- --exclude aclocal \- --exclude doc \- --exclude ECM \- --exclude eigen3 \- --exclude emacs \- --exclude gettext \- --exclude gettext-0.19.8 \- --exclude info \- --exclude kf5 \- --exclude kservices5 \- --exclude man \- --exclude ocio \- --exclude pkgconfig \- --exclude mime \- --exclude translations \- --exclude qml \- ${KRITA_DMG}/krita.app/Contents/Resources--- cd ${BUILDROOT}-- echo "Copying Qt translations..."- rsync -prul ${KIS_INSTALL_DIR}/translations ${KRITA_DMG}/krita.app/Contents/-- cd ${KRITA_DMG}/krita.app/Contents- ln -shF Resources share- ln -shF Frameworks lib-- echo "Copying mandatory libs..."- rsync -priul ${KIS_INSTALL_DIR}/lib/libKF5* ${KIS_INSTALL_DIR}/lib/libkrita* Frameworks/-- echo "Copying plugins..."- local KRITA_DMG_PLUGIN_DIR="${KRITA_DMG}/krita.app/Contents/PlugIns"-- # do not copy excluded files but delete if present in dst- cd ${KIS_INSTALL_DIR}/plugins/- rsync -prul --delete --delete-excluded ./ \- --exclude kritaquicklook.qlgenerator \- --exclude kritaspotlight.mdimporter \- ${KRITA_DMG_PLUGIN_DIR}-- echo "Copying QuickLook plugin..."- mkdir -p ${KRITA_DMG}/krita.app/Contents/Library/QuickLook- rsync -prul ${KIS_INSTALL_DIR}/plugins/kritaquicklook.qlgenerator ${KRITA_DMG}/krita.app/Contents/Library/QuickLook- echo "Copying Spotlight plugin..."- mkdir -p ${KRITA_DMG}/krita.app/Contents/Library/Spotlight- rsync -prul ${KIS_INSTALL_DIR}/plugins/kritaspotlight.mdimporter ${KRITA_DMG}/krita.app/Contents/Library/Spotlight-- # thumbnails for macOS 11.0 and up- echo "Copying Krita Thumbnailing extension..."- rsync -prul ${KIS_INSTALL_DIR}/plugins/krita-thumbnailer.appex ${KRITA_DMG_PLUGIN_DIR}-- echo "Copying Krita Preview extension..."- rsync -prul ${KIS_INSTALL_DIR}/plugins/krita-preview.appex ${KRITA_DMG_PLUGIN_DIR}--- cd ${BUILDROOT}- rsync -prul ${KIS_INSTALL_DIR}/lib/kritaplugins/* ${KRITA_DMG_PLUGIN_DIR}-- rsync -prul ${KIS_INSTALL_DIR}/lib/mlt ${KRITA_DMG_PLUGIN_DIR}-- echo "Adding ffmpeg to bundle"- cd ${KRITA_DMG}/krita.app/Contents/MacOS- for bin in ffmpeg ffprobe; do- cp ${KIS_INSTALL_DIR}/bin/${bin} ./- install_name_tool -add_rpath @executable_path/../Frameworks/ ${bin}- done-- # rsync -prul {KIS_INSTALL_DIR}/lib/libkrita* Frameworks/-- echo "Copying python..."- # Copy this framework last!- # It is best that macdeployqt does not modify Python.framework- # folders with period in name are treated as Frameworks for codesign- rsync -prul ${KIS_INSTALL_DIR}/lib/Python.framework ${KRITA_DMG}/krita.app/Contents/Frameworks/- krita_create_PyKrita-- # change perms on Python to allow header change- chmod +w ${KRITA_DMG}/krita.app/Contents/Frameworks/Python.framework/Python-- fix_python_framework- strip_python_dmginstall-- # fix python pyc- # precompile all pyc so the dont alter signature- echo "Precompiling all python files..."- cd ${KRITA_DMG}/krita.app- ${KIS_INSTALL_DIR}/bin/python -m compileall . &> /dev/null-- # remove unnecessary rpaths- install_name_tool -delete_rpath @executable_path/../lib ${KRITA_DMG}/krita.app/Contents/MacOS/krita_version- install_name_tool -delete_rpath @executable_path/../lib ${KRITA_DMG}/krita.app/Contents/MacOS/kritarunner- install_name_tool -delete_rpath @loader_path/../../../../lib ${KRITA_DMG}/krita.app/Contents/MacOS/krita- rm -rf ${KRITA_DMG}/krita.app/Contents/PlugIns/kf5/org.kde.kwindowsystem.platforms-- # Fix permissions- find "${KRITA_DMG}/krita.app/Contents" -type f -name "*.dylib" -or -name "*.so" -or -path "*/Contents/MacOS/*" | xargs -P4 -I FILE chmod a+x FILE- find "${KRITA_DMG}/krita.app/Contents/Resources/applications" -name "*.desktop" | xargs -P4 -I FILE chmod a-x FILE-- # repair krita for plugins- printf "Searching for missing libraries\n"- krita_findmissinglibs $(find ${KRITA_DMG}/krita.app/Contents -type f -perm 755 -or -name "*.dylib" -or -name "*.so")-- # we delay macdeployqt after searching for libs as it does not follow links correctly- run_macdeployqt-- # Fix rpath for plugins- # Uncomment if the Finder plugins (kritaquicklook, kritaspotlight) lack the rpath below- printf "Repairing rpath for Finder plugins\n"- find "${KRITA_DMG}/krita.app/Contents/Library" -type f -path "*/Contents/MacOS/*" -perm 755 | xargs -I FILE install_name_tool -add_rpath @loader_path/../../../../../Frameworks FILE-- printf "removing absolute or broken linksys, if any\n"- find "${KRITA_DMG}/krita.app/Contents" -type l \( -lname "/*" -or -not -exec test -e {} \; \) -print | xargs rm -v-- printf "clean any left over rpath\n"- libs_clean_rpath $(find "${KRITA_DMG}/krita.app/Contents" -type f -perm 755 -or -name "*.dylib" -or -name "*.so")-# libs_clean_rpath $(find "${KRITA_DMG}/krita.app/Contents/" -type f -name "lib*")-- # remove debug version as both versions can't be signed.- rm ${KRITA_DMG}/krita.app/Contents/Frameworks/QtScript.framework/Versions/Current/QtScript_debug- echo "## Finished preparing krita.app bundle!"--}---# helper to define function only once-batch_codesign() {- local entitlements="${1}"- if [[ -z "${1}" ]]; then- entitlements="${KIS_SRC_DIR}/packaging/macos/entitlements.plist"- fi- xargs -P4 -I FILE codesign --options runtime --timestamp -f -s "${CODE_SIGNATURE}" --entitlements "${entitlements}" FILE-}--# Code sign must be done as recommended by apple "sign code inside out in individual stages"-signBundle() {- # sign Frameworks and libs- cd ${KRITA_DMG}/krita.app/Contents/Frameworks-- # Do not sign binaries inside frameworks except for Python's- find . -type d -path "*.framework" -prune -false -o -perm +111 -not -type d | batch_codesign- find Python.framework -type f -name "*.o" -or -name "*.so" -or -perm +111 -not -type d -not -type l | batch_codesign- find . -type d -name "*.framework" | xargs printf "%s/Versions/Current\n" | batch_codesign-- # Sign all other files in Framework (needed)- # there are many files in python do we need to sign them all?- find krita-python-libs -type f | batch_codesign- # find python -type f | batch_codesign-- # Sign only libraries and plugins- cd ${KRITA_DMG}/krita.app/Contents/PlugIns- find . -type f | batch_codesign-- cd ${KRITA_DMG}/krita.app/Contents/Library/QuickLook- printf "kritaquicklook.qlgenerator" | batch_codesign-- cd ${KRITA_DMG}/krita.app/Contents/Library/Spotlight- printf "kritaspotlight.mdimporter" | batch_codesign-- cd ${KRITA_DMG}/krita.app/Contents/PlugIns- printf "krita-thumbnailer.appex" | batch_codesign- printf "krita-preview.appex" | batch_codesign-- # It is necessary to sign every binary Resource file- cd ${KRITA_DMG}/krita.app/Contents/Resources- find . -perm +111 -type f | batch_codesign-- printf "${KRITA_DMG}/krita.app/Contents/MacOS/ffmpeg" | batch_codesign- printf "${KRITA_DMG}/krita.app/Contents/MacOS/ffprobe" | batch_codesign-- printf "${KRITA_DMG}/krita.app/Contents/MacOS/kritarunner" | batch_codesign- printf "${KRITA_DMG}/krita.app/Contents/MacOS/krita_version" | batch_codesign-- #Finally sign krita and krita.app- printf "${KRITA_DMG}/krita.app/Contents/MacOS/krita" | batch_codesign- printf "${KRITA_DMG}/krita.app" | batch_codesign-}--sign_hasError() {- local CODESIGN_STATUS=0- for f in $(find "${KRITA_DMG}" -type f); do- if [[ -z $(file ${f} | grep "Mach-O") ]]; then- continue- fi-- CODESIGN_RESULT=$(codesign -vvv --strict ${f} 2>&1 | grep "not signed")-- if [[ -n "${CODESIGN_RESULT}" ]]; then- CODESIGN_STATUS=1- printf "${f} not signed\n" >&2- fi- done- echo ${CODESIGN_STATUS}-}--# Notarize build on macOS servers-# based on https://github.com/Beep6581/RawTherapee/blob/6fa533c40b34dec527f1176d47cc6c683422a73f/tools/osx/macosx_bundle.sh#L225-L250-notarize_build() {- local NOT_SRC_DIR=${1}- local NOT_SRC_FILE=${2}-- local notarization_complete="true"-- if [[ ${NOTARIZE} = "true" ]]; then- printf "performing notarization of %s\n" "${2}"- cd "${NOT_SRC_DIR}"-- ditto -c -k --sequesterRsrc --keepParent "${NOT_SRC_FILE}" "${BUILDROOT}/tmp_notarize/${NOT_SRC_FILE}.zip"-- if [[ ${NOTARYTOOL} = "short" ]]; then- xcrun notarytool submit "${BUILDROOT}/tmp_notarize/${NOT_SRC_FILE}.zip" --wait --keychain-profile KritaNotarizeAccount-- elif [[ ${NOTARYTOOL} = "long" ]]; then- xcrun notarytool submit "${BUILDROOT}/tmp_notarize/${NOT_SRC_FILE}.zip" --wait --apple-id "${NOTARIZE_ACC}" --password "${NOTARIZE_PASS}" --team-id "${APPLE_TEAMID}"-- else- # echo "xcrun altool --notarize-app --primary-bundle-id \"org.krita\" --username \"${NOTARIZE_ACC}\" --password \"${NOTARIZE_PASS}\" --file \"${BUILDROOT}/tmp_notarize/${NOT_SRC_FILE}.zip\""- local altoolResponse="$(xcrun altool --notarize-app --primary-bundle-id "org.krita" --username "${NOTARIZE_ACC}" --password "${NOTARIZE_PASS}" ${ASC_PROVIDER_OP} --file "${BUILDROOT}/tmp_notarize/${NOT_SRC_FILE}.zip" 2>&1)"-- if [[ -n "$(grep 'Error' <<< ${altoolResponse})" ]]; then- printf "ERROR: xcrun altool exited with the following error! \n\n%s\n\n" "${altoolResponse}"- printf "This could mean there is an error in AppleID authentication!\n"- printf "aborting notarization\n"- NOTARIZE="false"- return- else- printf "Response:\n\n%s\n\n" "${altoolResponse}"- fi-- local uuid="$(grep 'RequestUUID' <<< ${altoolResponse} | awk '{ print $NF }')"- echo "RequestUUID = ${uuid}" # Display identifier string-- waiting_fixed "Waiting to retrieve notarize status" 120-- while true ; do- fullstatus=$(xcrun altool --notarization-info "${uuid}" --username "${NOTARIZE_ACC}" --password "${NOTARIZE_PASS}" ${ASC_PROVIDER_OP} 2>&1) # get the status- notarize_status=`echo "${fullstatus}" | grep 'Status\:' | awk '{ print $2 }'`- echo "${fullstatus}"- if [[ "${notarize_status}" = "success" ]]; then- print_msg "Notarization success!"- break- elif [[ "${notarize_status}" = "in" ]]; then- waiting_fixed "Notarization still in progress, wait before checking again" 60- else- notarization_complete="false"- echo "Notarization failed! full status below"- echo "${fullstatus}"- exit 1- fi- done- fi-- if [[ "${notarization_complete}" = "true" ]]; then- xcrun stapler staple "${NOT_SRC_FILE}" #staple the ticket- xcrun stapler validate -v "${NOT_SRC_FILE}"- fi- fi-}--createDMG () {- printf "Creating of dmg with contents of %s...\n" "${KRITA_DMG}"- cd ${BUILDROOT}- DMG_size=1500-- if [[ -z "${DMG_NAME}" ]]; then- # Add git version number- DMG_NAME="krita-${KRITA_VERSION}.dmg"- else- DMG_NAME="${DMG_NAME}.dmg"- fi-- ## Build dmg from folder-- # create dmg on local system- # usage of -fsargs minimize gaps at front of filesystem (reduce size)- hdiutil create -srcfolder "${KRITA_DMG}" -volname "${DMG_title}" -fs APFS \- -format UDIF -verbose -size ${DMG_size}m krita.temp.dmg-- # Next line is only useful if we have a dmg as a template!- # previous hdiutil must be uncommented- # cp krita-template.dmg krita.dmg- device=$(hdiutil attach -readwrite -noverify -noautoopen "krita.temp.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}')-- # rsync -priul --delete ${KRITA_DMG}/krita.app "/Volumes/${DMG_title}"-- # Set style for dmg- if [[ ! -d "/Volumes/${DMG_title}/.background" ]]; then- mkdir "/Volumes/${DMG_title}/.background"- fi- cp -v ${DMG_background} "/Volumes/${DMG_title}/.background/"-- mkdir "/Volumes/${DMG_title}/Terms of Use"- cp -v "${KIS_SRC_DIR}/packaging/macos/Terms_of_use.rtf" "/Volumes/${DMG_title}/Terms of Use/"- ln -s "/Applications" "/Volumes/${DMG_title}/Applications"-- #Set Icon for DMG- cp -v "${KIS_SRC_DIR}/packaging/macos/KritaIcon.icns" "/Volumes/${DMG_title}/.VolumeIcon.icns"- SetFile -a C "/Volumes/${DMG_title}"-- ## Apple script to set style- style="$(<"${DMG_STYLE}")"- printf "${style}" "${DMG_title}" "${DMG_background##*/}" | osascript-- chmod -Rf go-w "/Volumes/${DMG_title}"- # ensure all writing operations to dmg are over- sync-- hdiutil detach $device- hdiutil convert "krita.temp.dmg" -format UDZO -imagekey -zlib-level=9 -o krita-out.dmg--- mv krita-out.dmg ${DMG_NAME}- echo "moved krita-out.dmg to ${DMG_NAME}"- rm krita.temp.dmg-- if [[ -n "${CODE_SIGNATURE}" ]]; then- printf "${DMG_NAME}" | batch_codesign- fi-- # notarize_build "${BUILDROOT}" "${DMG_NAME}"-- if [[ ! -d "${BUILDROOT}/_packaging" ]]; then- mkdir "${BUILDROOT}/_packaging"- fi-- mv ${DMG_NAME} ${BUILDROOT}/_packaging/-- echo "dmg done!"-}--#######################-# Program starts!!-########################-# Run deploy command, installation is assumed to exist in BUILDROOT/i-if [[ -z "${ONLY_DMG}" ]]; then- krita_deploy-fi--# # Code sign krita.app if signature given-# if [[ -n "${CODE_SIGNATURE}" ]]; then-# signBundle-# fi--# # Manually check every single Mach-O file for signature status-# if [[ "${NOTARIZE}" = "true" ]]; then-# print_msg "Checking if all files are signed before sending for notarization..."-# if [[ $(sign_hasError) -eq 1 ]]; then-# print_error "CodeSign errors cannot send to notarize!"-# echo "krita.app not sent to notarization, stopping...."-# exit 1-# fi-# print_msg "Done! all files appear to be correct."--# # notarize apple-# notarize_build "${KRITA_DMG}" krita.app-# fi--# Create DMG from files inside ${KRITA_DMG} folder-if [[ -z "${ONLY_APP}" ]]; then- createDMG-fi--# if [[ "${NOTARIZE}" = "false" ]]; then-# macosVersion="$(sw_vers | grep ProductVersion | awk '-# BEGIN { FS = "[ .\t]" }-# { print $3}-# ')"-# if (( ${macosVersion} == 15 )); then-# print_error "Build not notarized! Needed for macOS versions above 10.14"-# fi-# fi