[debhelper-devel] [debhelper] 18/21: dh_installsystemd: if --name is given, only generate maintainer scripts for matching files

Niels Thykier nthykier at moszumanska.debian.org
Fri Oct 13 18:27:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 3707f5c15c2ee53085386ab9faf88d577b926f0b
Author: Felipe Sateler <fsateler at debian.org>
Date:   Thu Oct 12 20:59:45 2017 -0300

    dh_installsystemd: if --name is given, only generate maintainer scripts for matching files
    
    Closes: #870768
---
 dh_installsystemd                       | 14 +++++++++++++-
 t/dh_installsystemd/dh_installsystemd.t | 15 +++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/dh_installsystemd b/dh_installsystemd
index efa5e02..29c60db 100755
--- a/dh_installsystemd
+++ b/dh_installsystemd
@@ -92,6 +92,8 @@ Install the service file as I<name.service> instead of the default filename,
 which is the I<package.service>. When this parameter is used,
 B<dh_installsystemd> looks for and installs files named
 F<debian/package.name.service> instead of the usual F<debian/package.service>.
+Moreover, maintainer scripts are only generated for units that match the given
+I<name>.
 
 =item B<--restart-after-upgrade>
 
@@ -247,7 +249,17 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 	# Handle either only the unit files which were passed as arguments or
 	# all unit files that are installed in this package.
-	my @args = @ARGV > 0 ? @ARGV : @installed_units;
+	my @args;
+	if (@ARGV > 0) {
+	       @args = @ARGV;
+	}
+	elsif ($dh{NAME}) {
+		# treat --name flag as if the corresponding units were passed in the command line
+		@args = grep /(^|\/)$dh{NAME}\.(mount|path|service|socket|target|tmpfile)$/, @installed_units;
+	}
+	else {
+		@args = @installed_units;
+	}
 
 	# support excluding units via -X
 	foreach my $x (@{$dh{EXCLUDE}}) {
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t
index d3cce0f..70133b9 100755
--- a/t/dh_installsystemd/dh_installsystemd.t
+++ b/t/dh_installsystemd/dh_installsystemd.t
@@ -116,6 +116,21 @@ each_compat_from_and_above_subtest(11, sub {
 	unit_is_enabled('foo', 'foo\x2dfuse', 1);
 	unit_is_started('foo', 'foo\x2dfuse', 1);
 	ok(run_dh_tool('dh_clean'));
+
+	# --name flag #870768
+	make_path('debian/foo/lib/systemd/system/');
+	install_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
+	ok(run_dh_tool({ 'needs_root' => 1 }, 'dh_installsystemd', '--name=foo'));
+	unit_is_enabled('foo', 'foo', 1);
+	unit_is_started('foo', 'foo', 1);
+	unit_is_enabled('foo', 'foo2', 0);
+	unit_is_started('foo', 'foo2', 0);
+	ok(run_dh_tool({ 'needs_root' => 1 }, 'dh_installsystemd', '--name=foo2'));
+	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'));
 });
 
 each_compat_up_to_and_incl_subtest(10, sub {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list