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