Skip to content

Commit

Permalink
Merge pull request #64 from homebysix/MunkiOptionalReceiptEditor
Browse files Browse the repository at this point in the history
1.12.4 merge to main
  • Loading branch information
homebysix committed Feb 26, 2023
2 parents f093f23 + 4793705 commit 1852669
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ All notable changes to this project will be documented in this file. This projec

Nothing yet.

## [1.12.4] - 2023-02-26

### Added

- Added compatibility checks for MunkiOptionalReceiptEditor processor, included in AutoPkg 2.7+.
- Added a `--require-pkg-blocking-apps` argument for the `check-munki-pkgsinfo` hook. If specified, tests will fail for any pkg installer that does not have a `blocking_applications` array (even an empty one). This change maintains the alignment with Munki's design established in 1.12.3 while allowing Munki repo admins flexibility to be stricter in their own environments.

### Changed

- Improved compatibility with Munki repos where the pkgsinfo folder is not at the root level. (#63, thanks to @kbrewersq)

## [1.12.3] - 2022-04-09

### Changed
Expand Down Expand Up @@ -293,7 +304,8 @@ Nothing yet.

- Initial release

[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.3...HEAD
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.4...HEAD
[1.12.4]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.3...v1.12.4
[1.12.3]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.2...v1.12.3
[1.12.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.1...v1.12.2
[1.12.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.0...v1.12.1
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.12.3
rev: v1.12.4
hooks:
- id: check-plists
# - id: ...
Expand Down Expand Up @@ -121,7 +121,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.12.3
rev: v1.12.4
hooks:
- id: check-munki-pkgsinfo
args: ['--catalogs', 'testing', 'stable', '--']
Expand All @@ -131,7 +131,7 @@ But if you also use the `--categories` argument, you would move the trailing `--

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.12.3
rev: v1.12.4
hooks:
- id: check-munki-pkgsinfo
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
Expand All @@ -143,7 +143,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu

```yaml
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.12.3
rev: v1.12.4
hooks:
- id: check-munki-pkgsinfo
args: [
Expand Down
4 changes: 3 additions & 1 deletion pre_commit_hooks/check_autopkg_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
"MunkiCatalogBuilder": "0.1.0",
"MunkiImporter": "0.1.0",
"MunkiInstallsItemsCreator": "0.1.0",
"MunkiOptionalReceiptEditor": "2.7",
"MunkiPkginfoMerger": "0.1.0",
"MunkiSetDefaultCatalog": "0.4.2",
"PackageRequired": "0.5.1",
Expand Down Expand Up @@ -376,7 +377,7 @@ def validate_proc_type_conventions(process, filename):
"""Ensure that processors used align with recipe type conventions."""

# For each processor type, this is the list of processors that
# we only expect to see in that type.
# we only expect to see in that type. List order is unimportant.
proc_type_conventions = {
"download": [
"SparkleUpdateInfoProvider",
Expand All @@ -390,6 +391,7 @@ def validate_proc_type_conventions(process, filename):
"MunkiPkginfoMerger",
"MunkiCatalogBuilder",
"MunkiSetDefaultCatalog",
"MunkiOptionalReceiptEditor",
"MunkiImporter",
],
"pkg": ["AppPkgCreator", "PkgCreator"],
Expand Down
10 changes: 8 additions & 2 deletions pre_commit_hooks/check_munki_pkgsinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def build_argument_parser():
default=["description", "name"],
help="List of required top-level keys.",
)
parser.add_argument(
"--require-pkg-blocking-apps",
action="store_true",
help="Require a blocking_applications array for pkg installers.",
)
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
return parser

Expand Down Expand Up @@ -120,7 +125,7 @@ def main(argv=None):

# Checking for the absence of blocking_applications for pkg installers.
# If a pkg doesn't require blocking_applications, use empty "<array/>" in pkginfo.
if all(
if args.require_pkg_blocking_apps and all(
(
"blocking_applications" not in pkginfo,
pkginfo.get("installer_item_location", "").endswith(".pkg"),
Expand All @@ -129,10 +134,11 @@ def main(argv=None):
)
):
print(
"WARNING: {}: contains a pkg installer but has no blocking applications".format(
"{}: contains a pkg installer but missing a blocking applications array".format(
filename
)
)
retval = 1

# Ensure an icon exists for the item.
if not any(
Expand Down
8 changes: 3 additions & 5 deletions pre_commit_hooks/munki_makecatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ 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 '.'")
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 munki's python.
python = "/usr/local/munki/munki-python"

# Path to makecatalogs.
makecatalogs = "/usr/local/munki/makecatalogs"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="pre-commit-macadmin",
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
url="https://github.com/homebysix/pre-commit-macadmin",
version="1.12.3",
version="1.12.4",
author="Elliot Jordan",
author_email="elliot@elliotjordan.com",
packages=["pre_commit_hooks"],
Expand Down

0 comments on commit 1852669

Please sign in to comment.