From: Ian Jackson Date: Sat, 8 Oct 2016 12:19:54 +0000 (+0100) Subject: Fix up .orig detection to be less trustful of (ambiguous) filenames. X-Git-Tag: archive/debian/2.0~98 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=68db28cfe420b28f3259f1048fa05cbfb903baa7;p=dgit.git Fix up .orig detection to be less trustful of (ambiguous) filenames. We cannot simply match the filenaem because `foo_1.0.orig.tar.gz' might be the `.orig.tar.gz' of foo version 1.0, or the `.tar.gz' of foo version 1.0.orig. We need either to consider the whole .dsc (this works since the formats with no `.orig' or `.debian' or whatever are precisely ones where there is only one file anyway), or know the version number. Replace is_orig_file with two functions, one for each situation. While we're here, do not barf if we find uncompressed tarballs. (We don't expect to find any but it would be nice if they worked...) Signed-off-by: Ian Jackson --- diff --git a/debian/changelog b/debian/changelog index e0d986c8..9082aad7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -55,6 +55,7 @@ dgit (1.5~~) unstable; urgency=medium --quilt modes. * Fix two calls to chdir without proper error checking. * Fix a couple of bugs in error reporting. + * Fix up .orig detection to be less trustful of (ambiguous) filenames. Test suite: * When sbuild fails, do not crash due to sed not finding the log diff --git a/dgit b/dgit index 39231bbe..c79deb48 100755 --- a/dgit +++ b/dgit @@ -1429,12 +1429,20 @@ sub dsc_files () { map { $_->{Filename} } dsc_files_info(); } -sub is_orig_file ($;$) { - local ($_) = $_[0]; - my $base = $_[1]; - m/\.orig(?:-\w+)?\.tar\.\w+$/ or return 0; - defined $base or return 1; - return $` eq $base; +sub is_orig_file_in_dsc ($$) { + my ($f, $dsc_files_info) = @_; + return 0 if @$dsc_files_info <= 1; + # One file means no origs, and the filename doesn't have a "what + # part of dsc" component. (Consider versions ending `.orig'.) + return 0 unless $f =~ m/\.orig(?:-\w+)?\.tar(?:\.\w+)?$/; + return 1; +} + +sub is_orig_file_of_vsn ($$) { + my ($f, $upstreamvsn) = @_; + my $base = srcfn $upstreamvsn, ''; + return 0 unless $f =~ m/^\Q$base\E\.orig(?:-\w+)?\.tar(?:\.\w+)?$/; + return 1; } sub make_commit ($) { @@ -1523,7 +1531,8 @@ sub generate_commits_from_dsc () { prep_ud(); changedir $ud; - foreach my $fi (dsc_files_info()) { + my @dfi = dsc_files_info(); + foreach my $fi (@dfi) { my $f = $fi->{Filename}; die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#; @@ -1534,7 +1543,7 @@ sub generate_commits_from_dsc () { complete_file_from_dsc('.', $fi) or next; - if (is_orig_file($f)) { + if (is_orig_file_in_dsc($f, \@dfi)) { link $f, "../../../../$f" or $!==&EEXIST or die "$f $!"; @@ -1643,9 +1652,10 @@ sub complete_file_from_dsc ($$) { } sub ensure_we_have_orig () { - foreach my $fi (dsc_files_info()) { + my @dfi = dsc_files_info(); + foreach my $fi (@dfi) { my $f = $fi->{Filename}; - next unless is_orig_file($f); + next unless is_orig_file_in_dsc($f, \@dfi); complete_file_from_dsc('..', $fi) or next; } @@ -3754,7 +3764,7 @@ sub quilt_fixup_linkorigs ($$) { local ($debuglevel) = $debuglevel-1; printdebug "QF linkorigs $b, $f ?\n"; } - next unless is_orig_file $b, srcfn $upstreamversion,''; + next unless is_orig_file_of_vsn $b, $upstreamversion; printdebug "QF linkorigs $b, $f Y\n"; link_ltarget $f, $b or die "$b $!"; $fn->($b);