summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-08-28 13:49:06 +0200
committerHelmut Grohne <helmut@subdivi.de>2023-08-28 13:49:06 +0200
commitf957e45d9f76317bb58b6163ddb27bd874baa916 (patch)
treeeac0831b755db5afa707dd6883367fb24972873a
parent259ab8a0d17d9846ae80a157b6636e9d22be131a (diff)
parentbf161bdf9cf3e48245b220c25cebd3cc58d8a820 (diff)
Merge vcs-git/main into dgit/sidHEADdebian/13.11.5archive/debian/13.11.5master
Thie merges the maintainer history so far into the dgit tree and hopefully enables me to push it.
-rwxr-xr-xdh_installsystemd41
-rwxr-xr-xdh_systemd_enable36
-rwxr-xr-xdh_systemd_start40
-rwxr-xr-xt/dh_installsystemd/dh_installsystemd.t25
-rwxr-xr-xt/dh_installsystemd/dh_systemd.t9
5 files changed, 78 insertions, 73 deletions
diff --git a/dh_installsystemd b/dh_installsystemd
index aba9d783..ec6fe860 100755
--- a/dh_installsystemd
+++ b/dh_installsystemd
@@ -249,30 +249,31 @@ sub extract_key {
sub list_installed_units {
my ($tmpdir, $aliases) = @_;
- my $lib_systemd_system = "$tmpdir/lib/systemd/system";
my @installed;
- return unless -d $lib_systemd_system;
- opendir(my $dh, "$lib_systemd_system") or error("Cannot opendir($lib_systemd_system): $!");
-
- foreach my $name (readdir($dh)) {
- my $path = "$lib_systemd_system/$name";
- next unless -f $path;
- if (-l "$path") {
- my $dest = basename(readlink($path));
- $aliases->{$dest} //= [ ];
- push @{$aliases->{$dest}}, $name;
- } else {
- push @installed, $name;
+ foreach my $unitdir ("$tmpdir/lib/systemd/system", "$tmpdir/usr/lib/systemd/system") {
+ next unless -d $unitdir;
+ opendir(my $dh, "$unitdir") or error("Cannot opendir($unitdir): $!");
+
+ foreach my $name (readdir($dh)) {
+ my $path = "$unitdir/$name";
+ next unless -f $path;
+ if (-l "$path") {
+ my $dest = basename(readlink($path));
+ $aliases->{$dest} //= [ ];
+ push @{$aliases->{$dest}}, $name;
+ } else {
+ push @installed, $name;
+ }
}
- }
- closedir($dh);
+ closedir($dh);
+ }
return @installed;
}
-# PROMISE: DH NOOP WITHOUT internal(bug#950723) tmp(lib/systemd/system) tmp(usr/lib/tmpfiles.d) tmp(etc/tmpfiles.d) mount path service socket target tmpfile timer cli-options()
+# PROMISE: DH NOOP WITHOUT internal(bug#950723) tmp(lib/systemd/system) tmp(usr/lib/systemd/system) tmp(usr/lib/tmpfiles.d) tmp(etc/tmpfiles.d) mount path service socket target tmpfile timer cli-options()
# Install package maintainer supplied unit files
@@ -363,9 +364,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# Must use while and shift because the loop alters the list.
while (@args) {
my $unit = shift @args;
- my $path = "${tmpdir}/lib/systemd/system/${unit}";
-
- error("Package '$package' does not install unit '$unit'.") unless (-f $path);
+ my $path = "${tmpdir}/usr/lib/systemd/system/${unit}";
+ unless (-f $path) {
+ $path = "${tmpdir}/lib/systemd/system/${unit}";
+ error("Package '$package' does not install unit '$unit'.") unless (-f $path);
+ }
# Skip template service files. Enabling, disabling, starting
# or stopping those services without specifying the instance
diff --git a/dh_systemd_enable b/dh_systemd_enable
index b5eaf4b5..d9ffcb57 100755
--- a/dh_systemd_enable
+++ b/dh_systemd_enable
@@ -141,7 +141,7 @@ sub install_unit {
install_file($unit, "${path}/${script}.${installsuffix}");
}
-# PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system) mount path service socket target tmpfile timer
+# PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system) tmp(usr/lib/systemd/system) mount path service socket target tmpfile timer
my %requested_files = map { basename($_) => 1 } @ARGV;
my %installed_files;
@@ -188,19 +188,23 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
install_unit($package, $script, 'mount', "$tmpdir/lib/systemd/system");
install_unit($package, $script, 'tmpfile', "$tmpdir/usr/lib/tmpfiles.d", 'conf');
- find({
- wanted => sub {
- my $name = $File::Find::name;
- return unless -f $name;
- # Skip symbolic links, their only legitimate use is for
- # adding an alias, e.g. linking smartmontools.service
- # -> smartd.service.
- return if -l $name;
- return unless $name =~ m,^$tmpdir/lib/systemd/system/[^/]+$,;
- push @installed_units, $name;
- },
- no_chdir => 1,
- }, "${tmpdir}/lib/systemd/system") if -d "${tmpdir}/lib/systemd/system";
+ foreach my $unitdir ("${tmpdir}/usr/lib/systemd/system", "${tmpdir}/lib/systemd/system") {
+ find({
+ wanted => sub {
+ my $name = $File::Find::name;
+ return unless -f $name;
+ # Skip symbolic links, their only legitimate
+ # use is for adding an alias, e.g. linking
+ # smartmontools.service -> smartd.service.
+ return if -l $name;
+ return unless $name =~ m,^\Q$unitdir\E/[^/]+$,;
+ error("Unit $name is installed in both the /usr/lib/systemd/system and /lib/systemd/system directories of $package.")
+ if (grep { $_ eq $name } @installed_units);
+ push @installed_units, $name;
+ },
+ no_chdir => 1,
+ }, $unitdir) if -d $unitdir;
+ }
# Handle either only the unit files which were passed as arguments or
# all unit files that are installed in this package.
@@ -216,8 +220,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# Try to make the path absolute, so that the user can call
# dh_installsystemd bacula-fd.service
if ($base eq $name) {
- # NB: This works because @installed_units contains
- # files from precisely one directory.
+ # NB: This works because each unit in @installed_units
+ # comes from exactly one directory.
my ($full) = grep { basename($_) eq $base } @installed_units;
if (defined($full)) {
$name = $full;
diff --git a/dh_systemd_start b/dh_systemd_start
index af988097..a2609486 100755
--- a/dh_systemd_start
+++ b/dh_systemd_start
@@ -126,7 +126,7 @@ sub extract_key {
}
-# PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system)
+# PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system) tmp(usr/lib/systemd/system)
my %requested_files = map { basename($_) => 1 } @ARGV;
my %installed_files;
@@ -138,21 +138,25 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
my %aliases;
my $oldcwd = getcwd();
- find({
- wanted => sub {
- my $name = $File::Find::name;
- return unless -f;
- return unless $name =~ m,^\Q${tmpdir}\E/lib/systemd/system/[^/]+$,;
- if (-l) {
- my $target = abs_path(readlink());
- $target =~ s,^\Q${oldcwd}\E/,,g;
- $aliases{$target} = [ $_ ];
- } else {
- push @installed_units, $name;
- }
- },
- }, "${tmpdir}/lib/systemd/system") if -d "${tmpdir}/lib/systemd/system";
- chdir($oldcwd);
+ foreach my $unitdir ("${tmpdir}/usr/lib/systemd/system", "${tmpdir}/lib/systemd/system") {
+ find({
+ wanted => sub {
+ my $name = $File::Find::name;
+ return unless -f;
+ return unless $name =~ m,^\Q$unitdir\E/[^/]+$,;
+ if (-l) {
+ my $target = abs_path(readlink());
+ $target =~ s,^\Q${oldcwd}\E/,,g;
+ $aliases{$target} = [ $_ ];
+ } else {
+ error("Unit $name is installed in both the /usr/lib/systemd/system and /lib/systemd/system directories of $package.")
+ if (grep { $_ eq $name } @installed_units);
+ push @installed_units, $name;
+ }
+ },
+ }, $unitdir) if -d $unitdir;
+ chdir($oldcwd);
+ }
# Handle either only the unit files which were passed as arguments or
# all unit files that are installed in this package.
@@ -179,8 +183,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# Try to make the path absolute, so that the user can call
# dh_installsystemd bacula-fd.service
if ($base eq $name) {
- # NB: This works because @installed_units contains
- # files from precisely one directory.
+ # NB: This works because each unit in @installed_units
+ # comes from exactly one directory.
my ($full) = grep { basename($_) eq $base } @installed_units;
if (defined($full)) {
$name = $full;
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t
index bbb4eb0d..cb1a3dab 100755
--- a/t/dh_installsystemd/dh_installsystemd.t
+++ b/t/dh_installsystemd/dh_installsystemd.t
@@ -105,6 +105,7 @@ each_compat_subtest {
unit_is_started('foo', 'foo2', 0);
ok(run_dh_tool('dh_clean'));
+ # Install unit directly below /lib
make_path('debian/foo/lib/systemd/system/');
copy_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
ok(run_dh_tool('dh_installsystemd'));
@@ -116,27 +117,11 @@ each_compat_subtest {
unit_is_started('foo', 'foo2', 1);
ok(run_dh_tool('dh_clean'));
-
- # lib -> usr/lib (if we ever support that)
- make_path('debian/foo/lib/systemd/system/');
- copy_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
- ok(run_dh_tool('dh_installsystemd'));
- ok(-e 'debian/foo/lib/systemd/system/foo2.service');
- ok(find_script('foo', 'postinst'));
- unit_is_enabled('foo', 'foo', 1);
- unit_is_started('foo', 'foo', 1);
- unit_is_enabled('foo', 'foo2', 1);
- unit_is_started('foo', 'foo2', 1);
- ok(run_dh_tool('dh_clean'));
-
- # lib -> usr/lib with both no-empty (if we ever suport that)
- make_path('debian/foo/lib/systemd/system/');
- make_path('debian/foo/lib/systemd/system/');
- copy_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
- copy_file('debian/foo2.service', 'debian/foo/lib/systemd/system/bar.service');
+ # Install unit directly below /usr/lib
+ make_path('debian/foo/usr/lib/systemd/system/');
+ copy_file('debian/foo2.service', 'debian/foo/usr/lib/systemd/system/foo2.service');
ok(run_dh_tool('dh_installsystemd'));
- ok(-e 'debian/foo/lib/systemd/system/bar.service');
- ok(-e 'debian/foo/lib/systemd/system/foo2.service');
+ ok(-e 'debian/foo/usr/lib/systemd/system/foo2.service');
ok(find_script('foo', 'postinst'));
unit_is_enabled('foo', 'foo', 1);
unit_is_started('foo', 'foo', 1);
diff --git a/t/dh_installsystemd/dh_systemd.t b/t/dh_installsystemd/dh_systemd.t
index c3c94015..1562ee1b 100755
--- a/t/dh_installsystemd/dh_systemd.t
+++ b/t/dh_installsystemd/dh_systemd.t
@@ -65,6 +65,15 @@ each_compat_from_x_to_and_incl_y_subtest(10, 10, sub {
unit_is_started('foo', 'foo2', 1);
ok(run_dh_tool('dh_clean'));
+ make_path('debian/foo/usr/lib/systemd/system/');
+ copy_file('debian/foo2.service', 'debian/foo/usr/lib/systemd/system/foo2.service');
+ ok(run_dh_tool('dh_systemd_enable'));
+ ok(run_dh_tool('dh_systemd_start'));
+ ok(-e "debian/foo.postinst.debhelper");
+ unit_is_enabled('foo', 'foo2', 1);
+ unit_is_started('foo', 'foo2', 1);
+ ok(run_dh_tool('dh_clean'));
+
make_path('debian/foo/lib/systemd/system/');
copy_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
ok(run_dh_tool('dh_systemd_enable'));