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>] [B<-X>I<item>] [I<upstream>]
18 dh_installchangelogs is a debhelper program that is responsible for
19 installing changelogs into package build directories.
21 An upstream changelog file may be specified as an option. If none is
22 specified, a few common filenames are tried. (In compatibility level 7 and
25 If there is an upstream changelog file, it will be be installed as
26 usr/share/doc/package/changelog in the package build directory. If the
27 changelog is a html file (determined by file extension), it will be
28 installed as usr/share/doc/package/changelog.html instead, and will be
29 converted to plain text with html2text to generate
30 usr/share/doc/package/changelog.
36 =item debian/changelog
40 =item debian/I<package>.changelog
42 =item debian/I<package>.NEWS
44 Automatically installed into usr/share/doc/I<package>/
45 in the package build directory.
47 Use the package specific name if I<package> needs a different
48 NEWS or changelog file.
50 The changelog file is installed with a name of changelog
51 for native packages, and changelog.Debian for non-native packages.
52 The NEWS file is always installed with a name of NEWS.Debian.
60 =item B<-k>, B<--keep>
62 Keep the original name of the upstream changelog. This will be accomplished
63 by installing the upstream changelog as "changelog", and making a symlink from
64 that to the original name of the changelog file. This can be useful if the
65 upstream changelog has an unusual name, or if other documentation in the
66 package refers to the changelog file.
68 =item B<-Xitem>, B<--exclude=item>
70 Exclude upstream changelog files that contain "item" anywhere in their
71 filename from being installed.
75 Install this file as the upstream changelog.
84 my $changelog_name="changelog.Debian";
85 if (! defined $upstream) {
86 if (! isnative($dh{MAINPACKAGE}) && !compat(6)) {
87 my @files=sort glob("*");
88 foreach my $name (qw{changelog changes changelog.txt changes.txt}) {
90 lc $_ eq $name && -s $_ && ! excludefile($_)
93 $upstream=shift @matches;
98 if (isnative($dh{MAINPACKAGE})) {
99 $changelog_name='changelog';
102 my $news_name="NEWS.Debian";
104 foreach my $package (@{$dh{DOPACKAGES}}) {
105 next if is_udeb($package);
107 my $tmp=tmpdir($package);
108 my $changelog=pkgfile($package,"changelog");
109 my $news=pkgfile($package,"NEWS");
112 $changelog="debian/changelog";
118 if (! -e $changelog) {
119 error("could not find changelog $changelog");
122 # If it is a symlink to a documentation directory from the same
123 # source package, then don't do anything. Think multi-binary
124 # packages that depend on each other and want to link doc dirs.
125 if (-l "$tmp/usr/share/doc/$package") {
126 my $linkval=readlink("$tmp/usr/share/doc/$package");
127 my %allpackages=map { $_ => 1 } getpackages();
128 if ($allpackages{basename($linkval)}) {
131 # Even if the target doesn't seem to be a doc dir from the
132 # same source package, don't do anything if it's a dangling
134 next unless -d "$tmp/usr/share/doc/$package";
137 if (! -d "$tmp/usr/share/doc/$package") {
138 doit("install","-d","$tmp/usr/share/doc/$package");
140 doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
141 "$tmp/usr/share/doc/$package/$changelog_name");
143 doit("install","-o",0,"-g",0,"-p","-m644",$news,
144 "$tmp/usr/share/doc/$package/$news_name");
147 if (defined $upstream) {
149 if ($upstream=~m/\.html?$/i) {
151 doit("install","-o",0,"-g",0,"-p","-m644",
152 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
153 doit("html2text","-nobs","-o","$tmp/usr/share/doc/$package/changelog",$upstream);
154 $link_to='changelog.html';
157 doit("install","-o",0,"-g",0,"-p","-m644",
158 $upstream,"$tmp/usr/share/doc/$package/changelog");
159 $link_to='changelog';
162 # Install symlink to original name of the upstream changelog file.
163 # Use basename in case original file was in a subdirectory or something.
164 doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
173 This program is a part of debhelper.
177 Joey Hess <joeyh@debian.org>