On Thu, Aug 19, 2021 at 01:57:28AM +0300, Peter Pentchev wrote: > Package: lintian > Version: 2.104.0 > Severity: normal > Tags: patch > X-Debbugs-Cc: roam@debian.org > > Hi, > > Thanks a lot for all your work on Lintian! > > The systemd-service-file-outside-lib checks have, since 2015, flagged > unit files found in the /usr/lib/systemd/system/ directory. It seems > that at some point since then (I'm not exactly sure when), maybe because > of the merged-/usr layout, maybe for other reasons, systemd on Debian > has started actually paying attention to unit files found there. > > I noticed this almost accidentally, when I rebuilt (still only locally, > although I do intend to upload it soon) my stunnel4 package with > debhelper 13.4 as found in unstable now: as part of fixing #987989, > debhelper now installs unit files in /usr/lib/systemd/system/ instead of > /lib/systemd/system/; see: > > https://salsa.debian.org/debian/debhelper/-/commit/d70caa69c64b124e3611c967cfab93aef48346d8 > > So debhelper now produces packages that will place unit files into /usr, > and I have just verified that the systemd in testing does, indeed, > notice these files - I successfully enabled and started a stunnel@foo > service through a stunnel@.service file in /usr/lib/systemd/system/. > > Maybe it's time to change the systemd-service-file-outside-lib check, at > least partially? (the "do not place unit files in /etc" part is still > very, very good advice for a package) What do you think about the > attached patch? Tomorrow I will also send another one that adds > (?:usr/)? to a couple of other regular expression checks (with some more > work for at least one of them) so that these files are properly checked, > too. So, as promised, here's another patch that tries to extend some more Lintian checks to files in /usr/lib/systemd/system. Note that it currently fails the Perl::Critic test, most probably because of the overly long line 605 in lib/Lintian/Check/InitD.pm, but I decided to send it to you this way, since I am not exactly sure how you prefer to resolve this type of problem (I personally would use the /x regex modifier and split the regex into several lines). Thanks again for your time and your work! G'luck, Peter -- Peter Pentchev roam@ringlet.net roam@debian.org pp@storpool.com PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13
From ad576808677d683860db06e17308895ed3449223 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam@ringlet.net>
Date: Fri, 20 Aug 2021 00:43:02 +0300
Subject: [PATCH 2/2] Check files in /usr/lib/systemd/system, too.
---
lib/Lintian/Check/InitD.pm | 10 +++++-----
lib/Lintian/Check/Systemd.pm | 12 ++++++------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/Lintian/Check/InitD.pm b/lib/Lintian/Check/InitD.pm
index e19231dc3..da6817afd 100644
--- a/lib/Lintian/Check/InitD.pm
+++ b/lib/Lintian/Check/InitD.pm
@@ -601,19 +601,19 @@ sub visit_installed_files {
# check for missing init.d script when alternative init system is present
- if ( $item =~ m{etc/sv/([^/]+)/run$}
- || $item =~ m{lib/systemd/system/([^/@]+)\.service}) {
+ if ( $item =~ m{etc/sv/(?<svc>[^/]+)/run$}
+ || $item =~ m{(?<usr>usr/)?lib/systemd/system/(?<svc>[^/@]+)\.service}) {
- my $service = $1;
+ my ($usr, $service) = ($+{usr} // $EMPTY, $+{svc});
$self->hint('package-supports-alternative-init-but-no-init.d-script',
$item)
unless $self->processable->installed->resolve_path(
"etc/init.d/${service}")
or $self->processable->installed->resolve_path(
- "lib/systemd/system/${service}.path")
+ "${usr}lib/systemd/system/${service}.path")
or $self->processable->installed->resolve_path(
- "lib/systemd/system/${service}.timer");
+ "${usr}lib/systemd/system/${service}.timer");
}
if ($item =~ m{etc/sv/([^/]+)/$}) {
diff --git a/lib/Lintian/Check/Systemd.pm b/lib/Lintian/Check/Systemd.pm
index 74a5c7eb6..06be256bf 100644
--- a/lib/Lintian/Check/Systemd.pm
+++ b/lib/Lintian/Check/Systemd.pm
@@ -116,7 +116,7 @@ sub setup_installed_files {
$self->services($self->get_systemd_service_names(\@service_files));
- my @timers = grep { m{^lib/systemd/system/[^\/]+\.timer$} }
+ my @timers = grep { m{^(?:usr/)?lib/systemd/system/[^\/]+\.timer$} }
@{$self->processable->installed->sorted_list};
$self->timers(\@timers);
@@ -325,15 +325,15 @@ sub check_systemd_service_file {
# We are a "standalone" service file if we have no .path or .timer
# equivalent.
my $is_standalone = 1;
- if ($file =~ m{^lib/systemd/system/([^/]*?)@?\.service$}) {
+ if ($file =~ m{^(usr/)?lib/systemd/system/([^/]*?)@?\.service$}) {
- my $service = $1;
+ my ($usr, $service) = ($1 // $EMPTY, $2);
$is_standalone = 0
if $self->processable->installed->resolve_path(
- "lib/systemd/system/${service}.path")
+ "${usr}lib/systemd/system/${service}.path")
|| $self->processable->installed->resolve_path(
- "lib/systemd/system/${service}.timer");
+ "${usr}lib/systemd/system/${service}.timer");
}
for my $target (@wanted_by) {
@@ -352,7 +352,7 @@ sub check_systemd_service_file {
if ( !@wanted_by
&& !$is_oneshot
&& $is_standalone
- && $file =~ m{^lib/systemd/[^\/]+/[^\/]+\.service$}
+ && $file =~ m{^(?:usr/)?lib/systemd/[^\/]+/[^\/]+\.service$}
&& $file !~ m{@\.service$}) {
$self->hint('systemd-service-file-missing-install-key', $file)
--
2.32.0
Attachment:
signature.asc
Description: PGP signature