chiark / gitweb /
dgit: factor out build_with_binary_builder()
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 1a4700ccfdb9af6e6ae544ff17cdd259475e9edb..031380c52e8ef51853d4c4871b694c3dcab89f16 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -6105,6 +6105,7 @@ sub build_or_push_prep_early () {
     $isuite = getfield $clogp, 'Distribution';
     $package = getfield $clogp, 'Source';
     $version = getfield $clogp, 'Version';
+    $dscfn = dscfn($version);
 }
 
 sub build_prep_early () {
@@ -6414,7 +6415,6 @@ sub build_source {
        unlink "$buildproductsdir/$sourcechanges" or $!==ENOENT
            or fail "remove $sourcechanges: $!";
     }
-    $dscfn = dscfn($version);
     my @cmd = (@dpkgsource, qw(-b --));
     my $leafdir;
     if (building_source_in_playtree()) {
@@ -6492,25 +6492,31 @@ sub cmd_push_source {
 }
 
 sub cmd_sbuild {
-    build_prep(WANTSRC_SOURCE); # not BUILDER because sbuild uses the .dsc
+    build_prep_early();
+    build_with_binary_builder(\@sbuild, <<END, qw(-d), $isuite, @ARGV, $dscfn);
+perhaps you need to pass -A ?  (sbuild's default is to build only
+arch-specific binaries; dgit 1.4 used to override that.)
+END
+}
+
+sub build_with_binary_builder ($$$) {
+    my ($bbuilder, $pbmc_msg, @args) = @_;
+    build_prep(WANTSRC_SOURCE);
     build_source();
     midbuild_checkchanges();
     in_bpd {
        if (act_local()) {
-           stat_exists $dscfn or fail "$dscfn (in parent directory): $!";
+           stat_exists $dscfn or fail "$dscfn (in build products dir): $!";
            stat_exists $sourcechanges
-               or fail "$sourcechanges (in parent directory): $!";
+               or fail "$sourcechanges (in build products dir): $!";
        }
-       runcmd_ordryrun_local @sbuild, qw(-d), $isuite, @ARGV, $dscfn;
+       runcmd_ordryrun_local @$bbuilder, @args;
     };
     maybe_unapply_patches_again();
     in_bpd {
-       postbuild_mergechanges(<<END);
-perhaps you need to pass -A ?  (sbuild's default is to build only
-arch-specific binaries; dgit 1.4 used to override that.)
-END
+       postbuild_mergechanges($pbmc_msg);
     };
-}    
+}
 
 sub cmd_quilt_fixup {
     badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;