From 38b6de937cdbf581d13b404b50183d1b7e457413 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 7 Jun 2014 15:35:25 -0400 Subject: paccache: read default cachedir from pacman.conf Implements FS#40738. --- contrib/paccache.sh.in | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'contrib/paccache.sh.in') diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in index 54bb3c41..eba315c7 100644 --- a/contrib/paccache.sh.in +++ b/contrib/paccache.sh.in @@ -37,6 +37,19 @@ die() { exit 1 } +get_cachedir_from_config() { + local key value + + while IFS=$'= \t' read -r key value _; do + if [[ $key = CacheDir ]]; then + echo "$value" + return 0 + fi + done <"$1" + + return 1 +} + # reads a list of files on stdin and prints out deletion candidates pkgfilter() { # there's whitelist and blacklist parameters passed to this @@ -166,7 +179,7 @@ Usage: ${myname} [options] [targets...] Options: -a, --arch scan for "arch" (default: all architectures). -c, --cachedir scan "dir" for packages. can be used more than once. - (default: @localstatedir@/cache/pacman/pkg). + (default: read from @sysconfdir@/pacman.conf). -f, --force apply force to mv(1) and rm(1) operations. -h, --help display this help message and exit. -i, --ignore ignore "pkgs", comma-separated. Alternatively, specify @@ -257,7 +270,13 @@ done m4_include(../scripts/library/term_colors.sh) # setting default cachedir -cachedirs=("${cachedirs[@]:-@localstatedir@/cache/pacman/pkg}") +if [[ -z $cachedirs ]]; then + if cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf"); then + cachedirs=("$cachedir") + else + cachedirs=("${cachedirs[@]:-@localstatedir@/cache/pacman/pkg}") + fi +fi # remaining args are a whitelist whitelist=("$@") -- cgit v1.2.3-70-g09d2