Re: Are archive files essential? - Thanks
On Fri, Jun 03, 2005 at 10:18:42PM +0200, Maurits van Rees wrote:
> On Fri, Jun 03, 2005 at 03:44:46PM -0400, Thomas H. George wrote:
> > I note that there are multiple entries for most of the packages in the
> > archive with dates going back two or three years. Perhaps it would have
> > been better to weed out the older entries. If so, is there a simple way
> > to do this?
>
> From the apt-get manual page:
>
> ------------
> clean
>
> clean clears out the local repository of retrieved package files. It
> removes everything but the lock file from /var/cache/apt/archives/ and
> /var/cache/apt/archives/partial/. When APT is used as a dselect(8)
> method, clean is run automatically. Those who do not use dselect will
> likely want to run apt-get clean from time to time to free up disk
> space.
>
> autoclean
>
> Like clean, autoclean clears out the local repository of retrieved
> package files. The differ- ence is that it only removes package files
> that can no longer be downloaded, and are largely useless. This
> allows a cache to be maintained over a long period without it growing
> out of control. The configuration option APT::Clean-Installed will
> prevent installed packages from being erased if it is set to off.
> ------------
>
> So call 'apt-get autoclean' to remove most of your packages or
> 'apt-get clean' to remove them all. It doesn't hurt. You just need to
> fetch those files again when you have to reinstall for some reason.
>
> Note though that having an older version of a package lying around in
> the apt cache can be useful when you discover a bug in the new version
> and want to revert to the old.
>
> To have more control, cobble together some shell commands. For example
> see this posting by me:
>
> http://lists.debian.org/debian-user/2004/10/msg01671.html
>
> At the end that post boils down to the following shell line that
> prints all packages that have a more than two versions in that
> directory.
>
> ls /var/cache/apt/archives | sort -g | uniq -c -t "_" -d -W 1 | grep -v -E "^[[:blank:]]*2 " | sed "s/ *[[:digit:]*] \(.*\)$/\1/g"
>
>
> I have another script in /usr/local/bin/cleanpackages that moves old
> packages to another directory. That should then be a directory on a
> partition where you have more space. Instead of moving them you can
> delete them if you want.
>
> ------------
> #! /bin/sh
>
> # Move old files to another dir. Mostly meant for the apt cache.
>
> if test $# -eq 1; then
> DAYS=$1
> else
> DAYS=90
> fi
>
> SRC_DIR="/var/cache/apt/archives"
> DEST_DIR="/backup/debian/packages/old"
> TMP_SCRIPT="tmp.sh"
>
> find "$SRC_DIR" -daystart -mtime +$DAYS -printf "mv \"%p\" \"$DEST_DIR\";\n" > "$TMP_SCRIPT"
> # For deleting the following should work (untested)
> #find "$SRC_DIR" -daystart -mtime +$DAYS -printf "rm \"%p\";\n" > "$TMP_SCRIPT"
>
> source "$TMP_SCRIPT"
> rm "$TMP_SCRIPT"
> ------------
Very neat. Thanks - Tom George
>
> --
> Maurits van Rees | http://maurits.vanrees.org/ [Dutch/Nederlands]
> Public GnuPG key: keyserver.net ID 0x1735C5C2
> "Let your advance worrying become advance thinking and planning."
> - Winston Churchill
Reply to: