Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making munki repo more flexible #63

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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