cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit 16f82b50df1cd737d5bfc972f91ddd132322b4a5
parent 99f34f547b141111f2a53d6ac5d690e872ede2f8
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Mon, 10 Feb 2020 20:02:45 +0200

kiss: Don't show messages if root

Diffstat:
Mkiss | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kiss b/kiss @@ -52,7 +52,7 @@ prompt() { as_root() { # Simple function to run a command as root using either 'sudo', # 'doas' or 'su'. Hurrah for choice. - log "Using '${su:-su}'" + [ "$uid" = 0 ] || log "Using '${su:-su}'" case $su in *sudo) sudo -Eu "${user:-root}" -- "$@" ;; @@ -1070,13 +1070,13 @@ pkg_updates() { *) log "$PWD" " " ;; esac - if [ -w "$PWD" ] && [ "$(id -u)" != 0 ]; then + if [ -w "$PWD" ] && [ "$uid" != 0 ]; then git fetch git diff >> "$mak_dir/log" git merge else - log "$PWD" "Need root to update" + [ "$uid" = 0 ] || log "$PWD" "Need root to update" # Find out the owner of the repository and spawn # git as this user below. @@ -1212,7 +1212,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" ] || [ "$(id -u)" = 0 ] || { + [ -z "$1" ] || [ "$uid" = 0 ] || { as_root kiss "$action" "$@" return } @@ -1223,7 +1223,7 @@ args() { # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ "$(id -u)" = 0 ] || { + [ "$uid" = 0 ] || { KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@" return } @@ -1289,7 +1289,7 @@ args() { l|list) pkg_list "$@" ;; u|update) pkg_updates ;; s|search) for pkg; do pkg_find "$pkg" all; done ;; - v|version) log kiss 1.4.3 ;; + v|version) log kiss 1.4.4 ;; h|help|-h|--help|'') log 'kiss [a|b|c|i|l|r|s|u|v] [pkg] [pkg] [pkg]' @@ -1344,6 +1344,10 @@ main() { # of the log files the package manager creates uring builds. time=$(date '+%Y-%m-%d-%H:%M') + # Make note of the user's current ID to do root checks later on. + # This is used enough to warrant a place here. + uid=$(id -u) + # This allows for automatic setup of a KISS chroot and will # do nothing on a normal system. mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||: