summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@gnu.org>2018-05-23 08:23:08 +0300
committerDmitry Bogatov <KAction@gnu.org>2018-05-27 11:13:01 +0300
commitc870dcaa53988f709b1152221e76992972365fb5 (patch)
treefc056e71e6208daeb60335d9f0d543674f34887e
parent9376da82f5ae0b68c361c314b8af09ab56229671 (diff)
Do not re-enable serice on upgrade
* Do not make symbolic link /etc/runit/runsvdir/default/$name -> /etc/sv/$name part of package files {in which case it will be unconditionally created on upgrade}; instead manage it in maintainer scripts: create it in postinst script on fresh install and remove on purge/remove in postrm. * Force versioned dependency on runit-helper, to make sure that versioned dependency on dh-runit would close #899242
-rw-r--r--debian/changelog7
-rw-r--r--debian/dh-runit.install1
-rwxr-xr-xdh_runit17
-rw-r--r--postinst-runit12
-rw-r--r--postrm-runit1
-rwxr-xr-xrunit-helper23
6 files changed, 51 insertions, 10 deletions
diff --git a/debian/changelog b/debian/changelog
index 9a92168..578581d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1dh-runit (2.7.3) unstable; urgency=medium
2
3 * Do not re-enable serice on upgrade, if it was disable by local
4 administrator (See #899242)
5
6 -- Dmitry Bogatov <KAction@gnu.org> Wed, 23 May 2018 08:19:55 +0300
7
1dh-runit (2.7.2) unstable; urgency=medium 8dh-runit (2.7.2) unstable; urgency=medium
2 9
3 * Invoke runit-helper only if it is available. It ensures, that in 10 * Invoke runit-helper only if it is available. It ensures, that in
diff --git a/debian/dh-runit.install b/debian/dh-runit.install
index 762f76a..e3f2d9d 100644
--- a/debian/dh-runit.install
+++ b/debian/dh-runit.install
@@ -1,3 +1,4 @@
1dh_runit /usr/bin 1dh_runit /usr/bin
2postrm-runit /usr/share/debhelper/autoscripts 2postrm-runit /usr/share/debhelper/autoscripts
3postinst-runit /usr/share/debhelper/autoscripts
3runit.pm /usr/share/perl5/Debian/Debhelper/Sequence 4runit.pm /usr/share/perl5/Debian/Debhelper/Sequence
diff --git a/dh_runit b/dh_runit
index 36031ed..e0a8d7e 100755
--- a/dh_runit
+++ b/dh_runit
@@ -72,11 +72,14 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
72 "/var/lib/runit/supervise/$name", $tmp); 72 "/var/lib/runit/supervise/$name", $tmp);
73 install_dir("$tmp/var/lib/runit/supervise/$name"); 73 install_dir("$tmp/var/lib/runit/supervise/$name");
74 74
75 if ($conf->{enable}) { 75 my $substitutions = {
76 make_symlink("/etc/runit/runsvdir/default/$name", 76 NAME => $name,
77 "/etc/sv/$name", $tmp); 77 ENABLE => $conf->{enable} ? "yes" : "no"
78 } 78 };
79 runit_autoscript($pkg, 'postrm', "s/#NAME#/$name/"); 79
80 runit_autoscript($pkg, 'postrm', $substitutions);
81 runit_autoscript($pkg, 'postinst', $substitutions);
82
80 if ($conf->{logscript}) { 83 if ($conf->{logscript}) {
81 my $logdir = "/var/log/runit/$name"; 84 my $logdir = "/var/log/runit/$name";
82 85
@@ -100,7 +103,7 @@ HERE
100 } 103 }
101 } 104 }
102 addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-7'); 105 addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-7');
103 addsubstvar($pkg, 'misc:Depends', 'runit-helper'); 106 addsubstvar($pkg, 'misc:Depends', 'runit-helper', '>= 2.7.3');
104} 107}
105 108
106# PROMISE: DH NOOP WITHOUT runit 109# PROMISE: DH NOOP WITHOUT runit
@@ -184,3 +187,5 @@ This section contains several example snippets from F<I<package>.runit>
184 path/to/directory name=my-preferred-name,logscript 187 path/to/directory name=my-preferred-name,logscript
185 188
186=cut 189=cut
190
191# vim: et:sw=4
diff --git a/postinst-runit b/postinst-runit
new file mode 100644
index 0000000..6110707
--- /dev/null
+++ b/postinst-runit
@@ -0,0 +1,12 @@
1# -*- shell-script -*-
2export NAME='#NAME#'
3export ENABLE='#ENABLE#'
4
5# Unlike postrm, I can be sure, that runit-helper is present on
6# postinst.
7/lib/runit-helper/runit-helper postinst "$@"
8
9# Local Variables:
10# eval: (sh-set-shell "sh" t nil)
11# End:
12# vim: ft=sh:sw=4
diff --git a/postrm-runit b/postrm-runit
index a306688..d5748c9 100644
--- a/postrm-runit
+++ b/postrm-runit
@@ -1,5 +1,6 @@
1# -*- shell-script -*- 1# -*- shell-script -*-
2export NAME='#NAME#' 2export NAME='#NAME#'
3export ENABLE='#ENABLE#'
3 4
4# Unfortunately, we can not assume, that bin:runit-helper package 5# Unfortunately, we can not assume, that bin:runit-helper package
5# is installed at postrm stage. 6# is installed at postrm stage.
diff --git a/runit-helper b/runit-helper
index e48020b..05724af 100755
--- a/runit-helper
+++ b/runit-helper
@@ -18,7 +18,25 @@
18 18
19set -e 19set -e
20 20
21postinst () {
22 local action="${1}" previous="${2:-}"
23
24 # Fresh installation (not upgrade). It is important to not override
25 # local admin decision (see #899242).
26 if [ "${ENABLE}" = yes ] && [ -z "${previous}" ] ; then
27 ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME"
28 fi
29}
30
21postrm () { 31postrm () {
32 local action="${1}"
33
34 if [ "${action}" != 'purge' ] && [ "${action}" != 'remove' ] ; then
35 return
36 fi
37
38 # Links in other runsvdirs is responsibility of administrator.
39 rm -f "/etc/runit/runsvdir/default/$NAME"
22 40
23 # Following code makes sure, that after removal of package, in default 41 # Following code makes sure, that after removal of package, in default
24 # setup, the only files belonged to log user, belong to root. 42 # setup, the only files belonged to log user, belong to root.
@@ -33,10 +51,6 @@ postrm () {
33 chown --recursive root:root "/var/log/runit/$NAME" 51 chown --recursive root:root "/var/log/runit/$NAME"
34 fi 52 fi
35 53
36 if [ "$1" != 'purge' ] ; then
37 return
38 fi
39
40 # If runscript was never invoked, there will be no files 54 # If runscript was never invoked, there will be no files
41 # in this directory, and `dpkg' will remove it. In this case, 55 # in this directory, and `dpkg' will remove it. In this case,
42 # we have nothing to do. 56 # we have nothing to do.
@@ -64,3 +78,4 @@ postrm () {
64} 78}
65 79
66"$@" 80"$@"
81# vim: sw=4:et