]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdeb
r392: * DH_COMPAT=3 now enables the following new features which I can't just
[debhelper.git] / dh_installdeb
1 #!/usr/bin/perl -w
2 #
3 # Install files from debian/ into the package's DEBIAN directory.
4
5 use Debian::Debhelper::Dh_Lib;
6 init();
7
8 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
9         $TMP=tmpdir($PACKAGE);
10         $EXT=pkgext($PACKAGE);
11
12         if (! -d "$TMP/DEBIAN") {
13                 doit("install","-o",0,"-g",0,"-d","$TMP/DEBIAN");
14         }
15
16         # Install debian install scripts.
17         # If any .debhelper files exist, add them into the scripts.
18         foreach $file (qw{postinst preinst prerm postrm}) {
19                 $f=pkgfile($PACKAGE,$file);
20                 if ($f) {
21                         if (-f "debian/$EXT$file.debhelper") {
22                                 # Add this into the script, where it has
23                                 # #DEBHELPER#
24                                 # TODO: do internally, no perl fork?
25                                 complex_doit("perl -pe 's~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg' < $f > $TMP/DEBIAN/$file");
26                         }
27                         else {
28                                 # Just get rid of any #DEBHELPER# in the 
29                                 # script.
30                                 complex_doit("sed s/#DEBHELPER#// < $f > $TMP/DEBIAN/$file");
31                         }
32                         doit("chown","0.0","$TMP/DEBIAN/$file");
33                         doit("chmod",755,"$TMP/DEBIAN/$file");
34                 }
35                 else {
36                         # Auto-generate script header and add .debhelper
37                         # content to it.
38                         if (-f "debian/$EXT$file.debhelper") {
39                                 complex_doit("echo '#!/bin/sh -e' > $TMP/DEBIAN/$file");
40                                 complex_doit("cat debian/$EXT$file.debhelper >> $TMP/DEBIAN/$file");
41                                 doit("chown","0.0","$TMP/DEBIAN/$file");
42                                 doit("chmod",755,"$TMP/DEBIAN/$file");
43                         }
44                 }
45         }
46
47         # Install non-executable files
48         foreach $file (qw{shlibs conffiles}) {
49                 $f=pkgfile($PACKAGE,$file);
50                 if ($f) {
51                         doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$TMP/DEBIAN/$file");
52                 }
53         }
54
55         # Automatic conffiles registration: If it is in /etc, it is a
56         # conffile.
57         if (! Debian::Debhelper::Dh_Lib::compat(2) && -d "$TMP/etc") {
58                 complex_doit("find $TMP/etc -type f |sed 's~^$TMP~~' >> $TMP/DEBIAN/conffiles");
59                 # Anything found?
60                 if (-z "$TMP/DEBIAN/conffiles") {
61                         doit("rm", "-f", "$TMP/DEBIAN/conffiles");
62                 }
63         }
64 }