]> git.donarmstrong.com Git - debhelper.git/blob - dh_installinfo
r431: pod over for the night
[debhelper.git] / dh_installinfo
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installinfo - install and register info files
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14   dh_installinfo [debhelper options] [-A] [-n] [file ...]
15
16 =head1 DESCRIPTION
17
18 dh_installinfo is a debhelper program that is responsible for installing
19 info files and registering them with install-info.
20
21 Any filenames specified as parameters will be installed into the first
22 package dh_installinfo is told to act on. By default, this is the first
23 binary package in debian/control, but if you use -p, -i, or -a flags, it
24 will be the first package specified by those flags.
25
26 Files named debian/package.info can list other files to be installed.
27
28 dh_installinfo will automatically generate the postinst and prerm commands
29 needed to interface with install-info. See L<dh_installdeb(1)> for an
30 explanation of how this works.
31
32 =head1 OPTIONS
33
34 =over 4
35
36 =item B<-A>, B<--all>
37
38 Install all files specified by command line parameters in ALL packages
39 acted on.
40
41 =item B<-n>, B<--noscripts>
42
43 Do not modify postinst/prerm scripts.
44
45 =item I<file ...>
46
47 Install these info files into the first package acted on. (Or in
48 all packages if -A is specified).
49
50 =back
51
52 =head1 NOTES
53
54 Note that this command is not idempotent. "dh_clean -k" should be called
55 between invocations of this command. Otherwise, it may cause multiple
56 instances of the same text to be added to maintainer scripts.
57
58 =cut
59
60 init();
61
62 foreach my $package (@{$dh{DOPACKAGES}}) {
63         my $tmp=tmpdir($package);
64         my $file=pkgfile($package,"info");
65
66         my @info;
67         
68         if ($file) {
69                 @info=filearray($file, ".");
70         }
71
72         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
73                 push @info, @ARGV;
74         }
75
76         if (@info) {
77                 if ( ! -d "$tmp/usr/share/info") {
78                         doit("install","-d","$tmp/usr/share/info");
79                 }
80                 doit("cp",@info,"$tmp/usr/share/info");
81                 doit("chmod","-R", "go=rX","$tmp/usr/share/info/");
82                 doit("chmod","-R", "u+rw","$tmp/usr/share/info/");
83         }
84
85         foreach $file (@info) {
86                 # Only register with install-info if this is a head file in
87                 # a tree of info files.
88                 if ($file !~ /-\d+$/ && ! $dh{NOSCRIPTS}) {
89                         # Figure out what section this file goes in.
90                         my $section='';
91                         open (IN, "<$file") || die "$file: $!";
92                         while (<IN>) {
93                                 if (/INFO-DIR-SECTION\s+(.*)/) {
94                                         $section=$1;
95                                         last;
96                                 }
97                         }
98                         close IN;
99                         
100                         my $fn="/usr/share/info/".basename($file);
101                         
102                         if ($section ne '') {
103                                 $section=~s:/:\\/:g; # allow / in section.
104                                 autoscript($package,"postinst","postinst-info",
105                                         "s/#SECTION#/$section/g;s:#FILE#:$fn:");
106                         }
107                         else {
108                                 autoscript($package,"postinst","postinst-info-nosection",
109                                         "s:#FILE#:$fn:");
110                         }
111                         autoscript($package,"prerm","prerm-info", "s:#FILE#:$fn:");
112                 }
113         }
114 }
115
116 =head1 SEE ALSO
117
118 L<debhelper(1)>
119
120 This program is a part of debhelper.
121
122 =head1 AUTHOR
123
124 Joey Hess <joeyh@debian.org>
125
126 =cut