mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-18 10:16:37 +00:00
Better handle the case where installing the Install macOS distribution fails.
This commit is contained in:
parent
08edce08e7
commit
50ecea40cf
@ -119,12 +119,15 @@ def unmountdmg(mountpoint):
|
|||||||
|
|
||||||
|
|
||||||
def install_product(dist_path, target_vol):
|
def install_product(dist_path, target_vol):
|
||||||
'''Install a product to a target volume'''
|
'''Install a product to a target volume.
|
||||||
|
Returns a boolean to indicate success or failure.'''
|
||||||
cmd = ['/usr/sbin/installer', '-pkg', dist_path, '-target', target_vol]
|
cmd = ['/usr/sbin/installer', '-pkg', dist_path, '-target', target_vol]
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
return True
|
||||||
except subprocess.CalledProcessError, err:
|
except subprocess.CalledProcessError, err:
|
||||||
print >> sys.stderr, err
|
print >> sys.stderr, err
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class ReplicationError(Exception):
|
class ReplicationError(Exception):
|
||||||
@ -396,9 +399,13 @@ def main():
|
|||||||
mountpoint = mountdmg(sparse_diskimage_path)
|
mountpoint = mountdmg(sparse_diskimage_path)
|
||||||
if mountpoint:
|
if mountpoint:
|
||||||
# install the product to the mounted sparseimage volume
|
# install the product to the mounted sparseimage volume
|
||||||
install_product(
|
success = install_product(
|
||||||
product_info[product_id]['DistributionPath'],
|
product_info[product_id]['DistributionPath'],
|
||||||
mountpoint)
|
mountpoint)
|
||||||
|
if not success:
|
||||||
|
print >> sys.stderr, 'Product installation failed.'
|
||||||
|
unmountdmg(mountpoint)
|
||||||
|
exit(-1)
|
||||||
print 'Product downloaded and installed to %s' % sparse_diskimage_path
|
print 'Product downloaded and installed to %s' % sparse_diskimage_path
|
||||||
if not args.compress:
|
if not args.compress:
|
||||||
unmountdmg(mountpoint)
|
unmountdmg(mountpoint)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user