Skip to content

Commit

Permalink
false positive: systemd-service-without-service_del_postun
Browse files Browse the repository at this point in the history
  • Loading branch information
danigm committed Nov 6, 2024
1 parent 036a257 commit 1a1f607
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rpmlint/checks/SystemdInstallCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def check(self, pkg):
break

# accept %service_del_postun_without_restart() macro
if not processed['postun'] and ':' == postun.strip():
postun_without_restart = ':' in (i.strip() for i in postun.split("\n"))
if not processed['postun'] and postun_without_restart:
processed['postun'] = True

basename = Path(fname).name
Expand Down
29 changes: 29 additions & 0 deletions test/test_systemd_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ def test_systemd_service_without_service_macro(tmp_path, package, systemdinstall
files=['/usr/lib/systemd/system/greetd.service'],
header={},
), True),
(get_tested_mock_package(
name='MirrorCache',
files=[
'/usr/lib/systemd/system/mirrorcache-backstage-hashes.service',
'/usr/lib/systemd/system/mirrorcache-backstage.service',
'/usr/lib/systemd/system/mirrorcache-hypnotoad.service',
'/usr/lib/systemd/system/mirrorcache-subtree.service',
'/usr/lib/systemd/system/mirrorcache.service',
],
header={
'PREUN': '/usr/lib/systemd/systemd-update-helper remove-system-units mirrorcache.service mirrorcache-backstage.service mirrorcache-backstage-hashes.service mirrorcache-subtree.service mirrorcache-hypnotoad.service',
'PREIN': '/usr/lib/systemd/systemd-update-helper mark-install-system-units mirrorcache.service mirrorcache-backstage.service mirrorcache-backstage-hashes.service mirrorcache-subtree.service mirrorcache-hypnotoad.service',
'POSTIN': '/usr/lib/systemd/systemd-update-helper install-system-units mirrorcache.service mirrorcache-backstage.service mirrorcache-backstage-hashes.service mirrorcache-subtree.service mirrorcache-hypnotoad.service',
'POSTUN': '''
if [ $1 -ge 1 ] && [ -x /usr/lib/systemd/systemd-update-helper ]; then
# Package upgrade, not uninstall
DISABLE_RESTART_ON_UPDATE=no
[ -e /etc/sysconfig/services ] && . /etc/sysconfig/services || :
case "$DISABLE_RESTART_ON_UPDATE" in
yes|1) ;;
*) /usr/lib/systemd/systemd-update-helper mark-restart-system-units mirrorcache.service mirrorcache-backstage.service mirrorcache-backstage-hashes.service mirrorcache-subtree.service || :
esac
fi
:
''',
},
), False),
])
def test_systemd_service_without_service_macro2(package, error, systemdinstallcheck):
output, test = systemdinstallcheck
Expand Down

0 comments on commit 1a1f607

Please sign in to comment.