jerryrw
April 10th, 2007, 01:30 AM
Does anyone know either where in the dpkg or apt sources the version comparison routines are or a good algorithm do it?
I've got this far in my research:
The General Form for a version number is E:M.m.r-XubuntuY
where E = epoch
M = Major Version
m = Minor revision
r = Revision
X = Debian Version
Y = Ubuntu Version
But this is no where near universal by any means and I would like to do this WITHOUT invoking re. From what I can tell many programmers far better than I have struggled with this problem so I'm sure there is an easy way out.
My first thought was to split on periods and dashes but I found some real oddball version numbers in the database:
1.2-1.39+1.40-WIP-2006.11.14+dfsg-2ubuntu1
2.0.6ubuntu1-5ubuntu1
3.10+debian~pre0-4build1
3:3.3.8really3.3.7-0ubuntu4
2:1.firefox2.0.0.3+1-0ubuntu1
The Debian package guide says to basically do a string comparison left to right but it also mentions splitting.
I am trying to write a Python script to do basically an 'apt-get -d update' that will run under windows to fetch packages for Linux systems that have no internet connection so I can't use any libs or system calls to accomplish this.
Python is preferred for portability but I am capable of at least reading most languages.
Thanks
I've got this far in my research:
The General Form for a version number is E:M.m.r-XubuntuY
where E = epoch
M = Major Version
m = Minor revision
r = Revision
X = Debian Version
Y = Ubuntu Version
But this is no where near universal by any means and I would like to do this WITHOUT invoking re. From what I can tell many programmers far better than I have struggled with this problem so I'm sure there is an easy way out.
My first thought was to split on periods and dashes but I found some real oddball version numbers in the database:
1.2-1.39+1.40-WIP-2006.11.14+dfsg-2ubuntu1
2.0.6ubuntu1-5ubuntu1
3.10+debian~pre0-4build1
3:3.3.8really3.3.7-0ubuntu4
2:1.firefox2.0.0.3+1-0ubuntu1
The Debian package guide says to basically do a string comparison left to right but it also mentions splitting.
I am trying to write a Python script to do basically an 'apt-get -d update' that will run under windows to fetch packages for Linux systems that have no internet connection so I can't use any libs or system calls to accomplish this.
Python is preferred for portability but I am capable of at least reading most languages.
Thanks