[pacman-contrib] [PATCH 1/2] pacscripts: use filename directly instead of parsing pacman.conf
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
This is not interesting information and doesn't modify anything for which logging it would be interesting. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- src/pacscripts.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacscripts.sh.in b/src/pacscripts.sh.in index 3f11d3d..ee4afa8 100644 --- a/src/pacscripts.sh.in +++ b/src/pacscripts.sh.in @@ -112,7 +112,7 @@ print_scriptlet() { fi url=$(pacman -Sddp $1) if [[ $url != file://* ]]; then - if ! spacman -Sddw --noconfirm $1 >&2; then + if ! spacman -Sddw --logfile /dev/null --noconfirm $1 >&2; then error "Failed to download $1" return 1 fi -- 2.18.0
participants (1)
-
Eli Schwartz