Skip to content

Commit 3fac82e

Browse files
committed
Ignore AutoPkg recipe substitution variables
1 parent 287ecac commit 3fac82e

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. This projec
2222
### Changed
2323

2424
- Improvements to `check-preference-manifests` hook. (#91, thanks to @relgit)
25+
- `check-autopkg-recipes` ignores `supported_architectures` values within Munki pkginfo dictionaries that appear to be AutoPkg recipe substitution variables (e.g. `%ARCH%`).
2526

2627
## [1.19.0] - 2025-01-16
2728

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ def main(argv=None):
639639
retval = 1
640640

641641
# Validate supported architectures.
642-
if not validate_supported_architectures(input_key["pkginfo"], filename):
642+
if not validate_supported_architectures(
643+
input_key["pkginfo"], filename, recipe_mode=True
644+
):
643645
retval = 1
644646

645647
# Check for deprecated pkginfo keys.

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def main(argv=None):
131131
retval = 1
132132

133133
# Validate supported architectures.
134-
if not validate_supported_architectures(pkginfo, filename):
134+
if not validate_supported_architectures(pkginfo, filename, recipe_mode=False):
135135
retval = 1
136136

137137
# Check for deprecated pkginfo keys.

pre_commit_hooks/util.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,19 @@ def validate_uninstall_method(pkginfo, filename):
177177
return passed
178178

179179

180-
def validate_supported_architectures(pkginfo, filename):
181-
"""Verifies that supported_architectures values are valid."""
180+
def validate_supported_architectures(pkginfo, filename, recipe_mode=False):
181+
"""Verifies that supported_architectures values are valid.
182+
183+
recipe_mode: Allow values wrapped in '%' which are typically substitution variables
184+
in AutoPkg recipes. Defaults to False.
185+
"""
182186
passed = True
183187
allowed_values = ("arm64", "x86_64")
184188
if "supported_architectures" in pkginfo:
185189
for arch in pkginfo["supported_architectures"]:
190+
if recipe_mode and arch.startswith("%") and arch.endswith("%"):
191+
# Skip values that are substituted during AutoPkg recipe runs
192+
continue
186193
if arch not in allowed_values:
187194
print(
188195
f"{filename}: supported_architectures contains unexpected value: {arch}"

0 commit comments

Comments
 (0)