]> git.donarmstrong.com Git - debhelper.git/blob - dh_builddeb
Updated French man page translation. Closes: #685560
[debhelper.git] / dh_builddeb
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_builddeb - build Debian binary 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 B<dh_builddeb> simply calls L<dpkg-deb(1)> to build a Debian package or
19 packages.
20
21 It supports building multiple binary packages in parallel, when enabled by
22 DEB_BUILD_OPTIONS.
23
24 =head1 OPTIONS
25
26 =over 4
27
28 =item B<--destdir=>I<directory>
29
30 Use this if you want the generated F<.deb> files to be put in a directory
31 other than the default of "F<..>".
32
33 =item B<--filename=>I<name>
34
35 Use this if you want to force the generated .deb file to have a particular
36 file name. Does not work well if more than one .deb is generated!
37
38 =item B<--> I<params>
39
40 Pass I<params> to L<dpkg-deb(1)> when it is used to build the
41 package.
42
43 =item B<-u>I<params>
44
45 This is another way to pass I<params> to L<dpkg-deb(1)>.
46 It is deprecated; use B<--> instead.
47
48 =back
49
50 =cut
51
52 init(options => {
53         "filename=s" => \$dh{FILENAME},
54         "destdir=s" => \$dh{DESTDIR},
55 });
56
57 # Set the default destination directory.
58 if (! defined $dh{DESTDIR}) {
59         $dh{DESTDIR}='..';
60 }
61
62 if (! defined $dh{FILENAME}) {
63         $dh{FILENAME}='';
64 }
65 else {
66         $dh{FILENAME}="/$dh{FILENAME}";
67 }
68
69 my $max_procs=get_buildoption("parallel") || 1;
70
71 my $processes=1;
72 my $exit=0;
73 sub reap {
74         if (wait == -1) {
75                 $processes=0;
76         }
77         else {
78                 $processes--;
79                 $exit=1 if $? != 0;
80         }
81 }
82
83 foreach my $package (@{$dh{DOPACKAGES}}) {
84         my $pid=fork();
85         if (! defined $pid) {
86                 error("fork failed! $!");
87         }
88         if ($pid) { # parent
89                 $processes++;
90                 reap while $processes > $max_procs;
91                 next;
92         }
93
94         # child
95         my $tmp=tmpdir($package);
96         if (exists $ENV{DH_ALWAYS_EXCLUDE} && length $ENV{DH_ALWAYS_EXCLUDE}) {
97                 if (! compat(5)) {
98                         complex_doit("find $tmp $dh{EXCLUDE_FIND} | xargs rm -rf");
99                 }
100                 else {
101                         # Old broken code here for compatibility. Does not
102                         # remove everything.
103                         complex_doit("find $tmp -name $_ | xargs rm -rf")
104                                 foreach split(":", $ENV{DH_ALWAYS_EXCLUDE});
105                 }
106         }
107         if (! is_udeb($package)) {
108                 doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
109         }
110         else {
111                 my $filename=$dh{FILENAME};
112                 if (! $filename) {
113                         $filename="/".udeb_filename($package);
114                 }
115                 doit("dpkg-deb", "-z1", "-Zxz", "-Sextreme",
116                         @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename);
117         }
118         exit 0;
119 }
120
121 reap while $processes;
122 exit $exit;
123
124 =head1 SEE ALSO
125
126 L<debhelper(7)>
127
128 This program is a part of debhelper.
129
130 =head1 AUTHOR
131
132 Joey Hess <joeyh@debian.org>
133
134 =cut