mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-18 02:06:26 +00:00
--list outputs to softwareupdate.plist, --build exits if no match found.
This commit is contained in:
parent
33ec252d47
commit
309678921f
@ -326,7 +326,6 @@ def replicate_product(catalog, product_id, workdir, ignore_cache=False):
|
|||||||
% (package['MetadataURL'], err))
|
% (package['MetadataURL'], err))
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
'''Do the main thing here'''
|
'''Do the main thing here'''
|
||||||
|
|
||||||
@ -352,8 +351,9 @@ def main():
|
|||||||
default='',
|
default='',
|
||||||
help='Specify a specific build to search for and '
|
help='Specify a specific build to search for and '
|
||||||
'download.')
|
'download.')
|
||||||
parser.add_argument('--displayonly', action='store_true',
|
parser.add_argument('--list', action='store_true',
|
||||||
help='Output the available updates and quit.')
|
help='Output the available updates to a plist '
|
||||||
|
'and quit.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# download sucatalog and look for products that are for macOS installers
|
# download sucatalog and look for products that are for macOS installers
|
||||||
@ -367,7 +367,9 @@ def main():
|
|||||||
'No macOS installer products found in the sucatalog.')
|
'No macOS installer products found in the sucatalog.')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
output_plist = "%s/softwareupdate.plist" % args.workdir
|
||||||
|
pl = {}
|
||||||
|
pl['result'] = []
|
||||||
|
|
||||||
# display a menu of choices (some seed catalogs have multiple installers)
|
# display a menu of choices (some seed catalogs have multiple installers)
|
||||||
print '%2s %12s %10s %8s %s' % ('#', 'ProductID', 'Version',
|
print '%2s %12s %10s %8s %s' % ('#', 'ProductID', 'Version',
|
||||||
@ -379,30 +381,47 @@ def main():
|
|||||||
product_info[product_id]['BUILD'],
|
product_info[product_id]['BUILD'],
|
||||||
product_info[product_id]['title'])
|
product_info[product_id]['title'])
|
||||||
|
|
||||||
# Quit now if displaynonly argument supplied
|
pl_index = {'index': index+1,
|
||||||
if args.displayonly:
|
'product_id': product_id,
|
||||||
|
'version': product_info[product_id]['version'],
|
||||||
|
'build': product_info[product_id]['BUILD'],
|
||||||
|
'title': product_info[product_id]['title'],
|
||||||
|
}
|
||||||
|
|
||||||
|
pl['result'].append(pl_index)
|
||||||
|
|
||||||
|
if args.build:
|
||||||
|
if args.build == product_info[product_id]['BUILD']:
|
||||||
|
answer = index+1
|
||||||
|
|
||||||
|
|
||||||
|
# Output a plist of available updates and quit if --list option chosen
|
||||||
|
if args.list:
|
||||||
|
plistlib.writePlist(pl, output_plist)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# check for specified build if argument supplied
|
# check for specified build if argument supplied
|
||||||
if args.build:
|
if args.build:
|
||||||
for index, product_id in enumerate(product_info):
|
try:
|
||||||
if args.build == product_info[product_id]['BUILD']:
|
answer
|
||||||
answer = index+1
|
except NameError:
|
||||||
print '# %s chosen.' % answer
|
print ('No valid build chosen. Run again without --build argument'
|
||||||
|
'to select a valid build to download.')
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
print '# %s chosen.' % answer
|
||||||
|
else:
|
||||||
|
answer = raw_input(
|
||||||
|
'\nChoose a product to download (1-%s): ' % len(product_info))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
answer
|
index = int(answer) - 1
|
||||||
except NameError:
|
if index < 0:
|
||||||
answer = raw_input(
|
raise ValueError
|
||||||
'\nChoose a product to download (1-%s): ' % len(product_info))
|
product_id = product_info.keys()[index]
|
||||||
try:
|
except (ValueError, IndexError):
|
||||||
index = int(answer) - 1
|
print 'Exiting.'
|
||||||
if index < 0:
|
exit(0)
|
||||||
raise ValueError
|
|
||||||
product_id = product_info.keys()[index]
|
|
||||||
except (ValueError, IndexError):
|
|
||||||
print 'Exiting.'
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
# download all the packages for the selected product
|
# download all the packages for the selected product
|
||||||
replicate_product(
|
replicate_product(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user