]> git.donarmstrong.com Git - debhelper.git/blob - dh_installchangelogs
r266: * FHS complience. Patch from Johnie Ingram <johnie@netgod.net>.
[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                 if ($upstream=~m/\.html?$/i) {
47                         # HTML changelog
48                         doit("install","-o","root","-g","root","-p","-m644",
49                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog.html");
50                         doit("ln", "-sf", 'changelog.html',
51                                 "$TMP/usr/share/doc/$PACKAGE/changelog");
52                 }
53                 else {
54                         doit("install","-o","root","-g","root","-p","-m644",
55                                 $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog");
56                 }
57                 if ($dh{K_FLAG}) {
58                         # Install symlink to original name of the upstream changelog file.
59                         # Use basename in case original file was in a subdirectory or something.
60                         doit("ln","-sf","changelog","$TMP/usr/share/doc/$PACKAGE/".Dh_Lib::basename($upstream));
61                 }
62         }
63 }