tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg_order() oddity
As part of my work on my Rust library for pkgsrc[0], I came across what I 
thought was a bit of an oddity in pkg_install's pkg_order().
For the uninitiated, this returns the "best" match for a pattern given 
two options.  In all situations where a version number is included, this 
will return the higher version number.
However, in the case of either a tie, or no version number, it will 
return the lexicographically _smaller_ of the two, as per this commit:
  https://github.com/NetBSD/pkgsrc/commit/3ce4880b5cfb35be79f75178decd0d596d1bde39
For example:
  pkg_order("{foo,bar}-[0-9]*", "foo-1.0", "bar-1.1")  =>  bar-1.1
  pkg_order("{foo,bar}-[0-9]*", "foo-1.1", "bar-1.0")  =>  foo-1.1
but:
  pkg_order("{foo,bar}-[0-9]*", "foo-1.0", "bar-1.0")  =>  bar-1.0
This strikes me as odd, especially as in all cases where version numbers 
are compared lexicographically, we always return the larger char value.
Now, in the real world this makes little practical difference, and of 
course nobody should be relying on this behaviour, but I thought I'd 
just check and perhaps add a better comment than the one I currently 
have to explain why it is this way.
Historical perspective appreciated!
Thanks,
[0]: https://github.com/jperkin/pkgsrc-rs/commit/8fd3f48aae8b93a9987cd7265ed75d2099e25642
--
Jonathan Perkin   -   mnx.io   -   pkgsrc.smartos.org
Open Source Complete Cloud   www.tritondatacenter.com
Home |
Main Index |
Thread Index |
Old Index