]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdeb
r2041: * dh_installdeb: Add support for dpkg triggers, by installing
[debhelper.git] / dh_installdeb
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installdeb - install files into the DEBIAN directory
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installdeb> [S<I<debhelper options>>]
15
16 =head1 DESCRIPTION
17
18 dh_installdeb is a debhelper program that is responsible for installing
19 files into the DEBIAN directories in package build directories with the
20 correct permissions.
21
22 dh_installdeb automatically installs the following files from debian/ into
23 the DEBIAN directory:
24   package.postinst
25   package.preinst
26   package.postrm
27   package.prerm
28   package.shlibs
29   package.conffiles
30   package.triggers
31
32 The postinst, preinst, postrm, and prerm are handled specially: If a
33 corresponding file named debian/package.script.debhelper exists, the contents
34 of that file are merged into the script as follows: If the script exists,
35 then anywhere in it that "#DEBHELPER#" appears, the text of the .debhelper
36 file is inserted. If the script does not exist, then a script is generated
37 from the .debhelper file. The .debhelper files are created by other debhelper
38 programs, such as L<dh_installmenu(1)>, and are shell script fragments.
39
40 In V3 compatibility mode and higher, all files in the etc/ directory in a
41 package will automatically be flagged as conffiles by this program, so
42 there is no need to list them manually in package.conffiles.
43
44 =cut
45
46 init();
47
48 foreach my $package (@{$dh{DOPACKAGES}}) {
49         my $tmp=tmpdir($package);
50
51         if (! -d "$tmp/DEBIAN") {
52                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
53         }
54
55         if (is_udeb($package)) {
56                 # For udebs, only do the postinst, and no #DEBHELPER#.
57                 my $f=pkgfile($package,"postinst");
58                 if ($f) {
59                         doit("install", "-o", 0, "-g", 0, "-m", 755, 
60                              $f, "$tmp/DEBIAN/postinst");
61                 }
62                 next;           
63         }
64         
65         # Install debian scripts.
66         foreach my $script (qw{postinst preinst prerm postrm}) {
67                 debhelper_script_subst($package, $script);
68         }
69
70         if (! is_udeb($package)) {
71                 # Install non-executable files
72                 foreach my $file (qw{shlibs conffiles triggers}) {
73                         my $f=pkgfile($package,$file);
74                         if ($f) {
75                                 doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$tmp/DEBIAN/$file");
76                         }
77                 }
78         }
79
80         # Automatic conffiles registration: If it is in /etc, it is a
81         # conffile.
82         if (! compat(2) && -d "$tmp/etc" && ! is_udeb($package)) {
83                 complex_doit("find $tmp/etc -type f -printf '/etc/%P\n' >> $tmp/DEBIAN/conffiles");
84                 # Anything found?
85                 if (-z "$tmp/DEBIAN/conffiles") {
86                         doit("rm", "-f", "$tmp/DEBIAN/conffiles");
87                 }
88                 else {
89                         doit("chmod", 644, "$tmp/DEBIAN/conffiles");
90                 }
91         }
92 }
93
94 =head1 SEE ALSO
95
96 L<debhelper(7)>
97
98 This program is a part of debhelper.
99
100 =head1 AUTHOR
101
102 Joey Hess <joeyh@debian.org>
103
104 =cut