summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2014-06-07 15:35:25 -0400
committerAllan McRae <allan@archlinux.org>2014-09-15 09:27:21 +1000
commit38b6de937cdbf581d13b404b50183d1b7e457413 (patch)
tree7483a00118b24ab353b87e18aba501fab0873884 /contrib
parent8122fae51abf382838d9e2fd58d51cd42d475579 (diff)
downloadpacman-38b6de937cdbf581d13b404b50183d1b7e457413.tar.xz
paccache: read default cachedir from pacman.conf
Implements FS#40738.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/paccache.sh.in23
1 files changed, 21 insertions, 2 deletions
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} <operation> [options] [targets...]
Options:
-a, --arch <arch> scan for "arch" (default: all architectures).
-c, --cachedir <dir> 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 <pkgs> 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=("$@")