]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r538: * Make dh_installchangelogs install debian/NEWS files as well, as
[debhelper.git] / dh_installchangelogs
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installchangelogs - install changelogs into package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installchangelogs> [<S<I<debhelper options>>] [B<-k>] [I<upstream>]
15
16 =head1 DESCRIPTION
17
18 dh_installchangelogs is a debhelper program that is responsible for
19 installing changelogs into package build directories.
20
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
26 to debian/changelog.)
27
28 Parallelling the debian changelog handling, this program also takes care of
29 debian NEWS files. If there is a debian/NEWS file, it is installed as
30 usr/share/doc/package/NEWS for native packages, and as
31 usr/share/doc/package/NEWS.Debian for non-native packages. debian/package.NEWS
32 files can also be used.
33
34 If an upstream changelog file is specified as an option, and the package is
35 not a native debian package, then this upstream changelog will be installed
36 as usr/share/doc/package/changelog in the package build directory. If the
37 changelog is a html file (determined by file extension), it will be
38 installed as usr/share/doc/package/changelog.html instead, and will be
39 converted to plain text with html2text to generate
40 usr/share/doc/package/changelog.
41
42 =head1 OPTIONS
43
44 =over 4
45
46 =item B<-k>, B<--keep>
47
48 Keep the original name of the upstream changelog. This will be accomplished
49 by installing the upstream changelog as "changelog", and making a symlink from
50 that to the original name of the changelog file. This can be useful if the
51 upstream changelog has an unusual name, or if other documentation in the
52 package refers to the changelog file.
53
54 =item I<upstream>
55
56 Install this file as the upstream changelog.
57
58 =back
59
60 =head1 NOTES
61
62 It is an error to specify an upstream changelog file for a debian native
63 package.
64
65 =cut
66
67 init();
68
69 my $upstream=shift;
70
71 if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
72         error("Cannot specify an upstream changelog for a native debian package.");
73 }
74
75 my $changelog_name="changelog.Debian";
76 my $news_name="NEWS.Debian";
77 if (isnative($dh{MAINPACKAGE})) {
78         $changelog_name='changelog';
79         $news_name='NEWS';
80 }
81
82 foreach my $package (@{$dh{DOPACKAGES}}) {
83         my $tmp=tmpdir($package);
84         my $changelog=pkgfile($package,"changelog");
85         my $news=pkgfile($package,"NEWS");
86
87         if (!$changelog) {
88                 $changelog="debian/changelog";
89         }
90         if (!$news) {
91                 $news="debian/NEWS";
92         }
93
94         if (! -e $changelog) {
95                 error("could not find changelog $changelog");
96         }
97
98         if (! -d "$tmp/usr/share/doc/$package") {
99                 # If it is a dangling symlink, then don't do anything.
100                 # Think multi-binary packages that depend on each other and
101                 # want to link doc dirs.
102                 next if -l "$tmp/usr/share/doc/$package";
103
104                 doit("install","-d","$tmp/usr/share/doc/$package");
105         }
106         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
107                 "$tmp/usr/share/doc/$package/$changelog_name");
108         if (-e $news) {
109                 doit("install","-o",0,"-g",0,"-p","-m644",$news,
110                         "$tmp/usr/share/doc/$package/$news_name");
111         }
112
113         if ($upstream) {
114                 my $link_to;
115                 if ($upstream=~m/\.html?$/i) {
116                         # HTML changelog
117                         doit("install","-o",0,"-g",0,"-p","-m644",
118                                 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
119                         doit("html2text","-nobs","-o","$tmp/usr/share/doc/$package/changelog",$upstream);
120                         $link_to='changelog.html';
121                 }
122                 else {
123                         doit("install","-o",0,"-g",0,"-p","-m644",
124                                 $upstream,"$tmp/usr/share/doc/$package/changelog");
125                         $link_to='changelog';
126                 }
127                 if ($dh{K_FLAG}) {
128                         # Install symlink to original name of the upstream changelog file.
129                         # Use basename in case original file was in a subdirectory or something.
130                         doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
131                 }
132         }
133 }
134
135 =head1 SEE ALSO
136
137 L<debhelper(1)>
138
139 This program is a part of debhelper.
140
141 =head1 AUTHOR
142
143 Joey Hess <joeyh@debian.org>
144
145 =cut