Skip to content

Commit ebd27a0

Browse files
committed
Fix to add SeedProgram extended attribute to the install application if --seedprogram option is used
1 parent 9d9bb51 commit ebd27a0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

installinstallmacos.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_input(prompt=None):
6969
return input(prompt)
7070

7171

72-
def readPlist(filepath):
72+
def read_plist(filepath):
7373
'''Wrapper for the differences between Python 2 and Python 3's plistlib'''
7474
try:
7575
with open(filepath, "rb") as fileobj:
@@ -79,10 +79,10 @@ def readPlist(filepath):
7979
return plistlib.readPlist(filepath)
8080

8181

82-
def readPlistFromString(bytestring):
82+
def read_plist_from_string(bytestring):
8383
'''Wrapper for the differences between Python 2 and Python 3's plistlib'''
8484
try:
85-
return plistlib.loads(bytestring)
85+
return plistlib.loads(bytestring)
8686
except AttributeError:
8787
# plistlib module doesn't have a load function (as in Python 2)
8888
return plistlib.readPlistFromString(bytestring)
@@ -91,7 +91,7 @@ def readPlistFromString(bytestring):
9191
def get_seeding_program(sucatalog_url):
9292
'''Returns a seeding program name based on the sucatalog_url'''
9393
try:
94-
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
94+
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
9595
for key, value in seed_catalogs.items():
9696
if sucatalog_url == value:
9797
return key
@@ -103,7 +103,7 @@ def get_seeding_program(sucatalog_url):
103103
def get_seed_catalog(seedname='DeveloperSeed'):
104104
'''Returns the developer seed sucatalog'''
105105
try:
106-
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
106+
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
107107
return seed_catalogs.get(seedname)
108108
except (OSError, ExpatError, AttributeError, KeyError):
109109
return ''
@@ -112,7 +112,7 @@ def get_seed_catalog(seedname='DeveloperSeed'):
112112
def get_seeding_programs():
113113
'''Returns the list of seeding program names'''
114114
try:
115-
seed_catalogs = readPlist(SEED_CATALOGS_PLIST)
115+
seed_catalogs = read_plist(SEED_CATALOGS_PLIST)
116116
return list(seed_catalogs.keys())
117117
except (OSError, ExpatError, AttributeError, KeyError):
118118
return ''
@@ -134,7 +134,7 @@ def make_sparse_image(volume_name, output_path):
134134
print(err, file=sys.stderr)
135135
exit(-1)
136136
try:
137-
return readPlistFromString(output)[0]
137+
return read_plist_from_string(output)[0]
138138
except IndexError as err:
139139
print('Unexpected output from hdiutil: %s' % output, file=sys.stderr)
140140
exit(-1)
@@ -177,7 +177,7 @@ def mountdmg(dmgpath):
177177
file=sys.stderr)
178178
return None
179179
if pliststr:
180-
plist = readPlistFromString(pliststr)
180+
plist = read_plist_from_string(pliststr)
181181
for entity in plist['system-entities']:
182182
if 'mount-point' in entity:
183183
mountpoints.append(entity['mount-point'])
@@ -258,7 +258,7 @@ def parse_server_metadata(filename):
258258
title = ''
259259
vers = ''
260260
try:
261-
md_plist = readPlist(filename)
261+
md_plist = read_plist(filename)
262262
except (OSError, IOError, ExpatError) as err:
263263
print('Error reading %s: %s' % (filename, err), file=sys.stderr)
264264
return {}
@@ -342,15 +342,15 @@ def download_and_parse_sucatalog(sucatalog, workdir, ignore_cache=False):
342342
with gzip.open(localcatalogpath) as the_file:
343343
content = the_file.read()
344344
try:
345-
catalog = readPlistFromString(content)
345+
catalog = read_plist_from_string(content)
346346
return catalog
347347
except ExpatError as err:
348348
print('Error reading %s: %s' % (localcatalogpath, err),
349349
file=sys.stderr)
350350
exit(-1)
351351
else:
352352
try:
353-
catalog = readPlist(localcatalogpath)
353+
catalog = read_plist(localcatalogpath)
354354
return catalog
355355
except (OSError, IOError, ExpatError) as err:
356356
print('Error reading %s: %s' % (localcatalogpath, err),
@@ -546,10 +546,12 @@ def main():
546546
unmountdmg(mountpoint)
547547
exit(-1)
548548
# add the seeding program xattr to the app if applicable
549-
seeding_program = get_seeding_program(args.catalogurl)
549+
seeding_program = get_seeding_program(su_catalog_url)
550550
if seeding_program:
551551
installer_app = find_installer_app(mountpoint)
552552
if installer_app:
553+
print("Adding seeding program %s extended attribute to app"
554+
% seeding_program)
553555
xattr.setxattr(installer_app, 'SeedProgram', seeding_program)
554556
print('Product downloaded and installed to %s' % sparse_diskimage_path)
555557
if args.raw:

0 commit comments

Comments
 (0)