Re: dpkg --compare-versions vs. ls

2010-01-20 Thread jidanni
JN Hope that helps,
OK, I found
apt-get -o Dir::Cache=/cf -o Dir::Cache::archives=debs/ autoclean
will do what I want, leave only the current versions on my sneakernet
shared memory card... Thanks.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: dpkg --compare-versions vs. ls

2010-01-19 Thread Jonathan Nieder
jida...@jidanni.org wrote:

 Is there any case where
 $ cd /var/cache/apt/archives
 $ set -- $(ls -r some_package_*)
 $ dpkg --compare-versions $1 gt $2
 isn't true?

Yes.

 * dpkg --compare-versions uses ASCII to compare letters (so B  a).
   In non-C locales, ls does not.

 * dpkg --compare-versions treats ~ specially (so
   git-core_1%3a1.6.6~rc-1_i386.deb  git-core_1%3a1.6.6-1_i386.deb).
   Even in the C locale, ls does not.

 * dpkg --compare-versions compares the numeric part of a version
   numerically (so 1.2  1.11).
   ls does not.

On the other hand, 'ls -v' behaves like dpkg --compare-versions in
the respects described above.  But:

 * dpkg --compare-versions treats : specially (so 3  1:1).
   ls -v does not.

'ls -v' and 'dpkg --compare-versions' differ in plenty of other ways,
too.

To handle epochs correctly, you really need to be unescaping the
version number part of the filename.  If your application permits the
slowdown, I think it would be simpler to use

show_version() {
dpkg-deb --showformat='${Version}' --show $1
}
dpkg --compare-versions $(show_version $1) gt $(show_version $2)

See http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version,
http://www.gnu.org/software/coreutils/manual/coreutils.html#Details-about-version-sort.

Hope that helps,
Jonathan


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org