]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebconf
r506: * Introduced the debian/compat file. This is the new, preferred way to say
[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>]
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. You may find it easiest to keep the
35 translations in 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 repended.
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 =back
55
56 =cut
57
58 init();
59
60 foreach my $package (@{$dh{DOPACKAGES}}) {
61         my $tmp=tmpdir($package);
62         my $config=pkgfile($package,"config");
63         my $templates=pkgfile($package,"templates");
64
65         if (! -d "$tmp/DEBIAN") {
66                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
67         }
68
69         if ($config ne '') {
70                 doit("install", "-o", 0, "-g", 0, "-m", 755, "-p",
71                      $config, "$tmp/DEBIAN/config");
72         }
73         
74         if ($templates ne '') {
75                 # Are there translated templates too?
76                 my @trans=(glob("$templates.??"), glob("$templates.??_??"));
77                 if (@trans) {
78                         complex_doit("debconf-mergetemplate @trans $templates > $tmp/DEBIAN/templates");
79                         chmod 0644, "$tmp/DEBIAN/templates";
80                         chown 0, 0, "$tmp/DEBIAN/templates";
81                 }
82                 else {
83                         doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
84                              $templates, "$tmp/DEBIAN/templates");
85                 }
86         }
87
88         if ($config ne '' || $templates ne '') {
89                 # I'm going with debconf 0.5 because it was the first
90                 # "modern" one.
91                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5");
92         }
93         else {
94                 addsubstvar($package, "misc:Depends", "debconf", ">= 0.5", 1); # remove
95         }
96         
97         if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
98                 autoscript($package,"postrm","postrm-debconf");
99         }
100 }
101
102 =head1 SEE ALSO
103
104 L<debhelper(1)>
105
106 This program is a part of debhelper.
107
108 =head1 AUTHOR
109
110 Joey Hess <joeyh@debian.org>
111
112 =cut