mirror of
https://github.com/munki/munki.git
synced 2026-05-14 00:08:48 -05:00
Better icon extraction from flat packages that aren't distribution pkgs
This commit is contained in:
@@ -107,20 +107,29 @@ def extractAppIconsFromFlatPkg(pkg_path):
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
(output, errors) = proc.communicate()
|
||||
if proc.returncode:
|
||||
print_err_utf8(u'Could not get bom files from %s' % pkg_path)
|
||||
return []
|
||||
bomfilepaths = output.splitlines()
|
||||
pkg_dict = {}
|
||||
for bomfile in bomfilepaths:
|
||||
# bomfile path is of the form:
|
||||
# /tmp/FlashPlayer.pkg.boms.2Rxa1z/AdobeFlashPlayerComponent.pkg/Bom
|
||||
pkgname = os.path.basename(os.path.dirname(bomfile))
|
||||
if not pkgname.endswith('.pkg'):
|
||||
# no subpackages; this is a component pkg
|
||||
pkgname = ''
|
||||
cmd = ['/usr/bin/lsbom', '-s', bomfile]
|
||||
proc = subprocess.Popen(cmd, shell=False, bufsize=-1,
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
(output, errors) = proc.communicate()
|
||||
if proc.returncode:
|
||||
print_err_utf8(u'Could not lsbom %s' % bomfile)
|
||||
# record paths to all app Info.plist files
|
||||
pkg_dict[pkgname]= [line for line in output.splitlines()
|
||||
if line.endswith('.app/Contents/Info.plist')]
|
||||
pkg_dict[pkgname]= [
|
||||
os.path.normpath(line) for line in output.splitlines()
|
||||
if line.endswith('.app/Contents/Info.plist')]
|
||||
if not pkg_dict[pkgname]:
|
||||
# remove empty lists
|
||||
del(pkg_dict[pkgname])
|
||||
@@ -143,6 +152,12 @@ def extractAppIconsFromFlatPkg(pkg_path):
|
||||
icon_path = findIconForApp(app_path)
|
||||
if icon_path:
|
||||
icon_paths.append(icon_path)
|
||||
else:
|
||||
print_err_utf8(
|
||||
u'pax could not read files from %s' % archive_path)
|
||||
return []
|
||||
else:
|
||||
print_err_utf8(u'Could not expand %s' % pkg_path)
|
||||
# clean up our expanded flat package; we no longer need it
|
||||
shutil.rmtree(pkgtmp)
|
||||
return icon_paths
|
||||
|
||||
Reference in New Issue
Block a user