Re: bug in dpkg --compare-versions
Package: dpkg
Version: 1.4.0.23.2
Edmund GRIMLEY EVANS writes ("bug in dpkg --compare-versions"):
> I'm not sure whether this is a bug in dpkg or boot-floppies ...
>
> The dpkg invocations that caused me problems were:
>
> if dpkg --compare-versions util-linux_2.7.1-3.deb gt util-linux_2.7.1-3.4.deb; then echo yes; fi
>
> if dpkg --compare-versions ae_962-21.deb gt ae_962-21.1.deb; then echo yes; fi
This is all wrong ! dpkg --compare-versions takes _version numbers_,
not package filenames.
> These cause boot-floppies to fail because it chose the older rather
> than the newer versions of those packages. The older versions then
> required older versions of slang and newt. It then ran out of space in
> the floppy image because there isn't space for two versions of slang
> and newt.
Please get boot-floppies to extract the version number from the
filename (or better, inside the file, using dpkg-deb -f).
There does seem to be some kind of bug in dpkg here though; those
`version numbers' you're passing it are rather strange, but the sort
order is indeed wrong. I'll BCC this to submit@bugs so that it gets
fixed.
> dpkg --compare-versions does seem to give the right result if you
> remove the ".deb" suffix; maybe dpkg is intended to assume that the
> suffix isn't there. Anyway, there is a simple work-around: in
> /usr/src/boot-floppies/common.sh replace `basename $x` by
> `basename $x | sed -e 's/\.deb$//'` (or a neater way of doing that).
YM `basename $x | sed -e 's/^[^_]*_//; s/\.deb$//; s/_.*//;'`
which will strip off the package name, and any architecture component,
or better still
`dpkg-deb -f $x version`
Ian.
Reply to: