You are not logged in.

#1 2011-07-06 19:40:32

freak
Member
Registered: 2009-04-15
Posts: 17

clearcache - another script to selectively clear your pacman cache.

https://aur.archlinux.org/packages.php?ID=50498

I learned there are a number of scripts designed to do the same thing after I
wrote the basic framework, but I went ahead and finished it anyway.

clearcache has a number of features I haven't seen elsewhere,

usage: clearcache [options] [targets]

Options:
  -h, --help          display this help menu
  -d, --dry           dry run, simply list targets instead of removing
  -q, --quiet         only prints filenames for -d/--dry or -l/--list-targets
  -f, --force         force removal of package files
  -i, --ignore <pkg>  specify package(s) to ignore. this can be a comma
                      separated list, or '-' reads a list from stdin, one
                      per line. can be used more than once.
  -k, --keep <num>    specify number of old package files to keep. by default,
                      clearcache will keep the two most recent versions.
  -l, --list-targets  list targets to remove, using PAGER/less, before
                      removing. may not be used with -d/--dry
  -t, --threads <num> use <num> threads. the default value is 5. using a
                      large number will not gain you much, and is not
                      recommended, but there is no hard limit.
  -u, --uninstalled   remove all package files for packages that are not
                      currently installed, while still keeping the
                      specified number of old files for installed packages
  -v, --verbose       output more

  there MUST be a space between the option and its argument.

Targets:
  targets are package names, as you would specify them to pacman.
  if targets are specified, only package files belonging to them will be
  removed. if no targets are specified, all packages except for thos
  specified to be ignored will be removed.

It now uses the .PKGINFO file within the package itself, in order to know which
package it belongs to (Thanks again brisbin).  This eliminates any issues with
parsing the name from the version info, in the filename.

Obviously using alpm or such would be faster, but this was a quick project.  I
wrote a short snippet for myself, and decided to extend it.

Anyway, hope someone else finds this useful, let me know if you find any bugs,
or have any feature reqs.

Potential issues:
  As seems to be the most common issue with scripts like this, it assumes the
  most recent package in the cache is the one installed, or the one you would
  want to keep.  I'm considering parsing pacman output to compare the versions,
  at least as an option.

EDIT:
  Now with multithreading!  It has taken about 10% off the execution time on a single
  core netbook, and gets faster on better processors.  If nothing else, it was a good
  experiment, but I think it turned out rather well.

Last edited by freak (2011-07-07 01:56:45)

Offline

Board footer

Powered by FluxBB