1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my $operation = shift;
die "pbuilder: you should use me only to build, dgit"
unless ($operation eq "build" || $operation eq "b");
my $debbuildopts = undef;
my $distribution = undef;
my $buildresult = undef;
GetOptions('debbuildopts=s' => \$debbuildopts,
'buildresult=s' => \$buildresult,
'distribution=s' => \$distribution)
or die;
die unless defined $buildresult; # dgit must always pass --buildresult
# ignore user args; last argument has to be the .dsc filename
my $dsc = $ARGV[-1];
die "pbuilder: last argument has wrong file extension"
unless ($dsc =~ m/^(.*)_.*\.dsc$/);
system <<END and die "$! $?";
set -ex
rm -rf pretend-pbuilder-work
mkdir pretend-pbuilder-work
mkdir pretend-pbuilder-work/pkg
dcmd cp "$dsc" pretend-pbuilder-work/pkg/.
cd pretend-pbuilder-work
dpkg-source -x pkg/*.dsc src
cd src
dpkg-buildpackage --changes-option=-DDistribution=$distribution $debbuildopts
cd ../..
dcmd mv pretend-pbuilder-work/*.changes $buildresult
rm -r pretend-pbuilder-work
END
|