Better icon extraction from flat packages that aren't distribution pkgs

This commit is contained in:
Greg Neagle
2014-03-24 16:13:16 -07:00
parent acdd39c035
commit 8090ce5817
+17 -2
View File
@@ -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