]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebconf
r1968: * dh_fixperms: Make all files in /usr/include 644, not only .h files.
[debhelper.git] / dh_installdebconf
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installdebconf - install files used by debconf in package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installdebconf> [S<I<debhelper options>>] [B<-n>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 dh_installdebconf is a debhelper program that is responsible for installing
19 files used by the debconf package into package build directories.
20
21 It also automatically generates the postrm commands needed to interface
22 with debconf. The commands are added to the maintainer scripts by
23 dh_installdeb. See L<dh_installdeb(1)> for an explanation of how that
24 works.
25
26 Files named debian/package.config and debian/package.templates are
27 installed into the DEBIAN directory in the package build directory.
28 If a file named debian/package.config.debhelper exists, the contents
29 of that file are merged into the config script as follows: If the script 
30 exists, then anywhere in it that "#DEBHELPER#" appears, the text of the 
31 .debhelper file is inserted. If the script does not exist, then a script 
32 is generated from the .debhelper file. The .debhelper files may be created 
33 by other debhelper programs, and are shell script fragments.
34
35 Note that if you use debconf, your package probably needs to depend on it
36 (it will be added to ${misc:Depends} by this program).
37
38 Note that for your config script to be called by dpkg, your postinst
39 needs to source debconf's confmodule. dh_installdebconf does not
40 install this statement into postinst automatically as it it too hard to
41 do it right.
42
43 =head1 LOCALIZED TEMPLATE FILES
44
45 This program will look to see if you have a debian/po directory and if so
46 will automatically call L<po2debconf(1)> to generate a merged templates
47 file containing the translations. For this to work, your package should
48 build-depend on po-debconf.
49
50 =head1 OPTIONS
51
52 =over 4
53
54 =item B<-n>, B<--noscripts>
55
56 Do not modify postrm script.
57
58 =item B<--> I<params>
59
60 Pass the params to po2debconf.
61
62 =back
63
64 =cut
65
66 init();
67
68 my @extraparams;
69 if (defined($dh{U_PARAMS})) {
70         @extraparams=@{$dh{U_PARAMS}};
71 }
72
73 foreach my $package (@{$dh{DOPACKAGES}}) {
74         my $tmp=tmpdir($package);
75         my $config=pkgfile($package,"config");
76         my $templates=pkgfile($package,"templates");
77
78         if (! -d "$tmp/DEBIAN") {
79                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
80         }
81
82         if (! is_udeb($package)) {
83                 debhelper_script_subst($package, "config");
84         }
85         
86         if ($templates ne '') {
87                 # Are there old-style translated templates?
88                 if (glob("$templates.??"), glob("$templates.??_??")) {
89                         warning "Ignoring debian/templates.ll files. Switch to po-debconf!";
90                 }
91
92                 umask(0022); # since I do a redirect below
93                 
94                 if (-d "debian/po") {
95                         complex_doit("po2debconf @extraparams $templates > $tmp/DEBIAN/templates");
96                 }
97                 else {
98                         doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
99                              $templates, "$tmp/DEBIAN/templates");
100                 }
101         }
102
103         # I'm going with debconf 0.5 because it was the first
104         # "modern" one. udebs just need cdebconf.
105         my $debconfdep=is_udeb($package) ? "cdebconf-udeb" : "debconf (>= 0.5) | debconf-2.0";
106         if ($config ne '' || $templates ne '') {
107                 addsubstvar($package, "misc:Depends", $debconfdep);
108         }
109         else {
110                 addsubstvar($package, "misc:Depends", $debconfdep, undef, 1); # remove
111         }
112         
113         if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
114                 autoscript($package,"postrm","postrm-debconf");
115         }
116 }
117
118 =head1 SEE ALSO
119
120 L<debhelper(7)>
121
122 This program is a part of debhelper.
123
124 =head1 AUTHOR
125
126 Joey Hess <joeyh@debian.org>
127
128 =cut