This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=0ff96cf6041979ed92cc2be6a204547d7d9f087f

commit 0ff96cf6041979ed92cc2be6a204547d7d9f087f
Author: Guillem Jover <[email protected]>
AuthorDate: Sun Jun 1 00:44:59 2025 +0200

    Dpkg::Source::Package: Add format vs version coherence warnings on extract
    
    Make this more visible on extract, by checking that there's coherence
    between the source format and its version, but allow the extraction
    regardless with a warning.
---
 scripts/Dpkg/Source/Package/V1.pm        | 21 ++++++++++++++++++---
 scripts/Dpkg/Source/Package/V2.pm        |  5 +++++
 scripts/Dpkg/Source/Package/V3/Native.pm |  5 +++++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/scripts/Dpkg/Source/Package/V1.pm 
b/scripts/Dpkg/Source/Package/V1.pm
index 566fd24c4..34a4bdec2 100644
--- a/scripts/Dpkg/Source/Package/V1.pm
+++ b/scripts/Dpkg/Source/Package/V1.pm
@@ -42,6 +42,7 @@ use File::Spec;
 use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
+use Dpkg::Version;
 use Dpkg::Compression;
 use Dpkg::Source::Archive;
 use Dpkg::Source::Patch;
@@ -199,9 +200,23 @@ sub do_extract {
 
     error(g_('no tarfile in Files field')) unless $tarfile;
     my $native = $difffile ? 0 : 1;
-    if ($native and ($tarfile =~ /\.orig\.tar\.gz$/)) {
-        warning(g_('native package with .orig.tar'));
-        $native = 0; # V3::Native doesn't handle orig.tar
+    my $v = Dpkg::Version->new($fields->{'Version'});
+    if ($native) {
+        if ($tarfile =~ m/\.orig\.tar\.gz$/) {
+            # We only need to warn on this branch, because of the $native reset
+            # below, otherwise the V3::Native module will handle the warning.
+            if (!$v->is_native()) {
+                warning(g_('native package version may not have a revision'));
+            }
+
+            warning(g_('native package with .orig.tar'));
+            # V3::Native doesn't handle "orig.tar".
+            $native = 0;
+        }
+    } else {
+        if ($v->is_native()) {
+            warning(g_('non-native package version does not contain a 
revision'))
+        }
     }
 
     if ($native) {
diff --git a/scripts/Dpkg/Source/Package/V2.pm 
b/scripts/Dpkg/Source/Package/V2.pm
index bb9217aef..160847ed3 100644
--- a/scripts/Dpkg/Source/Package/V2.pm
+++ b/scripts/Dpkg/Source/Package/V2.pm
@@ -219,6 +219,11 @@ sub do_extract {
             if $addonfile{$name} ne substr $addonsign{$name}, 0, -4;
     }
 
+    my $v = Dpkg::Version->new($fields->{'Version'});
+    if ($v->is_native()) {
+        warning(g_('non-native package version does not contain a revision'))
+    }
+
     if ($self->{options}{no_overwrite_dir} and -e $newdirectory) {
         error(g_('unpack target exists: %s'), $newdirectory);
     } else {
diff --git a/scripts/Dpkg/Source/Package/V3/Native.pm 
b/scripts/Dpkg/Source/Package/V3/Native.pm
index 80debf5fe..46f31efc5 100644
--- a/scripts/Dpkg/Source/Package/V3/Native.pm
+++ b/scripts/Dpkg/Source/Package/V3/Native.pm
@@ -70,6 +70,11 @@ sub do_extract {
 
     error(g_('no tarfile in Files field')) unless $tarfile;
 
+    my $v = Dpkg::Version->new($fields->{'Version'});
+    if (!$v->is_native()) {
+        warning(g_('native package version may not have a revision'));
+    }
+
     if ($self->{options}{no_overwrite_dir} and -e $newdirectory) {
         error(g_('unpack target exists: %s'), $newdirectory);
     } else {

-- 
Dpkg.Org's dpkg

Reply via email to