Skip to content

Commit 92d8e26

Browse files
authored
Merge pull request #94 from homebysix/dev
1.20.0 merge to main
2 parents be65b30 + 12718a1 commit 92d8e26

29 files changed

+2226
-7
lines changed

.coveragerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[run]
2+
include = pre_commit_hooks/*
3+
4+
[report]
5+
exclude_lines =
6+
pragma: no cover
7+
if __name__ == .__main__.:

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
# macOS
12
.DS_Store
3+
4+
# Compiled Python
25
*.pyc
6+
7+
# Unittest
8+
__pycache__/
9+
.coverage
10+
coverage.xml
11+
htmlcov/
12+
13+
# Virtual environments
14+
.venv/
15+
venv/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
- id: pyupgrade
2222
args: ['--py36-plus']
2323
- repo: https://github.com/pycqa/flake8
24-
rev: 7.2.0
24+
rev: 7.3.0
2525
hooks:
2626
- id: flake8
2727
- repo: https://github.com/pycqa/isort

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ All notable changes to this project will be documented in this file. This projec
1414

1515
Nothing yet.
1616

17+
## [1.20.0] - 2025-08-09
18+
19+
### Added
20+
21+
- `check-autopkg-recipes` and `check-munki-pkgsinfo` now validates that `supported_architectures` values are set appropriately.
22+
- In anticipation of Munki 7, `check-munki-pkgsinfo` validates that `version_script` is a string starting with a script shebang.
23+
- `check-munki-pkgsinfo` now checks for specific deprecated `installer_type` and `uninstall_method` values, most of which are detailed [here](https://github.com/munki/munki/wiki/Deprecation-Notes).
24+
- Added new FindAndReplace core processor version requirements for AutoPkg recipes.
25+
26+
### Changed
27+
28+
- Improvements to `check-preference-manifests` hook. (#91, thanks to @relgit)
29+
- `check-autopkg-recipes` ignores `supported_architectures` values within Munki pkginfo dictionaries that appear to be AutoPkg recipe substitution variables (e.g. `%ARCH%`).
30+
1731
## [1.19.0] - 2025-01-16
1832

1933
### Added

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit
1515

1616
```yaml
1717
- repo: https://github.com/homebysix/pre-commit-macadmin
18-
rev: v1.19.0
18+
rev: v1.20.0
1919
hooks:
2020
- id: check-plists
2121
# - id: ...
@@ -147,7 +147,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
147147

148148
```yaml
149149
- repo: https://github.com/homebysix/pre-commit-macadmin
150-
rev: v1.19.0
150+
rev: v1.20.0
151151
hooks:
152152
- id: check-munki-pkgsinfo
153153
args: ['--catalogs', 'testing', 'stable', '--']
@@ -157,7 +157,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
157157

158158
```yaml
159159
- repo: https://github.com/homebysix/pre-commit-macadmin
160-
rev: v1.19.0
160+
rev: v1.20.0
161161
hooks:
162162
- id: check-munki-pkgsinfo
163163
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -169,7 +169,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
169169

170170
```yaml
171171
- repo: https://github.com/homebysix/pre-commit-macadmin
172-
rev: v1.19.0
172+
rev: v1.20.0
173173
hooks:
174174
- id: check-munki-pkgsinfo
175175
args: [

RELEASING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
1. Update the versions in __README.md__ and __setup.py__.
44

5+
1. Check unit tests:
6+
7+
.venv/bin/python -m coverage run -m unittest discover -vs tests
8+
59
1. Update the change log.
610

711
1. Merge development branch to main.

pre_commit_hooks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file is intentionally left blank.

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
validate_pkginfo_key_types,
1717
validate_required_keys,
1818
validate_restart_action_key,
19+
validate_supported_architectures,
1920
validate_uninstall_method,
2021
)
2122

@@ -197,6 +198,7 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
197198
"FileCreator": "0.0",
198199
"FileFinder": "0.2.3",
199200
"FileMover": "0.2.9",
201+
"FindAndReplace": "2.7.6",
200202
"FlatPkgPacker": "0.2.4",
201203
"FlatPkgUnpacker": "0.1.0",
202204
"GitHubReleasesInfoProvider": "0.5.0",
@@ -636,6 +638,12 @@ def main(argv=None):
636638
if not validate_uninstall_method(input_key["pkginfo"], filename):
637639
retval = 1
638640

641+
# Validate supported architectures.
642+
if not validate_supported_architectures(
643+
input_key["pkginfo"], filename, recipe_mode=True
644+
):
645+
retval = 1
646+
639647
# Check for deprecated pkginfo keys.
640648
if not detect_deprecated_keys(input_key["pkginfo"], filename):
641649
retval = 1

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
validate_required_keys,
1515
validate_restart_action_key,
1616
validate_shebangs,
17+
validate_supported_architectures,
1718
validate_uninstall_method,
1819
)
1920

@@ -103,6 +104,7 @@ def main(argv=None):
103104

104105
retval = 0
105106
for filename in args.filenames:
107+
pkginfo = {}
106108
try:
107109
with open(filename, "rb") as openfile:
108110
pkginfo = plistlib.load(openfile)
@@ -128,6 +130,10 @@ def main(argv=None):
128130
if not validate_uninstall_method(pkginfo, filename):
129131
retval = 1
130132

133+
# Validate supported architectures.
134+
if not validate_supported_architectures(pkginfo, filename, recipe_mode=False):
135+
retval = 1
136+
131137
# Check for deprecated pkginfo keys.
132138
if not detect_deprecated_keys(pkginfo, filename):
133139
retval = 1
@@ -136,6 +142,36 @@ def main(argv=None):
136142
if not detect_typoed_keys(pkginfo, filename):
137143
retval = 1
138144

145+
# Check for deprecated installer_type values.
146+
depr_installer_types = (
147+
"AdobeAcrobatUpdater",
148+
"AdobeCCPInstaller",
149+
"AdobeCS5AAMEEPackage",
150+
"AdobeCS5PatchInstaller",
151+
"AdobeSetup",
152+
"AdobeUberInstaller",
153+
"appdmg",
154+
"apple_update_metadata",
155+
"profile",
156+
"startosinstall",
157+
)
158+
if pkginfo.get("installer_type") in depr_installer_types:
159+
print(
160+
f"{filename}: WARNING: installer_type '{pkginfo.get('installer_type')}' is deprecated"
161+
)
162+
163+
# Check for deprecated uninstall_method values.
164+
depr_uninstall_methods = (
165+
"AdobeCCPUninstaller",
166+
"AdobeCS5AAMEEPackage",
167+
"AdobeSetup",
168+
"AdobeUberUninstaller",
169+
)
170+
if pkginfo.get("uninstall_method") in depr_uninstall_methods:
171+
print(
172+
f"{filename}: WARNING: uninstall_method '{pkginfo.get('uninstall_method')}' is deprecated"
173+
)
174+
139175
# Check for rogue categories.
140176
if args.categories and pkginfo.get("category") not in args.categories:
141177
print(
@@ -219,6 +255,7 @@ def main(argv=None):
219255
"preinstall_script",
220256
"preuninstall_script",
221257
"uninstall_script",
258+
"version_script",
222259
)
223260
for s_type in script_types:
224261
if s_type in pkginfo:

pre_commit_hooks/util.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"#!/usr/bin/python3",
3333
"#!/usr/bin/python", # removed since macOS 12.3
3434
"#!/usr/bin/ruby",
35-
"#!/usr/local/munki/munki-python",
35+
"#!/usr/local/munki/munki-python", # removed in Munki 7
3636
"#!/usr/local/munki/Python.framework/Versions/Current/bin/python3",
3737
]
3838

@@ -177,6 +177,27 @@ def validate_uninstall_method(pkginfo, filename):
177177
return passed
178178

179179

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+
"""
186+
passed = True
187+
allowed_values = ("arm64", "x86_64")
188+
if "supported_architectures" in pkginfo:
189+
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
193+
if arch not in allowed_values:
194+
print(
195+
f"{filename}: supported_architectures contains unexpected value: {arch}"
196+
)
197+
passed = False
198+
return passed
199+
200+
180201
def validate_pkginfo_key_types(pkginfo, filename):
181202
"""Validation of pkginfo key types.
182203
@@ -244,6 +265,7 @@ def validate_pkginfo_key_types(pkginfo, filename):
244265
"uninstaller_item_location": str,
245266
"update_for": list,
246267
"version": str,
268+
"version_script": str,
247269
}
248270

249271
passed = True

0 commit comments

Comments
 (0)