From 66331c6b5a2851c979788cf29f54afd1d9aa00d3 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Wed, 31 Jul 2019 15:12:58 -0700 Subject: [PATCH 1/5] Work around a very dumb Apple bug in a package postinstall script. --- installinstallmacos.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/installinstallmacos.py b/installinstallmacos.py index 9d72b41..6ab7740 100755 --- a/installinstallmacos.py +++ b/installinstallmacos.py @@ -209,11 +209,28 @@ def install_product(dist_path, target_vol): cmd = ['/usr/sbin/installer', '-pkg', dist_path, '-target', target_vol] try: subprocess.check_call(cmd) - return True except subprocess.CalledProcessError as err: print(err, file=sys.stderr) return False - + else: + # Apple postinstall script bug ends up copying files to a path like + # /tmp/dmg.T9ak1HApplications + path = target_vol + 'Applications' + if os.path.exists(path): + print('*********************************************************') + print('*** Working around a very dumb Apple bug in a package ***') + print('*** postinstall script that fails to correctly target ***') + print('*** the Install macOS.app when installed to a volume ***') + print('*** other than the current boot volume. ***') + print('*** Please file feedback with Apple! ***') + print('*********************************************************') + subprocess.check_call( + ['/usr/bin/ditto', + path, + os.path.join(target_vol, 'Applications')] + ) + subprocess.check_call(['/bin/rm', '-r', path]) + return True class ReplicationError(Exception): '''A custom error when replication fails''' From 21dfc7551976bd3fa5cae622fc7fadb36e1dd093 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Wed, 7 Aug 2019 16:00:34 -0700 Subject: [PATCH 2/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4dd575c..022ea90 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Product installation failed. Use a compatible Mac or select a different build compatible with your current hardware and try again. You may also have success running the script in a VM; the InstallationCheck script in versions of the macOS installer to date skips the checks (and returns success) when run on a VM. +Graham Pugh has a fork with a lot more features and bells and whistles. Check it out if your needs aren't met by this tool. https://github.com/grahampugh/macadmin-scripts + #### make_firmwareupdater_pkg.sh This script was used to extract the firmware updaters from early High Sierra installers and make a standalone installer package that could be used to upgrade Mac firmware before installing High Sierra via imaging. From d573b4223211ec5c85a7dac843175fab0111d809 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Wed, 7 Aug 2019 16:02:51 -0700 Subject: [PATCH 3/5] Update README.md --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 022ea90..157199f 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,6 @@ Some scripts that might be of use to macOS admins. Might be related to Munki; might not. -#### createbootvolfromautonbi.py - -A tool to make bootable disk volumes from the output of autonbi. Especially -useful to make bootable disks containing Imagr and the 'SIP-ignoring' kernel, -which allows Imagr to run scripts that affect SIP state, set UAKEL options, and -run the `startosinstall` component, all of which might otherwise require network -booting from a NetInstall-style nbi. - -This provides a way to create a bootable external disk that acts like the Netboot environment used by/needed by Imagr. - -This command converts the output of Imagr's `make nbi` into a bootable external USB disk: -`sudo ./createbootvolfromautonbi.py --nbi ~/Desktop/10.13.6_Imagr.nbi --volume /Volumes/ExternalDisk` - #### installinstallmacos.py This script can create disk images containing macOS Installer applications available via Apple's softwareupdate catalogs. @@ -45,6 +32,22 @@ Use a compatible Mac or select a different build compatible with your current ha Graham Pugh has a fork with a lot more features and bells and whistles. Check it out if your needs aren't met by this tool. https://github.com/grahampugh/macadmin-scripts +#### createbootvolfromautonbi.py + +(This tool has not been tested/updated since before 10.14 shipped. It may not work as expected with current versions of macOS. There are currently no plans to update it.) + +A tool to make bootable disk volumes from the output of autonbi. Especially +useful to make bootable disks containing Imagr and the 'SIP-ignoring' kernel, +which allows Imagr to run scripts that affect SIP state, set UAKEL options, and +run the `startosinstall` component, all of which might otherwise require network +booting from a NetInstall-style nbi. + +This provides a way to create a bootable external disk that acts like the Netboot environment used by/needed by Imagr. + +This command converts the output of Imagr's `make nbi` into a bootable external USB disk: +`sudo ./createbootvolfromautonbi.py --nbi ~/Desktop/10.13.6_Imagr.nbi --volume /Volumes/ExternalDisk` + + #### make_firmwareupdater_pkg.sh This script was used to extract the firmware updaters from early High Sierra installers and make a standalone installer package that could be used to upgrade Mac firmware before installing High Sierra via imaging. From 7d1df62482c756414b85fbd971b7ce4ac6e741c9 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Sun, 18 Aug 2019 09:00:18 -0700 Subject: [PATCH 4/5] In os_installer_product_info better handle the failure to find a server metadata file for a macos product --- installinstallmacos.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/installinstallmacos.py b/installinstallmacos.py index 6ab7740..0983905 100755 --- a/installinstallmacos.py +++ b/installinstallmacos.py @@ -399,21 +399,22 @@ def os_installer_product_info(catalog, workdir, ignore_cache=False): for product_key in installer_products: product_info[product_key] = {} filename = get_server_metadata(catalog, product_key, workdir) - product_info[product_key] = parse_server_metadata(filename) - product = catalog['Products'][product_key] - product_info[product_key]['PostDate'] = product['PostDate'] - distributions = product['Distributions'] - dist_url = distributions.get('English') or distributions.get('en') - try: - dist_path = replicate_url( - dist_url, root_dir=workdir, ignore_cache=ignore_cache) - except ReplicationError as err: - print('Could not replicate %s: %s' % (dist_url, err), - file=sys.stderr) - else: - dist_info = parse_dist(dist_path) - product_info[product_key]['DistributionPath'] = dist_path - product_info[product_key].update(dist_info) + if filename: + product_info[product_key] = parse_server_metadata(filename) + product = catalog['Products'][product_key] + product_info[product_key]['PostDate'] = product['PostDate'] + distributions = product['Distributions'] + dist_url = distributions.get('English') or distributions.get('en') + try: + dist_path = replicate_url( + dist_url, root_dir=workdir, ignore_cache=ignore_cache) + except ReplicationError as err: + print('Could not replicate %s: %s' % (dist_url, err), + file=sys.stderr) + else: + dist_info = parse_dist(dist_path) + product_info[product_key]['DistributionPath'] = dist_path + product_info[product_key].update(dist_info) return product_info From c9846e8984318bb68999894c2a77c304001989f7 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Fri, 27 Sep 2019 15:37:13 -0700 Subject: [PATCH 5/5] Add Catalina sucatalog --- installinstallmacos.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/installinstallmacos.py b/installinstallmacos.py index 0983905..8888068 100755 --- a/installinstallmacos.py +++ b/installinstallmacos.py @@ -51,9 +51,11 @@ DEFAULT_SUCATALOGS = { '18': 'https://swscan.apple.com/content/catalogs/others/' 'index-10.14-10.13-10.12-10.11-10.10-10.9' '-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog', + '19': 'https://swscan.apple.com/content/catalogs/others/' + 'index-10.15-10.14-10.13-10.12-10.11-10.10-10.9' + '-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog', } - SEED_CATALOGS_PLIST = ( '/System/Library/PrivateFrameworks/Seeding.framework/Versions/Current/' 'Resources/SeedCatalogs.plist'