From c30e1eedaa9dcad2dff721b23455158049e3fc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Thu, 13 Jul 2023 08:45:49 +0200 Subject: [PATCH 1/4] Improve systemd scriptlet test name --- test/test_systemd_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_systemd_install.py b/test/test_systemd_install.py index 12fc8c9d5..39219ae83 100644 --- a/test/test_systemd_install.py +++ b/test/test_systemd_install.py @@ -15,7 +15,7 @@ def systemdinstallcheck(): @pytest.mark.parametrize('package', ['binary/dnf-automatic']) @pytest.mark.skipif(IS_FEDORA_RELEASE, reason='Fedora does not define %{_unitdir} rpm macro') -def test_bashisms(tmp_path, package, systemdinstallcheck): +def test_systemd_service_without_service_macro(tmp_path, package, systemdinstallcheck): output, test = systemdinstallcheck test.check(get_tested_package(package, tmp_path)) out = output.print_results(output.results) From 293e759b3979436a6b5d308bb6a22563f763476d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Thu, 13 Jul 2023 08:45:49 +0200 Subject: [PATCH 2/4] Don't skip systemd scriptlet test on Fedora %_unitdir is defined and has been for a while --- test/test_systemd_install.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_systemd_install.py b/test/test_systemd_install.py index 39219ae83..09c692266 100644 --- a/test/test_systemd_install.py +++ b/test/test_systemd_install.py @@ -2,7 +2,7 @@ from rpmlint.checks.SystemdInstallCheck import SystemdInstallCheck from rpmlint.filter import Filter -from Testing import CONFIG, get_tested_package, IS_FEDORA_RELEASE +from Testing import CONFIG, get_tested_package @pytest.fixture(scope='function', autouse=True) @@ -14,7 +14,6 @@ def systemdinstallcheck(): @pytest.mark.parametrize('package', ['binary/dnf-automatic']) -@pytest.mark.skipif(IS_FEDORA_RELEASE, reason='Fedora does not define %{_unitdir} rpm macro') def test_systemd_service_without_service_macro(tmp_path, package, systemdinstallcheck): output, test = systemdinstallcheck test.check(get_tested_package(package, tmp_path)) From 8bae6a87b8c83a6901b683588ba7f11333bd4448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Thu, 13 Jul 2023 08:45:49 +0200 Subject: [PATCH 3/4] Update search regexes for %service_* macros These macros used to call systemctl directly, but as of May 2023 they rely on systemd-update-helper in openSUSE. This results in false negatives for every package using these macros. --- rpmlint/checks/SystemdInstallCheck.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rpmlint/checks/SystemdInstallCheck.py b/rpmlint/checks/SystemdInstallCheck.py index 630390317..b189a7181 100644 --- a/rpmlint/checks/SystemdInstallCheck.py +++ b/rpmlint/checks/SystemdInstallCheck.py @@ -26,16 +26,17 @@ def check(self, pkg): processed = {'pre': False, 'post': False, 'preun': False, 'postun': False} escaped_basename = re.escape(Path(fname).name) - PRE_POST_PATTERN = re.compile(r'for service in .*' + escaped_basename) - PREUN_PATTERN = re.compile(r'systemctl --no-reload disable .*' + escaped_basename) - POSTUN_PATTERN = re.compile(r'(systemctl try-restart .*|# Restart of .*)' + escaped_basename) + PRE_PATTERN = re.compile(r'systemd-update-helper mark-install-system-units .*' + escaped_basename) + POST_PATTERN = re.compile(r'systemd-update-helper install-system-units .*' + escaped_basename) + PREUN_PATTERN = re.compile(r'systemd-update-helper remove-system-units .*' + escaped_basename) + POSTUN_PATTERN = re.compile(r'systemd-update-helper mark-restart-system-units .*' + escaped_basename) for line in pre.split('\n'): - if PRE_POST_PATTERN.search(line): + if PRE_PATTERN.search(line): processed['pre'] = True break for line in post.split('\n'): - if PRE_POST_PATTERN.search(line): + if POST_PATTERN.search(line): processed['post'] = True break for line in preun.split('\n'): From 91645e1f4c6572ae4d10a9fd63d9678ed6d8cce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Fri, 14 Jul 2023 10:54:38 +0200 Subject: [PATCH 4/4] Add missing dependency to rpmlint spec It looks like the %_unitdir macro is not defined in the Fedora buildroot --- .packit/rpmlint.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.packit/rpmlint.spec b/.packit/rpmlint.spec index ff529e4f1..372a383e6 100644 --- a/.packit/rpmlint.spec +++ b/.packit/rpmlint.spec @@ -52,6 +52,8 @@ BuildRequires: dash BuildRequires: /usr/bin/appstream-util BuildRequires: /usr/bin/checkbashisms BuildRequires: /usr/bin/desktop-file-validate +# required for the systemd test +BuildRequires: rpm_macro(_unitdir) %if 0%{?suse_version} BuildRequires: myspell-en_US