Added support for icon_hash to munkiimport

This commit is contained in:
Arjen van Bochoven
2015-01-19 22:49:57 +01:00
parent e660411348
commit c3577c210a
+18 -3
View File
@@ -217,17 +217,29 @@ def copyItemToRepo(itempath, vers, subdirectory=''):
return os.path.join(subdirectory, item_name)
def iconExistsInRepo(pkginfo):
"""Returns True if there is an icon for this item in the repo"""
def getIconPath(pkginfo):
"""Return path for icon"""
icon_name = pkginfo.get('icon_name') or pkginfo['name']
if not os.path.splitext(icon_name)[1]:
icon_name += u'.png'
icon_path = os.path.join(REPO_PATH, u'icons', icon_name)
return os.path.join(REPO_PATH, u'icons', icon_name)
def iconExistsInRepo(pkginfo):
"""Returns True if there is an icon for this item in the repo"""
icon_path = getIconPath(pkginfo)
if os.path.exists(icon_path):
return True
return False
def addIconHashToPkginfo(pkginfo):
"""Adds the icon hash tp pkginfo if the icon exists in repo"""
icon_path = getIconPath(pkginfo)
if os.path.isfile(icon_path):
pkginfo['icon_hash'] = munkicommon.getsha256hash(icon_path)
def generate_png_from_copy_from_dmg_item(dmg_path, pkginfo):
'''Generates a product icon from a copy_from_dmg item
and uploads to the repo'''
@@ -1064,6 +1076,9 @@ def main():
except RepoCopyError, errmsg:
print >> sys.stderr, errmsg
# add icon to pkginfo if in repository
addIconHashToPkginfo(pkginfo)
# installer_item upload was successful, so upload pkginfo to repo
try:
pkginfo_path = copyPkginfoToRepo(pkginfo, options.subdirectory)