]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r360: * Never refer to root, always uid/gid "0". Closes: #67508
[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                 doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
40         }
41         doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
42                 "$TMP/usr/share/doc/$PACKAGE/$changelog_name");
43
44         if ($upstream) {
45                 my $link_to;
46                 if ($upstream=~m/\.html?$/i) {
47                         # HTML changelog
48                         doit("install","-o",0,"-g",0,"-p","-m644",
49                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog.html");
50                         complex_doit("lynx -dump $upstream > $TMP/usr/share/doc/$PACKAGE/changelog");
51                         $link_to='changelog.html';
52                 }
53                 else {
54                         doit("install","-o",0,"-g",0,"-p","-m644",
55                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog");
56                         $link_to='changelog';                           
57                 }
58                 if ($dh{K_FLAG}) {
59                         # Install symlink to original name of the upstream changelog file.
60                         # Use basename in case original file was in a subdirectory or something.
61                         doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Debian::Debhelper::Dh_Lib::basename($upstream));
62                 }
63         }
64 }