summaryrefslogtreecommitdiffstats
path: root/tools/rpmlisting.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-07-14 15:24:01 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-07-14 15:24:01 +0000
commita34cdc40842a0c6613af5633227e8e8166d03367 (patch)
tree6ebd69a1f3ca8d21871aa53381a7475b6f964747 /tools/rpmlisting.py
parentbb090227d3dba94ad04fcb63c2e77c8da3c9f754 (diff)
downloadbcfg2-a34cdc40842a0c6613af5633227e8e8166d03367.tar.gz
bcfg2-a34cdc40842a0c6613af5633227e8e8166d03367.tar.bz2
bcfg2-a34cdc40842a0c6613af5633227e8e8166d03367.zip
handle prereleases and rc releases properly (From Jason Pepas)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1937 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'tools/rpmlisting.py')
-rw-r--r--tools/rpmlisting.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/rpmlisting.py b/tools/rpmlisting.py
index 8d9468f12..0bbfd1d14 100644
--- a/tools/rpmlisting.py
+++ b/tools/rpmlisting.py
@@ -9,7 +9,7 @@ import os
import sys
import commands
import getopt
-
+import re
def run_or_die(command):
(status, stdio) = commands.getstatusoutput(command)
@@ -35,6 +35,7 @@ def verstr_cmp(a, b):
index = 0
a_parts = subdivide(a)
b_parts = subdivide(b)
+ prerelease_pattern = re.compile('rc|pre')
while ret == 0 and index < min(len(a_parts), len(b_parts)):
subindex = 0
a_subparts = a_parts[index]
@@ -45,14 +46,24 @@ def verstr_cmp(a, b):
return ret
subindex = subindex + 1
if len(a_subparts) != len(b_subparts):
- return len(a_subparts) - len(b_subparts)
+ # handle prerelease special case at subpart level (ie, '4.0.2rc5').
+ if len(a_subparts) > len(b_subparts) and prerelease_pattern.match(a_subparts[subindex]):
+ return -1
+ elif len(a_subparts) < len(b_subparts) and prerelease_pattern.match(b_subparts[subindex]):
+ return 1
+ else:
+ return len(a_subparts) - len(b_subparts)
index = index + 1
if len(a_parts) != len(b_parts):
- return len(a_parts) - len(b_parts)
+ # handle prerelease special case at part level (ie, '4.0.2.rc5).
+ if len(a_parts) > len(b_parts) and prerelease_pattern.match(a_parts[index][0]):
+ return -1
+ elif len(a_parts) < len(b_parts) and prerelease_pattern.match(b_parts[index][0]):
+ return 1
+ else:
+ return len(a_parts) - len(b_parts)
return ret
-
-
def subdivide(verstr):
"""subdivide takes a version or release string and attempts to subdivide it into components to facilitate sorting. The string is divided into a two level hierarchy of sub-parts. The upper level is subdivided by periods, and the lower level is subdivided by boundaries between digit, alpha, and other character groupings."""
parts = []