Created
September 25, 2012 17:52
-
-
Save gregretkowski/3783409 to your computer and use it in GitHub Desktop.
python script to compare apt version numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Usage: | |
# python aptcompare.py foo-2.0.873-3ubuntu1 foo-2.0.873-3ubuntu1+foo | |
# Outputs: | |
# version foo-2.0.873-3ubuntu1 < version foo-2.0.873-3ubuntu1+foo | |
# See: | |
# http://stackoverflow.com/questions/4957514/how-to-compare-debian-package-versions | |
import apt | |
import sys | |
a=sys.argv[1] | |
b=sys.argv[2] | |
vc=apt.VersionCompare(a,b) | |
if vc > 0: | |
print('version %s > version %s' % (a, b) ) | |
elif vc == 0: | |
print('version %s == version %s' % (a, b) ) | |
elif vc < 0: | |
print('version %s < version %s' % (a, b) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment