mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-17 09:46:00 +00:00
Work around a very dumb Apple bug in a package postinstall script. (#9)
This commit is contained in:
parent
514fa3afe4
commit
e6222ad3f3
@ -266,11 +266,28 @@ def install_product(dist_path, target_vol):
|
||||
cmd = ['/usr/sbin/installer', '-pkg', dist_path, '-target', target_vol]
|
||||
try:
|
||||
subprocess.check_call(cmd)
|
||||
return True
|
||||
except subprocess.CalledProcessError as err:
|
||||
print(err, file=sys.stderr)
|
||||
return False
|
||||
|
||||
else:
|
||||
# Apple postinstall script bug ends up copying files to a path like
|
||||
# /tmp/dmg.T9ak1HApplications
|
||||
path = target_vol + 'Applications'
|
||||
if os.path.exists(path):
|
||||
print('*********************************************************')
|
||||
print('*** Working around a very dumb Apple bug in a package ***')
|
||||
print('*** postinstall script that fails to correctly target ***')
|
||||
print('*** the Install macOS.app when installed to a volume ***')
|
||||
print('*** other than the current boot volume. ***')
|
||||
print('*** Please file feedback with Apple! ***')
|
||||
print('*********************************************************')
|
||||
subprocess.check_call(
|
||||
['/usr/bin/ditto',
|
||||
path,
|
||||
os.path.join(target_vol, 'Applications')]
|
||||
)
|
||||
subprocess.check_call(['/bin/rm', '-r', path])
|
||||
return True
|
||||
|
||||
class ReplicationError(Exception):
|
||||
'''A custom error when replication fails'''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user