Created
January 4, 2017 19:52
-
-
Save brianwells/d8120e5eb46d1c441a796ab181fcc89e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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