3 # Install files from debian/ into the package's DEBIAN directory.
6 use Debian::Debhelper::Dh_Lib;
9 foreach my $package (@{$dh{DOPACKAGES}}) {
10 my $tmp=tmpdir($package);
11 my $ext=pkgext($package);
13 if (! -d "$tmp/DEBIAN") {
14 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
17 # Install debian install scripts.
18 # If any .debhelper files exist, add them into the scripts.
19 foreach my $file (qw{postinst preinst prerm postrm}) {
20 my $f=pkgfile($package,$file);
22 if (-f "debian/$ext$file.debhelper") {
23 # Add this into the script, where it has
25 # TODO: do internally, no perl fork?
26 complex_doit("perl -pe 's~#DEBHELPER#~qx{cat debian/$ext$file.debhelper}~eg' < $f > $tmp/DEBIAN/$file");
29 # Just get rid of any #DEBHELPER# in the
31 complex_doit("sed s/#DEBHELPER#// < $f > $tmp/DEBIAN/$file");
33 doit("chown","0.0","$tmp/DEBIAN/$file");
34 doit("chmod",755,"$tmp/DEBIAN/$file");
37 # Auto-generate script header and add .debhelper
39 if (-f "debian/$ext$file.debhelper") {
40 complex_doit("echo '#!/bin/sh -e' > $tmp/DEBIAN/$file");
41 complex_doit("cat debian/$ext$file.debhelper >> $tmp/DEBIAN/$file");
42 doit("chown","0.0","$tmp/DEBIAN/$file");
43 doit("chmod",755,"$tmp/DEBIAN/$file");
48 # Install non-executable files
49 foreach my $file (qw{shlibs conffiles}) {
50 my $f=pkgfile($package,$file);
52 doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$tmp/DEBIAN/$file");
56 # Automatic conffiles registration: If it is in /etc, it is a
58 if (! compat(2) && -d "$tmp/etc") {
59 complex_doit("find $tmp/etc -type f |sed 's~^$tmp~~' >> $tmp/DEBIAN/conffiles");
61 if (-z "$tmp/DEBIAN/conffiles") {
62 doit("rm", "-f", "$tmp/DEBIAN/conffiles");
65 doit("chmod", 644, "$tmp/DEBIAN/conffiles");