]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r378: * dh_movefiles: fixed a regexp quoting problem with --sourcedir.
[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 Debian::Debhelper::Dh_Lib;
11 init();
12
13 $upstream=shift;
14
15 if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
16         error("Cannot specify an upstream changelog for a native debian package.");
17 }
18
19 if (isnative($dh{MAINPACKAGE})) {
20         $changelog_name='changelog';
21 }
22 else {
23         $changelog_name='changelog.Debian';
24 }
25
26 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
27         $TMP=tmpdir($PACKAGE);
28         $changelog=pkgfile($PACKAGE,"changelog");
29
30         if (!$changelog) {
31                 $changelog="debian/changelog";
32         }
33
34         if (! -e $changelog) {
35                 error("could not find changelog $changelog");
36         }
37
38         if (! -d "$TMP/usr/share/doc/$PACKAGE") {
39                 # If it is a dangling symlink, then don't do anything.
40                 # Think multi-binary packages that depend on each other and
41                 # want to link doc dirs.
42                 next if -l "$TMP/usr/share/doc/$PACKAGE";
43
44                 doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
45         }
46         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
47                 "$TMP/usr/share/doc/$PACKAGE/$changelog_name");
48
49         if ($upstream) {
50                 my $link_to;
51                 if ($upstream=~m/\.html?$/i) {
52                         # HTML changelog
53                         doit("install","-o",0,"-g",0,"-p","-m644",
54                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog.html");
55                         complex_doit("lynx -dump $upstream > $TMP/usr/share/doc/$PACKAGE/changelog");
56                         $link_to='changelog.html';
57                 }
58                 else {
59                         doit("install","-o",0,"-g",0,"-p","-m644",
60                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog");
61                         $link_to='changelog';                           
62                 }
63                 if ($dh{K_FLAG}) {
64                         # Install symlink to original name of the upstream changelog file.
65                         # Use basename in case original file was in a subdirectory or something.
66                         doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Debian::Debhelper::Dh_Lib::basename($upstream));
67                 }
68         }
69 }