1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-11-04 05:55:36 -07:00

kiss: add tiny function to handle init of paths

This commit is contained in:
Dylan Araps 2020-09-27 21:04:33 +03:00
parent feb6e63dfd
commit 83c18335a1
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

22
kiss
View File

@ -54,6 +54,12 @@ contains() {
return 1
}
sys_dir() {
# Export environment variable named in $1.
# Strip all trailing slashes from path held in $2.
export "KISS_$1=${2%"${2##*[!/]}"}"
}
file_owner() {
read -r _ _ user _ <<EOF
$(ls -ld "$1")
@ -1506,12 +1512,13 @@ main() {
set -ef
# Set the default values of system directories.
export KISS_PREFIX=${KISS_PREFIX-/usr}
export KISS_LIBDIR=${KISS_LIBDIR:-lib}
export KISS_BINDIR=${KISS_BINDIR:-bin}
export KISS_ETCDIR=${KISS_ETCDIR:-etc}
export KISS_INCDIR=${KISS_INCDIR:-include}
export KISS_DATADIR=${KISS_DATADIR:-share}
sys_dir PREFIX "${KISS_PREFIX-/usr}"
sys_dir LIBDIR "${KISS_LIBDIR-lib}"
sys_dir BINDIR "${KISS_BINDIR-bin}"
sys_dir ETCDIR "${KISS_ETCDIR-etc}"
sys_dir INCDIR "${KISS_INCDIR-include}"
sys_dir DATADIR "${KISS_DATADIR-share}"
sys_dir ROOT "$KISS_ROOT"
# Allow the user to disable colors in output via an environment variable.
# Check this once so as to not slow down printing.
@ -1554,9 +1561,6 @@ main() {
# This is used enough to warrant a place here.
uid=$(id -u)
# Ensure that the KISS_ROOT doesn't end with a '/'.
KISS_ROOT=${KISS_ROOT%"${KISS_ROOT##*[!/]}"}
# Define some paths which we will then use throughout the script.
sys_db=$KISS_ROOT/${pkg_db:=var/db/kiss/installed}