--- 2.10.3/dh_runit 2020-12-29 11:34:35.000000000 +0000
+++ 2.10.3ubuntu3/dh_runit 2020-12-30 09:59:46.000000000 +0000
@@ -1,194 +1,6 @@
#!/usr/bin/perl -w
-
-use v5.10.1;
-use strict;
-use Debian::Debhelper::Dh_Lib;
-use File::Find;
-use File::Path qw(make_path);
-use File::stat;
-use Text::Hogan::Compiler;
-use File::Slurp qw(read_file write_file);
-use File::Copy::Recursive qw(dircopy);
-use feature 'signatures';
-no warnings 'experimental';
-
-our $VERSION = "2.10.3";
-
-# Create empty file {dest} and all required parent directories.
-sub create_empty_file {
- my ($dest) = @_;
- make_path(dirname($dest));
- write_file($dest, '') || die $!;
-}
-
-# Render mustache template {name} from data directory into {dest},
-# substituting {values} hash. If {perm} argument is provided, it is used
-# set permissions of {dest}. Intermediate directories to ${dest} are
-# created as needed.
-#
-# Data directory is specified by {DH_RUNIT_DATADIR} environment
-# variable, and defaults to /usr/share/dh-runit/data.
-sub template_from_data_directory {
- my ($name, $dest, $values, $perm) = @_;
- my $datadir = $ENV{DH_RUNIT_DATADIR} || "/usr/share/dh-runit/data";
- my $template = read_file("${datadir}/${name}");
- my $compiler = Text::Hogan::Compiler->new;
- my $output = $compiler->compile($template)->render($values);
-
- create_empty_file($dest);
- write_file($dest, $output);
-
- if (defined $perm) {
- chmod $perm, $dest;
- }
-}
-
-sub parse_options($opts) {
- my $conf = { enable => 1, onupgrade => 'restart' };
- for my $opt (split(/,/, $opts)) {
- given($opt) {
- when (/^disable$/) { $conf->{enable} = 0; };
- when (/^name=(.*)$/) { $conf->{name} = $1; };
- when (/^onupgrade=(.*)$/) { $conf->{onupgrade} = $1; };
- when (/^since=(.*)$/) { $conf->{since} = $1; };
- when (/^logscript$/) { $conf->{logscript} = 1};
- when (/^noreplace$/) { $conf->{noreplace} = 1};
- when (/^presubj$/) { $conf->{presubj} = 1; };
- when (/^defaults$/) { "do nothing"; };
- default { error("unknown option `$opt'"); }
- }
- }
- return $conf;
-}
-
-sub ensure_executable($directory) {
- my @scripts = (
- 'run',
- 'finish',
- 'check',
- 'log/run',
- 'log/finish',
- 'control/c',
- 'control/d',
- 'control/t',
- 'control/u',
- 'control/x',
- );
-
- for my $f (@scripts) {
- my $file = "$directory/$f";
- doit('chmod', '+x', $file) if (-e $file);
- }
-}
-
-sub runit_autoscript($pkg, $script, $sed) {
- autoscript($pkg, $script, "$script-runit", $sed);
-}
-
-init();
-
-PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
- next if is_udeb($pkg);
-
- my @entries = ();
- if (my $pkgfile = pkgfile($pkg, 'runit')) {
- @entries = filedoublearray($pkgfile);
- }
- while (@ARGV) {
- (my $path, my $opts) = splice(@ARGV, 0, 2);
- push @entries, [$path, $opts];
- }
-
- next unless @entries;
-
- my $tmp = tmpdir($pkg);
- my $sv_dir = "$tmp/etc/sv";
-
- for (@entries) {
- (my $path, my $opts) = @$_;
- error("can't read `$path'") unless -r $path;
-
- my $conf = parse_options($opts);
- my $name = $conf->{name} || basename($path);
-
- my @upgrades = ("restart", "stop", "nostop", "reload");
- foreach my $upstring (@upgrades) {
- last if ($conf->{onupgrade} eq $upstring );
- error("unknown onupgrade string") if ($upstring eq 'reload');
- }
-
- if ($conf->{onupgrade} eq 'nostop' || $conf->{onupgrade} eq 'reload') {
- create_empty_file("${tmp}/usr/share/runit/meta/${name}/noreplace");
- }
-
- if ($conf->{noreplace}) {
- warning("the noreplace option is deprecated, please use onupgrade=nostop instead");
- }
-
- # These files allow handling of uninstalled-not-purged situation.
- create_empty_file("${tmp}/usr/share/runit/meta/${name}/installed");
- create_empty_file("${tmp}/etc/sv/${name}/.meta/installed");
-
- if ( -f $path) {
- install_dir("$sv_dir/$name");
- install_prog($path, "$sv_dir/$name/run");
- } elsif ( -d $path) {
- dircopy($path, "$sv_dir/$name");
- # Unfortunately, dh_fixperms does not handle executable bit here.
- ensure_executable("$sv_dir/$name");
- }
- make_symlink("/etc/sv/$name/supervise", "/run/runit/supervise/$name", $tmp);
- install_dir("$tmp/etc/runit/runsvdir/default");
-
- my $substitutions = {
- NAME => $name,
- ENABLE => $conf->{enable} ? "yes" : "no",
- ONUPGRADE => $conf->{onupgrade}
- };
-
- runit_autoscript($pkg, 'postrm', $substitutions);
- runit_autoscript($pkg, 'postinst', $substitutions);
- runit_autoscript($pkg, 'prerm', $substitutions);
-
- if ($conf->{since}) {
- warning("the since option is deprecated and will be removed in future release of dh-runit");
- }
-
- if ($conf->{logscript}) {
- my $logdir = "/var/log/runit/$name";
-
- install_dir("$sv_dir/$name/log");
- install_dir($tmp . $logdir);
-
- template_from_data_directory('logscript', "$sv_dir/$name/log/run",
- { logdir => $logdir }, 0755);
-
- make_symlink("/etc/sv/$name/log/supervise", "/run/runit/supervise/$name.log", $tmp);
- } elsif ( -e "$sv_dir/$name/log/run") {
- make_symlink("/etc/sv/$name/log/supervise", "/run/runit/supervise/$name.log", $tmp);
- }
-
- if ($conf->{presubj}) {
- if ( -e "debian/$pkg.bug-presubj") {
- warning("presubj for $pkg already exists and takes precedence, runit presubj file not installed")
- }
- else {
- template_from_data_directory('presubj', "$tmp/usr/share/bug/$pkg/presubj",
- { pkg => $pkg }, 0644);
- }
- }
- }
- # runit=2.1.2-20 introduced 'runit-log' user
- # runit=2.1.2-23 introduced /lib/runit/invoke-run
- # runit=2.1.2-36 introduced '_runit-log' user
- # runit-helper 2.8.15 use dotlinks to mark a service as disabled, 'since' option is deprecated
- # runit-helper 2.9.0 has code for loguser transition
- # dh-runit 2.10.0 introduce the 'onupgrade' option that needs support in runit-helper
- addsubstvar($pkg, 'runit:Conflicts', 'runit', '<< 2.1.2-36~');
- addsubstvar($pkg, 'runit:Breaks', 'runit', '<< 2.1.2-36~');
- addsubstvar($pkg, 'misc:Depends', 'runit-helper', '>= 2.10.0~');
-}
+1;
# PROMISE: DH NOOP WITHOUT runit