makepkginfo now warns when provided a read/write disk image, and does not generate an installer_item_hash.

This commit is contained in:
Greg Neagle
2012-06-27 16:06:09 -07:00
parent fa5052e247
commit b4eb55cd84
2 changed files with 31 additions and 1 deletions
+10 -1
View File
@@ -612,6 +612,14 @@ def main():
itemhash = munkicommon.getsha256hash(item)
if item.endswith('.dmg'):
if munkicommon.DMGisWritable(item):
print >> sys.stderr, ("WARNING: %s is a writable disk "
"image. Checksum verification is not supported."
% item)
print >> sys.stderr, ("WARNING: Consider converting "
"%s to a read-only disk image."
% item)
itemhash = "N/A"
catinfo = getCatalogInfoFromDmg(item, options)
if (catinfo and
catinfo.get('installer_type') == "AdobeCS5Installer"):
@@ -668,7 +676,8 @@ def main():
catinfo['version'] = options.pkgvers
catinfo['installer_item_size'] = int(itemsize/1024)
catinfo['installer_item_hash'] = itemhash
if itemhash != "N/A":
catinfo['installer_item_hash'] = itemhash
# try to generate the correct item location
temppath = item
+21
View File
@@ -757,6 +757,27 @@ def getFirstPlist(textString):
# dmg helpers
def DMGisWritable(dmgpath):
'''Attempts to determine if the given disk image is writable'''
proc = subprocess.Popen(
['/usr/bin/hdiutil', 'imageinfo', dmgpath, '-plist'],
bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = proc.communicate()
if err:
print >> sys.stderr, (
'hdiutil error %s with image %s.' % (err, dmgpath))
(pliststr, out) = getFirstPlist(out)
if pliststr:
try:
plist = FoundationPlist.readPlistFromString(pliststr)
format = plist.get('Format')
if format in ['UDSB', 'UDSP', 'UDRW', 'RdWr']:
return True
except FoundationPlist.NSPropertyListSerializationException:
pass
return False
def DMGhasSLA(dmgpath):
'''Returns true if dmg has a Software License Agreement.
These dmgs normally cannot be attached without user intervention'''