]> git.donarmstrong.com Git - debhelper.git/blob - dh_installinfo
r397: horribly broke everything I touched :-)
[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 use Debian::Debhelper::Dh_Lib;
7 init();
8
9 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
10         $TMP=tmpdir($PACKAGE);
11         $file=pkgfile($PACKAGE,"info");
12
13         undef @info;
14         
15         if ($file) {
16                 @info=filearray($file, ".");
17         }
18
19         if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
20                 push @info, @ARGV;
21         }
22
23         if (@info) {
24                 if ( ! -d "$TMP/usr/share/info") {
25                         doit("install","-d","$TMP/usr/share/info");
26                 }
27                 doit("cp",@info,"$TMP/usr/share/info");
28                 doit("chmod","-R", "go=rX","$TMP/usr/share/info/");
29                 doit("chmod","-R", "u+rw","$TMP/usr/share/info/");
30         }
31
32         foreach $file (@info) {
33                 # Only register with install-info if this is a head file in
34                 # a tree of info files.
35                 if ($file !~ /-\d+$/ && ! $dh{NOSCRIPTS}) {
36                         # Figure out what section this file goes in.
37                         my $section='';
38                         open (IN, "<$file") || die "$file: $!";
39                         while (<IN>) {
40                                 if (/INFO-DIR-SECTION\s+(.*)/) {
41                                         $section=$1;
42                                         last;
43                                 }
44                         }
45                         close IN;
46                         
47                         my $fn="/usr/share/info/".Debian::Debhelper::Dh_Lib::basename($file);
48                         
49                         if ($section ne '') {
50                                 $section=~s:/:\\/:g; # allow / in section.
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 }