SHARE
TWEET

Untitled

a guest Jul 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import sys
  3. import rpm
  4. def stringToEVR(verstring):
  5.     if verstring in (None, ''):
  6.         return ('', '', '')
  7.     i = verstring.find(':')
  8.     if i == -1:
  9.         epoch = ''
  10.     else:
  11.         epoch = verstring[:i]
  12.     i += 1
  13.     j = verstring.find('-', i)
  14.     if j == -1:
  15.         version = verstring[i:]
  16.         release = ''
  17.     else:
  18.         version = verstring[i:j]
  19.         release = verstring[j+1:]
  20.     return (epoch, version, release)
  21.  
  22. (e1, v1, r1) = stringToEVR(sys.argv[1])
  23. (e2, v2, r2) = stringToEVR(sys.argv[2])
  24. rc = rpm.labelCompare((e1 or None, v1 or None, r1 or None),
  25.                       (e2 or None, v2 or None, r2 or None))
  26. if rc > 0:
  27.     # first ver is bigger
  28.     print "%s is bigger" % sys.argv[1]
  29. elif rc < 0:
  30.     # second ver is bigger
  31.     print "%s is bigger" % sys.argv[2]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top