]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r464: * Now uses html2text rather than lynx for converting html changelogs.
[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   dh_installchangelogs [debhelper options] [-k] [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 If an upstream changelog file is specified as an option, and the package is
29 not a native debian package, then this upstream changelog will be installed
30 as usr/share/doc/package/changelog in the package build directory. If the
31 changelog is a html file (determined by file extension), it will be
32 installed as usr/share/doc/package/changelog.html instead, and will be
33 converted to plain text with html2text to generate
34 usr/share/doc/package/changelog.
35
36 =head1 OPTIONS
37
38 =over 4
39
40 =item B<-k>, B<--keep>
41
42 Keep the original name of the upstream changelog. This will be accomplished
43 by installing the upstream changelog as "changelog", and making a symlink from
44 that to the original name of the changelog file. This can be useful if the
45 upstream changelog has an unusual name, or if other documentation in the
46 package refers to the changelog file.
47
48 =item I<upstream>
49
50 Install this file as the upstream changelog.
51
52 =back
53
54 =head1 NOTES
55
56 It is an error to specify an upstream changelog file for a debian native
57 package.
58
59 =cut
60
61 init();
62
63 my $upstream=shift;
64
65 if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
66         error("Cannot specify an upstream changelog for a native debian package.");
67 }
68
69 my $changelog_name="changelog.Debian";
70 if (isnative($dh{MAINPACKAGE})) {
71         $changelog_name='changelog';
72 }
73
74 foreach my $package (@{$dh{DOPACKAGES}}) {
75         my $tmp=tmpdir($package);
76         my $changelog=pkgfile($package,"changelog");
77
78         if (!$changelog) {
79                 $changelog="debian/changelog";
80         }
81
82         if (! -e $changelog) {
83                 error("could not find changelog $changelog");
84         }
85
86         if (! -d "$tmp/usr/share/doc/$package") {
87                 # If it is a dangling symlink, then don't do anything.
88                 # Think multi-binary packages that depend on each other and
89                 # want to link doc dirs.
90                 next if -l "$tmp/usr/share/doc/$package";
91
92                 doit("install","-d","$tmp/usr/share/doc/$package");
93         }
94         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
95                 "$tmp/usr/share/doc/$package/$changelog_name");
96
97         if ($upstream) {
98                 my $link_to;
99                 if ($upstream=~m/\.html?$/i) {
100                         # HTML changelog
101                         doit("install","-o",0,"-g",0,"-p","-m644",
102                                 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
103                         doit("html2text","-nobs","-o","$tmp/usr/share/doc/$package/changelog",$upstream);
104                         $link_to='changelog.html';
105                 }
106                 else {
107                         doit("install","-o",0,"-g",0,"-p","-m644",
108                                 $upstream,"$tmp/usr/share/doc/$package/changelog");
109                         $link_to='changelog';
110                 }
111                 if ($dh{K_FLAG}) {
112                         # Install symlink to original name of the upstream changelog file.
113                         # Use basename in case original file was in a subdirectory or something.
114                         doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
115                 }
116         }
117 }
118
119 =head1 SEE ALSO
120
121 L<debhelper(1)>
122
123 This program is a part of debhelper.
124
125 =head1 AUTHOR
126
127 Joey Hess <joeyh@debian.org>
128
129 =cut