Hello!

I'm attaching a lightly tested patch to implement support for
the -X option in both dh_systemd_enable and dh_systemd_start.
Please review carefully.

Regards,
Andreas Henriksson
>From 8ffc1b0c731a52bbbeb7411b08b77d5526403ff4 Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andr...@fatal.se>
Date: Mon, 17 Nov 2014 00:52:42 +0100
Subject: [PATCH] Add support for -X option. (Closes: #760168)

---
 debian/changelog         | 6 ++++++
 script/dh_systemd_enable | 5 +++++
 script/dh_systemd_start  | 5 +++++
 3 files changed, 16 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 9698e4c..dbb3375 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+init-system-helpers (1.21+nmu1) UNRELEASED; urgency=medium
+
+  * Add support for -X option. (Closes: #760168)
+
+ -- Andreas Henriksson <andr...@fatal.se>  Mon, 17 Nov 2014 00:26:13 +0100
+
 init-system-helpers (1.21) unstable; urgency=medium
 
   * Demote augeas-tools to Suggests and let the systemd2init tool error out
diff --git a/script/dh_systemd_enable b/script/dh_systemd_enable
index 41323dc..7fcd4bf 100755
--- a/script/dh_systemd_enable
+++ b/script/dh_systemd_enable
@@ -184,6 +184,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	# all unit files that are installed in this package.
 	my @args = @ARGV > 0 ? @ARGV : @installed_units;
 
+	# support excluding units via -X
+	foreach my $x (@{$dh{EXCLUDE}}) {
+		@args = grep !/(^|\/)$x$/, @args;
+	}
+
 	for my $name (@args) {
 		my $base = basename($name);
 
diff --git a/script/dh_systemd_start b/script/dh_systemd_start
index 297f9c5..279ea4c 100755
--- a/script/dh_systemd_start
+++ b/script/dh_systemd_start
@@ -131,6 +131,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	# all unit files that are installed in this package.
 	my @args = @ARGV > 0 ? @ARGV : @installed_units;
 
+	# support excluding units via -X
+	foreach my $x (@{$dh{EXCLUDE}}) {
+		@args = grep !/(^|\/)$x$/, @args;
+	}
+
 	# This hash prevents us from looping forever in the following while loop.
 	# An actual real-world example of such a loop is systemd’s
 	# systemd-readahead-drop.service, which contains
-- 
2.1.3

Reply via email to