The following commit has been merged in the master branch:
commit acc1f37933b2444631eb510f5450985c8f7270c7
Author: Bernhard R. Link <[email protected]>
Date:   Sun Feb 10 16:07:34 2013 +0100

    Dpkg: Catch mismatches between version strings and format versions
    
    Ensure that a 3.0 (quilt) package has a non-native version and that
    a 3.0 (native) package has a native version. To get the information,
    extend Dpkg::Version with a is_native method to check whether a
    version has a revision or not.
    
    [[email protected]:
     - Add is_native to history of changes.
     - Do not return an error string when returning a true result. ]
    
    Closes: #700177
    
    Signed-off-by: Guillem Jover <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index caa2a8c..1f6b0ba 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -114,6 +114,10 @@ dpkg (1.17.0) UNRELEASED; urgency=low
     Thanks to Colin Watson <[email protected]>. Closes: #697297
   * Move epoch-less or revision-less output logic to Dpkg::Version.
     Based on a patch by Bernhard R. Link <[email protected]>.
+  * Catch mismatches between version strings and format versions in
+    dpkg-source. Ensure that a 3.0 (quilt) package has a non-native version
+    and that a 3.0 (native) package has a native version. Closes: #700177
+    Thanks to Bernhard R. Link <[email protected]>.
 
   [ Updated programs translations ]
   * Fix typo in Spanish translation of update-alternatives.
diff --git a/scripts/Dpkg/Source/Package/V3/Native.pm 
b/scripts/Dpkg/Source/Package/V3/Native.pm
index 8ef3181..48f7eaa 100644
--- a/scripts/Dpkg/Source/Package/V3/Native.pm
+++ b/scripts/Dpkg/Source/Package/V3/Native.pm
@@ -27,6 +27,7 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Compression;
 use Dpkg::Exit;
+use Dpkg::Version;
 use Dpkg::Source::Archive;
 use Dpkg::Source::Functions qw(erasedir);
 
@@ -64,6 +65,12 @@ sub do_extract {
 }
 
 sub can_build {
+    my ($self, $dir) = @_;
+
+    my $v = Dpkg::Version->new($self->{fields}->{'Version'});
+    return (0, _g('native package version may not have a revision'))
+        unless $v->is_native();
+
     return 1;
 }
 
diff --git a/scripts/Dpkg/Source/Package/V3/Quilt.pm 
b/scripts/Dpkg/Source/Package/V3/Quilt.pm
index a0ec438..8a9b190 100644
--- a/scripts/Dpkg/Source/Package/V3/Quilt.pm
+++ b/scripts/Dpkg/Source/Package/V3/Quilt.pm
@@ -26,6 +26,7 @@ use parent qw(Dpkg::Source::Package::V2);
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
+use Dpkg::Version;
 use Dpkg::Source::Patch;
 use Dpkg::Source::Functions qw(erasedir fs_time);
 use Dpkg::Source::Quilt;
@@ -72,6 +73,10 @@ sub can_build {
     my ($self, $dir) = @_;
     my ($code, $msg) = $self->SUPER::can_build($dir);
     return ($code, $msg) if $code == 0;
+
+    my $v = Dpkg::Version->new($self->{fields}->{'Version'});
+    return (0, _g('version does not contain a revision')) if $v->is_native();
+
     my $quilt = $self->build_quilt_object($dir);
     $msg = $quilt->find_problems();
     return (0, $msg) if $msg;
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
index 82a3936..3f28faf 100644
--- a/scripts/Dpkg/Version.pm
+++ b/scripts/Dpkg/Version.pm
@@ -145,6 +145,17 @@ sub revision {
     return $self->{revision};
 }
 
+=item $v->is_native()
+
+Returns true if the version is native, false if it has a revision.
+
+=cut
+
+sub is_native {
+    my $self = shift;
+    return $self->{no_revision};
+}
+
 =item $v1 <=> $v2, $v1 < $v2, $v1 <= $v2, $v1 > $v2, $v1 >= $v2
 
 Numerical comparison of various versions numbers. One of the two operands
@@ -420,6 +431,8 @@ sub version_check($) {
 
 New argument: Accept an options argument in $v->as_string().
 
+New method: $v->is_native().
+
 =head1 AUTHOR
 
 Don Armstrong <[email protected]>, Colin Watson

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to