From 9e23a98894a22a6406d36c9025ac73759ccffae8 Mon Sep 17 00:00:00 2001 From: sickcodes <65906298+sickcodes@users.noreply.github.com> Date: Tue, 2 Nov 2021 03:15:52 +0000 Subject: [PATCH] Enable fetch-macOS-v2.py to run in unattended mode (via shortnames) --- Makefile | 3 ++- fetch-macOS-v2.py | 38 ++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index ad64cb0..efbe439 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +# export SHORTNAME=monterey DISK_SIZE := 128G all: BaseSystem.img mac_hdd_ng.img @@ -6,7 +7,7 @@ BaseSystem.img: BaseSystem.dmg qemu-img convert BaseSystem.dmg -O raw BaseSystem.img BaseSystem.dmg: - ./fetch-macOS-v2.py + ./fetch-macOS-v2.py --short=$(SHORTNAME) mac_hdd_ng.img: qemu-img create -f qcow2 mac_hdd_ng.img ${DISK_SIZE} diff --git a/fetch-macOS-v2.py b/fetch-macOS-v2.py index ae395d8..a8a16e0 100755 --- a/fetch-macOS-v2.py +++ b/fetch-macOS-v2.py @@ -433,6 +433,8 @@ def main(): parser.add_argument('-os', '--os-type', type=str, default='default', choices=['default', 'latest'], help='use specified os type, defaults to default ' + MLB_ZERO) parser.add_argument('-diag', '--diagnostics', action='store_true', help='download diagnostics image') + parser.add_argument('-s', '--shortname', type=str, default='', + help='available options: high-sierra, mojave, catalina, big-sur, monterey') parser.add_argument('-v', '--verbose', action='store_true', help='print debug information') parser.add_argument('-db', '--board-db', type=str, default=os.path.join(SELF_DIR, 'boards.json'), help='use custom board list for checking, defaults to boards.json') @@ -458,27 +460,39 @@ def main(): # No action specified, so present a download menu instead # https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/macrecovery/boards.json products = [ - {"name": "High Sierra (10.13)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000J80300"}, - {"name": "Mojave (10.14)", "b": "Mac-7BA5B2DFE22DDD8C", "m": "00000000000KXPG00"}, - {"name": "Catalina (10.15)", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000"}, - {"name": "Big Sur (11.6) - RECOMMENDED", "b": "Mac-2BD1B31983FE1663", "m": "00000000000000000"}, - {"name": "Monterey (latest)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000000000", "os_type": "latest"} + {"name": "High Sierra (10.13)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000J80300", "short": "high-sierra"}, + {"name": "Mojave (10.14)", "b": "Mac-7BA5B2DFE22DDD8C", "m": "00000000000KXPG00", "short": "mojave"}, + {"name": "Catalina (10.15)", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000", "short": "catalina"}, + {"name": "Big Sur (11.6) - RECOMMENDED", "b": "Mac-2BD1B31983FE1663", "m": "00000000000000000", "short": "big-sur"}, + {"name": "Monterey (latest)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000000000", "os_type": "latest", "short": "monterey"} ] for index, product in enumerate(products): name = product["name"] print('%s. %12s' % (index + 1, name)) - answer = input('\nChoose a product to download (1-%s): ' % len(products)) - try: - index = int(answer) - 1 - if index < 0: - raise ValueError - except (ValueError, IndexError): - pass + # test locally using args.shortname = 'mojave' + if not args.shortname or args.shortname == '': + answer = input('\nChoose a product to download (1-%s): ' % len(products)) + try: + index = int(answer) - 1 + if index < 0: + raise ValueError + except (ValueError, IndexError): + pass + else: + index = 0 + for product in products: + if args.shortname == product['short']: + break + else: + index = index+1 + + # action product = products[index] + print(product['name']) try: os_type = product["os_type"] except: