75000
  L   ˆl–Ðz¾” ”Ê:”Ê�jãm\ŠbÑ¿�þD&�Y¹BÓâ ÄB<çÍƒy×[Ìa–Ü4ý( ©¤ýÔâ€jà…pS�ÿÐ "G    #!/usr/bin/perl -w

=head1 NAME

dh_systemd_start - start/stop/restart systemd unit files

=cut

use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
use File::Find;
use Cwd qw(getcwd abs_path);

our $VERSION = DH_BUILTIN_VERSION;

=head1 SYNOPSIS

B<dh_systemd_start> [S<I<debhelper options>>] [B<--restart-after-upgrade>] [B<--no-stop-on-upgrade>] [S<I<unit file> ...>]

=head1 DESCRIPTION

B<dh_systemd_start> is a debhelper program that is responsible for
starting/stopping or restarting systemd unit files in case no corresponding
sysv init script is available.

As with B<dh_installinit>, the unit file is stopped before
upgrades and started afterwards (unless B<--restart-after-upgrade> is
specified, in which case it will only be restarted after the upgrade).
This logic is not used when there is a corresponding SysV init script
because invoke-rc.d performs the stop/start/restart in that case.

=head1 OPTIONS

=over 4

=item B<--restart-after-upgrade>

Do not stop the unit file until after the package upgrade has been completed.
This is the default behaviour in compat 10.

In earlier compat levels the default was to stop the unit file in the
F<prerm>, and start it again in the F<postinst>.

This can be useful for daemons that should not have a possibly long
downtime during upgrade. But you should make sure that the daemon will not
get confused by the package being upgraded while it's running before using
this option.

=item B<--no-restart-after-upgrade>

Undo a previous B<--restart-after-upgrade> (or the default of compat
10).  If no other options are given, this will cause the service to be
stopped in the F<prerm> script and started again in the F<postinst>
script.

=item B<-r>, B<--no-stop-on-upgrade>, B<--no-restart-on-upgrade>

Do not stop service on upgrade.

=item B<--no-start>

Do not start the unit file after upgrades and after initial installation (the
latter is only relevant for services without a corresponding init script).

=back

=head1 NOTES

Note that this command is not idempotent. L<dh_prep(1)> should be called
between invocations of this command (with the same arguments). Otherwise, it
may cause multiple instances of the same text to be added to maintainer
scripts.

Note that B<dh_systemd_start> should be run after B<dh_installinit> so that it
can detect corresponding SysV init scripts. The default sequence in B<dh> does
the right thing, this note is only relevant when you are calling
B<dh_systemd_start> manually.

=cut

if (not compat(10)) {
	error("dh_systemd_start is no longer used in compat >= 11, please use dh_installsystemd instead");
}

$dh{RESTART_AFTER_UPGRADE} = 1 if not compat(9);

init(options => {
	"r" => \$dh{R_FLAG},
	'no-stop-on-upgrade' => \$dh{R_FLAG},
	"no-restart-on-upgrade" => \$dh{R_FLAG},
	"no-start" => \$dh{NO_START},
	"R|restart-after-upgrade!" => \$dh{RESTART_AFTER_UPGRADE},
	"no-also" => \$dh{NO_ALSO},
});

# Extracts the Also= or Alias= line(s) from a unit file.
# In case this produces horribly wrong results, you can pass --no-also, but
# that should really not be necessary. Please report bugs to
# pkg-systemd-maintainers.
sub extract_key {
	my ($unit_path, $key) = @_;
	my @values;

	return if $dh{NO_ALSO};

	open(my $fh, '<', $unit_path) or error("Cannot open($unit_path) for extracting the Also= line(s): $!");

	while (my $line = <$fh>) {
		chomp($line);

		# The keys parsed from the unit file below can only have
		# unit names as values. Since unit names can't have
		# whitespace in systemd, simply use split and strip any
		# leading/trailing quotes. See systemd-escape(1) for
		# examples of valid unit names.
		if ($line =~ /^\s*$key=(.+)$/i) {
			for my $value (split(/\s+/, $1)) {
				$value =~ s/^(["'])(.*)\g1$/$2/;
				push @values, $value;
			}
		}
	}
	close($fh);
	return @values;
}


# PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system)

my %requested_files = map { basename($_) => 1 } @ARGV;
my %installed_files;

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmpdir = tmp