Work around a very dumb Apple bug in a package postinstall script.

This commit is contained in:
Greg Neagle 2019-07-31 15:12:58 -07:00
parent ebd27a06c2
commit 66331c6b5a

View File

@ -209,11 +209,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'''