[devscripts] 01/01: uscan: Use Dpkg::Version to perform version comparisons

James McCoy jamessan at debian.org
Tue Jul 4 17:36:26 UTC 2017


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

jamessan pushed a commit to branch master
in repository devscripts.

commit 65399e1e93dc0dcdfb2e4eca2a2b006d2760e649
Author: James McCoy <jamessan at debian.org>
Date:   Tue Jul 4 13:34:15 2017 -0400

    uscan: Use Dpkg::Version to perform version comparisons
    
    Since the versions we're comparing are known to be irregular (i.e.,
    upstream rather than Debian) versions, disabling the strict checks on
    version format.  This silences the "bad syntax" error that dpkg was
    emitting.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog |  6 ++++++
 scripts/uscan.pl | 13 ++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 635636e..7f1f141 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,12 @@ devscripts (2.17.7) UNRELEASED; urgency=medium
       solution for making builds independent of build path yet, so the current
       practice is to run both builds at the same location.
 
+  [ James McCoy ]
+  * uscan:
+    + Use Dpkg::Version instead of shelling out to dpkg to compare upstream &
+      mangled versions.  This improves the performance slightly and also
+      avoids dpkg's errors about malformed versions.  (Closes: #866998)
+
  -- Paul Wise <pabs at debian.org>  Sat, 17 Jun 2017 13:11:35 +0800
 
 devscripts (2.17.6) unstable; urgency=medium
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index dd1f423..8091859 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1705,6 +1705,7 @@ use Cwd qw/cwd abs_path/;
 use Dpkg::Changelog::Parse qw(changelog_parse);
 use Dpkg::Control::Hash;
 use Dpkg::IPC;
+use Dpkg::Version;
 use File::Basename;
 use File::Copy qw/copy/;
 use File::Spec::Functions qw/catfile/;
@@ -3327,13 +3328,15 @@ EOF
     $dehs_tags{'upstream-version'} = $newversion;
     $dehs_tags{'upstream-url'} = $upstream_url;
 
+    my $mangled_ver = Dpkg::Version->new("1:${mangled_lastversion}-0", check => 0);
+    my $upstream_ver = Dpkg::Version->new("1:${newversion}-0", check => 0);
     my $compver;
-    if (system("dpkg", "--compare-versions", "1:${mangled_lastversion}-0", "eq", "1:${newversion}-0") >> 8 == 0) {
-	$compver = 'same';  # ${mangled_lastversion} == ${newversion}
-    } elsif (system("dpkg", "--compare-versions", "1:${mangled_lastversion}-0", "gt", "1:${newversion}-0") >> 8 == 0) {
-	$compver = 'older'; # ${mangled_lastversion} >> ${newversion}
+    if ($mangled_ver == $upstream_ver) {
+	$compver = 'same';
+    } elsif ($mangled_ver > $upstream_ver) {
+	$compver = 'older';
     } else {
-	$compver = 'newer'; # ${mangled_lastversion} << ${newversion}
+	$compver = 'newer';
     }
 
     # Version dependent $download adjustment

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list