]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebconf
r530: updates...
[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 working with them. It is best to keep the translations in
35 separate files, and merge them only at build time. See 
36 L<debconf-mergetemplate(1)> and L<debconf-getlang(1)> for details.
37
38 This program will automatically call debconf-mergetemplate and merge 
39 templates on the fly if it finds your template files are accompanied
40 by translated files that have the same name as the template file, with a
41 dot and a locale name prepended.
42
43 For example, if you have a German translation,
44 debian/package.templates.de is merged with debian/package.templates.
45
46 =head1 OPTIONS
47
48 =over 4
49
50 =item B<-n>, B<--noscripts>
51
52 Do not modify postrm script.
53
54 =item B<--> I<params>
55
56 Pass the params to debconf-mergetemplate.
57
58 =back
59
60 =cut
61
62 init();
63
64 my @extraparams;
65 if (defined($dh{U_PARAMS})) {
66         @extraparams=@{$dh{U_PARAMS}};
67 }
68
69 foreach my $package (@{$dh{DOPACKAGES}}) {
70         my $tmp=tmpdir($package);
71         my $config=pkgfile($package,"config");
72         my $templates=pkgfile($package,"templates");
73
74         if (! -d "$tmp/DEBIAN") {
75                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
76         }
77
78         if ($config ne '') {
79                 doit("install", "-o", 0, "-g", 0, "-m", 755, "-p",
80                      $config, "$tmp/DEBIAN/config");
81         }
82         
83         if ($templates ne '') {
84                 # Are there translated templates too?
85                 my @trans=(glob("$templates.??"), glob("$templates.??_??"));
86                 if (@trans) {
87                         complex_doit("debconf-mergetemplate --drop-old-templates @extraparams @trans $templates > $tmp/DEBIAN/templates");
88                         chmod 0644, "$tmp/DEBIAN/templates";
89                         chown 0, 0, "$tmp/DEBIAN/templates";
90                 }
91                 else {
92                         doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
93                              $templates, "$tmp/DEBIAN/templates");
94                 }
95         }
96
97         if ($config ne '' || $templates ne '') {
98                 # I'm going with debconf 0.5 because it was the first
99                 # "modern" one.
100                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5");
101         }
102         else {
103                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5", 1); # remove
104         }
105         
106         if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
107                 autoscript($package,"postrm","postrm-debconf");
108         }
109 }
110
111 =head1 SEE ALSO
112
113 L<debhelper(1)>
114
115 This program is a part of debhelper.
116
117 =head1 AUTHOR
118
119 Joey Hess <joeyh@debian.org>
120
121 =cut