Skip to content

Commit abb690c

Browse files
committed
Apply Munki installer checks to uninstallers
1 parent 4d4fd0f commit abb690c

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Nothing yet.
1919
### Added
2020

2121
- Added `--warn-on-missing-installer-items` flag that makes missing Munki install/uninstall items a warning instead of a failure. (#86, thanks to @haircut)
22+
- Apply the same checks to `uninstaller_item_location` that were previously applied to `installer_item_location`.
2223
- `check-autopkg-recipes` requires Munki recipe `pkginfo` dicts to contain at least `name` and `description`.
2324
- `check-autopkg-recipes` now validates that `uninstall_method` and `uninstall_script` are set appropriately in Munki recipes.
2425

@@ -30,6 +31,7 @@ Nothing yet.
3031
### Fixed
3132

3233
- Bug fix in `check-munkiadmin-scripts` that prevented script names from processing correctly.
34+
- Bug fix in `check-munki-pkgsinfo` that prevented `--warn-on-duplicate-imports` flag from working correctly.
3335

3436
## [1.18.0] - 2025-01-04
3537

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
120120
- Choose to just warn if icons referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
121121
`args: ['--warn-on-missing-icons]`
122122

123-
- Choose to just warn if installer items (`installer_item_location`) referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
123+
- Choose to just warn if installer/uninstaller items (`installer_item_location` or `uninstaller_item_location`) referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
124124
`args: ['--warn-on-missing-installer-items]`
125125

126126
- Choose to just warn if pkg/pkginfo files with __1 (or similar) suffixes are detected (this will allow pre-commit checks to pass if no other issues exist):

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,31 +150,6 @@ def main(argv=None):
150150
print(f'{filename}: catalog "{catalog}" is not in approved list')
151151
retval = 1
152152

153-
# Check for missing or case-conflicted installer items
154-
if not _check_case_sensitive_path(
155-
os.path.join(
156-
args.munki_repo, "pkgs", pkginfo.get("installer_item_location", "")
157-
)
158-
):
159-
msg = "installer item does not exist or path is not case sensitive"
160-
if args.warn_on_missing_installer_items:
161-
print(f"{filename}: WARNING: {msg}")
162-
else:
163-
print(f"{filename}: {msg}")
164-
retval = 1
165-
166-
# Check for pkg filenames showing signs of duplicate imports.
167-
if pkginfo.get("installer_item_location", "").endswith(tuple(dupe_suffixes)):
168-
installer_item_location = pkginfo["installer_item_location"]
169-
msg = (
170-
f"installer item '{installer_item_location}' may be a duplicate import"
171-
)
172-
if args.warn_on_missing_icons:
173-
print(f"{filename}: WARNING: {msg}")
174-
else:
175-
print(f"{filename}: {msg}")
176-
retval = 1
177-
178153
# Checking for the absence of blocking_applications for pkg installers.
179154
# If a pkg doesn't require blocking_applications, use empty "<array/>" in pkginfo.
180155
if args.require_pkg_blocking_apps and all(
@@ -190,6 +165,34 @@ def main(argv=None):
190165
)
191166
retval = 1
192167

168+
# Begin checks that apply to both installers and uninstallers
169+
for i_type in ("installer", "uninstaller"):
170+
171+
# Check for missing or case-conflicted installer or uninstaller items
172+
if not _check_case_sensitive_path(
173+
os.path.join(
174+
args.munki_repo, "pkgs", pkginfo.get(f"{i_type}_item_location", "")
175+
)
176+
):
177+
msg = f"{i_type} item does not exist or path is not case sensitive"
178+
if args.warn_on_missing_installer_items:
179+
print(f"{filename}: WARNING: {msg}")
180+
else:
181+
print(f"{filename}: {msg}")
182+
retval = 1
183+
184+
# Check for pkg filenames showing signs of duplicate imports.
185+
if pkginfo.get(f"{i_type}_item_location", "").endswith(
186+
tuple(dupe_suffixes)
187+
):
188+
item_loc = pkginfo[f"{i_type}_item_location"]
189+
msg = f"{i_type} item '{item_loc}' may be a duplicate import"
190+
if args.warn_on_duplicate_imports:
191+
print(f"{filename}: WARNING: {msg}")
192+
else:
193+
print(f"{filename}: {msg}")
194+
retval = 1
195+
193196
# Ensure an icon exists for the item.
194197
if not any(
195198
(

0 commit comments

Comments
 (0)