diff options
author | Dmitry Bogatov <KAction@gnu.org> | 2016-06-09 18:50:22 +0300 |
---|---|---|
committer | Dmitry Bogatov <KAction@gnu.org> | 2016-06-09 18:50:22 +0300 |
commit | fc35408ab60287a4e978ba93e61c2ded44342e7d (patch) | |
tree | 2d96b90cc3a03e1daeefb9d540046c6ae5efb634 | |
parent | 9002e984d29480a3287506c73d82f247b0dbacea (diff) |
Improve handling of maintainer scripts
* checking for /etc/service symlink is moved into preinst
* runscripts are enabled in postinst
* runscripts are disables in prerm
* supervise directory is purged on 'postrm purge'
-rw-r--r-- | debian/dh-runit.install | 2 | ||||
-rwxr-xr-x | dh_runit | 10 | ||||
-rw-r--r-- | postinst-runit | 19 | ||||
-rw-r--r-- | postrm-runit | 12 | ||||
-rw-r--r-- | preinst-runit | 19 | ||||
-rw-r--r-- | prerm-runit | 3 |
6 files changed, 43 insertions, 22 deletions
diff --git a/debian/dh-runit.install b/debian/dh-runit.install index faa7e8b..5b296b5 100644 --- a/debian/dh-runit.install +++ b/debian/dh-runit.install | |||
@@ -1,4 +1,6 @@ | |||
1 | dh_runit /usr/bin | 1 | dh_runit /usr/bin |
2 | preinst-runit /usr/share/debhelper/autoscripts | ||
2 | postinst-runit /usr/share/debhelper/autoscripts | 3 | postinst-runit /usr/share/debhelper/autoscripts |
3 | prerm-runit /usr/share/debhelper/autoscripts | 4 | prerm-runit /usr/share/debhelper/autoscripts |
5 | postrm-runit /usr/share/debhelper/autoscripts | ||
4 | runit.pm /usr/share/perl5/Debian/Debhelper/Sequence | 6 | runit.pm /usr/share/perl5/Debian/Debhelper/Sequence |
@@ -72,6 +72,10 @@ sub ensure_executable($directory) { | |||
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | sub runit_autoscript($pkg, $script, $sed) { | ||
76 | autoscript($pkg, $script, "$script-runit", $sed); | ||
77 | } | ||
78 | |||
75 | init(option => { 'no-enable' => \$dh{NO_ENABLE} }); | 79 | init(option => { 'no-enable' => \$dh{NO_ENABLE} }); |
76 | 80 | ||
77 | PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { | 81 | PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { |
@@ -82,6 +86,7 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { | |||
82 | my $runit = pkgfile($pkg, 'runit'); | 86 | my $runit = pkgfile($pkg, 'runit'); |
83 | next unless $runit; | 87 | next unless $runit; |
84 | 88 | ||
89 | runit_autoscript($pkg, 'preinst', ''); | ||
85 | install_dir($sv_dir); | 90 | install_dir($sv_dir); |
86 | 91 | ||
87 | for my $words (filedoublearray($runit)) { | 92 | for my $words (filedoublearray($runit)) { |
@@ -102,9 +107,10 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { | |||
102 | "/var/lib/runit/supervise/$name", $tmp); | 107 | "/var/lib/runit/supervise/$name", $tmp); |
103 | 108 | ||
104 | if ($enable eq 'enable' && !$dh{NO_ENABLE}) { | 109 | if ($enable eq 'enable' && !$dh{NO_ENABLE}) { |
105 | autoscript($pkg, 'postinst', 'postinst-runit', "s/#NAME#/$name/"); | 110 | runit_autoscript($pkg, 'postinst', "s/#NAME#/$name/"); |
106 | } | 111 | } |
107 | autoscript($pkg, 'prerm', 'prerm-runit', "s/#NAME#/$name/"); | 112 | runit_autoscript($pkg, 'prerm', "s/#NAME#/$name/"); |
113 | runit_autoscript($pkg, 'postrm', "s/#NAME#/$name/"); | ||
108 | } | 114 | } |
109 | addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-4'); | 115 | addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-4'); |
110 | } | 116 | } |
diff --git a/postinst-runit b/postinst-runit index 7c21f0e..1955857 100644 --- a/postinst-runit +++ b/postinst-runit | |||
@@ -1,20 +1,3 @@ | |||
1 | SV_ABS_DIR=/var/lib/runit/service | ||
2 | SV_DIR=/etc/service | 1 | SV_DIR=/etc/service |
3 | mkdir -p "$SV_ABS_DIR" | ||
4 | if [ ! -e "$SV_DIR" ] ; then | ||
5 | ln -s "$SV_ABS_DIR" "$SV_DIR" | ||
6 | fi | ||
7 | |||
8 | if [ "$(readlink -f "$SV_DIR")" != "$SV_ABS_DIR" ] ; then | ||
9 | cat <<EOF | ||
10 | Service directory '$SV_DIR' exists, but is not symbolic link | ||
11 | to '$SV_ABS_DIR'. It probably means that it was created by | ||
12 | hand or versions of runit below 2.1.2-4. | ||
13 | |||
14 | In either case, please remove service directory yourself and | ||
15 | restart installation. | ||
16 | EOF | ||
17 | exit 1 | ||
18 | fi | ||
19 | ln -sf '/etc/sv/#NAME#' "$SV_DIR/" | 2 | ln -sf '/etc/sv/#NAME#' "$SV_DIR/" |
20 | mkdir -p /var/lib/runit/supervise/#NAME# | 3 | mkdir -p '/var/lib/runit/supervise/#NAME#' |
diff --git a/postrm-runit b/postrm-runit new file mode 100644 index 0000000..9556830 --- /dev/null +++ b/postrm-runit | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/sh # just to convince emacs that it is shell script | ||
2 | |||
3 | if [ "$1" = 'purge' ] ; then | ||
4 | # If runscript was never invoked, these files would not exist, | ||
5 | # so we use -f option of rm(1). | ||
6 | for file in control lock ok pid stat status ; do | ||
7 | rm -f "/var/lib/runit/supervise/#NAME#/$file" | ||
8 | done | ||
9 | # It should exist and be empty now. If it is not, either user touched it, | ||
10 | # or there is a BUG in dh-runit! | ||
11 | rmdir "/var/lib/runit/supervise/#NAME#" | ||
12 | fi | ||
diff --git a/preinst-runit b/preinst-runit new file mode 100644 index 0000000..eaccc4a --- /dev/null +++ b/preinst-runit | |||
@@ -0,0 +1,19 @@ | |||
1 | #!/bin/sh # -*- shell-script -*- | ||
2 | SV_ABS_DIR=/var/lib/runit/service | ||
3 | SV_DIR=/etc/service | ||
4 | mkdir -p "$SV_ABS_DIR" | ||
5 | if [ ! -e "$SV_DIR" ] ; then | ||
6 | ln -s "$SV_ABS_DIR" "$SV_DIR" | ||
7 | fi | ||
8 | |||
9 | if [ "$(readlink -f "$SV_DIR")" != "$SV_ABS_DIR" ] ; then | ||
10 | cat <<EOF | ||
11 | Service directory '$SV_DIR' exists, but is not symbolic link | ||
12 | to '$SV_ABS_DIR'. It probably means that it was created by | ||
13 | hand or versions of runit below 2.1.2-4. | ||
14 | |||
15 | In either case, please remove service directory yourself and | ||
16 | restart installation. | ||
17 | EOF | ||
18 | exit 1 | ||
19 | fi | ||
diff --git a/prerm-runit b/prerm-runit index b23abeb..08aae6b 100644 --- a/prerm-runit +++ b/prerm-runit | |||
@@ -1,2 +1 @@ | |||
1 | rm -f /etc/service/#NAME# | rm -f '/etc/service/#NAME#' | |
2 | rm -fr /var/lib/runit/supervise/#NAME#/* | ||