0
  6   ˆl–Ðz¾” ”Ê:”Ê�jãm\ŠbÑ¿�þDV£Y¹BÓâ ÄB<çÍ„^l?ÌËÊ .K    #!/usr/bin/perl

=head1 NAME

dh_installchangelogs - install changelogs into package build directories

=cut

use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
use Time::Piece;

our $VERSION = DH_BUILTIN_VERSION;

=head1 SYNOPSIS

B<dh_installchangelogs> [S<I<debhelper options>>] [B<-k>] [B<-X>I<item>] [B<--no-trim>] [I<upstream>]

=head1 DESCRIPTION

B<dh_installchangelogs> is a debhelper program that is responsible for
installing changelogs into package build directories.

An upstream F<changelog> file may be specified as an option. If none
is specified, B<dh_installchangelogs> may look for files with names
that seem likely to be changelogs as described in the next paragraphs.

In non-native packages, B<dh_installchangelogs> will first look for
changelog files installed by the upstream build system into F<<
usr/share/doc/I<package> >> (of the package build directory) and
rename the most likely candidate (if any) to F<<
usr/share/doc/I<package>/changelog >>.  Note that
B<dh_installchangelogs> does I<not> look into any source directory
(such as F<debian/tmp>). Otherwise, B<dh_installchangelogs> (at
compatibility level 7 or any later) will look for changelog files in
the source directory (e.g. the root or the F<docs> subdirectory).  It
will look for F<changelog>, F<changes> and F<history> optionally with
common extensions (such as F<.txt>, F<.md> and F<.rst>).

If a changelog file is specified and is an F<html> file (determined by file
extension), it will be installed as F<usr/share/doc/package/changelog.html>
instead. If the html changelog is converted to plain text, that variant
can be specified as a second parameter. When no plain text variant is
specified, a short F<usr/share/doc/package/changelog> is generated,
pointing readers at the html changelog file.

The B<debchange>-style Debian changelogs are trimmed to include only
entries more recent than the release date of I<oldstable>.
No trimming will be performed if the B<--no-trim> option is passed or
if the B<DEB_BUILD_OPTIONS> environment variable contains B<notrimdch>.

=head1 FILES

=over 4

=item F<debian/changelog>

=item F<debian/NEWS>

=item debian/I<package>.changelog

=item debian/I<package>.NEWS

Automatically installed into usr/share/doc/I<package>/
in the package build directory.

Use the package specific name if I<package> needs a different
F<NEWS> or F<changelog> file.

The F<changelog> file is installed with a name of changelog
for native packages, and F<changelog.Debian> for non-native packages.
The F<NEWS> file is always installed with a name of F<NEWS.Debian>.

=back

=head1 OPTIONS

=over 4

=item B<-k>, B<--keep>

Keep the original name of the upstream changelog. This will be accomplished
by installing the upstream changelog as F<changelog>, and making a symlink from
that to the original name of the F<changelog> file. This can be useful if the
upstream changelog has an unusual name, or if other documentation in the
package refers to the F<changelog> file.

=item B<-X>I<item>, B<--exclude=>I<item>

Exclude upstream F<changelog> files that contain I<item> anywhere in their
filename from being installed.

Note that directory name of the changelog is also part of the match.

=item B<--no-trim>

Install the full changelog, not its trimmed version that includes only
recent entries.

=item I<upstream>

Install this file as the upstream changelog.

=back

=cut

init(options => {
	'keep|k'  => \$dh{K_FLAG},
	'no-trim' => \$dh{NO_TRIM},
});

my $news_name="NEWS.Debian";
my $changelog_name="changelog.Debian";

use constant CUTOFF_DATE_STR => "2019-07-06"; # oldstable = Debian 10 Buster
use constant CUTOFF_DATE => Time::Piece->strptime(CUTOFF_DATE_STR, "%Y-%m-%d");
use constant MIN_NUM_ENTRIES => 4;

my $explicit_changelog = @ARGV ? 1 : 0;
my $default_upstream = $ARGV[0];
my $default_upstream_text=$default_upstream;
my $default_upstream_html;
if (! defined($default_upstream)) {
	if (! isnative($dh{MAINPACKAGE}) && !compat(6)) {
		foreach my $dir (qw{. doc docs}) {
			my $changelo