dmgutils.mountdmg can now optionally mount a dmg under /Volumes; adobeutils.mount_adobe_dmg now just calls dmgutils.mountdmg

This commit is contained in:
Greg Neagle
2017-04-01 08:28:38 -07:00
parent a303cfe72a
commit 62aacdeed6
2 changed files with 7 additions and 22 deletions

View File

@@ -37,7 +37,6 @@ from .. import munkilog
from .. import osutils
from .. import prefs
from .. import utils
from .. import FoundationPlist
def get_pdapp_log_path():
@@ -186,29 +185,12 @@ class AdobeInstallProgressMonitor(object):
# dmg helper
# we need this instead of the one in munkicommon because the Adobe stuff
# needs the dmgs mounted under /Volumes. We can merge this later (or not).
def mount_adobe_dmg(dmgpath):
"""
Attempts to mount the dmg at dmgpath
and returns a list of mountpoints
"""
mountpoints = []
dmgname = os.path.basename(dmgpath)
proc = subprocess.Popen(['/usr/bin/hdiutil', 'attach', dmgpath,
'-nobrowse', '-noverify', '-plist'],
bufsize=-1,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(pliststr, err) = proc.communicate()
if err:
display.display_error('Error %s mounting %s.' % (err, dmgname))
if pliststr:
plist = FoundationPlist.readPlistFromString(pliststr)
for entity in plist['system-entities']:
if 'mount-point' in entity:
mountpoints.append(entity['mount-point'])
return mountpoints
return dmgutils.mountdmg(dmgpath, random_mountpoint=False)
def get_percent(current, maximum):

View File

@@ -173,11 +173,13 @@ def mount_points_for_disk_image(dmgpath):
return mountpoints
def mountdmg(dmgpath, use_shadow=False, use_existing_mounts=False):
def mountdmg(dmgpath, use_shadow=False, use_existing_mounts=False,
random_mountpoint=True):
"""
Attempts to mount the dmg at dmgpath
and returns a list of mountpoints
If use_shadow is true, mount image with shadow file
If random_mountpoint, mount at random dir under /tmp
"""
mountpoints = []
dmgname = os.path.basename(dmgpath)
@@ -195,8 +197,9 @@ def mountdmg(dmgpath, use_shadow=False, use_existing_mounts=False):
stdin = 'Y\n'
display.display_detail(
'NOTE: %s has embedded Software License Agreement' % dmgname)
cmd = ['/usr/bin/hdiutil', 'attach', dmgpath,
'-mountRandom', '/tmp', '-nobrowse', '-plist']
cmd = ['/usr/bin/hdiutil', 'attach', dmgpath, '-nobrowse', '-plist']
if random_mountpoint:
cmd.extend(['-mountRandom', '/tmp'])
if use_shadow:
cmd.append('-shadow')
proc = subprocess.Popen(cmd,