From 62aacdeed60e9cd17ea01291297dcab3fba178ba Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Sat, 1 Apr 2017 08:28:38 -0700 Subject: [PATCH] dmgutils.mountdmg can now optionally mount a dmg under /Volumes; adobeutils.mount_adobe_dmg now just calls dmgutils.mountdmg --- code/client/munkilib/adobeutils/core.py | 20 +------------------- code/client/munkilib/dmgutils.py | 9 ++++++--- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/code/client/munkilib/adobeutils/core.py b/code/client/munkilib/adobeutils/core.py index dbdad7ad..21d294c2 100644 --- a/code/client/munkilib/adobeutils/core.py +++ b/code/client/munkilib/adobeutils/core.py @@ -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): diff --git a/code/client/munkilib/dmgutils.py b/code/client/munkilib/dmgutils.py index 128808a1..789e42b3 100644 --- a/code/client/munkilib/dmgutils.py +++ b/code/client/munkilib/dmgutils.py @@ -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,