From 5bbe89573164607e91d411bc6b0b3a676471c8dd Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 23 Oct 2020 14:28:26 +0300 Subject: [PATCH] kiss: Store downloaded sources using dest if set This prevents naming conflicts in the cache. Example: https://github.com/opencv/opencv/archive/4.5.0.tar.gz https://github.com/opencv/opencv_contrib/archive/4.5.0.tar.gz contrib Fixes #196 --- kiss | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kiss b/kiss index 62de948..17f28c2 100755 --- a/kiss +++ b/kiss @@ -278,13 +278,14 @@ pkg_sources() { elif [ -z "${src##git+*}" ]; then printf 'found git %s\n' "${src##git+}" - elif [ -f "${src##*/}" ]; then + elif [ -f "./${dest:-.}/${src##*/}" ]; then printf 'found cached %s\n' "${src##*/}" elif [ -z "${src##*://*}" ]; then printf 'downloading %s\n' "$src" + mkdir -p "$PWD/$dest" - curl "$src" -fLo "${src##*/}" || { + curl "$src" -fLo "./${dest:-.}/${src##*/}" || { rm -f "${src##*/}" die "$1" "failed to download $src" } @@ -394,6 +395,10 @@ pkg_extract() { elif [ -f "/$src" ]; then cp -f "/$src" . + # Remote file + dest. + elif [ -f "$src_dir/$1/$dest/${src##*/}" ]; then + cp -f "$src_dir/$1/$dest/${src##*/}" . + # Remote file. elif [ -f "$src_dir/$1/${src##*/}" ]; then cp -f "$src_dir/$1/${src##*/}" . @@ -821,14 +826,14 @@ pkg_checksums() { [ -f "$repo_dir/sources" ] || return 0 - while read -r src _ || [ "$src" ]; do + while read -r src dest || [ "$src" ]; do # Skip comments, blank lines and git sources. if [ -z "${src##\#*}" ] || [ -z "${src##git+*}" ]; then continue # Remote source. elif [ -z "${src##*://*}" ]; then - sh256 "$src_dir/$1/${src##*/}" + sh256 "$src_dir/$1/${dest:-.}/${src##*/}" # Skip directories. elif [ -d "$repo_dir/$src" ] || [ -d "/$src" ]; then