]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r420: big monsta changes
[debhelper.git] / dh_installchangelogs
1 #!/usr/bin/perl -w
2 #
3 # Installs debian/changelog. If another filename is passed to it, installs
4 # that file as the upstream changelog.
5 #
6 # Looks at debian/control to determine if this is a native debian package,
7 # if so, the debian changelog is just installed as "changelog", and it is an 
8 # error to specify an upstream changelog on the command line.
9
10 use strict;
11 use Debian::Debhelper::Dh_Lib;
12 init();
13
14 my $upstream=shift;
15
16 if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
17         error("Cannot specify an upstream changelog for a native debian package.");
18 }
19
20 my $changelog_name="changelog.Debian";
21 if (isnative($dh{MAINPACKAGE})) {
22         $changelog_name='changelog';
23 }
24
25 foreach my $package (@{$dh{DOPACKAGES}}) {
26         my $tmp=tmpdir($package);
27         my $changelog=pkgfile($package,"changelog");
28
29         if (!$changelog) {
30                 $changelog="debian/changelog";
31         }
32
33         if (! -e $changelog) {
34                 error("could not find changelog $changelog");
35         }
36
37         if (! -d "$tmp/usr/share/doc/$package") {
38                 # If it is a dangling symlink, then don't do anything.
39                 # Think multi-binary packages that depend on each other and
40                 # want to link doc dirs.
41                 next if -l "$tmp/usr/share/doc/$package";
42
43                 doit("install","-d","$tmp/usr/share/doc/$package");
44         }
45         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
46                 "$tmp/usr/share/doc/$package/$changelog_name");
47
48         if ($upstream) {
49                 my $link_to;
50                 if ($upstream=~m/\.html?$/i) {
51                         # HTML changelog
52                         doit("install","-o",0,"-g",0,"-p","-m644",
53                                 $upstream,"$tmp/usr/share/doc/$package/changelog.html");
54                         complex_doit("lynx -dump $upstream > $tmp/usr/share/doc/$package/changelog");
55                         $link_to='changelog.html';
56                 }
57                 else {
58                         doit("install","-o",0,"-g",0,"-p","-m644",
59                                 $upstream,"$tmp/usr/share/doc/$package/changelog");
60                         $link_to='changelog';
61                 }
62                 if ($dh{K_FLAG}) {
63                         # Install symlink to original name of the upstream changelog file.
64                         # Use basename in case original file was in a subdirectory or something.
65                         doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream));
66                 }
67         }
68 }