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