Skip to content

Instantly share code, notes, and snippets.

@brianwells
Created January 4, 2017 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianwells/d8120e5eb46d1c441a796ab181fcc89e to your computer and use it in GitHub Desktop.
Save brianwells/d8120e5eb46d1c441a796ab181fcc89e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# script to build recipe_list.txt for AutoPkgr from the recipe overrides
from __future__ import print_function
import os, sys, inspect, plistlib, xml
def errprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
currentdir = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))
recipefiles = [
os.path.join(currentdir,x) for x in os.listdir(currentdir)
if (x.endswith(".recipe") and x != "MakeCatalogs.munki.recipe")
]
identifiers = []
for file in recipefiles:
try:
data = plistlib.readPlist(file)
if 'Identifier' in data:
identifiers.append(data['Identifier'])
else:
errprint("No 'Identifier' for %s" % os.path.basename(file))
except xml.parsers.expat.ExpatError as exc:
errprint("Unable to read %s: %s" % (os.path.basename(file),exc))
list_file = os.path.expanduser("~/Library/Application Support/AutoPkgr/recipe_list.txt")
with open(list_file, 'w') as the_file:
the_file.write("\n".join(identifiers + ["MakeCatalogs.munki"]))
print("Wrote %d identifiers to %s" % (len(identifiers),os.path.basename(list_file)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment