X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=36afdaf04b7ca0961785fc61150f08ab6999c30c;hp=0a770cd09b91c6e18cf68922d8dfaaa2878b4777;hb=dbee6afd429a8cf4136a040d95ea10fe3a38520e;hpb=67fc3a6fb0abda68f201893e16392f6d15ec16e3 diff --git a/dgit b/dgit index 0a770cd0..36afdaf0 100755 --- a/dgit +++ b/dgit @@ -166,7 +166,7 @@ our $keyid; autoflush STDOUT 1; our $supplementary_message = ''; -our $need_split_build_invocation = 0; +our $need_split_build_invocation = 1; our $split_brain = 0; END { @@ -4756,8 +4756,14 @@ sub cmd_push { dopush(); } +our $sourcechanges; + sub cmd_push_source { prep_push(); + fail "dgit push-source: --include-dirty/--ignore-dirty does not make". + "sense with push-source!" if $includedirty; + clean_tree(); + build_maybe_quilt_fixup(); if ($changesfile) { my $changes = parsecontrol("$buildproductsdir/$changesfile", "source changes file"); @@ -4766,7 +4772,10 @@ sub cmd_push_source { } } else { # Building a source package is very fast, so just do it - build_source_for_push(); + build_source(); + die "er, patches are applied dirtily but shouldn't be.." + if $patches_applied_dirtily; + $changesfile = $sourcechanges; } dopush(); } @@ -5060,7 +5069,6 @@ sub i_want_signed_dsc_changes { #---------- building etc. ---------- our $version; -our $sourcechanges; our $dscfn; #----- `3.0 (quilt)' handling ----- @@ -6106,6 +6114,10 @@ sub cmd_clean () { maybe_unapply_patches_again(); } +# return values from massage_dbp_args are one or both of these flags +sub WANTSRC_SOURCE () { 01; } # caller should build source (separately) +sub WANTSRC_BUILDER () { 02; } # caller should run dpkg-buildpackage + sub build_or_push_prep_early () { our $build_or_push_prep_early_done //= 0; return if $build_or_push_prep_early_done++; @@ -6122,9 +6134,12 @@ sub build_prep_early () { check_not_dirty(); } -sub build_prep () { +sub build_prep ($) { + my ($wantsrc) = @_; build_prep_early(); - clean_tree(); + # clean the tree if we're trying to include dirty changes in the + # source package, or we are running the builder in $maindir + clean_tree() if $includedirty || ($wantsrc & WANTSRC_BUILDER); build_maybe_quilt_fixup(); if ($rmchanges) { my $pat = changespat $version; @@ -6181,10 +6196,6 @@ sub changesopts () { return (changesopts_initial(), changesopts_version()); } -# return values from massage_dbp_args are one or both of these flags -sub WANTSRC_SOURCE () { 01; } # caller should build source (separately) -sub WANTSRC_BUILDER () { 02; } # caller should run dpkg-buildpackage - sub massage_dbp_args ($;$) { my ($cmd,$xargs) = @_; # We need to: @@ -6247,7 +6258,7 @@ sub postbuild_mergechanges ($) { # or if that is undef, be a no-op. # Returns the changes file to report to the user. my $pat = changespat $version; - my @changesfiles = glob $pat; + my @changesfiles = grep { !m/_multi\.changes/ } glob $pat; @changesfiles = sort { ($b =~ m/_source\.changes$/ <=> $a =~ m/_source\.changes$/) or $a cmp $b @@ -6284,7 +6295,10 @@ sub midbuild_checkchanges () { my $pat = changespat $version; return if $rmchanges; my @unwanted = map { s#.*/##; $_; } glob "$bpd_glob/$pat"; - @unwanted = grep { $_ ne changespat $version,'source' } @unwanted; + @unwanted = grep { + $_ ne changespat $version,'source' and + $_ ne changespat $version,'multi' + } @unwanted; fail < !$includedirty + return !$includedirty; } sub build_source { - build_prep_early(); - build_prep(); $sourcechanges = changespat $version,'source'; if (act_local()) { unlink "$buildproductsdir/$sourcechanges" or $!==ENOENT @@ -6419,43 +6453,48 @@ sub build_source { } $dscfn = dscfn($version); my @cmd = (@dpkgsource, qw(-b --)); - if ($split_brain) { + my $leafdir; + if (building_source_in_playtree()) { + $leafdir = 'work'; + my $headref = git_rev_parse('HEAD'); + # If we are in split brain, there is already a playtree with + # the thing we should package into a .dsc (thanks to quilt + # fixup). If not, make a playtree + prep_ud() unless $split_brain; changedir $playground; - runcmd_ordryrun_local @cmd, "work"; - my @udfiles = <${package}_*>; - changedir $maindir; - foreach my $f (@udfiles) { - printdebug "source copy, found $f\n"; - next unless - $f eq $dscfn or - ($f =~ m/\.debian\.tar(?:\.\w+)$/ && - $f eq srcfn($version, $&)); - printdebug "source copy, found $f - renaming\n"; - rename "$playground/$f", "$buildproductsdir/$f" or $!==ENOENT - or fail "put in place new source file ($f): $!"; + unless ($split_brain) { + my $upstreamversion = upstreamversion $version; + unpack_playtree_linkorigs($upstreamversion, sub { }); + unpack_playtree_mkwork($headref); + changedir '..'; } } else { - my $pwd = must_getcwd(); - my $leafdir = basename $pwd; - changedir ".."; - runcmd_ordryrun_local @cmd, $leafdir; - changedir $pwd; + $leafdir = basename $maindir; + changedir '..'; } + runcmd_ordryrun_local @cmd, $leafdir; + + changedir $leafdir; runcmd_ordryrun_local qw(sh -ec), - 'exec >$1; shift; exec "$@"','x', - "$buildproductsdir/$sourcechanges", + 'exec >../$1; shift; exec "$@"','x', $sourcechanges, @dpkggenchanges, qw(-S), changesopts(); + changedir '..'; + move_dsc_to_bpd($dscfn); + rename "$sourcechanges", bpd_abs()."/$sourcechanges" + or fail "put in place source changes file ($sourcechanges): $!"; + changedir $maindir; } sub cmd_build_source { - build_prep_early(); badusage "build-source takes no additional arguments" if @ARGV; + build_prep(WANTSRC_SOURCE); build_source(); maybe_unapply_patches_again(); printdone "source built, results in $dscfn and $sourcechanges"; } sub cmd_sbuild { + build_prep(WANTSRC_SOURCE); # not BUILDER because sbuild uses the .dsc build_source(); midbuild_checkchanges(); in_bpd { @@ -6909,7 +6948,7 @@ sub parseopts () { $tagformat_want = [ $1, 'command line', 1 ]; # 1 menas overrides distro configuration } elsif (m/^--always-split-source-build$/s) { - # undocumented, for testing + # undocumented, was once for testing, now a no-op push @ropts, $_; $need_split_build_invocation = 1; } elsif (m/^--config-lookup-explode=(.+)$/s) {