1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/usr/bin/perl -w
=head1 NAME
dh_runit - install/enable runit runscripts
=cut
use strict;
use Debian::Debhelper::Dh_Lib;
use File::Find;
use Path::Tiny;
use File::stat;
=head1 SYNOPSIS
B<dh_runit> [S<I<debhelper options>>] [B<--no-enable>]
=head1 DESCRIPTION
B<dh_runit> is a debhelper program that is responsible for
installing and enabling I<runit> runscripts. If file named
F<debian/I<package>.runit> exists, then different actions
are performed, depending on its format.
For runit, every unit of supervision, simply speaking program, is
represented by directory under F</etc/sv>, containing at least F<run>
executable file. Every enabled program is represented by symbolic link
under F</etc/services> pointing to some directory under F</etc/sv>.
If F<debian/I<package>.runit> is not executable, but contains shebang
(#!) in first line, it is installed as F</etc/sv/I<package>/run> and
enabled.
Alternatively, F<debian/I<package>.runit> is a list of lines, where
every line is either starts with hash symbol and considered comment,
or contains two or three space-separated words.
# In this case file is installed as 'run' script. Directory name under
# /etc/sv is derived from file basename
enable path/to/file/to/be/installed/as/run/script
# Same, but install directory as whole. It is your responsibility
# to ensure is contains everything required.
enable path/to/directory
# Same as above, but do not create symlink under /etc/service
disable path/to/directory
# Also, you can explicitly specify name of directory under /etc/sv
enable path/to/directory my-preferred-name
=head1 OPTIONS
=over 4
=item B<--no-enable>
Do not enable any runscripts. Useful, when F<debian/I<package>.runit>
is the only runscript, in which case you have no other ways to
specify, that it should not be enabled.
=back
=cut
init(option => { 'no-enable' => \$dh{NO_ENABLE} });
PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
next if is_udeb($pkg);
my $tmp = tmpdir($pkg);
my $sv_dir = "$tmp/etc/sv";
my $runit = pkgfile($pkg, 'runit');
next unless $runit;
doit('install', '-d', $sv_dir);
for my $line (path($runit)->lines) {
next if ($line =~ /^#/); # skip comments
next if ($line =~ /^\s*$/); # skip empty lines
(my $enable, my $path, my $name) = split /\s/, $line;
$name = $name || basename($path);
error("can't read `$path'") unless -r $path;
if ( -f $path) {
doit('install', 'd', '-m755', $path, "$sv_dir/$name/run");
} elsif ( -d $path) {
doit('cp', '-r', $path, "$sv_dir/$name");
}
if ($enable -eq 'enable' && !$DH{NO_ENABLE}) {
}
}
}
|