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