kiss: clean up

This commit is contained in:
Dylan Araps 2020-09-09 15:03:57 +03:00
parent 67ccf37ac6
commit f619fad60f
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

38
kiss
View File

@ -56,9 +56,17 @@ as_root() {
[ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})" [ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})"
case ${su##*/} in case ${su##*/} in
doas|sudo|sls) "$su" -u "$user" -- env "$@" ;; doas|sudo|sls)
su) "$su" -c "env $* <&3" "$user" 3<&0 </dev/tty ;; "$su" -u "$user" -- env "$@"
*) die "Invalid KISS_SU value: $su (valid: doas, sudo, sls, su)" ;;
su)
"$su" -c "env $* <&3" "$user" 3<&0 </dev/tty
;;
*)
die "Invalid KISS_SU value: $su (valid: doas, sudo, sls, su)"
;;
esac esac
} }
@ -78,16 +86,18 @@ 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.
[ "${KISS_HOOK:-}" ] || { case ${KISS_HOOK:--}$1 in
case $1 in post-build) -post-build)
rm -rf "$3/usr/share/gettext" "$3/usr/share/polkit-1" \ rm -rf "$3/usr/share/gettext" \
"$3/usr/share/locale" "$3/usr/share/info" "$3/usr/share/polkit-1" \
esac "$3/usr/share/locale" \
"$3/usr/share/info"
return 0 ;;
}
[!-]*)
TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$KISS_HOOK" TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$KISS_HOOK"
;;
esac
} }
decompress() { decompress() {
@ -112,11 +122,13 @@ sh256() {
# Example: '<checksum> <file>' # Example: '<checksum> <file>'
[ -e "$1" ] || return 0 [ -e "$1" ] || return 0
hash=$(sha256sum "$1" || hash=$(
sha256sum "$1" ||
sha256 -r "$1" || sha256 -r "$1" ||
openssl dgst -sha256 -r "$1" || openssl dgst -sha256 -r "$1" ||
shasum -a 256 "$1" || shasum -a 256 "$1" ||
digest -a sha256 "$1") 2>/dev/null digest -a sha256 "$1"
) 2>/dev/null
printf '%s\n' "${hash%% *}" printf '%s\n' "${hash%% *}"
} }