diff options
author | Dmitry Bogatov <KAction@gnu.org> | 2017-03-02 13:48:19 +0300 |
---|---|---|
committer | Dmitry Bogatov <KAction@gnu.org> | 2017-03-02 13:48:19 +0300 |
commit | 1d0b451857a58613deb0366cc3436a0bad25a938 (patch) | |
tree | 3ab33bce4b2b2dcba47c599cbcdee5433959a47b | |
parent | fa229e9d6d037e08ff548b80a9b43ffded8e352a (diff) |
Introduce new binary package 'runit-helper', allowing packages to access fixes and improvements in 'dh-runit' without rebuild.
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | debian/control | 12 | ||||
-rw-r--r-- | debian/runit-helper.install | 1 | ||||
-rwxr-xr-x | dh_runit | 1 | ||||
-rw-r--r-- | postrm-runit | 42 | ||||
-rwxr-xr-x | runit-helper | 66 |
6 files changed, 84 insertions, 40 deletions
diff --git a/debian/changelog b/debian/changelog index 2e667cb..cf18f07 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -9,6 +9,8 @@ dh-runit (2.7) UNRELEASED; urgency=medium | |||
9 | backward-incompatible change, hence the version major bump, but I am | 9 | backward-incompatible change, hence the version major bump, but I am |
10 | unaware of any actual users of this option. | 10 | unaware of any actual users of this option. |
11 | * Ensure that after package removal logs belong to root. | 11 | * Ensure that after package removal logs belong to root. |
12 | * Introduce new binary package 'runit-helper', allowing packages to | ||
13 | access fixes and improvements in 'dh-runit' without rebuild. | ||
12 | 14 | ||
13 | -- Dmitry Bogatov <KAction@gnu.org> Wed, 01 Mar 2017 18:38:17 +0300 | 15 | -- Dmitry Bogatov <KAction@gnu.org> Wed, 01 Mar 2017 18:38:17 +0300 |
14 | 16 | ||
diff --git a/debian/control b/debian/control index 74b3dba..03f464d 100644 --- a/debian/control +++ b/debian/control | |||
@@ -20,3 +20,15 @@ Description: debhelper add-on to handle runit runscripts | |||
20 | The dh_runit command installs runscripts and adds the appropriate code to | 20 | The dh_runit command installs runscripts and adds the appropriate code to |
21 | the postinst, prerm and postrm maint scripts to properly enable/disable | 21 | the postinst, prerm and postrm maint scripts to properly enable/disable |
22 | runscripts. | 22 | runscripts. |
23 | |||
24 | Package: runit-helper | ||
25 | Architecture: all | ||
26 | Depends: ${misc:Depends}, ${shlibs:Depends} | ||
27 | Description: dh-sysuser implementation detail | ||
28 | runit-helper provides code, which actually perform actions on system | ||
29 | users on behalf of dh-runit package. This separation allows packages | ||
30 | take advantage of improvement or fixes in 'dh-runit' without | ||
31 | rebuilding. | ||
32 | . | ||
33 | This package is implementation detail of 'dh-runit'. It should never | ||
34 | be installed manually. No assumption about its content can be made. | ||
diff --git a/debian/runit-helper.install b/debian/runit-helper.install new file mode 100644 index 0000000..3d377d2 --- /dev/null +++ b/debian/runit-helper.install | |||
@@ -0,0 +1 @@ | |||
runit-helper /lib/runit-helper/ | |||
@@ -100,6 +100,7 @@ HERE | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-7'); | 102 | addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-7'); |
103 | addsubstvar($pkg, 'misc:Depends', 'runit-helper'); | ||
103 | } | 104 | } |
104 | 105 | ||
105 | # PROMISE: DH NOOP WITHOUT runit | 106 | # PROMISE: DH NOOP WITHOUT runit |
diff --git a/postrm-runit b/postrm-runit index 5ce6acf..edd9ee7 100644 --- a/postrm-runit +++ b/postrm-runit | |||
@@ -1,44 +1,6 @@ | |||
1 | # -*- shell-script -*- | 1 | # -*- shell-script -*- |
2 | 2 | export NAME='#NAME#' | |
3 | if [ "$1" = 'purge' ] ; then | 3 | /lib/runit-helper/runit-helper postrm "$@" |
4 | # If runscript was never invoked, there will be no files | ||
5 | # in this directory, and `dpkg' will remove it. In this case, | ||
6 | # we have nothing to do. | ||
7 | for supervise in '/var/lib/runit/supervise/#NAME#' \ | ||
8 | '/var/lib/runit/log/supervise/#NAME#' ; do | ||
9 | if [ -d "$supervise" ] ; then | ||
10 | |||
11 | # Actually only `down' may be absent, but it does not | ||
12 | # matter. | ||
13 | |||
14 | for file in control lock ok pid stat status down ; do | ||
15 | rm -f "$supervise/$file" | ||
16 | done | ||
17 | |||
18 | # It should be empty now. If it is not, it means that | ||
19 | # system administrator put something there. It is very | ||
20 | # stupid, but will of user is sacred, and directory is | ||
21 | # left as-is in such case. | ||
22 | # | ||
23 | # NOTE: Non-POSIX option is used. The day coreutils will | ||
24 | # no longer be essential, it will require a fix. | ||
25 | rmdir --ignore-fail-on-non-empty "$supervise" | ||
26 | fi | ||
27 | done | ||
28 | fi | ||
29 | |||
30 | # Following code makes sure, that after removal of package, in default | ||
31 | # setup, the only files belonged to log user, belong to root. | ||
32 | # | ||
33 | # This way user can be safely removed, solving part of #848239 (need | ||
34 | # interoperation from dh-sysuser). | ||
35 | # | ||
36 | # Sure, system administrator can make stupid thing and chown some file | ||
37 | # to log user, but consequences do not seem to be so severe. After | ||
38 | # all, with great power comes great responsibility. | ||
39 | if [ -d '/var/log/runit/#NAME#' ] ; then | ||
40 | chown --recursive root:root '/var/log/runit/#NAME#' | ||
41 | fi | ||
42 | 4 | ||
43 | # Local Variables: | 5 | # Local Variables: |
44 | # eval: (sh-set-shell "sh" t nil) | 6 | # eval: (sh-set-shell "sh" t nil) |
diff --git a/runit-helper b/runit-helper new file mode 100755 index 0000000..e48020b --- /dev/null +++ b/runit-helper | |||
@@ -0,0 +1,66 @@ | |||
1 | #!/bin/sh | ||
2 | # Copyright (C) 2017 Dmitry Bogatov <KAction@gnu.org> | ||
3 | |||
4 | # Author: Dmitry Bogatov <KAction@gnu.org> | ||
5 | |||
6 | # This program is free software; you can redistribute it and/or | ||
7 | # modify it under the terms of the GNU General Public License | ||
8 | # as published by the Free Software Foundation; either version 3 | ||
9 | # of the License, or (at your option) any later version. | ||
10 | |||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | |||
16 | # You should have received a copy of the GNU General Public License | ||
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | |||
19 | set -e | ||
20 | |||
21 | postrm () { | ||
22 | |||
23 | # Following code makes sure, that after removal of package, in default | ||
24 | # setup, the only files belonged to log user, belong to root. | ||
25 | # | ||
26 | # This way user can be safely removed, solving part of #848239 (need | ||
27 | # interoperation from dh-sysuser). | ||
28 | # | ||
29 | # Sure, system administrator can make stupid thing and chown some file | ||
30 | # to log user, but consequences do not seem to be so severe. After | ||
31 | # all, with great power comes great responsibility. | ||
32 | if [ -d "/var/log/runit/$NAME" ] ; then | ||
33 | chown --recursive root:root "/var/log/runit/$NAME" | ||
34 | fi | ||
35 | |||
36 | if [ "$1" != 'purge' ] ; then | ||
37 | return | ||
38 | fi | ||
39 | |||
40 | # If runscript was never invoked, there will be no files | ||
41 | # in this directory, and `dpkg' will remove it. In this case, | ||
42 | # we have nothing to do. | ||
43 | for supervise in "/var/lib/runit/supervise/$NAME" \ | ||
44 | "/var/lib/runit/log/supervise/$NAME" ; do | ||
45 | if [ -d "$supervise" ] ; then | ||
46 | |||
47 | # Actually only `down' may be absent, but it does not | ||
48 | # matter. | ||
49 | |||
50 | for file in control lock ok pid stat status down ; do | ||
51 | rm -f "$supervise/$file" | ||
52 | done | ||
53 | |||
54 | # It should be empty now. If it is not, it means that | ||
55 | # system administrator put something there. It is very | ||
56 | # stupid, but will of user is sacred, and directory is | ||
57 | # left as-is in such case. | ||
58 | # | ||
59 | # NOTE: Non-POSIX option is used. The day coreutils will | ||
60 | # no longer be essential, it will require a fix. | ||
61 | rmdir --ignore-fail-on-non-empty "$supervise" | ||
62 | fi | ||
63 | done | ||
64 | } | ||
65 | |||
66 | "$@" | ||