dpkg version sorting

Use this as you would use | sort | to sort package names according to dpkg versioning logic:

#!/usr/bin/perl
sub dpkgcomp
{
return 1 if(system("dpkg --compare-versions $a lt $b"));
return -1 if(system("dpkg --compare-versions $a gt $b"));
return 0;
}
@l = <>;
chomp(@l);
@s = sort dpkgcomp @l;
print join(”\n”, @s), “\n”;


No Responses to “dpkg version sorting”

Both comments and pings are currently closed.

Comments are closed.