]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdeb
r420: big monsta changes
[debhelper.git] / dh_installdeb
1 #!/usr/bin/perl -w
2 #
3 # Install files from debian/ into the package's DEBIAN directory.
4
5 use strict;
6 use Debian::Debhelper::Dh_Lib;
7 init();
8
9 foreach my $package (@{$dh{DOPACKAGES}}) {
10         my $tmp=tmpdir($package);
11         my $ext=pkgext($package);
12
13         if (! -d "$tmp/DEBIAN") {
14                 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
15         }
16
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);
21                 if ($f) {
22                         if (-f "debian/$ext$file.debhelper") {
23                                 # Add this into the script, where it has
24                                 # #DEBHELPER#
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");
27                         }
28                         else {
29                                 # Just get rid of any #DEBHELPER# in the 
30                                 # script.
31                                 complex_doit("sed s/#DEBHELPER#// < $f > $tmp/DEBIAN/$file");
32                         }
33                         doit("chown","0.0","$tmp/DEBIAN/$file");
34                         doit("chmod",755,"$tmp/DEBIAN/$file");
35                 }
36                 else {
37                         # Auto-generate script header and add .debhelper
38                         # content to it.
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");
44                         }
45                 }
46         }
47
48         # Install non-executable files
49         foreach my $file (qw{shlibs conffiles}) {
50                 my $f=pkgfile($package,$file);
51                 if ($f) {
52                         doit("install","-o",0,"-g",0,"-m",644,"-p",$f,"$tmp/DEBIAN/$file");
53                 }
54         }
55
56         # Automatic conffiles registration: If it is in /etc, it is a
57         # conffile.
58         if (! compat(2) && -d "$tmp/etc") {
59                 complex_doit("find $tmp/etc -type f |sed 's~^$tmp~~' >> $tmp/DEBIAN/conffiles");
60                 # Anything found?
61                 if (-z "$tmp/DEBIAN/conffiles") {
62                         doit("rm", "-f", "$tmp/DEBIAN/conffiles");
63                 }
64                 else {
65                         doit("chmod", 644, "$tmp/DEBIAN/conffiles");
66                 }
67         }
68 }