summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Sateler <fsateler@debian.org>2016-12-14 22:31:27 -0300
committerNiels Thykier <niels@thykier.net>2016-12-15 07:23:17 +0000
commitdc22817e139ba9924bd428c0a244c878117372ca (patch)
tree06f9d1eb6a0dfa27ab6601adead34af99551cc5a
parent8bf26d222b21c89794d9ff19886145527eef6992 (diff)
installinit: do not process systemd files from compat 11 onwards
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--debhelper.pod6
-rwxr-xr-xdh_installinit12
-rw-r--r--t/dh_installinit/debian/changelog5
-rw-r--r--t/dh_installinit/debian/compat1
-rw-r--r--t/dh_installinit/debian/control20
-rw-r--r--t/dh_installinit/debian/foo.service5
-rwxr-xr-xt/dh_installinit/dh_installinit.t57
7 files changed, 101 insertions, 5 deletions
diff --git a/debhelper.pod b/debhelper.pod
index e7697ead..c9a3739e 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 087a3bd8..a727af42 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 00000000..5850f0e2
--- /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@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 00000000..f599e28b
--- /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 00000000..48d4de2f
--- /dev/null
+++ b/t/dh_installinit/debian/control
@@ -0,0 +1,20 @@
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing@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 00000000..aa216362
--- /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 00000000..d05c2074
--- /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: