diff options
author | Dmitry Bogatov <KAction@gnu.org> | 2016-06-04 16:22:47 +0300 |
---|---|---|
committer | Dmitry Bogatov <KAction@gnu.org> | 2016-06-04 16:22:47 +0300 |
commit | dc74a67ae5e1e13b8fb815236dd8efdfce962ba0 (patch) | |
tree | c8a1a1425f1e412f310eca651b303d6c3092fd39 |
Initial commit
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/clean | 1 | ||||
-rw-r--r-- | debian/compat | 1 | ||||
-rw-r--r-- | debian/control | 19 | ||||
-rw-r--r-- | debian/copyright | 24 | ||||
-rw-r--r-- | debian/dh-runit.install | 2 | ||||
-rw-r--r-- | debian/dh-runit.manpages | 1 | ||||
-rwxr-xr-x | debian/rules | 8 | ||||
-rw-r--r-- | debian/source/format | 1 | ||||
-rwxr-xr-x | dh_runit | 96 | ||||
-rw-r--r-- | runit.pm | 11 |
11 files changed, 169 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..85b528f --- /dev/null +++ b/debian/changelog | |||
@@ -0,0 +1,5 @@ | |||
1 | dh-runit (0.1) unstable; urgency=medium | ||
2 | |||
3 | * Initial release (Closes: #nnnn) | ||
4 | |||
5 | -- Dmitry Bogatov <KAction@gnu.org> Sat, 04 Jun 2016 13:41:17 +0300 | ||
diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..0bbfb79 --- /dev/null +++ b/debian/clean | |||
@@ -0,0 +1 @@ | |||
dh_runit.1 \ No newline at end of file | |||
diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat | |||
@@ -0,0 +1 @@ | |||
9 | |||
diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..08d73ab --- /dev/null +++ b/debian/control | |||
@@ -0,0 +1,19 @@ | |||
1 | Source: dh-runit | ||
2 | Section: admin | ||
3 | Priority: optional | ||
4 | Maintainer: Dmitry Bogatov <KAction@gnu.org> | ||
5 | Build-Depends: debhelper (>=9), perl, perl-doc | ||
6 | Standards-Version: 3.9.8 | ||
7 | Vcs-Browser: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git | ||
8 | Vcs-Git: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git | ||
9 | |||
10 | Package: dh-runit | ||
11 | Architecture: any | ||
12 | Depends: debhelper (>= 9), ${shlibs:Depends}, ${misc:Depends} | ||
13 | Description: debhelper add-on to handle runit runscripts | ||
14 | dh-runit provides a debhelper sequence addon named 'runit' and the | ||
15 | dh_runit command. | ||
16 | . | ||
17 | The dh_runit command installs runscripts and adds the appropriate code to | ||
18 | the postinst, prerm and postrm maint scripts to properly enable/disable | ||
19 | runscripts. \ No newline at end of file | ||
diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..76c07b8 --- /dev/null +++ b/debian/copyright | |||
@@ -0,0 +1,24 @@ | |||
1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
2 | Upstream-Name: dh-runit | ||
3 | Source: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git | ||
4 | |||
5 | Files: * | ||
6 | Copyright: 2016 Dmitry Bogatov <KAction@gnu.org> | ||
7 | License: GPL-3+ | ||
8 | |||
9 | License: GPL-3+ | ||
10 | This package is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 3 of the License, or | ||
13 | (at your option) any later version. | ||
14 | . | ||
15 | This package is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | . | ||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program. If not, see <https://www.gnu.org/licenses/> | ||
22 | . | ||
23 | On Debian systems, the complete text of the GNU General | ||
24 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". \ No newline at end of file | ||
diff --git a/debian/dh-runit.install b/debian/dh-runit.install new file mode 100644 index 0000000..7899e96 --- /dev/null +++ b/debian/dh-runit.install | |||
@@ -0,0 +1,2 @@ | |||
1 | dh_runit /usr/bin | ||
2 | runit.pm /usr/share/perl5/Debian/Debhelper/Sequence \ No newline at end of file | ||
diff --git a/debian/dh-runit.manpages b/debian/dh-runit.manpages new file mode 100644 index 0000000..0bbfb79 --- /dev/null +++ b/debian/dh-runit.manpages | |||
@@ -0,0 +1 @@ | |||
dh_runit.1 \ No newline at end of file | |||
diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6f65fce --- /dev/null +++ b/debian/rules | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/usr/bin/make -f | ||
2 | |||
3 | %: | ||
4 | dh $@ | ||
5 | |||
6 | override_dh_installman: | ||
7 | pod2man dh_runit dh_runit.1 | ||
8 | dh_installman | ||
diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format | |||
@@ -0,0 +1 @@ | |||
3.0 (native) | |||
diff --git a/dh_runit b/dh_runit new file mode 100755 index 0000000..dec7c5a --- /dev/null +++ b/dh_runit | |||
@@ -0,0 +1,96 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | =head1 NAME | ||
4 | |||
5 | dh_runit - install/enable runit runscripts | ||
6 | |||
7 | =cut | ||
8 | |||
9 | use strict; | ||
10 | use Debian::Debhelper::Dh_Lib; | ||
11 | use File::Find; | ||
12 | use Path::Tiny; | ||
13 | use File::stat; | ||
14 | |||
15 | =head1 SYNOPSIS | ||
16 | |||
17 | B<dh_runit> [S<I<debhelper options>>] [B<--no-enable>] | ||
18 | |||
19 | =head1 DESCRIPTION | ||
20 | |||
21 | B<dh_runit> is a debhelper program that is responsible for | ||
22 | installing and enabling I<runit> runscripts. If file named | ||
23 | F<debian/I<package>.runit> exists, then different actions | ||
24 | are performed, depending on its format. | ||
25 | |||
26 | For runit, every unit of supervision, simply speaking program, is | ||
27 | represented by directory under F</etc/sv>, containing at least F<run> | ||
28 | executable file. Every enabled program is represented by symbolic link | ||
29 | under F</etc/services> pointing to some directory under F</etc/sv>. | ||
30 | |||
31 | If F<debian/I<package>.runit> is not executable, but contains shebang | ||
32 | (#!) in first line, it is installed as F</etc/sv/I<package>/run> and | ||
33 | enabled. | ||
34 | |||
35 | Alternatively, F<debian/I<package>.runit> is a list of lines, where | ||
36 | every line is either starts with hash symbol and considered comment, | ||
37 | or contains two or three space-separated words. | ||
38 | |||
39 | # In this case file is installed as 'run' script. Directory name under | ||
40 | # /etc/sv is derived from file basename | ||
41 | enable path/to/file/to/be/installed/as/run/script | ||
42 | |||
43 | # Same, but install directory as whole. It is your responsibility | ||
44 | # to ensure is contains everything required. | ||
45 | enable path/to/directory | ||
46 | |||
47 | # Same as above, but do not create symlink under /etc/service | ||
48 | disable path/to/directory | ||
49 | |||
50 | # Also, you can explicitly specify name of directory under /etc/sv | ||
51 | enable path/to/directory my-preferred-name | ||
52 | |||
53 | =head1 OPTIONS | ||
54 | |||
55 | =over 4 | ||
56 | |||
57 | =item B<--no-enable> | ||
58 | |||
59 | Do not enable any runscripts. Useful, when F<debian/I<package>.runit> | ||
60 | is the only runscript, in which case you have no other ways to | ||
61 | specify, that it should not be enabled. | ||
62 | |||
63 | =back | ||
64 | |||
65 | =cut | ||
66 | |||
67 | init(option => { 'no-enable' => \$dh{NO_ENABLE} }); | ||
68 | |||
69 | PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { | ||
70 | next if is_udeb($pkg); | ||
71 | |||
72 | my $tmp = tmpdir($pkg); | ||
73 | my $sv_dir = "$tmp/etc/sv"; | ||
74 | my $runit = pkgfile($pkg, 'runit'); | ||
75 | next unless $runit; | ||
76 | |||
77 | doit('install', '-d', $sv_dir); | ||
78 | |||
79 | for my $line (path($runit)->lines) { | ||
80 | next if ($line =~ /^#/); # skip comments | ||
81 | next if ($line =~ /^\s*$/); # skip empty lines | ||
82 | (my $enable, my $path, my $name) = split /\s/, $line; | ||
83 | $name = $name || basename($path); | ||
84 | |||
85 | error("can't read `$path'") unless -r $path; | ||
86 | |||
87 | if ( -f $path) { | ||
88 | doit('install', 'd', '-m755', $path, "$sv_dir/$name/run"); | ||
89 | } elsif ( -d $path) { | ||
90 | doit('cp', '-r', $path, "$sv_dir/$name"); | ||
91 | } | ||
92 | if ($enable -eq 'enable' && !$DH{NO_ENABLE}) { | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | |||
diff --git a/runit.pm b/runit.pm new file mode 100644 index 0000000..d434d1b --- /dev/null +++ b/runit.pm | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use warnings; | ||
3 | use strict; | ||
4 | use Debian::Debhelper::Dh_Lib; | ||
5 | |||
6 | # dh_runit installs scripts as provided by source package. It would | ||
7 | # be nice to maintainers to allow them to not worry about executable | ||
8 | # bit. | ||
9 | insert_before('dh_fixperms', 'dh_runit'); | ||
10 | |||
11 | 1; | ||