1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-25 08:30:05 -07:00

kiss: more clean up

This commit is contained in:
Dylan Araps 2020-09-11 17:58:16 +03:00
parent f915d9aebc
commit fda570d0d2
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

28
kiss
View File

@ -21,7 +21,6 @@ die() {
} }
contains() { contains() {
# Check if a "string list" contains a word.
case " $1 " in *" $2 "*) return 0; esac; return 1 case " $1 " in *" $2 "*) return 0; esac; return 1
} }
@ -64,6 +63,8 @@ run_hook() {
# Provide a default post-build hook to remove files and directories # Provide a default post-build hook to remove files and directories
# for things we don't support out of the box. One can simply define # for things we don't support out of the box. One can simply define
# their own hook to override this behavior. # their own hook to override this behavior.
set -- "${1:-null}" "${2:-null}" "${3:-null}"
case ${KISS_HOOK:--}$1 in case ${KISS_HOOK:--}$1 in
-post-build) -post-build)
rm -rf "$3/usr/share/gettext" \ rm -rf "$3/usr/share/gettext" \
@ -73,31 +74,26 @@ run_hook() {
;; ;;
[!-]*) [!-]*)
TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$KISS_HOOK" TYPE=$1 PKG=$2 DEST=$3 . "$KISS_HOOK"
;; ;;
esac esac
} }
decompress() { decompress() {
case $1 in case ${1##*.} in
*.bz2) bzip2 -d ;; bz2) bzip2 -dc ;;
*.lzma) lzma -dc ;; lzma) lzma -dc ;;
*.lz) lzip -dc ;; lz) lzip -dc ;;
*.tar) cat ;; tar) cat ;;
*.tgz|*.gz) gzip -d ;; tgz | gz) gzip -dc ;;
*.xz|*.txz) xz -dcT 0 ;; txz | xz) xz -dc ;;
*.zst) zstd -dc ;; zst) zstd -dc ;;
esac < "$1" esac < "$1"
} }
sh256() { sh256() {
# There's no standard utility to generate sha256 checksums. # There's no standard utility to generate sha256 checksums.
# This is a simple wrapper around sha256sum, sha256, shasum, # This unifies various tools using the first available.
# openssl, digest, ... which will use whatever is available.
#
# All utilities must match 'sha256sum' output.
#
# Example: '<checksum> <file>'
[ -e "$1" ] || return 0 [ -e "$1" ] || return 0
hash=$( hash=$(