Debian Codegraph @

scripts/debaux-build

raw
1 #! /usr/bin/perl -w
2 #
3 # debaux-build - Debian package building script
4 #
5 # Copyright 2000,2001,2002,2003,2004,2005,2006,2007,2008,2010 Stefan Hornburg (Racke) <[email protected]>
6 #
7 # This program is free software; you can redistribute it
8 # and/or modify it under the terms of the GNU General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public
19 # License along with this program; if not, write to the Free
20 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 # MA 02111-1307 USA.
22
23 # Parameters
24 # debdir - Directory with Debian files
25 # builddir - Build directory
26 # sourcedir - Directory with source archive
27
28 use vars qw($VERSION);
29 $VERSION = '0.001_011';
30
31 # MODULES
32 # =======
33
34 use strict;
35 use AppConfig qw(:argcount :expand);
36 use CPAN;
37 use Cwd;
38 use File::Basename;
39 use File::Copy;
40 use File::Find;
41 use Getopt::Long;
42 use LWP::UserAgent;
43 use Net::SSH qw(sshopen2 ssh_cmd);
44 use POSIX qw(strftime);
45 use Time::Zone;
46
47 use DebAux::Util;
48
49 # VARIABLES
50 # =========
51
52 # Upstream version number, Debian version number,
53 # Debian release number and source package
54 my ($vupstream, $version, $debnumber, $srcname);
55 # Source package
56 my ($archive, $archivefile, @archivecandidates);
57 # Debian package name and architecture
58 my ($debname, $debarch);
59 # Name of .dsc file
60 my $dscfile;
61 # Configuration
62 my %vars;
63 # List of generated packages (used for installation)
64 my @pkglist;
65 # Chroot parameter
66 my ($chroothost, $chrootdir, $chrootuser);
67
68 # COMMANDLINE PARAMETERS
69 # ======================
70
71 my %opts = (version => '');
72 my $whandler = $SIG{__WARN__};
73 my @OLDARGV = @ARGV;
74 $SIG{__WARN__} = sub {print STDERR "$0: @_";};
75 unless (GetOptions (\%opts, 'apt', 'append-version=s', 'archive=s',
76 'build-options=s', 'changelog-message=s',
77 'chroot=s', 'chroot-user=s', 'cpan',
78 'directory=s', 'empty', 'env=s@', 'epoch=i', 'extra-sources=s',
79 'install:s', 'lintian|l', 'make-archive=s',
80 'release', 'rpm|alien', 'sign|s',
81 'skip-patches',
82 'source-name=s', 'source-tree=s',
83 'stop-after-unpack', 'stop-before-build',
84 'version=s')) {
85 exit 1;
86 }
87 $SIG{__WARN__} = $whandler;
88
89 # sanity checks
90 unless (@ARGV) {
91 die "Usage: $0 DEBIANDIR\n";
92 }
93 my ($debiandir, $builddir, $sourcedir) = @ARGV;
94 my $pkgname;
95
96 if ($opts{'append-version'} && ! $opts{'changelog-message'}) {
97 die "$0: Missing changelog message\n";
98 }
99
100 # read global configuration file
101 my $cfgfileref;
102 my $conf = new AppConfig ({GLOBAL => {ARGCOUNT => ARGCOUNT_ONE},
103 ERROR => sub {
104 die ("$0: $$cfgfileref: @_\n");
105 }
106 });
107 $conf -> define ('debauxdir', {ARGCOUNT => ARGCOUNT_HASH});
108 $conf -> define ('debiandir', {DEFAULT => '', EXPAND => EXPAND_ALL});
109 $conf -> define ('email', {DEFAULT => ''});
110 $conf -> define ('fullname', {DEFAULT => ''});
111 $conf -> define ('maintainer', {DEFAULT => ''});
112 $conf -> define ('sharedir', {DEFAULT => '/usr/share/debaux', EXPAND => EXPAND_ALL});
113 $conf -> define ('sourcedir', {DEFAULT => '/usr/local/src'});
114 $conf -> define ('source-tree', {ARGCOUNT => ARGCOUNT_HASH});
115
116 for my $cfgfile ("$ENV{'HOME'}/.debauxrc", '.debauxrc') {
117 $cfgfileref = \$cfgfile;
118 if (-f $cfgfile) {
119 open (CONF, $cfgfile)
120 || die "$0: Couldn't open configuration file $cfgfile: $!\n";
121 $conf -> file (\*CONF);
122 close (CONF);
123 }
124 }
125
126 if (substr($conf->get('sharedir'),0,1) ne '/') {
127 $conf->set('sharedir', cwd() . '/' . $conf->get('sharedir'));
128 }
129
130 # determine architecture
131 $debarch = DebAux::Util::architecture();
132
133 unless (-d $debiandir && -f "$debiandir/debbuild") {
134 if (-f $debiandir) {
135 # check if filename matches archive
136 if (basename($debiandir) =~ m%(.*?)-(\d+(\.\d+)*)\.tar\.gz%) {
137 # build directly from the archive
138 $srcname = $1;
139 $version = $2;
140 } else {
141 die "$0: This seems not to be an archive file\n";
142 }
143 } else {
144 $pkgname = $debiandir;
145 $srcname = $debiandir;
146
147 if (exists ($conf->get('debauxdir')->{$pkgname})
148 && -d $conf->get('debauxdir')->{$pkgname}) {
149 $debiandir = $conf->get('debauxdir')->{$pkgname};
150 } elsif ($conf->get('debiandir') =~ /\S/
151 && -d join('/',$conf->get('debiandir'),$debiandir)) {
152 $debiandir = join('/',$conf->get('debiandir'),$debiandir);
153 }
154 }
155 } else {
156 $pkgname = basename($debiandir);
157 }
158
159 $builddir = join('-', '/var/tmp/debaux', (getpwuid($<))[0])
160 unless defined $builddir && $builddir =~ /\S/;
161 $sourcedir = $conf->get('sourcedir')
162 unless defined $sourcedir && $sourcedir =~ /\S/;
163
164 if ($builddir !~ /^[\w\.\/\+~:-]+$/) {
165 die "$0: Suspicious directory name \"$builddir\"\n";
166 }
167
168 if ($opts{chroot}) {
169 if ($opts{chroot} =~ /^(.*?):(.*?)$/) {
170 $chroothost = $1;
171 $chrootdir = $2;
172 } else {
173 $chroothost = 'localhost';
174 $chrootdir = $opts{chroot};
175 }
176 }
177
178 if (! $opts{'source-tree'} && exists $conf->get('source-tree')->{$pkgname}) {
179 $opts{'source-tree'} = $conf->get('source-tree')->{$pkgname};
180 }
181
182 my $aptsource = 0;
183 my $oldbuilddir = $builddir;
184
185 if ($opts{'cpan'}) {
186 if ($conf->get('debiandir') !~ /\S/) {
187 die "$0: Global configuration option 'debiandir' needed for --cpan\n";
188 }
189 my $debianbasedir = $conf->get('debiandir');
190
191 if ($debiandir =~ m%/%) {
192 $debiandir = substr($debiandir, length($debianbasedir) + 1);
193 }
194
195 # CPAN configuration
196 $CPAN::Config->{keep_source} = 1;
197
198 # check CPAN
199 my @objs = CPAN::Shell->expand ('Module', $debiandir);
200 unless (@objs) {
201 die "$0: No hit on CPAN for $debiandir\n";
202 }
203 if (@objs > 1) {
204 die "$0: More than one hit on CPAN for $debiandir\n";
205 }
206 my $cpan_file = $objs[0]->cpan_file();
207 my $dir = basename($cpan_file,'.tar.gz');
208 my $aname;
209
210 if ($dir =~ /(.*?)-\d+(\.\d+)*$/) {
211 $aname = $1;
212 } else {
213 die "$0: Couldn't extract version number for CPAN archive out of \"$dir\"\n";
214 }
215
216 # download archive
217 CPAN::Shell->get ($debiandir);
218 my $cpansourcedir = $CPAN::Config->{keep_source_where};
219
220 # set parameters
221 if ($opts{version} !~ /\S/) {
222 $opts{'version'} .= $objs[0]->cpan_version();
223 }
224 $opts{'archive'} = "$cpansourcedir/authors/id/$cpan_file";
225 $opts{'directory'} ||= "$aname-" . $opts{'version'};
226 $opts{'source-tree'} = join ('/', $CPAN::Config->{build_dir}, $dir);
227
228 # determine package name and create Debian packaging files
229 # if necessary
230 my $buf;
231 my $pkgname = join ('-', map {$buf = lc($_); $buf =~ s/_//g; $buf} (split(/::/, $debiandir)), 'perl');
232 $opts{'source-name'} = $pkgname;
233
234 my $dconfdir = "$debianbasedir/$pkgname/debian";
235
236 if (! -d $dconfdir) {
237 DebAux::Util::mkdir ($dconfdir);
238 }
239
240 sub mycopy {
241 my ($from, $to, %filter) = @_;
242
243 open (FROM, $from)
244 || die "$0: Couldn't open $from: $!\n";
245 open (TO, ">$to")
246 || die "$0: Couldn't open $to for writing: $!\n";
247 while (<FROM>) {
248 s/\#(.*?)\#/$filter{$1} || ''/eg;
249 print TO;
250 }
251 close (FROM)
252 || die "$0: Couldn't close $from: $!\n";
253 close (TO)
254 || die "$0: Couldn't close $to: $!\n";
255 }
256
257 my %filter = (DATE => changelog_date(),
258 DIRECTORY => $opts{directory},
259 EMAIL => $conf->get('email') || $ENV{'DEBEMAIL'},
260 PACKAGE => $pkgname,
261 POLICY => '3.9.1',
262 USERNAME => $conf->get('fullname') || $ENV{'DEBFULLNAME'},
263 VERSION => $opts{epoch} ? "$opts{epoch}:$opts{version}" : $opts{version},
264 );
265
266 &mycopy ('/usr/share/debhelper/dh_make/debian/changelog',
267 "$dconfdir/changelog", %filter);
268 &mycopy ($conf->get('sharedir') . '/cpan/compat',
269 "$dconfdir/compat", %filter);
270 &mycopy ($conf->get('sharedir') . '/cpan/control',
271 "$dconfdir/control", %filter);
272 &mycopy ($conf->get('sharedir') . '/cpan/debbuild',
273 "$debianbasedir/$pkgname/debbuild", %filter);
274 &mycopy ($conf->get('sharedir') . '/cpan/rules',
275 "$dconfdir/rules", %filter);
276
277 $debiandir = "$debianbasedir/$pkgname";
278 }
279
280 if ($opts{'apt'}
281 || ! (-d $debiandir || -f $debiandir || $opts{'source-tree'})) {
282 # looks like we have no information about this package,
283 # so we call apt-get source
284 $builddir = mkbuilddir ($builddir, $pkgname);
285 $opts{'source-tree'} = '';
286 chdir ($builddir) || die "$0: Couldn't enter build directory $builddir\n";
287 open (AGS, "apt-get --print-uris source $pkgname |");
288 while (<AGS>) {
289 if (/\s(.*?)_(.*?)\.orig\.tar\.gz/
290 || /\s(.*?)_(.*?)(-\d+)?\.tar\.gz/) {
291 $opts{'source-tree'} = "$builddir/$1-$2";
292 }
293 }
294 close (AGS) || die "$0: Errors while executing apt-get source $pkgname\n";
295 unless ($opts{'source-tree'}) {
296 die "$0: Couldn't determine package version\n";
297 }
298
299 # we may use patches, so we have to erase the old build
300 # directory
301 if (-d $opts{'source-tree'}) {
302 DebAux::Util::remove ($opts{'source-tree'});
303 }
304
305 open (AGS, "apt-get -qq source $pkgname |");
306 while (<AGS>) {
307 print;
308 }
309 close (AGS) || die "$0: Errors while executing apt-get source $debiandir\n";
310 $aptsource = 1;
311 } elsif ($debiandir !~ m%^/%) {
312 $debiandir = cwd() . '/' . $debiandir;
313 }
314
315 # PARSE DEBIAN CHANGELOG
316 # ======================
317
318 # first get version number from changelog file
319 my $changelog;
320
321 if ($opts{'source-tree'}) {
322 $changelog = $opts{'source-tree'} . '/debian/changelog';
323 }
324
325 unless ($changelog && -f $changelog) {
326 $changelog = "$debiandir/debian/changelog";
327 }
328
329 my $vfound = 0;
330 my $chlref;
331
332 if (-f $changelog) {
333 $chlref = parse_changelog ($changelog);
334
335 $debnumber = $chlref->{'debnumber'};
336 $vfound = $chlref->{'found'};
337 $srcname = $chlref->{'sourcename'};
338 $version = $chlref->{'version'};
339
340 unless ($vfound) {
341 die "$0: Couldn't detect package version number\n";
342 }
343 unless ($srcname) {
344 die "$0: Couldn't detect source package name\n";
345 }
346 } else {
347 warn ("No changelog $changelog\n");
348 }
349
350 if ($opts{'source-name'}) {
351 $srcname = $opts{'source-name'};
352 }
353 parse_config("$debiandir/debbuild", \%vars, \%opts, $version, $srcname);
354
355 $srcname = $vars{'source-name'};
356 $vupstream = $vars{'version'};
357
358 unless ($vfound || length($vupstream)) {
359 die "$0: Couldn't detect package version number\n";
360 }
361 unless ($srcname) {
362 die "$0: Couldn't detect source package name\n";
363 }
364
365 # add source name to build directory and check if
366 # we have to create the directory
367
368 unless ($aptsource) {
369 $builddir = mkbuilddir ($builddir, $srcname);
370 }
371
372 # MAKE ARCHIVE (optional)
373 # =======================
374
375 my $archive_tree = $sourcedir;
376
377 unless ($aptsource || $vars{'empty'}) {
378 if ($vars{'make-archive'}) {
379 $archive_tree = $debiandir;
380 if ($vars{'source-tree'}) {
381 $archive_tree = $vars{'source-tree'};
382 }
383 chdir ($archive_tree) || die ("$0: Couldn't enter directory $archive_tree: $!\n");
384 my $retval = system ($vars{'make-archive'});
385 if ($retval) {
386 die "$0: Couldn't make archive\n";
387 }
388 }
389 }
390
391 # REMOVE OLD STUFF
392 # ================
393
394 chdir ($builddir)
395 || die "$0: Couldn't enter build directory \"$builddir\": $!\n";
396
397 unless ($aptsource) {
398 DebAux::Util::remove ("$srcname-$vupstream.orig");
399 DebAux::Util::remove ("$srcname-$vupstream");
400
401 # remove old orig.tar.gz to avoid problems with dpkg-source
402 if (-f "${srcname}_$vupstream.orig.tar.gz") {
403 unlink ("${srcname}_$vupstream.orig.tar.gz")
404 || die "$0: Couldn't remove ${srcname}_$vupstream.orig.tar.gz: $!\n";
405 }
406 }
407
408 # UNPACK ARCHIVE
409 # ==============
410
411 my ($curdir, $pkgdebdir);
412
413 unless ($aptsource || $vars{'empty'}) {
414 FIND_ARCHIVE: {
415 my $arfile;
416 for my $arname (@{$vars{archive}}) {
417 if (substr($arname,0,1) eq '/') {
418 $arfile = $arname;
419 } else {
420 $arfile = "$archive_tree/$arname";
421 }
422
423 push (@archivecandidates, $arfile);
424 if (-f $arfile) {
425 $archivefile = $arfile;
426 last FIND_ARCHIVE;
427 }
428 }
429
430 my $sourcesdir = "$debiandir/sources";
431 if ($vars{download}) {
432 # download archive
433
434 my $ua = LWP::UserAgent->new;
435 my ($url, $request, $response);
436
437 $request = HTTP::Request->new('GET', $vars{download});
438 print "Downloading $vars{download}:";
439 $response = $ua->request($request);
440
441 unless ($response->is_success) {
442 print " failed.\n";
443 die "$0: Couldn't get original sources ($vars{download}): ", $response->code, " ", $response->message, "\n";
444 }
445 print " done.\n";
446
447 my $archive = "$archive_tree/" . basename($vars{download});
448 open (ARCHIVE, ">$archive")
449 || die "$0: Couldn't open $archive\n";
450 print ARCHIVE $response->content;
451 close (ARCHIVE);
452
453 $archivefile = $archive;
454 } elsif (-d $sourcesdir) {
455 # make an archive from the contents of this directory
456 $archivefile = &packsources ($builddir, $srcname, $vupstream, $sourcesdir);
457 }
458 }
459
460 unless (defined $archivefile) {
461 die ("$0: No archive file found (Tried: ",
462 join (', ', @archivecandidates), ")\n");
463 }
464
465 if ($archivefile =~ /\.bz2$/) {
466 open UNPACK, "tar -xjf $archivefile |";
467 } else {
468 open UNPACK, "tar -xzf $archivefile |";
469 }
470
471 while (<UNPACK>) {
472 print;
473 }
474 close (UNPACK) || die ("$0: Couldn't unpack \"$archivefile\"\n");
475
476 # move to the location for the original sources
477 rename ($vars{'directory'}, "$srcname-$vupstream.orig")
478 || die "$0: Couldn't move sources to original source directory: $vars{directory} => $srcname-$vupstream.orig : $!\n";
479 # copy to the package build directory
480 system ("cp -a $srcname-$vupstream.orig $srcname-$vupstream");
481 exit 0 if $opts{'stop-after-unpack'};
482 }
483
484 if ($vars{empty}) {
485 mkdir ("$srcname-$vupstream", 0755)
486 || die "$0: Couldn't create directory $srcname-$vupstream: $!\n";
487 }
488
489 # copy Debian files into that directory
490 chdir ("$srcname-$vupstream")
491 || die "$0: Couldn't enter directory $srcname-$vupstream: $!\n";
492 unless ($aptsource) {
493 unless (-d 'debian') {
494 mkdir ('debian', 0755)
495 || die "$0: Couldn't make debian directory: $!\n";
496 }
497
498 $curdir = cwd;
499 $pkgdebdir = "$debiandir/debian";
500
501 if (-l "$debiandir/debian") {
502 unless ($pkgdebdir = readlink ("$debiandir/debian")) {
503 die "$0: Couldn't determine value of symbolic link: $!\n";
504 }
505 }
506
507 if (-e $pkgdebdir && -d $pkgdebdir) {
508 find (sub{&filecopy($pkgdebdir,"$curdir/debian")}, $pkgdebdir);
509 }
510
511 if (! $vfound && -f "debian/changelog") {
512 my $inforef = parse_changelog('debian/changelog');
513 $debnumber = $inforef->{debnumber};
514 }
515 }
516
517 # check source format
518
519 my $sfref = source_format($builddir, $srcname, $vupstream);
520
521 if ($sfref->{version} >= 3) {
522 # create original tar file
523 open (PACK, "tar -czf $builddir/${srcname}_$vupstream.orig.tar.gz ../$srcname-$vupstream.orig |");
524 while (<PACK>) {print;}
525 close PACK
526 || die "$0: Errors while packing sources\n";
527
528 }
529
530 # APPLY PATCHES
531 # =============
532
533 if ($vars{'skip-patches'}) {
534 warn "Skipping patches\n";
535 } else {
536 if (-d "$debiandir/patches") {
537 # apply arch-independent patches in this directory
538 find (\&applypatches, "$debiandir/patches");
539
540 my $archdir = "$debiandir/patches/arch/$debarch";
541 if (-d $archdir) {
542 # apply arch-dependent patches
543 find (\&applypatches, $archdir);
544 }
545 }
546 if (-f "$debiandir/sources.diff") {
547 chdir ("$builddir/$srcname-$vupstream")
548 || die "$0: Couldn't enter directory \"$builddir/$srcname-$vupstream\": $!\n";
549 open PATCH, "patch -p1 --no-backup-if-mismatch < $debiandir/sources.diff |";
550 while (<PATCH>) {
551 print;
552 }
553 close (PATCH) || die "$0: Patch failed\n";
554 }
555 }
556
557 if (-f "$debiandir/sources.tar") {
558 chdir ("$builddir/$srcname-$vupstream")
559 || die "$0: Couldn't enter directory \"$builddir\": $!\n";
560 open TAR, "tar -xvf $debiandir/sources.tar |";
561 while (<TAR>) {
562 print;
563 }
564 close (TAR) || die "$0: Unarchiving extra sources failed\n";
565 }
566
567 if ($vars{'extra-sources'}) {
568 find (sub{&filecopy("$debiandir/$vars{'extra-sources'}", "$builddir/$srcname-$vupstream/$vars{'extra-sources'}")},"$debiandir/$vars{'extra-sources'}");
569 }
570
571 if ($vars{'append-version'}) {
572 # add new entry to debian/changelog
573 if ($conf->get('maintainer')) {
574 $chlref->{maintainer} = $conf->get('maintainer');
575 }
576
577 update_changelog ($srcname,
578 "$version-$debnumber" . '.' . $vars{'append-version'},
579 $opts{'changelog-message'},
580 $chlref);
581 }
582
583 # DSC file
584 my $fv = $vupstream;
585 if (defined $debnumber) {
586 $fv .= "-$debnumber";
587 }
588
589 $dscfile = "${srcname}_$fv.dsc";
590
591 # now make debian/rules executable
592 unless ($aptsource) {
593 chmod (0755, "$builddir/$srcname-$vupstream/debian/rules")
594 || die "$0: Couldn't make $builddir/$srcname-$vupstream/debian/rules executable: $!\n";
595 }
596
597 if ($opts{'release'}) {
598 download_orig_archive ($srcname, $vupstream, $builddir);
599 }
600
601 if ($opts{'chroot'}) {
602 chdir ("$builddir")
603 || die "$0: Couldn't enter directory \"$builddir\": $!\n";
604
605 # build Debian source packages
606 if (defined $debnumber) {
607 open DSRC, "dpkg-source -b $srcname-$vupstream |";
608 } else {
609 open DSRC, "dpkg-source -b $srcname-$vupstream '' |";
610 }
611
612 while (<DSRC>) {
613 print;
614 }
615 close (DSRC) || die "$0: dpkg-source packing failed\n";
616 # copy them to the chroot
617 my @buildfiles;
618 if ($vars{empty} || ! defined $debnumber) {
619 @buildfiles = ("${srcname}_$vupstream.tar.gz", $dscfile);
620 } else {
621 @buildfiles = ("${srcname}_$vupstream.orig.tar.gz", "${srcname}_$fv.diff.gz", $dscfile);
622 }
623
624 open RSYNC, "rsync -vv @buildfiles root\@$chroothost:$chrootdir/tmp |";
625 while (<RSYNC>) {
626 print;
627 }
628 close (RSYNC) || die "$0: couldn't copy source stuff to chroot\n";
629
630 # build the package
631 #------------------------ START BUILD SCRIPT
632 my $script = <<'EOF';
633 #!/usr/bin/perl
634
635 my $builddir = '/tmp';
636 my $lintian = '@lintian@';
637 my $debnumber = '@debnumber@';
638 my @pkglist;
639 my @pkgfiles;
640 my $rcmd = '';
641
642 $| = 1; # force immediate output
643
644 @env@
645
646 # reset locale to get expected messages from build process
647 $ENV{LANG} = 'C';
648
649 if ("@chroot@") {
650 chroot("@chroot@") || die ("@prog@: couldn't go to chroot: $!\n");
651 } else {
652 $rcmd = ' -rfakeroot';
653 }
654
655 chdir("$builddir") || die ("@prog@: couldn't enter $builddir: $!\n");
656 open (DSRC, "dpkg-source -x @dsc@ |");
657 while (<DSRC>) {
658 print;
659 }
660 close (DSRC) || die ("@prog@: unpack of source according to @dsc@ failed\n");
661 exit unless @build@;
662 chdir("$builddir/@dir@") || die ("@prog@: couldn't enter $builddir/@dir@: $!\n");
663 open (BUILD, "dpkg-buildpackage$rcmd @buildopts@ |");
664 while (<BUILD>) {
665 if ($lintian) {
666 if (/^dpkg-deb:\s*building package \`(.*?)\' in \`(.*?)\'/) {
667 push (@pkglist, $2);
668 }
669 }
670 print;
671 }
672 close (BUILD) || die ("@prog@: Couldn't build package\n");
673 exit 0 unless $lintian;
674
675 if ($lintian) {
676 print "Running lintian on ../@dsc@ @pkglist\n";
677 open (LINTIAN, "lintian -i ../@dsc@ @pkglist |");
678 while (<LINTIAN>) {
679 print;
680 }
681 close (LINTIAN) || die ("@prog@: Lintian failed\n");
682 }
683 EOF
684 #----------------------- END BUILD SCRIPT
685 my (@chenv, $name, $value);
686
687 for (@{$opts{env}}) {
688 ($name, $value) = split(/=/, $_, 2);
689 # replace shell variables with Perl variables
690 $value =~ s/\$([A-Z_]+)/\$ENV{$1}/g;
691 push (@chenv, qq{\$ENV{"$name"} = "$value";});
692 }
693
694 remote_perl ($script, {chroot => ($opts{'chroot-user'} ? '' : $chrootdir),
695 dir => "${srcname}-$vupstream",
696 dsc => $dscfile,
697 env => join("\n", @chenv),
698 build => ($opts{'stop-before-build'} ? 0 : 1),
699 buildopts => join(' ', '-uc', '-us', $vars{'build-options'}),
700 lintian => $vars{'lintian'},
701 prog => $0,
702 upstream => $vupstream,
703 debnumber => $debnumber},
704 $chroothost, $opts{'chroot-user'}, $chrootdir,
705 @buildfiles);
706 exit 0;
707 }
708
709 exit 0 if $opts{'stop-before-build'};
710
711 # BUILD PACKAGE
712 # =============
713
714 my @buildopts = ('-rfakeroot', $vars{'build-options'});
715 my %pkghash;
716
717 unless (defined $debnumber) {
718 # force inclusion of source code
719 push (@buildopts, '-sa');
720 }
721
722 unless ($opts{sign}) {
723 # bypass signing
724 push (@buildopts, '-uc', '-us');
725 }
726
727 # reset locale to get expected messages from build process
728 $ENV{LANG} = 'C';
729
730 open BUILD, join(' ', 'dpkg-buildpackage', @buildopts, '|');
731
732 while (<BUILD>) {
733 if (exists $opts{'install'} || $opts{'lintian'} || $opts{'rpm'}) {
734 # filter out package names
735 if (/^dpkg-deb:\s*building package \`(.*?)\' in \`(.*?)\'/) {
736 $pkghash{$1} = $2;
737 push (@pkglist, $2);
738 }
739 }
740 print;
741 }
742
743 # we need absolute paths
744 my @pkgfiles;
745
746 if ($aptsource) {
747 for (keys %pkghash) {
748 $pkghash{$_} =~ s%^..%$oldbuilddir/$srcname%;
749 }
750 @pkgfiles = map {$_ =~ s%^..%$oldbuilddir/$srcname%; $_} @pkglist;
751 } else {
752 for (keys %pkghash) {
753 $pkghash{$_} =~ s/^../$builddir/;
754 }
755 @pkgfiles = map {$_ =~ s/^../$builddir/; $_} @pkglist;
756 }
757
758 close (BUILD) || die ("$0: Couldn't build package\n");
759
760 # clean and reverse patches
761 #open CLEAN, "fakeroot make -f debian/rules clean |";
762 #while (<CLEAN>) {
763 # print;
764 #}
765 #close (CLEAN) || die ("$0: Error while cleansing build tree\n");
766
767 # BUILD CORRESPONDING RPM's WITH ALIEN
768 # ====================================
769
770 if ($opts{'rpm'}) {
771 my $rpmdir = "$builddir/rpm";
772
773 if (! -d $rpmdir) {
774 mkdir ($rpmdir, 0755)
775 || die ("$0: Couldn't create directory $rpmdir: $!\n");
776 }
777
778 chdir ($rpmdir)
779 || die ("$0: Couldn't enter build directory $builddir: $!\n");
780
781 for (@pkgfiles) {
782 print "Building RPM package from $_\n";
783 open (ALIEN, "alien --to-rpm $_ |");
784 while (<ALIEN>) {
785 print;
786 }
787 close (ALIEN);
788 }
789 }
790
791 # INSTALL PACKAGE
792 # ===============
793
794 if (exists $opts{'install'}) {
795 if ($opts{'install'} =~ /\S/) {
796 @pkgfiles = ();
797
798 for (split(/[,\s]+/, $opts{install})) {
799 if (exists $pkghash{$_}) {
800 push (@pkgfiles, $pkghash{$_});
801 } else {
802 die "$0: package '$_' not available for installation\n";
803 }
804 }
805 }
806 open (INSTALL, "ssh root\@localhost dpkg -i @pkgfiles |");
807 while (<INSTALL>) {
808 print;
809 }
810 close (INSTALL);
811 }
812
813 # CHECK PACKAGES WITH LINTIAN
814 # ===========================
815
816 if ($opts{'lintian'}) {
817 print "Running lintian on $builddir/$dscfile and @pkgfiles\n";
818 open (LINTIAN, "lintian -i $builddir/$dscfile @pkgfiles |");
819 while (<LINTIAN>) {
820 print;
821 }
822 close (LINTIAN) || die ("$0: Lintian failed\n");
823 }
824
825 #
826 # FUNCTIONS
827 # =========
828
829 # --------------------------------------------------
830 # FUNCTION: cut_epoch VERSION
831 #
832 # Removes epoch from VERSION and returns the result.
833 # --------------------------------------------------
834
835 sub cut_epoch {
836 my ($version) = @_;
837 $version =~ s/^\d+://;
838 $version;
839 }
840
841 # -------------------------------------------------------------
842 # FUNCTION: download_orig_archive SRCNAME VUPSTREAM DIR
843 #
844 # Fetch the sources in the official archive to keep the md5sum.
845 # -------------------------------------------------------------
846
847 sub download_orig_archive {
848 my ($srcname, $vupstream, $dir) = @_;
849
850 my $ua = new LWP::UserAgent (env_proxy => 1);
851 my ($url, $request, $response);
852
853 for (['ftp.debian.org','debian','main'],
854 ['nonus.debian.org','debian-non-US','non-US/main']) {
855 $url = "http://$_->[0]/$_->[1]/pool/$_->[2]/" . ($srcname =~ /^lib/ ? substr($srcname,0,4) : substr($srcname,0,1)) . "/$srcname/${srcname}_$vupstream.orig.tar.gz";
856 $request = HTTP::Request->new('GET', $url);
857 $response = $ua->request($request);
858 last if $response->is_success();
859 warn "$0: Failed to download sources from $url: ", $response->code, " ", $response->message, "\n";
860 }
861
862 unless ($response->is_success) {
863 die "$0: Couldn't get original sources ($url): ", $response->code, " ", $response->message, "\n";
864 }
865
866 my $origarchive = "$dir/${srcname}_$vupstream.orig.tar.gz";
867 open (ORIGARCHIVE, ">$origarchive")
868 || die "$0: Couldn't open $origarchive\n";
869 print ORIGARCHIVE $response->content;
870 close (ORIGARCHIVE);
871 }
872
873 # ------------------------------------------------
874 # FUNCTION: parse_changelog FILE
875 #
876 # Parses changelog FILE and returns hash reference
877 # with the following key/value pairs:
878 #
879 # debnumber
880 # found
881 # sourcename
882 # version
883 # ------------------------------------------------
884
885 sub parse_changelog {
886 my ($file) = @_;
887 my (%info);
888
889 open (PARSECHL, "dpkg-parsechangelog -l$file |");
890 while (<PARSECHL>) {
891 if (/^Version: (.*)(-(\d.*))$/) {
892 $info{version} = $1;
893 $info{debnumber} = $3;
894 $info{found} = 1;
895 } elsif (/^Version: (.*)$/) {
896 $info{version} = $1;
897 $info{found} = 1;
898 } elsif (/^Source: (\S+)/) {
899 $info{sourcename} = $1;
900 } elsif (/^(Distribution|Urgency|Maintainer): (.*)$/) {
901 $info{lc($1)} = $2;
902 }
903 }
904 close (PARSECHL) || die "$0: Errors while executing dpkg-parsechangelog on $file\n";
905 \%info;
906 }
907
908 # ---------------------------------------------------------
909 # FUNCTION: update_changelog SRCNAME VERSION MESSAGE CHLREF
910 #
911 # Adds a changelog entry.
912 # ---------------------------------------------------------
913
914 sub update_changelog {
915 my ($srcname, $version, $message, $chlref) = @_;
916 my ($chl, $date);
917
918 # read changelog into memory
919 open (CHL, "debian/changelog")
920 || die "$0: failed to open debian/changelog: $!\n";
921 while (<CHL>) {
922 $chl .= $_;
923 }
924 close (CHL);
925
926 # determine current date
927 $date = changelog_date();
928
929 # prepend new entry
930
931 $chl = qq{$srcname ($version) $chlref->{distribution}; urgency=$chlref->{urgency}
932
933 * $message
934
935 -- $chlref->{maintainer} $date
936
937 }
938 . $chl;
939
940 # update changelog
941 open (CHL, ">debian/changelog")
942 || die "$0: failed to open debian/changelog for writing: $!\n";
943 print CHL $chl;
944 close (CHL);
945 }
946
947 # ---------------------------------------------------------------
948 # FUNCTION: source_format
949 #
950 # Determines source format.
951 # ---------------------------------------------------------------
952
953 sub source_format {
954 my ($builddir, $package, $vupstream) = @_;
955 my ($sf_file, %sf);
956
957 $sf_file = join('/', $builddir, "$package-$vupstream", 'debian',
958 'source', 'format');
959
960 if (-f $sf_file) {
961 open (SF, $sf_file)
962 || die "$0: failed to open source format file $sf_file: $!\n";
963 while (<SF>) {
964 if (/^((\d+)(\.\d+)+)(\s*\((quilt|native)\))?/) {
965 $sf{version} = $1;
966 $sf{type} = $5;
967 }
968 else {
969 warn "Not matched: $_\n";
970 }
971 }
972 close (SF);
973 }
974
975 unless (exists $sf{version}) {
976 $sf{version} = '1.0';
977 }
978
979 return \%sf;
980 }
981
982 # ---------------------------------------------------------------
983 # FUNCTION: changelog_date
984 #
985 # Returns current date in a format suitable for debian/changelog.
986 # ---------------------------------------------------------------
987
988 sub changelog_date {
989 my ($offset, $offset_sign, $offsetstr);
990
991 $offset = tz_local_offset();
992
993 if ($offset > 0) {
994 $offset_sign = '+';
995 } else {
996 $offset_sign = '-';
997 $offset = - $offset;
998 }
999
1000 $offsetstr = sprintf("$offset_sign%02d%02d",
1001 $offset / 3600, ($offset % 3600) / 60);
1002
1003 return strftime ('%a, %m %b %Y %H:%M:%S ', localtime())
1004 . $offsetstr;
1005 }
1006
1007 # ------------------------------------------------------------
1008 # FUNCTION: parse_config FILE VREF OPTREF VERSION SOURCENAME
1009 #
1010 # Parses configuration file FILE and records the configuration
1011 # information into the hash referenced by VREF.
1012 # OPTREF is a reference to the hash with the already parsed
1013 # command line options.
1014 # SOURCENAME is the upstream package name.
1015 # VERSION is the version of the upstream package (may be
1016 # omitted).
1017 # ------------------------------------------------------------
1018
1019 sub parse_config {
1020 my ($file, $vref, $optref, $version, $sourcename) = @_;
1021 my ($vv, $config, @pseudoargs, %defhash);
1022
1023 $vv = cut_epoch($version) if defined $version;
1024
1025 $config = new AppConfig ({ERROR => sub {die "$0: $file: @_\n";},
1026 GLOBAL => {ARGCOUNT => ARGCOUNT_ONE,
1027 EXPAND => EXPAND_ALL}});
1028
1029 %defhash = ('apt' => {ARGCOUNT => ARGCOUNT_NONE},
1030 'append-version' => {DEFAULT => ''},
1031 'archive' => {ARGCOUNT => ARGCOUNT_LIST},
1032 'build-options' => {DEFAULT => ''},
1033 'changelog-message' => {DEFAULT => ''},
1034 'chroot' => {DEFAULT => ''},
1035 'chroot-user' => {DEFAULT => ''},
1036 'cpan' => {ARGCOUNT => ARGCOUNT_NONE},
1037 'directory' => {DEFAULT => ''},
1038 'download' => {DEFAULT => ''},
1039 'empty' => {DEFAULT => 0},
1040 'env' => {ARGCOUNT => ARGCOUNT_LIST},
1041 'epoch' => {DEFAULT => 0},
1042 'extra-sources' => {DEFAULT => ''},
1043 'install' => {ARGCOUNT => ARGCOUNT_NONE},
1044 'lintian' => {ARGCOUNT => ARGCOUNT_NONE},
1045 'make-archive' => {DEFAULT => ''},
1046 'release' => {ARGCOUNT => ARGCOUNT_NONE},
1047 'rpm' => {DEFAULT => 0},
1048 'sign' => {DEFAULT => 0},
1049 'skip-patches' => {DEFAULT => 0},
1050 'source-name' => {DEFAULT => $sourcename || ''},
1051 'source-tree' => {DEFAULT => ''},
1052 'stop-after-unpack' => {DEFAULT => 0},
1053 'stop-before-build' => {DEFAULT => 0},
1054 'version' => {DEFAULT => $vv});
1055
1056 $config -> define (%defhash);
1057
1058 if (-f $file) {
1059 open (PKGVAR, $file) || die "$0: Couldn't open $file: $!\n";
1060 $config -> file (\*PKGVAR);
1061 close (PKGVAR);
1062 }
1063
1064 for (keys %$optref) {
1065 if ($optref->{$_}) {
1066 if (exists ($defhash{$_}->{ARGCOUNT})
1067 && $defhash{$_}->{ARGCOUNT} == ARGCOUNT_NONE) {
1068 push (@pseudoargs, "--$_");
1069 } else {
1070 push (@pseudoargs, "--$_=$optref->{$_}");
1071 }
1072 }
1073 }
1074
1075 $config -> getopt (\@pseudoargs);
1076 %$vref = $config -> varlist (".*");
1077
1078 unless (defined ($$vref{'version'})) {
1079 die "$0: Couldn't detect version of upstream package\n";
1080 }
1081
1082 # set missing variables based on upstream version
1083 unless (length ($$vref{'directory'})) {
1084 $$vref{'directory'} = "$$vref{'source-name'}-$$vref{version}";
1085 }
1086
1087 # sanity checks
1088 for (keys (%$vref)) {
1089 unless (defined ($config -> get ($_))) {
1090 die "$0: $file: variable $_ not found\n";
1091 }
1092 }
1093 if ($$vref{'directory'} !~ /^\w[\w\.\+~:-]*$/) {
1094 die "$0: Suspicious directory name \"$$vref{'directory'}\"\n";
1095 }
1096
1097 $vv = $$vref{'version'};
1098
1099 # defaults doesn't seem to work with lists
1100 unless ($$vref{'empty'} || @{$$vref{'archive'}}) {
1101 $$vref{'archive'} = ["$$vref{'source-name'}-$vv.tar.gz",
1102 "$$vref{'source-name'}-$vv.tar.gz",
1103 "$$vref{'source-name'}-$vv.tgz",
1104 "$$vref{'source-name'}-$vv.tar.bz2"];
1105 }
1106 }
1107
1108 # ----------------------------------------------
1109 # FUNCTION: applypatches
1110 #
1111 # Applies any files found in a directory tree
1112 # as patches to the original sources.
1113 # ----------------------------------------------
1114
1115 sub applypatches {
1116 return if $_ =~ /^\.\.?$/;
1117
1118 # don't descend into arch directory and version control directories
1119 if (-d $File::Find::name && ($_ eq 'arch' || $_ eq 'CVS')) {
1120 $File::Find::prune = 1;
1121 return;
1122 }
1123 chdir ("$builddir/$srcname-$vupstream")
1124 || die "$0: Couldn't enter directory \"$builddir/$srcname-$vupstream\": $!\n";
1125 print "applying patches from $File::Find::name\n";
1126 open PATCH, "patch -p1 --no-backup-if-mismatch < $File::Find::name |";
1127 while (<PATCH>) {
1128 print;
1129 }
1130 close (PATCH) || die "$0: Patch $File::Find::name failed\n";
1131 }
1132
1133 # ---------------------------------------
1134 # FUNCTION: filecopy SOURCESDIR TARGETDIR
1135 # ---------------------------------------
1136
1137 sub filecopy {
1138 my ($sourcesdir, $targetdir) = @_;
1139 my ($perms, $loc);
1140
1141 return if $_ =~ /^\.\.?$/;
1142 if (-d && $_ eq 'CVS') {
1143 $File::Find::prune = 1;
1144 return;
1145 }
1146 if (-f && (/^\.\#/ || /\.~(\d+\.)+\d+~$/)) {
1147 # remove old CVS versions
1148 return;
1149 }
1150
1151 # determine relative target location
1152 $loc = substr ($File::Find::name, length($sourcesdir) + 1);
1153
1154 if (-d) {
1155 mkdir ("$targetdir/$loc", 0755)
1156 || die "$0: Couldn't make directory $targetdir/$loc: $!\n";
1157 } else {
1158 my $perms = (stat ($_)) [2];
1159 copy ("$File::Find::name", "$targetdir/$loc")
1160 || die ("$0: Copy of $File::Find::name to $targetdir failed: $!\n");
1161 chmod (oct (substr sprintf("%o", $perms), -3), "$targetdir/$loc")
1162 || die ("$0: Couldn't change permissions on $targetdir/$loc: $!\n");
1163 }
1164 }
1165
1166 # -----------------------------------------------------------
1167 # FUNCTION: packsources BUILDDIR SRCNAME VUPSTREAM SOURCESDIR
1168 #
1169 # This function creates an tarball of all files within
1170 # the directory SOURCESDIR except CVS files. An toplevel
1171 # SRCNAME-VUPSTREAM is created which contains all files.
1172 # The packing is performed in the directory BUILDDIR.
1173 # -----------------------------------------------------------
1174
1175 sub packsources {
1176 my ($builddir, $srcname, $vupstream, $sourcesdir) = @_;
1177 my $packdir = "$builddir/$srcname-$vupstream";
1178 my $archivefile;
1179
1180 # create directory
1181 mkdir ($packdir, 0755)
1182 || die "$0: Couldn't make directory for packing sources: $packdir: $!\n";
1183 # copy stuff from sources
1184 find (sub{&filecopy($sourcesdir,$packdir)}, $sourcesdir);
1185
1186 # make an archive
1187 chdir ($builddir)
1188 || die "$0: Couldn't enter build directory $builddir: $!\n";
1189 open (PACK, "tar -czf $srcname-$vupstream.tar.gz $srcname-$vupstream |");
1190 while (<PACK>) {print;}
1191 close PACK
1192 || die "$0: Errors while packing sources\n";
1193
1194 "$srcname-$vupstream.tar.gz";
1195 }
1196
1197
1198 # --------------------------------------------------------------------
1199 # FUNCTION: mkbuilddir BASEDIR SRCNAME
1200 #
1201 # Add source name SRCNAME to build base directory BASEDIR and check if
1202 # we have to create the directory. Returns the build directory.
1203 # --------------------------------------------------------------------
1204
1205 sub mkbuilddir {
1206 my ($basedir, $srcname) = @_;
1207 my $builddir;
1208
1209 if (-d $basedir) {
1210 $builddir = $basedir . "/" . $srcname;
1211 unless (-d $builddir) {
1212 mkdir ($builddir, 0755)
1213 || die "$0: Couldn't create package build directory $builddir: $!\n";
1214 }
1215 } else {
1216 die "$0: Build base directory \"$basedir\" doesn't exist\n";
1217 }
1218 $builddir;
1219 }
1220
1221 # FUNCTION: remote_perl SCRIPT REPLACEMENTS HOST USER DIR FILES
1222
1223 sub remote_perl {
1224 my ($script, $repref, $host, $user, $dir, @files) = @_;
1225 my $reg;
1226
1227 for (keys %$repref) {
1228 $reg = qr/\@$_\@/;
1229 $script =~ s/$reg/$$repref{$_} || ''/eg;
1230 }
1231
1232 if ($user) {
1233 sshopen2("root\@$host", *READER, *WRITER, "/bin/cat >$dir/tmp/debaux.$$");
1234 print WRITER $script;
1235 close WRITER;
1236 while (<READER>) {
1237 }
1238 close READER;
1239
1240 # change ownership on needed files
1241 @files = map {"/tmp/$_"} @files;
1242 push (@files, "/tmp/debaux.$$");
1243 ssh_cmd("root\@$host", 'chroot', $dir, 'chown', $user, @files);
1244
1245 sshopen2("root\@$host", *READER1, *WRITER1, "/bin/cat >$dir/tmp/debaux-launch.$$");
1246 print WRITER1 <<EOF;
1247 #!/bin/sh
1248 /usr/bin/perl /tmp/debaux.$$
1249 rm /tmp/debaux.$$
1250 EOF
1251 print WRITER1 "test\n";
1252 close WRITER1;
1253 while (<READER1>) {
1254 }
1255 close READER1;
1256 ssh_cmd("root\@$host", 'chmod', '+x', "$dir/tmp/debaux*.$$");
1257 # ssh_cmd("root\@$host", 'chroot', $dir, 'su', $user, "/tmp/debaux-launch.$$");
1258 sshopen2("root\@$host", *READER, *WRITER, "chroot $dir su $user /tmp/debaux-launch.$$");
1259 ssh_cmd("root\@$host", 'rm', "$dir/tmp/debaux-launch.$$");
1260 close WRITER;
1261 while (<READER>) {
1262 print;
1263 }
1264 close READER;
1265 } else {
1266 sshopen2("root\@$host", *READER, *WRITER, "/usr/bin/perl -");
1267 print WRITER $script;
1268 close WRITER;
1269 while (<READER>) {
1270 print;
1271 }
1272 close READER;
1273 }
1274 }
1275
1276 # DOCUMENTATION
1277 # =============
1278
1279 =head1 NAME
1280
1281 debaux-build - Debian package building script
1282
1283 =head1 SYNOPSIS
1284
1285 debaux-build [OPTIONS] DEBDIR [BUILDDIR SOURCEDIR]
1286
1287 debaux-build --cpan Net::Google
1288
1289 =head1 VERSION
1290
1291 0.1.11
1292
1293 =head1 DESCRIPTION
1294
1295 debaux-build is a helper script for building Debian packages.
1296 Besides options it takes up to three parameters: DEBDIR, BUILDDIR,
1297 SOURCEDIR. DEBDIR is a required parameter.
1298
1299 If DEBDIR doesn't exist, debaux-build tries to download the
1300 package with apt-get source.
1301
1302 debaux-build applies all patches found in the DEBDIR subdirectory
1303 patches.
1304
1305 If no source tarball exist and the DEBDIR subdirectory sources
1306 exist, all files in this directory get packed and used as
1307 source tarball.
1308
1309 =head1 OPTIONS
1310
1311 =over 4
1312
1313 =item C<--apt>
1314
1315 Forces apt-get source mode.
1316
1317 =back
1318
1319 =over 4
1320
1321 =item C<--archive>
1322
1323 Specifies file name of source archive.
1324
1325 =back
1326
1327 =over 4
1328
1329 =item C<--build-options>
1330
1331 Options passed to C<dpkg-buildpackage>.
1332
1333 =back
1334
1335 =over 4
1336
1337 =item C<--chroot=DIRECTORY>
1338
1339 Build package in a chroot environment.
1340
1341 =back
1342
1343 =over 4
1344
1345 =item C<--cpan>
1346
1347 Download Perl module from CPAN and create necessary Debian
1348 packaging files. You need to have the dh-make Debian package
1349 installed in order to utilize this option.
1350
1351 =back
1352
1353 =over 4
1354
1355 =item C<--empty>
1356
1357 Empty package (no source code archive). Intended to use
1358 for task packages.
1359
1360 =back
1361
1362 =over 4
1363
1364 =item C<--env=NAME=VALUE>
1365
1366 Sets environment variable(s) for builds in chroot environments.
1367
1368 Example for using gcc-snapshot in a chroot containing Debian
1369 unstable (sid):
1370
1371 C<--env='PATH=/usr/lib/gcc-snapshot/bin:$PATH' --env='LD_LIBRARY_PATH=/usr/lib/gcc-snapshot/lib:$LD_LIBRARY_PATH'>
1372
1373 =back
1374
1375 =over 4
1376
1377 =item C<--epoch>
1378
1379 Specifies epoch for CPAN builds.
1380
1381 =back
1382
1383 =over 4
1384
1385 =item C<--extra-sources>
1386
1387 Specifies a directory below DEBDIR which is copied to the
1388 build directory.
1389
1390 =back
1391
1392 =over 4
1393
1394 =item C<-i, --install, --install=PACKAGE>
1395
1396 Install build package.
1397
1398 =back
1399
1400 =over 4
1401
1402 =item C<-l, --lintian>
1403
1404 Run lintian on the source file and the generated packages.
1405
1406 =back
1407
1408 =over 4
1409
1410 =item C<--make-archive>
1411
1412 Intended to use for native Debian packages. Specify the commands
1413 to build the archive here.
1414
1415 =back
1416
1417 =over 4
1418
1419 =item C<--release>
1420
1421 The generated packages are targeted for official Debian packages.
1422
1423 =back
1424
1425 =over 4
1426
1427 =item C<--rpm, --alien>
1428
1429 Convert generated packages into RPM packages by
1430 using C<alien>.
1431
1432 =back
1433
1434 =over 4
1435
1436 =item C<-s, --sign>
1437
1438 Sign source package and changelog.
1439
1440 =back
1441
1442 =over 4
1443
1444 =item C<--skip-patches>
1445
1446 Don't apply patches from the patches directory and sources.diff file.
1447
1448 =back
1449
1450 =over 4
1451
1452 =item C<--source-tree>
1453
1454 Instructs C<debaux-build> to use the specified directory instead of
1455 an archive file.
1456
1457 =back
1458
1459 =over 4
1460
1461 =item C<--stop-before-build>
1462
1463 Stop script before calling C<dpkg-buildpackage>.
1464
1465 =back
1466
1467 =head1 CONFIGURATION FILE
1468
1469 C<debaux-build> looks for the configuration file C<.debauxrc> in the
1470 home directory and in the current directory and
1471 recognizes the following directives:
1472
1473 =over 4
1474
1475 =item C<debauxdir> PACKAGE
1476
1477 Used as C<DEBDIR> for package if it is an existing directory.
1478 Considered before the <debiandir> directive.
1479
1480 =item C<debiandir>
1481
1482 If the directory C<DEBDIR> on the commandline doesn't exist,
1483 C<debaux-build> appends C<DEBDIR> to the specified directory
1484 and tries again.
1485
1486 =item C<sourcedir>
1487
1488 Directory with the source archives. Can be overridden by the
1489 commandline parameter C<SOURCEDIR>.
1490
1491 =item C<source-tree> PACKAGE
1492
1493 Directory with the source code for PACKAGE.
1494
1495 =back
1496
1497 =head1 SEE ALSO
1498
1499 dpkg(8), dpkg-source(1), apt-get(8)
1500
1501 =head1 AUTHOR
1502
1503 Stefan Hornburg (Racke) <[email protected]>.
1504
1505 =head1 LICENSE
1506
1507 debaux-build comes with ABSOLUTELY NO WARRANTY. This is free software, and
1508 you are welcome to redistribute and modify it under the terms of the
1509 GNU General Public License.
1510
1511 =head1 COPYRIGHT
1512
1513 Copyright 2000,2001,2002,2003,2004,2005,2006,2007,2008,2010 Stefan Hornburg (Racke) <[email protected]>.
1514
1515 =cut