Chris Oliver Chris Oliver

Cross-Platform Version Comparison

Jul 5, 2009

For both Keryx and GSoC 2009′s WinLibre, we were in need of a Python port of dpkg’s version comparison algorithm. Instead of hacking together some new code, I decided to port dpkg’s algorithm straight from C to Python. The end result? A clean and simple algorithm that is capable of comparing quickly and accurately along with returning results in standard Python sorting function format (-1 for less than, 0 for equal, 1 for greater than). This function can be used on a list to sort versions with the [].sort() function. Very handy and being written in pure Python makes it an excellent choice for cross-platform apt tools like Keryx as well as apps like WinLibre who use the same versioning system as Debian.

Check out the code here: http://bitbucket.org/excid3/winlibre/src/tip/wpkg/vercmp.py


Continue reading

Using Zoom 3095 Modem with Debian Random Mac Address on Start Up with Ubuntu