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