Hello.

I think I know how to get rid of obsolete packages from DebTorrent's
cache if it is placed in the same filesystem the APT's cache is and if
apt-get clean hasn't been executed lately (if it had, some fresh
packages may be removed with the following method).


Step I
Uncomment entries (you want to keep packages from)
in /etc/apt/sources.list and execute:
#apt-get update

Step II
Now we need packages in DebTorrent's cache to be hardlinked to files in
APT's cache. there are couple of methods for doing that. Some were/are
discussed at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=464386#25

method I (remember: both caches on the same filesystem only!)
#if ! [ -f /usr/share/fslint/fslint/findup ];then \
apt-get install fslint;fi && /usr/share/fslint/fslint/findup -m \
/var/cache/debtorrent /var/cache/apt/archives
This method is rather slow and requires to get a fslint package. Maybe
someone knows how to use fdupes (IMO faster) to achieve the same goal.

method II (if debtorrent is the only method of obtaining packages)
#apt-get clean
#ln /var/cache/debtorrent/*/pool/*/*/*/*.deb /var/cache/apt/archives
Does not work with packages which names contain colon (see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=464386#50 for details).
It generates needless hardlinks in APT's cache instead.
Likely to work in future.
I've writen a workaround, but then I realised it's useless, because
package files in DebTorrent's cache do not contain colons or anything
indicating there is a colon in the name of relevant file in APT's cache.

method III
The probable future solution to wishlist item #464386.

Step III
APT knows which packages are in repositories, so let it remove these,
which are not.
#apt-get autoclean
Now only packages that are available to be downloaded are left in APT's
cache. They are hardlinked to files in DebTorrent's cache so their
hardlink count is 2 (or more). Package Files in Debtorrent's cache which
do not have other hardlinks, are not available to fetch. If the previos
step went good we can safely (well, I'm not sure about it, as I don't
know how DebTorrent reacts to such changes, but I didn't noticed
anything strange after I did that) remove them as obsolete.
#rm `find /var/cache/debtorrent/*/pool/*/*/*/*.deb -links -2`
This method will only work for files which only hardlinks were in
DebTorrent's and APT's cache before this step.


I hope this will inspire someone to find a more universal solution.


-- 
Sorry for my English.
Regards from Poland
Mateusz "Old" Poszwa



Reply via email to