mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-17 17:56:33 +00:00
Fix to add SeedProgram extended attribute to the install application if --seedprogram option is used
This commit is contained in:
parent
9d9bb51ab1
commit
ebd27a06c2
@ -69,7 +69,7 @@ def get_input(prompt=None):
|
||||
return input(prompt)
|
||||
|
||||
|
||||
def readPlist(filepath):
|
||||
def read_plist(filepath):
|
||||
'''Wrapper for the differences between Python 2 and Python 3's plistlib'''
|
||||
try:
|
||||
with open(filepath, "rb") as fileobj:
|
||||
@ -79,10 +79,10 @@ def readPlist(filepath):
|
||||
return plistlib.readPlist(filepath)
|
||||
|
||||
|
||||
def readPlistFromString(bytestring):
|
||||
def read_plist_from_string(bytestring):
|
||||
'''Wrapper for the differences between Python 2 and Python 3's plistlib'''
|
||||
try:
|
||||
return plistlib.loads(bytestring)
|
||||
return plistlib.loads(bytestring)
|
||||
except AttributeError:
|
||||
# plistlib module doesn't have a load function (as in Python 2)
|
||||
return plistlib.readPlistFromString(bytestring)
|
||||
@ -91,7 +91,7 @@ def readPlistFromString(bytestring):
|
||||
def get_seeding_program(sucatalog_url):
|
||||
'''Returns a seeding program name based on the sucatalog_url'''
|
||||
try:
|
||||
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
|
||||
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
|
||||
for key, value in seed_catalogs.items():
|
||||
if sucatalog_url == value:
|
||||
return key
|
||||
@ -103,7 +103,7 @@ def get_seeding_program(sucatalog_url):
|
||||
def get_seed_catalog(seedname='DeveloperSeed'):
|
||||
'''Returns the developer seed sucatalog'''
|
||||
try:
|
||||
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
|
||||
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
|
||||
return seed_catalogs.get(seedname)
|
||||
except (OSError, ExpatError, AttributeError, KeyError):
|
||||
return ''
|
||||
@ -112,7 +112,7 @@ def get_seed_catalog(seedname='DeveloperSeed'):
|
||||
def get_seeding_programs():
|
||||
'''Returns the list of seeding program names'''
|
||||
try:
|
||||
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
|
||||
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
|
||||
return list(seed_catalogs.keys())
|
||||
except (OSError, ExpatError, AttributeError, KeyError):
|
||||
return ''
|
||||
@ -134,7 +134,7 @@ def make_sparse_image(volume_name, output_path):
|
||||
print(err, file=sys.stderr)
|
||||
exit(-1)
|
||||
try:
|
||||
return readPlistFromString(output)[0]
|
||||
return read_plist_from_string(output)[0]
|
||||
except IndexError as err:
|
||||
print('Unexpected output from hdiutil: %s' % output, file=sys.stderr)
|
||||
exit(-1)
|
||||
@ -177,7 +177,7 @@ def mountdmg(dmgpath):
|
||||
file=sys.stderr)
|
||||
return None
|
||||
if pliststr:
|
||||
plist = readPlistFromString(pliststr)
|
||||
plist = read_plist_from_string(pliststr)
|
||||
for entity in plist['system-entities']:
|
||||
if 'mount-point' in entity:
|
||||
mountpoints.append(entity['mount-point'])
|
||||
@ -258,7 +258,7 @@ def parse_server_metadata(filename):
|
||||
title = ''
|
||||
vers = ''
|
||||
try:
|
||||
md_plist = readPlist(filename)
|
||||
md_plist = read_plist(filename)
|
||||
except (OSError, IOError, ExpatError) as err:
|
||||
print('Error reading %s: %s' % (filename, err), file=sys.stderr)
|
||||
return {}
|
||||
@ -342,7 +342,7 @@ def download_and_parse_sucatalog(sucatalog, workdir, ignore_cache=False):
|
||||
with gzip.open(localcatalogpath) as the_file:
|
||||
content = the_file.read()
|
||||
try:
|
||||
catalog = readPlistFromString(content)
|
||||
catalog = read_plist_from_string(content)
|
||||
return catalog
|
||||
except ExpatError as err:
|
||||
print('Error reading %s: %s' % (localcatalogpath, err),
|
||||
@ -350,7 +350,7 @@ def download_and_parse_sucatalog(sucatalog, workdir, ignore_cache=False):
|
||||
exit(-1)
|
||||
else:
|
||||
try:
|
||||
catalog = readPlist(localcatalogpath)
|
||||
catalog = read_plist(localcatalogpath)
|
||||
return catalog
|
||||
except (OSError, IOError, ExpatError) as err:
|
||||
print('Error reading %s: %s' % (localcatalogpath, err),
|
||||
@ -546,10 +546,12 @@ def main():
|
||||
unmountdmg(mountpoint)
|
||||
exit(-1)
|
||||
# add the seeding program xattr to the app if applicable
|
||||
seeding_program = get_seeding_program(args.catalogurl)
|
||||
seeding_program = get_seeding_program(su_catalog_url)
|
||||
if seeding_program:
|
||||
installer_app = find_installer_app(mountpoint)
|
||||
if installer_app:
|
||||
print("Adding seeding program %s extended attribute to app"
|
||||
% seeding_program)
|
||||
xattr.setxattr(installer_app, 'SeedProgram', seeding_program)
|
||||
print('Product downloaded and installed to %s' % sparse_diskimage_path)
|
||||
if args.raw:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user