summaryrefslogtreecommitdiff
path: root/scripts/dpkg-source.pl
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2010-04-28 22:27:08 +0200
committerRaphaël Hertzog <hertzog@debian.org>2010-05-02 21:08:05 +0200
commit8c1fc347f7d50b64f3693ba1d7e064bf9ccbae8c (patch)
treeb2df449436900af90e5c0de07a1b02016974615a /scripts/dpkg-source.pl
parent6a606c37571a2aa25dd7d4d46d4ed45206e4dbeb (diff)
downloaddpkg-8c1fc347f7d50b64f3693ba1d7e064bf9ccbae8c.tar.gz
dpkg-source: implement --before-build and --after-build command
Those commands are really hooks that source formats can use and that will be called by dpkg-buildpackage before and after the actual build. Source formats "2.0" and "3.0 (quilt)" use this hook to ensure patches are applied before the build.
Diffstat (limited to 'scripts/dpkg-source.pl')
-rwxr-xr-xscripts/dpkg-source.pl22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index d8cfda2ef..a5e29af0d 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -83,6 +83,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
setopmode('-b');
} elsif (m/^-x$/) {
setopmode('-x');
+ } elsif (m/^--(before|after)-build$/) {
+ setopmode($_);
} elsif (m/^--print-format$/) {
setopmode('--print-format');
report_options(info_fh => \*STDERR); # Avoid clutter on STDOUT
@@ -93,7 +95,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
my $dir;
if (defined($options{'opmode'}) &&
- $options{'opmode'} =~ /^(-b|--print-format)$/) {
+ $options{'opmode'} =~ /^(-b|--print-format|--before-build|--after-build)$/) {
if (not scalar(@ARGV)) {
usageerr(_g("%s needs a directory"), $options{'opmode'});
}
@@ -188,10 +190,10 @@ while (@options) {
}
unless (defined($options{'opmode'})) {
- usageerr(_g("need -x or -b"));
+ usageerr(_g("need a command (-x, -b, --before-build, --after-build, --print-format)"));
}
-if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
+if ($options{'opmode'} =~ /^(-b|--print-format|--(before|after)-build)$/) {
$options{'ARGV'} = \@ARGV;
@@ -304,7 +306,8 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
close(FORMAT);
} else {
warning(_g("no source format specified in %s, " .
- "see dpkg-source(1)"), "debian/source/format");
+ "see dpkg-source(1)"), "debian/source/format")
+ if $options{'opmode'} eq "-b";
$build_format = "1.0";
}
}
@@ -322,8 +325,17 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
# Verify pre-requesites are met
my ($res, $msg) = $srcpkg->can_build($dir);
error(_g("can't build with source format '%s': %s"), $build_format, $msg) unless $res;
- info(_g("using source format `%s'"), $fields->{'Format'});
+ if ($options{'opmode'} eq "--before-build") {
+ $srcpkg->before_build($dir);
+ exit(0);
+ } elsif ($options{'opmode'} eq "--after-build") {
+ $srcpkg->after_build($dir);
+ exit(0);
+ }
+
+ # Only -b left
+ info(_g("using source format `%s'"), $fields->{'Format'});
run_vendor_hook("before-source-build", $srcpkg);
# Build the files (.tar.gz, .diff.gz, etc)
$srcpkg->build($dir);