]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebconf
r1743: releasing version 4.2.32
[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.script.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 filesmay 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 Debconf also supports localized template files, and this program has some
45 support to aid is working with them. It is best to keep the translations in
46 .po files under debian/po, and merge them only at build time. See 
47 L<po2debconf(1)> and L<debconf-getlang(1)> for details.
48
49 This program will look to see if you have a debian/po directory and if so will
50 automatically call L<po2debconf(1)> to generate a merged templates file. Or 
51 if you have debian/templates.ll files, it will use the older 
52 L<debconf-mergetemplate(1)> program to merge those together.
53
54 Note that if your package has a debian/po directory it should build-depend on po-debconf.
55
56 For example, if you have a German translation,
57 strings from debian/po/de.po are merged with debian/package.templates.
58
59 =head1 OPTIONS
60
61 =over 4
62
63 =item B<-n>, B<--noscripts>
64
65 Do not modify postrm script.
66
67 =item B<--> I<params>
68
69 Pass the params to po2debconf, if it is run or debconf-mergetemplate, if it
70 is run.
71
72 =back
73
74 =cut
75
76 init();
77
78 my @extraparams;
79 if (defined($dh{U_PARAMS})) {
80         @extraparams=@{$dh{U_PARAMS}};
81 }
82
83 foreach my $package (@{$dh{DOPACKAGES}}) {
84         my $tmp=tmpdir($package);
85         my $config=pkgfile($package,"config");
86         my $templates=pkgfile($package,"templates");
87
88         if (! -d "$tmp/DEBIAN") {
89                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
90         }
91
92         if (! is_udeb($package)) {
93                 debhelper_script_subst($package, "config");
94         }
95         
96         if ($templates ne '') {
97                 # Are there old-style translated templates?
98                 my @trans=(glob("$templates.??"), glob("$templates.??_??"));
99
100                 umask(0022); # since I do a redirect below
101                 
102                 # Look for po directory.
103                 if (-d "debian/po") {
104                         if (@trans) {
105                                 warning "ignoring debian/templates.ll files in favour of debian/po directory";
106                         }
107                         complex_doit("po2debconf @extraparams $templates > $tmp/DEBIAN/templates");
108                 }
109                 elsif (@trans) {
110                         complex_doit("debconf-mergetemplate --drop-old-templates @extraparams @trans $templates > $tmp/DEBIAN/templates");
111                         chmod 0644, "$tmp/DEBIAN/templates";
112                         chown 0, 0, "$tmp/DEBIAN/templates";
113                 }
114                 else {
115                         doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
116                              $templates, "$tmp/DEBIAN/templates");
117                 }
118         }
119
120         # I'm going with debconf 0.5 because it was the first
121         # "modern" one.
122         my $debconfdep="debconf (>= 0.5) | debconf-2.0";
123         if ($config ne '' || $templates ne '') {
124                 addsubstvar($package, "misc:Depends", $debconfdep);
125         }
126         else {
127                 addsubstvar($package, "misc:Depends", $debconfdep, undef, 1); # remove
128         }
129         
130         if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
131                 autoscript($package,"postrm","postrm-debconf");
132         }
133 }
134
135 =head1 SEE ALSO
136
137 L<debhelper(7)>
138
139 This program is a part of debhelper.
140
141 =head1 AUTHOR
142
143 Joey Hess <joeyh@debian.org>
144
145 =cut