summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-10-08 13:19:54 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-10-08 16:02:44 +0100
commit68db28cfe420b28f3259f1048fa05cbfb903baa7 (patch)
treec74125fcb9dcf1cb118e8632750c39d84c86e57f
parente4942960b8725f17f78c4d4113aea34958bb42ee (diff)
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 <ijackson@chiark.greenend.org.uk>
-rw-r--r--debian/changelog1
-rwxr-xr-xdgit32
2 files changed, 22 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog
index e0d986c..9082aad 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 39231bb..c79deb4 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);