[arch-projects] [devtools] [PATCH] find_cached_package: avoid adding duplicates
If PKGDEST is set when makepkg was run, the package will be present in find_cached_package's search path by default, causing an error. This also fixes a display bug which causes no output to be shown when multiple packages are found. Fixes FS#37626. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- lib/common.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 1812cb7..cb9db76 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -181,7 +181,7 @@ pkgver_equal() { find_cached_package() { local searchdirs=("$PWD" "$PKGDEST") results=() local targetname=$1 targetver=$2 targetarch=$3 - local dir pkg pkgbasename pkgparts name ver rel arch size results + local dir pkg pkgbasename pkgparts name ver rel arch size r results for dir in "${searchdirs[@]}"; do [[ -d $dir ]] || continue @@ -189,6 +189,11 @@ find_cached_package() { for pkg in "$dir"/*.pkg.tar?(.?z); do [[ -f $pkg ]] || continue + # avoid adding duplicates of the same inode + for r in "${results[@]}"; do + [[ $r -ef $pkg ]] && continue 2 + done + # split apart package filename into parts pkgbasename=${pkg##*/} pkgbasename=${pkgbasename%.pkg.tar?(.?z)} @@ -219,7 +224,7 @@ find_cached_package() { ;; *) error 'Multiple packages found:' - printf '\t%s\n' "${results[@]}" + printf '\t%s\n' "${results[@]}" >&2 return 1 esac } -- 1.8.4.2
participants (1)
-
Dave Reisner