Admin Stuff

This is much harder than it should be. There is dpkg --compare-versions to compare two Version numbers but that doesn not help to sort a list of debian archives. There is a little perl module which implements debian version sorting as part of the devscripts package.

I have written a tiny script to utilize this module to sort debian filenames (the script assumes the files all belong to the same package as only the version numbers are sorted. The package name and architecture are ignored). This script is just a quick hack and only works with packages with architecture in their name:

#!/usr/bin/perl -l -I/usr/share/devscripts

use Devscripts::Versort;

$,="\n"; $"="_";
print map { "@{$_}[1,0,2]" } Devscripts::Versort::deb_versort(map { [@{[split("_",$_)]}[1,0,2]] } @ARGV)

Usage is simple:

$ debsort *.deb
otdsprod_0.1~100.g53c7877_i386.deb
otdsprod_0.1~68.gae5bb9f_i386.deb
otdsprod_0.1~67.gf8a80d1_i386.deb
otdsprod_0.1~30.g2b40f0b_i386.deb
otdsprod_0.1~28.g824d4b2_i386.deb