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, it looks for files with names that seem likely to be changelogs.
23 (In compatibility level 7 and above.)
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 foreach my $dir (qw{. doc docs}) {
88 my @files=sort glob("$dir/*");
89 foreach my $name (qw{changelog changes changelog.txt changes.txt history history.txt}) {
91 lc basename($_) eq $name && -s $_ && ! excludefile($_)
94 $upstream=shift @matches;
100 if (isnative($dh{MAINPACKAGE})) {
101 $changelog_name='changelog';
104 my $news_name="NEWS.Debian";
106 foreach my $package (@{$dh{DOPACKAGES}}) {
107 next if is_udeb($package);
109 my $tmp=tmpdir($package);
110 my $changelog=pkgfile($package,"changelog");
111 my $news=pkgfile($package,"NEWS");
114 $changelog="debian/changelog";
120 if (! -e $changelog) {
121 error("could not find changelog $changelog");
124 # If it is a symlink to a documentation directory from the same
125 # source package, then don't do anything. Think multi-binary
126 # packages that depend on each other and want to link doc dirs.
127 if (-l "$tmp/usr/share/doc/$package") {
128 my $linkval=readlink("$tmp/usr/share/doc/$package");
129 my %allpackages=map { $_ => 1 } getpackages();
130 if ($allpackages{basename($linkval)}) {
133 # Even if the target doesn't seem to be a doc dir from the
134 # same source package, don't do anything if it's a dangling
136 next unless -d "$tmp/usr/share/doc/$package";
139 if (! -d "$tmp/usr/share/doc/$package") {
140 doit("install","-d","$tmp/usr/share/doc/$package");
142 doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
143 "$tmp/usr/share/doc/$package/$changelog_name");
145 doit("install","-o",0,"-g",0,"-p","-m644",$news,
146 "$tmp/usr/share/doc/$package/$news_name");
149 if (defined $upstream) {
151 if ($upstream=~m/\.html?$/i) {
153 doit("install","-o",0,"-g",0,"-p","-m644",
154 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
155 doit("html2text","-nobs","-o","$tmp/usr/share/doc/$package/changelog",$upstream);
156 $link_to='changelog.html';
159 doit("install","-o",0,"-g",0,"-p","-m644",
160 $upstream,"$tmp/usr/share/doc/$package/changelog");
161 $link_to='changelog';
164 # Install symlink to original name of the upstream changelog file.
165 # Use basename in case original file was in a subdirectory or something.
166 doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
175 This program is a part of debhelper.
179 Joey Hess <joeyh@debian.org>