From dc74a67ae5e1e13b8fb815236dd8efdfce962ba0 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Sat, 4 Jun 2016 16:22:47 +0300 Subject: Initial commit --- debian/changelog | 5 +++ debian/clean | 1 + debian/compat | 1 + debian/control | 19 ++++++++++ debian/copyright | 24 ++++++++++++ debian/dh-runit.install | 2 + debian/dh-runit.manpages | 1 + debian/rules | 8 ++++ debian/source/format | 1 + dh_runit | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ runit.pm | 11 ++++++ 11 files changed, 169 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/clean create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dh-runit.install create mode 100644 debian/dh-runit.manpages create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100755 dh_runit create mode 100644 runit.pm diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..85b528f --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dh-runit (0.1) unstable; urgency=medium + + * Initial release (Closes: #nnnn) + + -- Dmitry Bogatov 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 @@ +Source: dh-runit +Section: admin +Priority: optional +Maintainer: Dmitry Bogatov +Build-Depends: debhelper (>=9), perl, perl-doc +Standards-Version: 3.9.8 +Vcs-Browser: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git +Vcs-Git: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git + +Package: dh-runit +Architecture: any +Depends: debhelper (>= 9), ${shlibs:Depends}, ${misc:Depends} +Description: debhelper add-on to handle runit runscripts + dh-runit provides a debhelper sequence addon named 'runit' and the + dh_runit command. + . + The dh_runit command installs runscripts and adds the appropriate code to + the postinst, prerm and postrm maint scripts to properly enable/disable + 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 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dh-runit +Source: https://anonscm.debian.org/cgit/users/kaction-guest/cligh.git + +Files: * +Copyright: 2016 Dmitry Bogatov +License: GPL-3+ + +License: GPL-3+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + 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 @@ +dh_runit /usr/bin +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 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_installman: + pod2man dh_runit dh_runit.1 + 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 @@ +#!/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 [S>] [B<--no-enable>] + +=head1 DESCRIPTION + +B is a debhelper program that is responsible for +installing and enabling I runscripts. If file named +F.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, containing at least F +executable file. Every enabled program is represented by symbolic link +under F pointing to some directory under F. + +If F.runit> is not executable, but contains shebang +(#!) in first line, it is installed as F/run> and +enabled. + +Alternatively, F.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.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}) { + } + } +} + diff --git a/runit.pm b/runit.pm new file mode 100644 index 0000000..d434d1b --- /dev/null +++ b/runit.pm @@ -0,0 +1,11 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Debian::Debhelper::Dh_Lib; + +# dh_runit installs scripts as provided by source package. It would +# be nice to maintainers to allow them to not worry about executable +# bit. +insert_before('dh_fixperms', 'dh_runit'); + +1; -- cgit v1.2.3