kiss: swap to if tests

This commit is contained in:
Dylan Araps 2019-09-23 09:30:34 +03:00
parent 815e14d61e
commit 0c1188533f
1 changed files with 30 additions and 38 deletions

68
kiss
View File

@ -132,27 +132,24 @@ pkg_sources() {
repo_dir=$(pkg_find "$1") repo_dir=$(pkg_find "$1")
while read -r src _; do while read -r src _; do
case $src in # Remote source (cached).
# Remote source. if [ -f "${src##*/}" ]; then
*://*) log "$1" "Found cached source '${src##*/}'"
[ -f "${src##*/}" ] && {
log "$1" "Found cached source '${src##*/}'"
continue
}
wget "$src" || { # Remote source.
rm -f "${src##*/}" elif [ -z "${src##*://*}" ]; then
die "$1" "Failed to download $src" wget "$src" || {
} rm -f "${src##*/}"
;; die "$1" "Failed to download $src"
}
# Local source. # Local source.
*) elif [ -f "$repo_dir/$src" ]; then
[ -f "$repo_dir/$src" ] || die "$1" "No local file '$src'" log "$1" "Found local file '$src'"
log "$1" "Found local file '$src'" else
;; die "$1" "No local file '$src'"
esac fi
done < "$repo_dir/sources" done < "$repo_dir/sources"
} }
@ -166,29 +163,24 @@ pkg_extract() {
while read -r src dest; do while read -r src dest; do
mkdir -p "$mak_dir/$1/$dest" && cd "$mak_dir/$1/$dest" mkdir -p "$mak_dir/$1/$dest" && cd "$mak_dir/$1/$dest"
case $src in # Only 'tar' archives are currently supported for extraction.
# Only 'tar' archives are currently supported for extraction. # Any other file-types are simply copied to '$mak_dir' which
# Any other file-types are simply copied to '$mak_dir' which # allows for manual extraction.
# allows for manual extraction. if [ -z "${src##*.tar*}" ]; then
*://*.tar*|*://*.tgz) tar xf "$src_dir/$1/${src##*/}" --strip-components 1 \
tar xf "$src_dir/$1/${src##*/}" --strip-components 1 \ || die "$1" "Couldn't extract ${src##*/}"
|| die "$1" "Couldn't extract ${src##*/}"
;;
*) # Local file.
# Local file. elif [ -f "$repo_dir/$src" ]; then
if [ -f "$repo_dir/$src" ]; then cp -f "$repo_dir/$src" .
cp -f "$repo_dir/$src" .
# Remote file. # Remote file.
elif [ -f "$src_dir/$1/${src##*/}" ]; then elif [ -f "$src_dir/$1/${src##*/}" ]; then
cp -f "$src_dir/$1/${src##*/}" . cp -f "$src_dir/$1/${src##*/}" .
else else
die "$1" "Local file $src not found" die "$1" "Local file $src not found"
fi fi
;;
esac
done < "$repo_dir/sources" done < "$repo_dir/sources"
} }