5 dh_installchangelogs - install changelogs into package build directories
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_installchangelogs> [S<I<debhelper options>>] [B<-k>] [I<upstream>]
18 dh_installchangelogs is a debhelper program that is responsible for
19 installing changelogs into package build directories.
21 dh_installchangelogs determines if the package is a debian native package,
22 and if so, it installs debian/changelog into usr/share/doc/package/changelog
23 in the package build directory. Otherwise, it installs debian/changelog
24 into usr/share/doc/package/changelog.Debian in the package build directory. (If
25 files named debian/package.changelog exist, they will be used in preference
28 Parallelling the debian changelog handling, this program also takes care of
29 NEWS.Debian files. If there is a debian/NEWS file, it is installed as
30 usr/share/doc/package/NEWS.Debian. debian/package.NEWS files can also be
33 An upstream changelog file may be specified as an option. If none is
34 specified, a few common filenames are tried. (In compatability level 7 and
37 If there is an upstream changelog file, it will be be installed as
38 usr/share/doc/package/changelog in the package build directory. If the
39 changelog is a html file (determined by file extension), it will be
40 installed as usr/share/doc/package/changelog.html instead, and will be
41 converted to plain text with html2text to generate
42 usr/share/doc/package/changelog.
48 =item B<-k>, B<--keep>
50 Keep the original name of the upstream changelog. This will be accomplished
51 by installing the upstream changelog as "changelog", and making a symlink from
52 that to the original name of the changelog file. This can be useful if the
53 upstream changelog has an unusual name, or if other documentation in the
54 package refers to the changelog file.
58 Install this file as the upstream changelog.
67 my $changelog_name="changelog.Debian";
68 if (! defined $upstream) {
69 if (! isnative($dh{MAINPACKAGE}) && !compat(6)) {
70 my @files=sort glob("*");
71 foreach my $name (qw{changelog changes}) {
72 my @matches=grep { lc $_ eq $name } @files;
74 $upstream=shift @matches;
79 if (isnative($dh{MAINPACKAGE})) {
80 $changelog_name='changelog';
83 my $news_name="NEWS.Debian";
85 foreach my $package (@{$dh{DOPACKAGES}}) {
86 next if is_udeb($package);
88 my $tmp=tmpdir($package);
89 my $changelog=pkgfile($package,"changelog");
90 my $news=pkgfile($package,"NEWS");
93 $changelog="debian/changelog";
99 if (! -e $changelog) {
100 error("could not find changelog $changelog");
103 if (! -d "$tmp/usr/share/doc/$package") {
104 # If it is a dangling symlink, then don't do anything.
105 # Think multi-binary packages that depend on each other and
106 # want to link doc dirs.
107 next if -l "$tmp/usr/share/doc/$package";
109 doit("install","-d","$tmp/usr/share/doc/$package");
111 doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
112 "$tmp/usr/share/doc/$package/$changelog_name");
114 doit("install","-o",0,"-g",0,"-p","-m644",$news,
115 "$tmp/usr/share/doc/$package/$news_name");
118 if (defined $upstream) {
120 if ($upstream=~m/\.html?$/i) {
122 doit("install","-o",0,"-g",0,"-p","-m644",
123 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
124 doit("html2text","-nobs","-o","$tmp/usr/share/doc/$package/changelog",$upstream);
125 $link_to='changelog.html';
128 doit("install","-o",0,"-g",0,"-p","-m644",
129 $upstream,"$tmp/usr/share/doc/$package/changelog");
130 $link_to='changelog';
133 # Install symlink to original name of the upstream changelog file.
134 # Use basename in case original file was in a subdirectory or something.
135 doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
144 This program is a part of debhelper.
148 Joey Hess <joeyh@debian.org>