0
  5   ˆl–Ü4ý(Ëm
‚fãB¸ÛjbÑ¿�þZ‘å›+2µ_’YçÃƒšÂÁÀ Ø    Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: rhash
Upstream-Contact: Aleksey Kravchenko <rhash.admin@gmail.com>
Source: http://rhash.sourceforge.net/

Files: *
Copyright: 2005 Aleksey Kravchenko
License: 0BSD

Files: bindings/*
Copyright: 2011 Sergey Basalaev
           2011 Aleksey Kravchenko
License: 0BSD

Files: debian/*
Copyright: 2011-2022 Aleksey Kravchenko
           2017 Gianfranco Costamagna
           2018 Lukas Schwaighofer
           2018 RaphaÃ«l Hertzog
           2019 Jelmer VernooÄ³
           2019 Samuel Henrique
License: 0BSD

License: 0BSD
 Permission to use, copy, modify, and/or distribute this software for any
 purpose with or without fee is hereby granted.
 .
 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
 REGARD TO THIS SOFTWARE  INCLUDING ALL IMPLIED WARRANTIES OF  MERCHANTABILITY
 AND FITNESS.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
 INDIRECT,  OR CONSEQUENTIAL DAMAGES  OR ANY DAMAGES WHATSOEVER RESULTING FROM
 LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION OF CONTRACT,  NEGLIGENCE
 OR OTHER TORTIOUS ACTION,  ARISING OUT OF  OR IN CONNECTION  WITH THE USE  OR
 PERFORMANCE OF THIS SOFTWARE.
  5   ˆl–Ðz¾” ”Ê:”Ê�jãm\ŠbÑ¿�þB7$Y¹BÓâ ÄB<çÄƒq×ÃÂÁ m    #!/usr/bin/perl

=head1 NAME

dh_installalternatives - install declarative alternative rules

=cut

use strict;
use warnings;
use constant LINE_PREFIX => ' ' . q{\\} . "\n            ";
use Debian::Debhelper::Dh_Lib;

our $VERSION = DH_BUILTIN_VERSION;

=head1 SYNOPSIS

B<dh_installalternatives> [S<I<debhelper options>>]

=head1 DESCRIPTION

B<dh_installalternatives> is a debhelper program that is responsible for
parsing the declarative alternatives format and insert the relevant
maintscripts snippets to interface with L<update-alternatives(1)>

=head1 FILES

=over 4

=item debian/I<package>.alternatives

An example of the format:

    Name: editor
    Link: /usr/bin/editor
    Alternative: /usr/bin/vim.basic
    Dependents:
      /usr/share/man/man1/editor.1.gz editor.1.gz /usr/share/man/man1/vim.1.gz
      /usr/share/man/fr/man1/editor.1.gz editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
      /usr/share/man/it/man1/editor.1.gz editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
      /usr/share/man/pl/man1/editor.1.gz editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
      /usr/share/man/ru/man1/editor.1.gz editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
    Priority: 50

The fields B<Link>, B<Name>, B<Alternative>, and B<Priority> are mandatory and correspond
to the L<update-alternatives(1)> B<--install> parameters B<link>, B<name>, B<path>, and
B<priority> respectively.

The B<Dependents> field is optional and consists of one or more lines. Each non-empty
line must contain exactly 3 space separated values that match (in order) the values passed
to the B<--slave> parameter for L<update-alternatives(1)>.

=back

=head1 OPTIONS

=over 4

=item B<-n>, B<--no-scripts>

Do not modify F<postinst>/F<postrm>/F<prerm> scripts.

=back

=cut

init();

# Explicitly discard attempts to use --name; it does not make sense for
# this helper.
if ($dh{NAME}) {
	warning('Ignoring unsupported --name option');
}
$dh{NAME} = undef;

# PROMISE: DH NOOP WITHOUT alternatives cli-options()

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp = tmpdir($package);
	my $alternatives = pkgfile($package, 'alternatives');

	if (-f $alternatives) {
		_parse_alternatives_file_and_generate_maintscripts($package, $tmp, $alternatives);
	}
}

sub _parse_alternative_and_generate_maintscript {
	my ($package, $tmpdir, $alternatives_file, $ctrl) = @_;

	my $link_name = $ctrl->{'Name'} // error("Missing mandatory \"Name\" field in ${alternatives_file}");
	my $link_path = $ctrl->{'Link'}
		// error("Missing mandatory \"Link\" field for \"${link_name}\" in ${alternatives_file}");
	my $impl_path = $ctrl->{'Alternative'}
		// error("Missing mandatory \"Alternative\" field for \"${link_name}\" in ${alternatives_file}"