]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebconf
r553: * dh_installdebconf: Support po-debconf debian/po directories.
[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 =head1 LOCALIZED TEMPLATE FILES
32
33 Debconf also supports localized template files, and this program has some
34 support to aid is working with them. It is best to keep the translations in
35 .po files under debian/po, and merge them only at build time. See 
36 L<po2debconf(1)> and L<debconf-getlang(1)> for details.
37
38 This program will look to see if you have a debian/po directory and if so will
39 automatically call L<po2debconf(1)> to generate a merged templates file. Or 
40 if you have debian/templates.ll files, it will use the older 
41 L<debconf-mergetemplate(1)> program to merge those together.
42
43 Note that if your package has a debian/po directory it should build-depend on po-debconf.
44
45 For example, if you have a German translation,
46 strings from debian/po/de.po are merged with debian/package.templates.
47
48 =head1 OPTIONS
49
50 =over 4
51
52 =item B<-n>, B<--noscripts>
53
54 Do not modify postrm script.
55
56 =item B<--> I<params>
57
58 Pass the params to po2debconf, if it is run or debconf-mergetemplate, if it
59 is run.
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 ($config ne '') {
82                 doit("install", "-o", 0, "-g", 0, "-m", 755, "-p",
83                      $config, "$tmp/DEBIAN/config");
84         }
85         
86         if ($templates ne '') {
87                 # Are there old-style translated templates?
88                 my @trans=(glob("$templates.??"), glob("$templates.??_??"));
89
90                 # Look for po directory.
91                 if (-d "debian/po") {
92                         if (@trans) {
93                                 warning "ignoring debian/templates.ll files in favour of debian/po directory";
94                         }
95                         else {
96                                 complex_doit("po2debconf @extraparams $templates > $tmp/DEBIAN/templates");
97                         }
98                 }
99                 elsif (@trans) {
100                         complex_doit("debconf-mergetemplate --drop-old-templates @extraparams @trans $templates > $tmp/DEBIAN/templates");
101                         chmod 0644, "$tmp/DEBIAN/templates";
102                         chown 0, 0, "$tmp/DEBIAN/templates";
103                 }
104                 else {
105                         doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
106                              $templates, "$tmp/DEBIAN/templates");
107                 }
108         }
109
110         if ($config ne '' || $templates ne '') {
111                 # I'm going with debconf 0.5 because it was the first
112                 # "modern" one.
113                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5");
114         }
115         else {
116                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5", 1); # remove
117         }
118         
119         if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
120                 autoscript($package,"postrm","postrm-debconf");
121         }
122 }
123
124 =head1 SEE ALSO
125
126 L<debhelper(1)>
127
128 This program is a part of debhelper.
129
130 =head1 AUTHOR
131
132 Joey Hess <joeyh@debian.org>
133
134 =cut