[debhelper-devel] [debhelper] 01/01: installinit: do not process systemd files from compat 11 onwards

Niels Thykier nthykier at moszumanska.debian.org
Thu Dec 15 07:30:43 UTC 2016


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

nthykier pushed a commit to branch master
in repository debhelper.

commit dc22817e139ba9924bd428c0a244c878117372ca
Author: Felipe Sateler <fsateler at debian.org>
Date:   Wed Dec 14 22:31:27 2016 -0300

    installinit: do not process systemd files from compat 11 onwards
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debhelper.pod                       |  6 ++++
 dh_installinit                      | 12 ++++----
 t/dh_installinit/debian/changelog   |  5 ++++
 t/dh_installinit/debian/compat      |  1 +
 t/dh_installinit/debian/control     | 20 +++++++++++++
 t/dh_installinit/debian/foo.service |  5 ++++
 t/dh_installinit/dh_installinit.t   | 57 +++++++++++++++++++++++++++++++++++++
 7 files changed, 101 insertions(+), 5 deletions(-)

diff --git a/debhelper.pod b/debhelper.pod
index e7697ea..c9a3739 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -586,6 +586,12 @@ F<menu-method> files are still installed.
 
 =item -
 
+B<dh_installinit> no longer installs F<service> or F<tmpfile> files, nor
+generates maintainer scripts for those files. Use B<dh_systemd_enable> and
+B<dh_systemd_start> instead.
+
+=item -
+
 The B<-s> (B<--same-arch>) option is removed.
 
 =item -
diff --git a/dh_installinit b/dh_installinit
index 087a3bd..a727af4 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -47,13 +47,13 @@ build directory.
 =item debian/I<package>.service
 
 If this exists, it is installed into lib/systemd/system/I<package>.service in
-the package build directory.
+the package build directory. Only compat levels 10 and below.
 
 =item debian/I<package>.tmpfile
 
 If this exists, it is installed into usr/lib/tmpfiles.d/I<package>.conf in the
 package build directory. (The tmpfiles.d mechanism is currently only used
-by systemd.)
+by systemd.) Only compat levels 10 and below.
 
 =back
 
@@ -216,14 +216,16 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		}
 	}       
 
-	my $service=pkgfile($package,"service");
+	my $service='';
+	$service=pkgfile($package,"service") if compat(10);
 	if ($service ne '' && ! $dh{ONLYSCRIPTS}) {
 		my $path="$tmp/lib/systemd/system";
 		install_dir($path);
 		install_file($service, "$path/$script.service");
 	}
 
-	my $tmpfile=pkgfile($package,"tmpfile");
+	my $tmpfile='';
+	$tmpfile=pkgfile($package,"tmpfile") if compat(10);
 	if ($tmpfile ne '' && ! $dh{ONLYSCRIPTS}) {
 		my $path="$tmp/usr/lib/tmpfiles.d";
 		install_dir($path);
@@ -254,7 +256,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		error("Can't use --init-script with an upstart job");
 	}
 
-	if (!$dh{NOSCRIPTS}) {
+	if (compat(10) && !$dh{NOSCRIPTS}) {
 		# Include postinst-init-tmpfiles if the package ships any files
 		# in /usr/lib/tmpfiles.d or /etc/tmpfiles.d
 		my @tmpfiles;
diff --git a/t/dh_installinit/debian/changelog b/t/dh_installinit/debian/changelog
new file mode 100644
index 0000000..5850f0e
--- /dev/null
+++ b/t/dh_installinit/debian/changelog
@@ -0,0 +1,5 @@
+foo (1.0-1) unstable; urgency=low
+
+  * Initial release. (Closes: #XXXXXX)
+
+ -- Test <testing at nowhere>  Mon, 11 Jul 2016 18:10:59 +0200
diff --git a/t/dh_installinit/debian/compat b/t/dh_installinit/debian/compat
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/t/dh_installinit/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/t/dh_installinit/debian/control b/t/dh_installinit/debian/control
new file mode 100644
index 0000000..48d4de2
--- /dev/null
+++ b/t/dh_installinit/debian/control
@@ -0,0 +1,20 @@
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing at nowhere>
+Standards-Version: 3.9.8
+
+Package: foo
+Architecture: all
+Description: package foo
+ Package foo
+
+Package: bar
+Architecture: all
+Description: package bar
+ Package bar
+
+Package: baz
+Architecture: all
+Description: package baz
+ Package baz
diff --git a/t/dh_installinit/debian/foo.service b/t/dh_installinit/debian/foo.service
new file mode 100644
index 0000000..aa21636
--- /dev/null
+++ b/t/dh_installinit/debian/foo.service
@@ -0,0 +1,5 @@
+[Unit]
+Description=A unit
+
+[Service]
+ExecStart=/bin/true
diff --git a/t/dh_installinit/dh_installinit.t b/t/dh_installinit/dh_installinit.t
new file mode 100755
index 0000000..d05c207
--- /dev/null
+++ b/t/dh_installinit/dh_installinit.t
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+use strict;
+use Test::More;
+use File::Basename ();
+
+# Let the tests be run from anywhere, but current directory
+# is expected to be the one where this test lives in.
+chdir File::Basename::dirname($0) or die "Unable to chdir to ".File::Basename::dirname($0);
+
+my $TOPDIR = "../..";
+my $rootcmd;
+
+if ($< == 0) {
+	$rootcmd = '';
+}
+else {
+	system("fakeroot true 2>/dev/null");
+	$rootcmd = $? ? undef : 'fakeroot';
+}
+
+if (not defined($rootcmd)) {
+	plan skip_all => 'fakeroot required';
+}
+else {
+	plan(tests => 5);
+}
+
+system("$TOPDIR/dh_clean");
+
+my $service = "debian/foo.service";
+
+system("mkdir -p debian/foo debian/bar debian/baz");
+system("$rootcmd $TOPDIR/dh_installinit");
+ok(-e "debian/foo/lib/systemd/system/foo.service");
+ok(-e "debian/foo.postinst.debhelper");
+system("$TOPDIR/dh_clean");
+
+system("mkdir -p debian/foo debian/bar debian/baz");
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installinit");
+ok(! -e "debian/foo/lib/systemd/system/foo.service");
+ok(! -e "debian/foo.postinst.debhelper");
+system("$TOPDIR/dh_clean");
+
+system("mkdir -p debian/foo debian/bar debian/baz");
+system("mkdir -p debian/foo/lib/systemd/system/");
+system("cp debian/foo.service debian/foo/lib/systemd/system/");
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installinit");
+ok(! -e "debian/foo.postinst.debhelper");
+system("$TOPDIR/dh_clean");
+
+system("$TOPDIR/dh_clean");
+
+# Local Variables:
+# indent-tabs-mode: t
+# tab-width: 4
+# cperl-indent-level: 4
+# End:

-- 
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