Skip to content

Commit 5c890c7

Browse files
committed
Detect missing uninstall_script
1 parent cf6d54f commit 5c890c7

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ All notable changes to this project will be documented in this file. This projec
1212

1313
## [Unreleased]
1414

15-
Nothing yet.
15+
### Added
16+
17+
- `check-munki-pkgsinfo` now produces an error if `uninstall_method` is set to `uninstall_script` but no uninstall script is present in the pkginfo.
1618

1719
## [1.17.0] - 2024-12-22
1820

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,19 @@ def main(argv=None):
202202
retval = 1
203203

204204
# Ensure uninstall method is set correctly if uninstall_script exists.
205-
if "uninstall_script" in pkginfo:
206-
if pkginfo.get("uninstall_method") != "uninstall_script":
207-
print(
208-
f'{filename}: has uninstall script, but the uninstall method is set to "{pkginfo.get("uninstall_method")}"'
209-
)
210-
retval = 1
205+
uninst_method = pkginfo.get("uninstall_method")
206+
if "uninstall_script" in pkginfo and uninst_method != "uninstall_script":
207+
print(
208+
f"{filename}: has an uninstall script, but the uninstall "
209+
f'method is set to "{uninst_method}"'
210+
)
211+
retval = 1
212+
elif "uninstall_script" not in pkginfo and uninst_method == "uninstall_script":
213+
print(
214+
f"{filename}: uninstall_method is set to uninstall_script, "
215+
'but no uninstall script is present"'
216+
)
217+
retval = 1
211218

212219
# Ensure all pkginfo scripts have a proper shebang.
213220
script_types = (

0 commit comments

Comments
 (0)