]> git.donarmstrong.com Git - debhelper.git/blob - dh_installinfo
r267: * dh_installinfo: use FHS info dir. I wonder how I missed that..
[debhelper.git] / dh_installinfo
1 #!/usr/bin/perl -w
2 #
3 # Reads debian/info, installs all files listed there into /usr/share/info
4 # and puts appropriate commands into the postinst.
5
6 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
7 use Dh_Lib;
8 init();
9
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11         $TMP=tmpdir($PACKAGE);
12         $file=pkgfile($PACKAGE,"info");
13
14         undef @info;
15         
16         if ($file) {
17                 @info=filearray($file);
18         }
19
20         if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
21                 push @info, @ARGV;
22         }
23
24         if (@info) {
25                 if ( ! -d "$TMP/usr/share/info") {
26                         doit("install","-d","$TMP/usr/share/info");
27                 }
28                 doit("cp",@info,"$TMP/usr/share/info");
29                 doit("chmod","-R", "go=rX","$TMP/usr/share/info/");
30                 doit("chmod","-R", "u+rw","$TMP/usr/share/info/");
31         }
32
33         foreach $file (@info) {
34                 # Only register with install-info if this is a head file in
35                 # a tree of info files.
36                 if ($file=~/\.info$/ && ! $dh{NOSCRIPTS}) {
37                         # Figure out what section this file goes in.
38                         my $section='';
39                         open (IN, "<$file") || die "$file: $!";
40                         while (<IN>) {
41                                 if (/INFO-DIR-SECTION\s+(.*)/) {
42                                         $section=$1;
43                                         last;
44                                 }
45                         }
46                         close IN;
47                         
48                         my $fn="/usr/share/info/".Dh_Lib::basename($file);
49                         
50                         if ($section ne '') {
51                                 autoscript($PACKAGE,"postinst","postinst-info",
52                                         "s/#SECTION#/$section/g;s:#FILE#:$fn:");
53                         }
54                         else {
55                                 autoscript($PACKAGE,"postinst","postinst-info-nosection",
56                                         "s:#FILE#:$fn:");
57                         }
58                         autoscript($PACKAGE,"prerm","prerm-info", "s:#FILE#:$fn:");
59                 }
60         }
61 }