]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
Updated French man page translation. Closes: #685560
[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>] [B<-X>I<item>] [I<upstream>]
15
16 =head1 DESCRIPTION
17
18 B<dh_installchangelogs> is a debhelper program that is responsible for
19 installing changelogs into package build directories.
20
21 An upstream F<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.)
24
25 If there is an upstream F<changelog> file, it will be be installed as
26 F<usr/share/doc/package/changelog> in the package build directory. If the
27 changelog is a F<html> file (determined by file extension), it will be
28 installed as F<usr/share/doc/package/changelog.html> instead, and will be
29 converted to plain text with B<html2text> to generate
30 F<usr/share/doc/package/changelog>.
31
32 =head1 FILES
33
34 =over 4
35
36 =item F<debian/changelog>
37
38 =item F<debian/NEWS>
39
40 =item debian/I<package>.changelog
41
42 =item debian/I<package>.NEWS
43
44 Automatically installed into usr/share/doc/I<package>/
45 in the package build directory.
46
47 Use the package specific name if I<package> needs a different
48 F<NEWS> or F<changelog> file.
49
50 The F<changelog> file is installed with a name of changelog
51 for native packages, and F<changelog.Debian> for non-native packages.
52 The F<NEWS> file is always installed with a name of F<NEWS.Debian>.
53
54 =back
55
56 =head1 OPTIONS
57
58 =over 4
59
60 =item B<-k>, B<--keep>
61
62 Keep the original name of the upstream changelog. This will be accomplished
63 by installing the upstream changelog as F<changelog>, and making a symlink from
64 that to the original name of the F<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 F<changelog> file.
67
68 =item B<-X>I<item>, B<--exclude=>I<item>
69
70 Exclude upstream F<changelog> files that contain I<item> anywhere in their
71 filename from being installed.
72
73 =item I<upstream>
74
75 Install this file as the upstream changelog.
76
77 =back
78
79 =cut
80
81 init();
82
83 my $upstream=shift;
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}) {
90                                 my @matches=grep {
91                                         lc basename($_) eq $name && -s $_ && ! excludefile($_)
92                                 } @files;
93                                 if (@matches) {
94                                         $upstream=shift @matches;
95                                         last;
96                                 }
97                         }
98                 }
99         }
100         if (isnative($dh{MAINPACKAGE})) {
101                 $changelog_name='changelog';
102         }
103 }
104 my $news_name="NEWS.Debian";
105
106 foreach my $package (@{$dh{DOPACKAGES}}) {
107         next if is_udeb($package);
108         
109         my $tmp=tmpdir($package);
110         my $changelog=pkgfile($package,"changelog");
111         my $news=pkgfile($package,"NEWS");
112
113         if (!$changelog) {
114                 $changelog="debian/changelog";
115         }
116         if (!$news) {
117                 $news="debian/NEWS";
118         }
119
120         if (! -e $changelog) {
121                 error("could not find changelog $changelog");
122         }
123
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)}) {
131                         next;
132                 }
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
135                 # symlink.
136                 next unless -d "$tmp/usr/share/doc/$package";
137         }
138
139         if (! -d "$tmp/usr/share/doc/$package") {
140                 doit("install","-d","$tmp/usr/share/doc/$package");
141         }
142         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
143                 "$tmp/usr/share/doc/$package/$changelog_name");
144         if (-e $news) {
145                 doit("install","-o",0,"-g",0,"-p","-m644",$news,
146                         "$tmp/usr/share/doc/$package/$news_name");
147         }
148
149         if (defined $upstream) {
150                 my $link_to;
151                 if ($upstream=~m/\.html?$/i) {
152                         # HTML changelog
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';
157                 }
158                 else {
159                         doit("install","-o",0,"-g",0,"-p","-m644",
160                                 $upstream,"$tmp/usr/share/doc/$package/changelog");
161                         $link_to='changelog';
162                 }
163                 if ($dh{K_FLAG}) {
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));
167                 }
168         }
169 }
170
171 =head1 SEE ALSO
172
173 L<debhelper(7)>
174
175 This program is a part of debhelper.
176
177 =head1 AUTHOR
178
179 Joey Hess <joeyh@debian.org>
180
181 =cut