Skip to content

Commit

Permalink
Merge pull request #63 from kbrewersq/flexible_munki_repo
Browse files Browse the repository at this point in the history
making munki repo more flexible
  • Loading branch information
homebysix authored Feb 26, 2023
2 parents 664524b + 8a7e4fb commit f093f23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
description: This hook checks Munki pkginfo files to ensure they are valid.
entry: check-munki-pkgsinfo
language: python
files: "^pkgsinfo/"
files: "pkgsinfo/"
types: [text]

- id: check-munkiadmin-scripts
Expand Down
10 changes: 6 additions & 4 deletions pre_commit_hooks/munki_makecatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ def build_argument_parser():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("--munki_repo", default='.',
help="path to local munki repo defaults to '.'")
# TODO: Support makecatalogs options, ideally with kwargs for flexibility.
return parser


def main(argv=None):
"""Main process."""

# Path to Python 2.
python = "/usr/bin/python"
# Path to munki's python.
python = "/usr/local/munki/munki-python"

# Path to makecatalogs.
makecatalogs = "/usr/local/munki/makecatalogs"
Expand All @@ -32,7 +34,7 @@ def main(argv=None):
args = argparser.parse_args(argv)

retval = 0
if not os.path.isdir("pkgsinfo"):
if not os.path.isdir(os.path.join(args.munki_repo, "pkgsinfo")):
print("Could not find pkgsinfo folder.")
retval = 1
elif not os.path.isfile(python):
Expand All @@ -42,7 +44,7 @@ def main(argv=None):
print("{} does not exist.".format(makecatalogs))
retval = 1
else:
retval = subprocess.call([python, makecatalogs, "."])
retval = subprocess.call([makecatalogs, args.munki_repo])

return retval

Expand Down

0 comments on commit f093f23

Please sign in to comment.