]> git.donarmstrong.com Git - debhelper.git/blob - dh_builddeb
r1980: * prerm and postrm scripts are now generated in a reverse order than
[debhelper.git] / dh_builddeb
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_builddeb - build debian packages
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_builddeb> [S<I<debhelper options>>] [B<--destdir=>I<directory>] [B<--filename=>I<name>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 dh_builddeb simply calls L<dpkg-deb(8)> to build a debian package or
19 packages.
20
21 =head1 OPTIONS
22
23 =over 4
24
25 =item B<--destdir=>I<directory>
26
27 Use this if you want the generated .deb files to be put in a directory
28 other than the default of ".."
29
30 =item B<--filename=>I<name>
31
32 Use this if you want to force the generated .deb file to have a particular
33 file name. Does not work well if more than one .deb is generated!
34
35 =item B<-u>I<params>
36
37 =item B<--> I<params>
38
39 Pass I<params> to L<dpkg-deb(1)> when it is used to build the
40 package.
41
42 =back
43
44 =cut
45
46 init();
47
48 # Set the default destination directory.
49 if (! defined $dh{DESTDIR}) {
50         $dh{DESTDIR}='..';
51 }
52
53 if (! defined $dh{FILENAME}) {
54         $dh{FILENAME}='';
55 }
56 else {
57         $dh{FILENAME}="/$dh{FILENAME}";
58 }
59
60 foreach my $package (@{$dh{DOPACKAGES}}) {
61         my $tmp=tmpdir($package);
62         if (exists $ENV{DH_ALWAYS_EXCLUDE} && length $ENV{DH_ALWAYS_EXCLUDE}) {
63                 if (! compat(5)) {
64                         complex_doit("find $tmp $dh{EXCLUDE_FIND} | xargs rm -rf");
65                 }
66                 else {
67                         # Old broken code here for compatability. Does not
68                         # remove everything.
69                         complex_doit("find $tmp -name $_ | xargs rm -rf")
70                                 foreach split(":", $ENV{DH_ALWAYS_EXCLUDE});
71                 }
72         }
73         if (! is_udeb($package)) {
74                 doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
75         }
76         else {
77                 my $filename=$dh{FILENAME};
78                 if (! $filename) {
79                         $filename="/".udeb_filename($package);
80                 }
81                 doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename);
82         }
83 }
84
85 =head1 SEE ALSO
86
87 L<debhelper(7)>
88
89 This program is a part of debhelper.
90
91 =head1 AUTHOR
92
93 Joey Hess <joeyh@debian.org>
94
95 =cut