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
This commit is contained in:
Dylan Araps 2020-10-23 14:28:26 +03:00
parent 71b4c0f447
commit 5bbe895731
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 9 additions and 4 deletions

13
kiss
View File

@ -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