From e049f468ecc5d1fc0c74dc9e433f31fbc8ac3018 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 12 May 2020 11:02:08 +0300 Subject: [PATCH] kiss: Allow full rootless use via KISS_ROOT --- kiss | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kiss b/kiss index 465d889..bde2b95 100755 --- a/kiss +++ b/kiss @@ -869,7 +869,7 @@ pkg_conflicts() { # directory. cd -P "${file%/*}" 2>/dev/null || PWD=${file%/*} - printf '%s\n' "$PWD/${file##*/}" + printf '%s\n' "${PWD#$KISS_ROOT}/${file##*/}" cd "$old_PWD" done < "$tar_dir/$1/$pkg_db/$1/manifest" > "$cac_dir/$pid-m" @@ -1490,7 +1490,7 @@ args() { a|alternatives) # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ -z "$1" ] || [ "$uid" = 0 ] || { + [ -z "$1" ] || [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || { as_root kiss "$action" "$@" return } @@ -1499,7 +1499,7 @@ args() { i|install|r|remove) # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ "$uid" = 0 ] || { + [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || { KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@" return } @@ -1673,9 +1673,13 @@ main() { # break some operations. KISS_ROOT=${KISS_ROOT%/} + # Define this variable but don't create its directory structure from + # the get go. It will be created as needed by package installation. + sys_db=$KISS_ROOT/$pkg_db + # This allows for automatic setup of a KISS chroot and will # do nothing on a normal system. - mkdir -p "${sys_db:=$KISS_ROOT/}" 2>/dev/null ||: + mkdir -p "$KISS_ROOT/" 2>/dev/null ||: # Create the required temporary directories and set the variables # which point to them.