pacman-conf may return multiple cachedirs, in which case we treat it as one cachedir containing newline characters, which is certainly wrong in every case. However, pacman -Sddp already returns a filepath when the package is cached. This also properly handles packages already available in a secondary cache directory without looping through each one and checking for ourselves, where it is located. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- src/pacscripts.sh.in | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pacscripts.sh.in b/src/pacscripts.sh.in index 17e2625..3f11d3d 100644 --- a/src/pacscripts.sh.in +++ b/src/pacscripts.sh.in @@ -52,9 +52,7 @@ if ! DBPath="$(pacman-conf DBPath)"; then error "unable to read @sysconfdir@/pacman.conf" exit 1 fi -CacheDir="$(pacman-conf CacheDir)" pac_db="${DBPath:-@localstatedir@/lib/pacman}/local" -pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}" version() { printf "%s %s\n" "$myname" "$myver" @@ -113,15 +111,15 @@ print_scriptlet() { return 1 fi url=$(pacman -Sddp $1) - filename=$(basename $url) - if [ ! -f "$pac_cache/$filename" ]; then + if [[ $url != file://* ]]; then if ! spacman -Sddw --noconfirm $1 >&2; then error "Failed to download $1" return 1 fi echo >&2 + url=$(pacman -Sddp $1) fi - print_pkg "$pac_cache/$filename" + print_pkg "${url#file://}" return } -- 2.18.0