mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-17 17:56:33 +00:00
Add --beta option
This commit is contained in:
parent
57dd500dec
commit
620038efc4
@ -485,12 +485,12 @@ def os_installer_product_info(catalog, workdir, ignore_cache=False):
|
|||||||
return product_info
|
return product_info
|
||||||
|
|
||||||
|
|
||||||
def get_lowest_version(current_item, lowest_item):
|
def get_latest_version(current_item, latest_item):
|
||||||
'''Compares versions between two values and returns the lowest value'''
|
'''Compares versions between two values and returns the latest (highest) value'''
|
||||||
if LooseVersion(current_item) < LooseVersion(lowest_item):
|
if LooseVersion(current_item) > LooseVersion(latest_item):
|
||||||
return current_item
|
return current_item
|
||||||
else:
|
else:
|
||||||
return lowest_item
|
return latest_item
|
||||||
|
|
||||||
|
|
||||||
def replicate_product(catalog, product_id, workdir, ignore_cache=False):
|
def replicate_product(catalog, product_id, workdir, ignore_cache=False):
|
||||||
@ -580,13 +580,16 @@ def main():
|
|||||||
parser.add_argument('--auto', action='store_true',
|
parser.add_argument('--auto', action='store_true',
|
||||||
help='Automatically select the appropriate valid build '
|
help='Automatically select the appropriate valid build '
|
||||||
'for the current device.')
|
'for the current device.')
|
||||||
|
parser.add_argument('--beta', action='store_true',
|
||||||
|
help='Include beta versions in the selection '
|
||||||
|
'(in conjunction with --auto, --os or --version)')
|
||||||
parser.add_argument('--version', metavar='match_version',
|
parser.add_argument('--version', metavar='match_version',
|
||||||
default='',
|
default='',
|
||||||
help='Selects the lowest valid build ID matching '
|
help='Selects the latest valid build ID matching '
|
||||||
'the selected version (e.g. 10.14.3).')
|
'the selected version (e.g. 10.14.3).')
|
||||||
parser.add_argument('--os', metavar='match_os',
|
parser.add_argument('--os', metavar='match_os',
|
||||||
default='',
|
default='',
|
||||||
help='Selects the lowest valid build ID matching '
|
help='Selects the latest valid build ID matching '
|
||||||
'the selected OS version (e.g. 10.14).')
|
'the selected OS version (e.g. 10.14).')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -647,7 +650,7 @@ def main():
|
|||||||
not_valid = 'Unsupported Model Identifier'
|
not_valid = 'Unsupported Model Identifier'
|
||||||
elif board_id not in product_info[product_id]['BoardIDs'] and is_vm == False:
|
elif board_id not in product_info[product_id]['BoardIDs'] and is_vm == False:
|
||||||
not_valid = 'Unsupported Board ID'
|
not_valid = 'Unsupported Board ID'
|
||||||
elif get_lowest_version(build_info[0],product_info[product_id]['version']) != build_info[0]:
|
elif get_latest_version(build_info[0],product_info[product_id]['version']) != build_info[0]:
|
||||||
not_valid = 'Unsupported macOS version'
|
not_valid = 'Unsupported macOS version'
|
||||||
else:
|
else:
|
||||||
valid_build_found = True
|
valid_build_found = True
|
||||||
@ -680,20 +683,21 @@ def main():
|
|||||||
if args.os != os_version:
|
if args.os != os_version:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# determine the lowest valid build ID and select this
|
# determine the latest valid build ID and select this
|
||||||
# when using auto and version options
|
# when using auto and version options
|
||||||
if (args.auto or args.version or args.os) and 'Beta' not in product_info[product_id]['title']:
|
if (args.auto or args.version or args.os):
|
||||||
try:
|
if (args.beta or 'Beta' not in product_info[product_id]['title']):
|
||||||
lowest_valid_build
|
try:
|
||||||
except NameError:
|
latest_valid_build
|
||||||
lowest_valid_build = product_info[product_id]['BUILD']
|
except NameError:
|
||||||
answer = index+1
|
latest_valid_build = product_info[product_id]['BUILD']
|
||||||
else:
|
|
||||||
lowest_valid_build = get_lowest_version(
|
|
||||||
product_info[product_id]['BUILD'],
|
|
||||||
lowest_valid_build)
|
|
||||||
if lowest_valid_build == product_info[product_id]['BUILD']:
|
|
||||||
answer = index+1
|
answer = index+1
|
||||||
|
else:
|
||||||
|
latest_valid_build = get_latest_version(
|
||||||
|
product_info[product_id]['BUILD'],
|
||||||
|
latest_valid_build)
|
||||||
|
if latest_valid_build == product_info[product_id]['BUILD']:
|
||||||
|
answer = index+1
|
||||||
|
|
||||||
# Write this build info to plist
|
# Write this build info to plist
|
||||||
pl_index = {'index': index+1,
|
pl_index = {'index': index+1,
|
||||||
@ -768,7 +772,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print('\n'
|
print('\n'
|
||||||
'Build %s selected. Downloading #%s...\n'
|
'Build %s selected. Downloading #%s...\n'
|
||||||
% (lowest_valid_build, answer))
|
% (latest_valid_build, answer))
|
||||||
elif args.os:
|
elif args.os:
|
||||||
try:
|
try:
|
||||||
answer
|
answer
|
||||||
@ -781,7 +785,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print('\n'
|
print('\n'
|
||||||
'Build %s selected. Downloading #%s...\n'
|
'Build %s selected. Downloading #%s...\n'
|
||||||
% (lowest_valid_build, answer))
|
% (latest_valid_build, answer))
|
||||||
elif args.auto:
|
elif args.auto:
|
||||||
try:
|
try:
|
||||||
answer
|
answer
|
||||||
@ -794,7 +798,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print('\n'
|
print('\n'
|
||||||
'Build %s selected. Downloading #%s...\n'
|
'Build %s selected. Downloading #%s...\n'
|
||||||
% (lowest_valid_build, answer))
|
% (latest_valid_build, answer))
|
||||||
else:
|
else:
|
||||||
# default option to interactively offer selection
|
# default option to interactively offer selection
|
||||||
answer = get_input(
|
answer = get_input(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user