]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r308: * dh_suidregister: Die with understandable error message if asked to
[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 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
11 use Dh_Lib;
12 init();
13
14 $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 if (isnative($dh{MAINPACKAGE})) {
21         $changelog_name='changelog';
22 }
23 else {
24         $changelog_name='changelog.Debian';
25 }
26
27 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
28         $TMP=tmpdir($PACKAGE);
29         $changelog=pkgfile($PACKAGE,"changelog");
30
31         if (!$changelog) {
32                 $changelog="debian/changelog";
33         }
34
35         if (! -e $changelog) {
36                 error("could not find changelog $changelog");
37         }
38
39         if (! -d "$TMP/usr/share/doc/$PACKAGE") {
40                 doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
41         }
42         doit("install","-o","root","-g","root","-p","-m644",$changelog,
43                 "$TMP/usr/share/doc/$PACKAGE/$changelog_name");
44
45         if ($upstream) {
46                 my $link_to;
47                 if ($upstream=~m/\.html?$/i) {
48                         # HTML changelog
49                         doit("install","-o","root","-g","root","-p","-m644",
50                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog.html");
51                         complex_doit("lynx -dump $upstream > $TMP/usr/share/doc/$PACKAGE/changelog");
52                         $link_to='changelog.html';
53                 }
54                 else {
55                         doit("install","-o","root","-g","root","-p","-m644",
56                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog");
57                         $link_to='changelog';                           
58                 }
59                 if ($dh{K_FLAG}) {
60                         # Install symlink to original name of the upstream changelog file.
61                         # Use basename in case original file was in a subdirectory or something.
62                         doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Dh_Lib::basename($upstream));
63                 }
64         }
65 }