3 # Install files from debian/ into the package's DEBIAN directory.
5 use Debian::Debhelper::Dh_Lib;
8 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
10 $EXT=pkgext($PACKAGE);
12 if (! -d "$TMP/DEBIAN") {
13 doit("install","-o",0,"-g",0,"-d","$TMP/DEBIAN");
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);
21 if (-f "debian/$EXT$file.debhelper") {
22 # Add this into the script, where it has
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");
28 # Just get rid of any #DEBHELPER# in the
30 complex_doit("sed s/#DEBHELPER#// < $f > $TMP/DEBIAN/$file");
32 doit("chown","0.0","$TMP/DEBIAN/$file");
33 doit("chmod",755,"$TMP/DEBIAN/$file");
36 # Auto-generate script header and add .debhelper
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");
47 # Install non-executable files
48 foreach $file (qw{shlibs conffiles}) {
49 $f=pkgfile($PACKAGE,$file);
51 doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$TMP/DEBIAN/$file");
55 # Automatic conffiles registration: If it is in /etc, it is a
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");
60 if (-z "$TMP/DEBIAN/conffiles") {
61 doit("rm", "-f", "$TMP/DEBIAN/conffiles");
64 doit("chmod", 644, "$TMP/DEBIAN/conffiles");