2017-10-29 16:28:55 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from sys import argv
|
|
|
|
from subprocess import run, PIPE, DEVNULL
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
srcimg = 'SourceForEmulator.dmg'
|
|
|
|
|
|
|
|
rsync_opts = [
|
|
|
|
'--exclude', '.*', # Down with dotfiles.
|
|
|
|
'--exclude', srcimg,
|
|
|
|
'--exclude', 'Desktop DB',
|
|
|
|
'--exclude', 'Desktop DF',
|
2017-11-27 13:34:49 +00:00
|
|
|
'--exclude', 'Desktop Folder',
|
2017-10-29 16:28:55 +00:00
|
|
|
'--exclude', 'Trash',
|
2017-11-27 13:34:49 +00:00
|
|
|
'--exclude', 'TheVolumeSettingsFolder',
|
|
|
|
'--exclude', 'TheFindByContentFolder',
|
2017-10-29 16:28:55 +00:00
|
|
|
'--recursive',
|
|
|
|
'-tX', # consider times and xattrs
|
|
|
|
'--delete', # may delete things on the vMac drive
|
|
|
|
# '--itemize-changes',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-27 13:34:49 +00:00
|
|
|
cmdresult = run(['hdiutil', 'attach', '-nobrowse', srcimg], stdout=PIPE, check=True).stdout.decode('ascii')
|
|
|
|
mountpoint = next(x for x in cmdresult.split() if x.startswith('/') and not x.startswith('/dev'))
|
2017-10-29 16:28:55 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
mountpoint = mountpoint.rstrip('/') # try to deal in clean paths
|
|
|
|
|
|
|
|
run(['rsync', *rsync_opts, mountpoint+'/', './'], check=True)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
run(['hdiutil', 'detach', mountpoint], stdout=DEVNULL, check=True)
|