Comment 0 for bug 1276155

Revision history for this message
Dimitri John Ledkov (xnox) wrote : dpkg-dev: please reject native/non-native version when building native/non-native source packages

Imported from Debian bug http://bugs.debian.org/700177:

Package: dpkg-dev
Version: 1.16.9
Severity: wishlist
Tags: patch

Please ensure that the package version matches its nativity state
in 3.0 (quilt/native) packages. Having dpkg-source allow to create
native packages with non-native versions and non-native packages with
native versions can be quite confusing, so better reject them directly.
(Attached patch does this for 3.0 (quilt) and 3.0 (native) packages,
where this change should be safe to be done and does not touch any legacy
source package formats).

From: "Bernhard R. Link" <email address hidden>
Date: Sat, 9 Feb 2013 14:59:00 +0100
Subject: [PATCH] Dpkg::Version,
 Dpkg::Source::Package::V3::{quilt,native}: catch
 invalid version strings

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.
---
 scripts/Dpkg/Source/Package/V3/native.pm | 4 +++-
 scripts/Dpkg/Source/Package/V3/quilt.pm | 2 ++
 scripts/Dpkg/Version.pm | 11 +++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Source/Package/V3/native.pm b/scripts/Dpkg/Source/Package/V3/native.pm
index ba6539a..32e3c1b 100644
--- a/scripts/Dpkg/Source/Package/V3/native.pm
+++ b/scripts/Dpkg/Source/Package/V3/native.pm
@@ -64,7 +64,9 @@ sub do_extract {
 }

 sub can_build {
- return 1;
+ my ($self, $dir) = @_;
+ my $v = Dpkg::Version->new($self->{'fields'}->{'Version'});
+ return (!!$v->is_native(), _g("native package version may not have a revision"));
 }

 sub do_build {
diff --git a/scripts/Dpkg/Source/Package/V3/quilt.pm b/scripts/Dpkg/Source/Package/V3/quilt.pm
index f5875c1..8a6cc54 100644
--- a/scripts/Dpkg/Source/Package/V3/quilt.pm
+++ b/scripts/Dpkg/Source/Package/V3/quilt.pm
@@ -72,6 +72,8 @@ sub can_build {
     my ($self, $dir) = @_;
     my ($code, $msg) = $self->SUPER::can_build($dir);
     return ($code, $msg) if $code eq 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 26ee154..042bd8e 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
--
1.7.10.4

-- System Information:
Debian Release: 7.0
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dpkg-dev depends on:
ii base-files 7.1
ii binutils 2.22-7.1
ii bzip2 1.0.6-4
ii libdpkg-perl 1.16.9
ii make 3.81-8.2
ii patch 2.6.1-3
ii xz-utils 5.1.1alpha+20120614-2

Versions of packages dpkg-dev recommends:
ii build-essential 11.6
ii fakeroot 1.18.4-2
ii gcc [c-compiler] 4:4.7.2-1
ii gcc-4.6 [c-compiler] 4.6.3-15
ii gcc-4.7 [c-compiler] 4.7.2-5
ii gnupg 1.4.12-7
ii gpgv 1.4.12-7
ii libalgorithm-merge-perl 0.08-2

Versions of packages dpkg-dev suggests:
ii debian-keyring 2012.11.15

-- no debconf information