Bug#690399: dh_installinit: add systemd support
Hi Joey, Thanks for applying my previous patch. Attached you can find another patch for dh_installinit. Quote from the commit message: dh_installinit: call systemd-tmpfiles with the config file names This makes the invocation more specific and thus less likely to have any unwanted side effects. The invocation before was: systemd-tmpfiles --create /dev/null || true With this commit, it becomes: systemd-tmpfiles --create bacula.conf /dev/null || true (for bacula-fd shipping /etc/tmpfiles.d/bacula.conf) Could you please apply it, too? Thanks. -- Best regards, Michael From 063a29e793dfd639bb450b4035125e0a85cf54ef Mon Sep 17 00:00:00 2001 From: Michael Stapelberg mich...@stapelberg.de Date: Sat, 4 May 2013 18:49:28 +0200 Subject: [PATCH] dh_installinit: call systemd-tmpfiles with the config file names This makes the invocation more specific and thus less likely to have any unwanted side effects. The invocation before was: systemd-tmpfiles --create /dev/null || true With this commit, it becomes: systemd-tmpfiles --create bacula.conf /dev/null || true (for bacula-fd shipping /etc/tmpfiles.d/bacula.conf) --- autoscripts/postinst-init-tmpfiles |2 +- dh_installinit | 12 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/autoscripts/postinst-init-tmpfiles b/autoscripts/postinst-init-tmpfiles index e6cb785..fd613bc 100644 --- a/autoscripts/postinst-init-tmpfiles +++ b/autoscripts/postinst-init-tmpfiles @@ -1,5 +1,5 @@ # In case this system is running systemd, we need to ensure that all # necessary tmpfiles (if any) are created before starting. if [ -d /run/systemd/system ] ; then - systemd-tmpfiles --create /dev/null || true + systemd-tmpfiles --create #TMPFILES# /dev/null || true fi diff --git a/dh_installinit b/dh_installinit index 2daad63..29937c5 100755 --- a/dh_installinit +++ b/dh_installinit @@ -254,21 +254,21 @@ foreach my $package (@{$dh{DOPACKAGES}}) { if (! $dh{NOSCRIPTS}) { # Include postinst-init-tmpfiles if the package ships any files # in /usr/lib/tmpfiles.d or /etc/tmpfiles.d - my $got_tmpfile = undef; my $tmpdir = tmpdir($package); + my @tmpfiles; find({ wanted = sub { return unless -f $File::Find::name; - if (!$got_tmpfile - $File::Find::name =~ m,^$tmpdir/usr/lib/tmpfiles\.d/, || + if ($File::Find::name =~ m,^$tmpdir/usr/lib/tmpfiles\.d/, || $File::Find::name =~ m,^$tmpdir/etc/tmpfiles\.d/,) { - $got_tmpfile = 1; + push @tmpfiles, $File::Find::name; } }, no_chdir = 1, }, $tmpdir); - if ($got_tmpfile) { -autoscript($package,postinst, postinst-init-tmpfiles, ); + if (@tmpfiles 0) { +autoscript($package,postinst, postinst-init-tmpfiles, + s/#TMPFILES#/ . join( , map { basename($_) } @tmpfiles)./); } if (! $dh{NO_START}) { -- 1.7.10.4
Bug#690399: dh_installinit: add systemd support
Michael Stapelberg wrote: Thanks for applying my previous patch. Attached you can find another patch for dh_installinit. Quote from the commit message: dh_installinit: call systemd-tmpfiles with the config file names This makes the invocation more specific and thus less likely to have any unwanted side effects. The invocation before was: systemd-tmpfiles --create /dev/null || true With this commit, it becomes: systemd-tmpfiles --create bacula.conf /dev/null || true (for bacula-fd shipping /etc/tmpfiles.d/bacula.conf) Could you please apply it, too? Thanks. applied -- see shy jo signature.asc Description: Digital signature
Bug#690399: dh_installinit: add systemd support
Hi Joey, Here is another patch which I’d like you to apply. Quote from the commit message: [PATCH] systemd: update check to look for /run/systemd/system The old check (for /sys/fs/cgroup/systemd) is a false-positive on systems which use standalone logind, but not systemd. The new one is recommended and used by upstream systemd in their sd_booted() implementation, see http://cgit.freedesktop.org/systemd/systemd/tree/src/libsystemd-daemon/sd-daemon.c#n518 Thanks! -- Best regards, Michael From c4d06b521ac6fc9bfb611646d01fd706516d8274 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg stapelb...@debian.org Date: Thu, 21 Mar 2013 00:37:47 +0100 Subject: [PATCH] systemd: update check to look for /run/systemd/system The old check (for /sys/fs/cgroup/systemd) is a false-positive on systems which use standalone logind, but not systemd. The new one is recommended and used by upstream systemd in their sd_booted() implementation, see http://cgit.freedesktop.org/systemd/systemd/tree/src/libsystemd-daemon/sd-daemon.c#n518 --- autoscripts/postinst-init-nostart |2 +- autoscripts/postinst-init-restart |2 +- autoscripts/postinst-init-tmpfiles |2 +- autoscripts/postrm-init|2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autoscripts/postinst-init-nostart b/autoscripts/postinst-init-nostart index ec6bdbd..6ccb483 100644 --- a/autoscripts/postinst-init-nostart +++ b/autoscripts/postinst-init-nostart @@ -1,7 +1,7 @@ if [ -x /etc/init.d/#SCRIPT# ]; then # In case this system is running systemd, we need to ensure that all # necessary tmpfiles (if any) are created before starting. - if [ -d /sys/fs/cgroup/systemd ] ; then + if [ -d /run/systemd/system ] ; then systemd-tmpfiles --create /dev/null || true fi diff --git a/autoscripts/postinst-init-restart b/autoscripts/postinst-init-restart index 862f9cc..d27cc8d 100644 --- a/autoscripts/postinst-init-restart +++ b/autoscripts/postinst-init-restart @@ -1,7 +1,7 @@ if [ -x /etc/init.d/#SCRIPT# ]; then # In case this system is running systemd, we need to ensure that all # necessary tmpfiles (if any) are created before starting. - if [ -d /sys/fs/cgroup/systemd ] ; then + if [ -d /run/systemd/system ] ; then systemd-tmpfiles --create /dev/null || true fi diff --git a/autoscripts/postinst-init-tmpfiles b/autoscripts/postinst-init-tmpfiles index 41f738a..e6cb785 100644 --- a/autoscripts/postinst-init-tmpfiles +++ b/autoscripts/postinst-init-tmpfiles @@ -1,5 +1,5 @@ # In case this system is running systemd, we need to ensure that all # necessary tmpfiles (if any) are created before starting. -if [ -d /sys/fs/cgroup/systemd ] ; then +if [ -d /run/systemd/system ] ; then systemd-tmpfiles --create /dev/null || true fi diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init index 61dcfc5..6f5bb09 100644 --- a/autoscripts/postrm-init +++ b/autoscripts/postrm-init @@ -5,6 +5,6 @@ fi # In case this system is running systemd, we make systemd reload the unit files # to pick up changes. -if [ -d /sys/fs/cgroup/systemd ] ; then +if [ -d /run/systemd/system ] ; then systemctl --system daemon-reload /dev/null || true fi -- 1.7.10.4
Bug#690399: dh_installinit: add systemd support
Hi Joey, Joey Hess jo...@debian.org writes: No, there isn’t. In other words: If debhelper can do it, you can skip the boilerplate unless the package ships any files in /etc/tmpfiles.d or /usr/lib/tmpfiles.d. Obviously debhelper can do it, it just needs to be split out into a separate autoscript that is conditionally included. Perhaps you can do that? Attached you can find a patch which will make dh_installinit only add the systemd-tmpfiles --create to postinst when the package actually ships a tmpfiles config file. mbiebl had a quick look over this patch and is okay with it. I hope this was the solution you had in mind when you said that debhelper can obviously do it… :-) -- Best regards, Michael From c1ac43595f282edee8b88ccf08bc64f731522921 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg stapelb...@debian.org Date: Mon, 29 Oct 2012 18:06:29 +0100 Subject: [PATCH] dh_installinit: only add systemd-tmpfiles --create when shipping tmpfiles --- autoscripts/postinst-init |6 -- autoscripts/postinst-init-tmpfiles |5 + dh_installinit | 20 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 autoscripts/postinst-init-tmpfiles diff --git a/autoscripts/postinst-init b/autoscripts/postinst-init index f5371ce..2430b2c 100644 --- a/autoscripts/postinst-init +++ b/autoscripts/postinst-init @@ -1,10 +1,4 @@ if [ -x /etc/init.d/#SCRIPT# ]; then - # In case this system is running systemd, we need to ensure that all - # necessary tmpfiles (if any) are created before starting. - if [ -d /sys/fs/cgroup/systemd ] ; then - systemd-tmpfiles --create /dev/null || true - fi - update-rc.d #SCRIPT# #INITPARMS# /dev/null invoke-rc.d #SCRIPT# start || #ERROR_HANDLER# fi diff --git a/autoscripts/postinst-init-tmpfiles b/autoscripts/postinst-init-tmpfiles new file mode 100644 index 000..41f738a --- /dev/null +++ b/autoscripts/postinst-init-tmpfiles @@ -0,0 +1,5 @@ +# In case this system is running systemd, we need to ensure that all +# necessary tmpfiles (if any) are created before starting. +if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true +fi diff --git a/dh_installinit b/dh_installinit index f657f85..2daad63 100755 --- a/dh_installinit +++ b/dh_installinit @@ -8,6 +8,7 @@ dh_installinit - install service init files into package build directories use strict; use Debian::Debhelper::Dh_Lib; +use File::Find; =head1 SYNOPSIS @@ -251,6 +252,25 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } if (! $dh{NOSCRIPTS}) { + # Include postinst-init-tmpfiles if the package ships any files + # in /usr/lib/tmpfiles.d or /etc/tmpfiles.d + my $got_tmpfile = undef; + my $tmpdir = tmpdir($package); + find({ +wanted = sub { + return unless -f $File::Find::name; + if (!$got_tmpfile + $File::Find::name =~ m,^$tmpdir/usr/lib/tmpfiles\.d/, || + $File::Find::name =~ m,^$tmpdir/etc/tmpfiles\.d/,) { + $got_tmpfile = 1; + } +}, +no_chdir = 1, + }, $tmpdir); + if ($got_tmpfile) { +autoscript($package,postinst, postinst-init-tmpfiles, ); + } + if (! $dh{NO_START}) { if ($dh{RESTART_AFTER_UPGRADE}) { # update-rc.d, and restart (or -- 1.7.10.4
Bug#690399: dh_installinit: add systemd support
Michael Stapelberg wrote: I talked to mbiebl and Mithrandir about it and we’ve come to the conclusion that we want to ship the files in /lib instead (for consistency with upstream packages and other distributions) and maybe work on UCF support for this location instead of shipping the service files in /etc. I have updated the patch and attached the new version. This is applied. However, I wonder about this part of it: --- a/autoscripts/postinst-init +++ b/autoscripts/postinst-init @@ -1,4 +1,10 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null invoke-rc.d #SCRIPT# start || #ERROR_HANDLER# This is a lot of boilerplate to add to every init script in Debian. Is there any reason to add this to packages that have no systemd tmpfiles? diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init index 1c29298..61dcfc5 100644 --- a/autoscripts/postrm-init +++ b/autoscripts/postrm-init @@ -1,3 +1,10 @@ if [ $1 = purge ] ; then update-rc.d #SCRIPT# remove /dev/null fi + + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /sys/fs/cgroup/systemd ] ; then + systemctl --system daemon-reload /dev/null || true +fi I'm a bit surprised this is necessary. Is this package removal case currently broken when using systemd with all the packages out there that don't do this? -- see shy jo signature.asc Description: Digital signature
Bug#690399: dh_installinit: add systemd support
Hi Joey, Joey Hess jo...@debian.org writes: This is applied. However, I wonder about this part of it: Thanks for applying! Is there a rough time estimate on when the next version of debhelper will be released? This is a lot of boilerplate to add to every init script in Debian. Is there any reason to add this to packages that have no systemd tmpfiles? No, there isn’t. In other words: If debhelper can do it, you can skip the boilerplate unless the package ships any files in /etc/tmpfiles.d or /usr/lib/tmpfiles.d. +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /sys/fs/cgroup/systemd ] ; then +systemctl --system daemon-reload /dev/null || true +fi I'm a bit surprised this is necessary. Is this package removal case currently broken when using systemd with all the packages out there that don't do this? It’s not exactly broken, but it results in quite a few unnecessary error messages and potential confusion for our users in the case when a service is not stopped on uninstall. mbiebl tested what happens in various cases: http://paste.debian.net/204443/ delete the service file, stop the service, everything fine. http://paste.debian.net/204447/ delete the service file, systemctl status will still show wrong state but mention that you should daemon-reload. http://paste.debian.net/204454/ delete the service file, try to issue a restart (fails). http://paste.debian.net/204456/ delete the service file, try to issue a stop (works). In summary: No, not all cases are broken, but there might be some. mbiebl and I agreed that the safest way is to just keep the daemon-reload in there. -- Best regards, Michael -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#690399: dh_installinit: add systemd support
Michael Stapelberg wrote: Hi Joey, Joey Hess jo...@debian.org writes: This is applied. However, I wonder about this part of it: Thanks for applying! Is there a rough time estimate on when the next version of debhelper will be released? After the release. This is a lot of boilerplate to add to every init script in Debian. Is there any reason to add this to packages that have no systemd tmpfiles? No, there isn’t. In other words: If debhelper can do it, you can skip the boilerplate unless the package ships any files in /etc/tmpfiles.d or /usr/lib/tmpfiles.d. Obviously debhelper can do it, it just needs to be split out into a separate autoscript that is conditionally included. Perhaps you can do that? -- see shy jo signature.asc Description: Digital signature
Bug#690399: dh_installinit: add systemd support
Hi Joey, hi Gergely, On 24.10.2012 16:18, Joey Hess wrote: Gergely Nagy wrote: Another option could perhaps be to ship the files in /lib, but instead of relying on UCF or some other kind of mechanism to fiddle with the symlinks in /etc, ship files there too. Files that do nothing but .include the file in /lib. Things like: .include /lib/systemd/system/foo.service The advantage of this is that the whole conffile handling is left up to dpkg, no other mechanism is needed, neither in maintainer scripts, nor elsewhere. Users can still modify the files, or even remove them: it will be handled correctly. In most cases, they can even leave the .include there, and just override the few things they need to override. (and dh_installinit could then perhaps assist with creating these .include-only files automatically, based on what the package installs under /lib/systemd) Yes, it certianly could. Choice is entirely up to the systemd maintainers.. Tollef, Michael S. and I discussed this. We do like the .include mechanism and prefer it over copying the whole .service file. That said, shipping such an .include-only file in /etc/ by default for every package providing a .service file will clutter /etc notably and we are worried about that, especially since overriding settings from .service files will be the exception rather then the norm. So we don't think dh_installinit should create such .include-only files (at least not by default). For now we will try to address this issue with better documentation e.g. in README.Debian. Another idea could be having a small helper tool, like say systemd-edit $foo.service, which could assist in creating such override/.include files. This is something we can work on in the systemd package though, so I don't think we should bother Joey with this. I'd be fine if the patch is merged as-is. Cheers, Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? signature.asc Description: OpenPGP digital signature
Bug#690399: dh_installinit: add systemd support
Michael Stapelberg stapelb...@debian.org writes: Hi Joey, Thanks for the quick review. Joey Hess jo...@debian.org writes: The only questionable part seems to be the direct use of of /etc/systemd/system/. Is there a consensus that this is the right thing to do? I see symlinks being dropped in there by many packages currently. I talked to mbiebl and Mithrandir about it and we’ve come to the conclusion that we want to ship the files in /lib instead (for consistency with upstream packages and other distributions) and maybe work on UCF support for this location instead of shipping the service files in /etc. Another option could perhaps be to ship the files in /lib, but instead of relying on UCF or some other kind of mechanism to fiddle with the symlinks in /etc, ship files there too. Files that do nothing but .include the file in /lib. Things like: .include /lib/systemd/system/foo.service The advantage of this is that the whole conffile handling is left up to dpkg, no other mechanism is needed, neither in maintainer scripts, nor elsewhere. Users can still modify the files, or even remove them: it will be handled correctly. In most cases, they can even leave the .include there, and just override the few things they need to override. (and dh_installinit could then perhaps assist with creating these .include-only files automatically, based on what the package installs under /lib/systemd) -- |8] -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#690399: dh_installinit: add systemd support
Gergely Nagy wrote: Another option could perhaps be to ship the files in /lib, but instead of relying on UCF or some other kind of mechanism to fiddle with the symlinks in /etc, ship files there too. Files that do nothing but .include the file in /lib. Things like: .include /lib/systemd/system/foo.service The advantage of this is that the whole conffile handling is left up to dpkg, no other mechanism is needed, neither in maintainer scripts, nor elsewhere. Users can still modify the files, or even remove them: it will be handled correctly. In most cases, they can even leave the .include there, and just override the few things they need to override. (and dh_installinit could then perhaps assist with creating these .include-only files automatically, based on what the package installs under /lib/systemd) Yes, it certianly could. Choice is entirely up to the systemd maintainers.. -- see shy jo signature.asc Description: Digital signature
Bug#690399: dh_installinit: add systemd support
Hi Joey, Thanks for the quick review. Joey Hess jo...@debian.org writes: The only questionable part seems to be the direct use of of /etc/systemd/system/. Is there a consensus that this is the right thing to do? I see symlinks being dropped in there by many packages currently. I talked to mbiebl and Mithrandir about it and we’ve come to the conclusion that we want to ship the files in /lib instead (for consistency with upstream packages and other distributions) and maybe work on UCF support for this location instead of shipping the service files in /etc. I have updated the patch and attached the new version. -- Best regards, Michael From 836c4369f15d641648a7e26d9a12ac4d6d28941b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg stapelb...@debian.org Date: Sun, 29 Jul 2012 19:46:53 +0200 Subject: [PATCH] Support systemd in dh_installinit and postinst/postrm --- autoscripts/postinst-init |6 + autoscripts/postinst-init-nostart |6 + autoscripts/postinst-init-restart |6 + autoscripts/postrm-init |7 ++ dh_installinit| 47 + 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/autoscripts/postinst-init b/autoscripts/postinst-init index 2430b2c..f5371ce 100644 --- a/autoscripts/postinst-init +++ b/autoscripts/postinst-init @@ -1,4 +1,10 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null invoke-rc.d #SCRIPT# start || #ERROR_HANDLER# fi diff --git a/autoscripts/postinst-init-nostart b/autoscripts/postinst-init-nostart index 7a1bd5e..ec6bdbd 100644 --- a/autoscripts/postinst-init-nostart +++ b/autoscripts/postinst-init-nostart @@ -1,3 +1,9 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null || #ERROR_HANDLER# fi diff --git a/autoscripts/postinst-init-restart b/autoscripts/postinst-init-restart index 35bba20..862f9cc 100644 --- a/autoscripts/postinst-init-restart +++ b/autoscripts/postinst-init-restart @@ -1,4 +1,10 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null if [ -n $2 ]; then _dh_action=restart diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init index 1c29298..61dcfc5 100644 --- a/autoscripts/postrm-init +++ b/autoscripts/postrm-init @@ -1,3 +1,10 @@ if [ $1 = purge ] ; then update-rc.d #SCRIPT# remove /dev/null fi + + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /sys/fs/cgroup/systemd ] ; then + systemctl --system daemon-reload /dev/null || true +fi diff --git a/dh_installinit b/dh_installinit index 9c8c155..65e143a 100755 --- a/dh_installinit +++ b/dh_installinit @@ -2,7 +2,7 @@ =head1 NAME -dh_installinit - install init scripts and/or upstart jobs into package build directories +dh_installinit - install init scripts and/or upstart jobs and/or systemd services into package build directories =cut @@ -42,6 +42,16 @@ build directory. If this exists, it is installed into etc/init/Ipackage.conf in the package build directory. +=item debian/Ipackage.service + +If this exists, it is installed into lib/systemd/system/Ipackage.service in +the package build directory. + +=item debian/Ipackage.tmpfile + +If this exists, it is installed into usr/lib/tmpfiles.d/Ipackage.conf in the +package build directory. + =back =head1 OPTIONS @@ -55,9 +65,10 @@ Do not modify Fpostinst/Fpostrm/Fprerm scripts. =item B-o, B--onlyscripts Only modify Fpostinst/Fpostrm/Fprerm scripts, do not actually install any init -script, default files, or upstart job. May be useful if the init script or -upstart job is shipped and/or installed by upstream in a way that doesn't -make it easy to let Bdh_installinit find it. +script, default files, upstart job or systemd service file. May be useful if +the init script, upstart job or systemd service file is shipped and/or +installed by upstream in a way that doesn't make it easy to let +Bdh_installinit find it. =item B-R, B--restart-after-upgrade @@ -171,6 +182,26 @@ foreach my $package (@{$dh{DOPACKAGES}}) { $script=$package; } + my $service=pkgfile($package,service); + if ($service ne '' ! $dh{ONLYSCRIPTS}) { + my $path=$tmp/lib/systemd/system; + if (! -d $path) {
Bug#690399: dh_installinit: add systemd support
Package: debhelper Severity: wishlist Tags: patch Hello, attached you can find a patch which adds support for systemd packaging in dh_installinit, just like upstart is already supported. The patch installs systemd files to /etc/systemd/system/ (see the patch for rationale) and tmpfiles to /usr/lib/tmpfiles.d. Additionally it calls systemctl daemon-reload (to pick up service file changes) and systemd-tmpfiles --create (to apply tmpfiles changes) on systems where systemd is running. -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (990, 'testing') Architecture: amd64 (x86_64) Foreign Architectures: armel i386 Kernel: Linux 3.5.0 (SMP w/8 CPU cores) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages debhelper depends on: ii binutils2.22-6.1 ii dpkg1.16.4.3 ii dpkg-dev1.16.4.3 ii file5.11-1 ii html2text 1.3.2a-15 ii man-db 2.6.2-1 ii perl5.14.2-12 ii po-debconf 1.0.16+nmu2 debhelper recommends no packages. Versions of packages debhelper suggests: ii dh-make 0.60 -- no debconf information From b544e0542f8663498f7b89c0b23f8e5fadff4a47 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg stapelb...@debian.org Date: Sun, 29 Jul 2012 19:46:53 +0200 Subject: [PATCH] Support systemd in dh_installinit and postinst/postrm --- autoscripts/postinst-init |6 + autoscripts/postinst-init-nostart |6 + autoscripts/postinst-init-restart |6 + autoscripts/postrm-init |7 + dh_installinit| 51 +++-- 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/autoscripts/postinst-init b/autoscripts/postinst-init index 2430b2c..f5371ce 100644 --- a/autoscripts/postinst-init +++ b/autoscripts/postinst-init @@ -1,4 +1,10 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null invoke-rc.d #SCRIPT# start || #ERROR_HANDLER# fi diff --git a/autoscripts/postinst-init-nostart b/autoscripts/postinst-init-nostart index 7a1bd5e..ec6bdbd 100644 --- a/autoscripts/postinst-init-nostart +++ b/autoscripts/postinst-init-nostart @@ -1,3 +1,9 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null || #ERROR_HANDLER# fi diff --git a/autoscripts/postinst-init-restart b/autoscripts/postinst-init-restart index 35bba20..862f9cc 100644 --- a/autoscripts/postinst-init-restart +++ b/autoscripts/postinst-init-restart @@ -1,4 +1,10 @@ if [ -x /etc/init.d/#SCRIPT# ]; then + # In case this system is running systemd, we need to ensure that all + # necessary tmpfiles (if any) are created before starting. + if [ -d /sys/fs/cgroup/systemd ] ; then + systemd-tmpfiles --create /dev/null || true + fi + update-rc.d #SCRIPT# #INITPARMS# /dev/null if [ -n $2 ]; then _dh_action=restart diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init index 1c29298..61dcfc5 100644 --- a/autoscripts/postrm-init +++ b/autoscripts/postrm-init @@ -1,3 +1,10 @@ if [ $1 = purge ] ; then update-rc.d #SCRIPT# remove /dev/null fi + + +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /sys/fs/cgroup/systemd ] ; then + systemctl --system daemon-reload /dev/null || true +fi diff --git a/dh_installinit b/dh_installinit index 9c8c155..60277f6 100755 --- a/dh_installinit +++ b/dh_installinit @@ -2,7 +2,7 @@ =head1 NAME -dh_installinit - install init scripts and/or upstart jobs into package build directories +dh_installinit - install init scripts and/or upstart jobs and/or systemd services into package build directories =cut @@ -42,6 +42,16 @@ build directory. If this exists, it is installed into etc/init/Ipackage.conf in the package build directory. +=item debian/Ipackage.service + +If this exists, it is installed into etc/systemd/system/Ipackage.service in +the package build directory. + +=item debian/Ipackage.tmpfile + +If this exists, it is installed into usr/lib/tmpfiles.d/Ipackage.conf in the +package build directory. + =back =head1 OPTIONS @@ -88,6 +98,13 @@ is installed as in Fetc/default/ . This may be useful for daemons with names ending in Bd. (Note: this takes precedence over the B--init-script parameter described below.) +=item B--systemd-lib + +Install the system service files to lib/systemd/system instead of +etc/systemd/system. This flag should Bonly be used when there is absolutely +no reason
Bug#690399: dh_installinit: add systemd support
Michael Stapelberg wrote: attached you can find a patch which adds support for systemd packaging in dh_installinit, just like upstart is already supported. The patch installs systemd files to /etc/systemd/system/ (see the patch for rationale) and tmpfiles to /usr/lib/tmpfiles.d. Additionally it calls systemctl daemon-reload (to pick up service file changes) and systemd-tmpfiles --create (to apply tmpfiles changes) on systems where systemd is running. This looks good. It would be nice if some of the code duplication in the autoscripts could be eliminated, but perhaps there is not a very good way to do that. The only questionable part seems to be the direct use of of /etc/systemd/system/. Is there a consensus that this is the right thing to do? I see symlinks being dropped in there by many packages currently. -- see shy jo signature.asc Description: Digital signature