]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdeb
r495: * dh_undocumented: check for existing uncompressed man pages. Closes: #87972
[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   dh_installdeb [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
31 The postinst, preinst, postrm, and prerm are handled specially: If a
32 corresponding file named debian/script.debhelper exists, the contents of that
33 file are merged into the script as follows: If the script exists, then
34 anywhere in it that "#DEBHELPER#" appears, the text of the .debhelper file is
35 inserted. If the script does not exist, then a script is generated from
36 the .debhelper file. The .debhelper files are created by other debhelper
37 programs, such as L<dh_installmenu(1)>, and are shell script fragments.
38
39 If DH_COMPAT is set to 3 or higher, all files in the etc/ directory in a
40 package will automatically be flagged as conffiles by this program, so
41 there is no need to list them manually in package.conffiles.
42
43 =cut
44
45 init();
46
47 foreach my $package (@{$dh{DOPACKAGES}}) {
48         my $tmp=tmpdir($package);
49         my $ext=pkgext($package);
50
51         if (! -d "$tmp/DEBIAN") {
52                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
53         }
54
55         # Install debian install scripts.
56         # If any .debhelper files exist, add them into the scripts.
57         foreach my $file (qw{postinst preinst prerm postrm}) {
58                 my $f=pkgfile($package,$file);
59                 if ($f) {
60                         if (-f "debian/$ext$file.debhelper") {
61                                 # Add this into the script, where it has
62                                 # #DEBHELPER#
63                                 # TODO: do internally, no perl fork?
64                                 complex_doit("perl -pe 's~#DEBHELPER#~qx{cat debian/$ext$file.debhelper}~eg' < $f > $tmp/DEBIAN/$file");
65                         }
66                         else {
67                                 # Just get rid of any #DEBHELPER# in the 
68                                 # script.
69                                 complex_doit("sed s/#DEBHELPER#// < $f > $tmp/DEBIAN/$file");
70                         }
71                         doit("chown","0.0","$tmp/DEBIAN/$file");
72                         doit("chmod",755,"$tmp/DEBIAN/$file");
73                 }
74                 else {
75                         # Auto-generate script header and add .debhelper
76                         # content to it.
77                         if (-f "debian/$ext$file.debhelper") {
78                                 complex_doit("printf '#!/bin/sh\nset -e\n' > $tmp/DEBIAN/$file");
79                                 complex_doit("cat debian/$ext$file.debhelper >> $tmp/DEBIAN/$file");
80                                 doit("chown","0.0","$tmp/DEBIAN/$file");
81                                 doit("chmod",755,"$tmp/DEBIAN/$file");
82                         }
83                 }
84         }
85
86         # Install non-executable files
87         foreach my $file (qw{shlibs conffiles}) {
88                 my $f=pkgfile($package,$file);
89                 if ($f) {
90                         doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$tmp/DEBIAN/$file");
91                 }
92         }
93
94         # Automatic conffiles registration: If it is in /etc, it is a
95         # conffile.
96         if (! compat(2) && -d "$tmp/etc") {
97                 complex_doit("find $tmp/etc -type f -printf '/etc/%P\n' >> $tmp/DEBIAN/conffiles");
98                 # Anything found?
99                 if (-z "$tmp/DEBIAN/conffiles") {
100                         doit("rm", "-f", "$tmp/DEBIAN/conffiles");
101                 }
102                 else {
103                         doit("chmod", 644, "$tmp/DEBIAN/conffiles");
104                 }
105         }
106 }
107
108 =head1 SEE ALSO
109
110 L<debhelper(1)>
111
112 This program is a part of debhelper.
113
114 =head1 AUTHOR
115
116 Joey Hess <joeyh@debian.org>
117
118 =cut