[kernel] r21848 - in dists/trunk/linux-base: debian lib lib/t

Ben Hutchings benh at moszumanska.debian.org
Mon Sep 15 16:36:44 UTC 2014


Author: benh
Date: Mon Sep 15 16:36:44 2014
New Revision: 21848

Log:
linux-version: Fix sorting of version strings containing -trunk (Closes: #761614)

The regex used to split up versions into components would yield
'-trunk-flavour' as a single component, but we only treated '-rc' and
'-trunk' as special.  This didn't affect '-rc1-flavour' because it
would break at the digit.

Change it to break at hyphens as well as digits.

Add regression tests for this.

Modified:
   dists/trunk/linux-base/debian/changelog
   dists/trunk/linux-base/lib/DebianLinux.pm
   dists/trunk/linux-base/lib/t/DebianLinux.t

Modified: dists/trunk/linux-base/debian/changelog
==============================================================================
--- dists/trunk/linux-base/debian/changelog	Mon Sep 15 16:21:55 2014	(r21847)
+++ dists/trunk/linux-base/debian/changelog	Mon Sep 15 16:36:44 2014	(r21848)
@@ -21,6 +21,8 @@
   * debian/postinst: When checking which configuration files are present,
     treat ENOTDIR like ENOENT (Closes: #698203)
   * Run version_cmp() unit tests at build time
+  * linux-version: Fix sorting of version strings containing -trunk
+    (Closes: #761614)
 
  -- Ben Hutchings <ben at decadent.org.uk>  Tue, 01 May 2012 01:54:46 +0100
 

Modified: dists/trunk/linux-base/lib/DebianLinux.pm
==============================================================================
--- dists/trunk/linux-base/lib/DebianLinux.pm	Mon Sep 15 16:21:55 2014	(r21847)
+++ dists/trunk/linux-base/lib/DebianLinux.pm	Mon Sep 15 16:36:44 2014	(r21848)
@@ -27,10 +27,10 @@
 }
 
 sub version_split {
-    # Split into numbers, hyphens with optional non-numeric suffixes
-    # (for pre-releases), and strings of any other characters
+    # Split into numbers and non-numeric strings, but break the non-
+    # numeric strings at hyphens
     my $version = shift;
-    return $version =~ /(?:\d+|-\D*|[^-\d]+)/g;
+    return $version =~ /(?:\d+|-?[^-\d]*)/g;
 }
 
 sub version_cmp {

Modified: dists/trunk/linux-base/lib/t/DebianLinux.t
==============================================================================
--- dists/trunk/linux-base/lib/t/DebianLinux.t	Mon Sep 15 16:21:55 2014	(r21847)
+++ dists/trunk/linux-base/lib/t/DebianLinux.t	Mon Sep 15 16:36:44 2014	(r21848)
@@ -5,7 +5,7 @@
 use DebianLinux qw(version_cmp);
 
 BEGIN {
-    plan test => 27;
+    plan test => 34;
 }
 
 # Simple numeric comparison
@@ -38,6 +38,14 @@
 # Pre-release < non-numeric non-pre-release
 ok(version_cmp('2.6.32-local', '2.6.32-trunk'), 1);
 ok(version_cmp('2.6.32-trunk', '2.6.32-local'), -1);
+# Pre-release cases including flavour (#761614)
+ok(version_cmp('2.6.33-trunk-flavour', '2.6.33-trunk-flavour'), 0);
+ok(version_cmp('2.6.33-rc1', '2.6.33-trunk-flavour'), -1);
+ok(version_cmp('2.6.33-rc1-flavour', '2.6.33-trunk-flavour'), -1);
+ok(version_cmp('2.6.32-1-flavour', '2.6.32-trunk-flavour'), 1);
+ok(version_cmp('2.6.32-trunk-flavour', '2.6.32-1-flavour'), -1);
+ok(version_cmp('2.6.32-local', '2.6.32-trunk-flavour'), 1);
+ok(version_cmp('2.6.32-trunk-flavour', '2.6.32-local'), -1);
 # Numeric < non-numeric non-pre-release
 ok(version_cmp('2.6.32-1', '2.6.32-local'), -1);
 ok(version_cmp('2.6.32-local', '2.6.32-1'), 1);



More information about the Kernel-svn-changes mailing list