KISS tips and tricks

More blogs about KISS are good. I hope this will give you some ideas for your system.

  1. Hooks
  2. My $KISS_HOOK file begins with:

    PKG=$2
    DEST=$3
    KISS_TMPDIR=${KISS_TMPDIR:-/tmp}
    
    case $1 in
    as well as a copy of log() from kiss itself.

    Firstly, one to update the man page database after installation. This is quicker than running just plain makewhatis because it only updates entries for the added files.

    post-install)
    	man="$(kiss-manifest "$PKG" | grep '/usr/share/man/man./.')" || :
    	# shellcheck disable=2086
    	[ "$man" ] && {
    		log "$PKG" "Updating manpage database"
    		makewhatis -d "$KISS_ROOT/usr/share/man" $man
    	} || :
    ;;
    Note that I call kiss-manifest directly. Calling kiss from within a hook can be bad.

    This is probably the most useful one - gives me a shell in the build directory if something goes wrong.

    build-fail)
    	printf "\a"
    	log "$PKG" "Dropped into subshell"
    	sh >/dev/tty
    ;;
    I also have a patched kiss which can continue and finish a build that was stopped in this way.

    One to set my terminal title, a classic.

    queue-status)
    	# Set the terminal title
    	[ -t 2 ] && {
    		printf '\033]0;kiss: %s (%d/%d)\a' \
    			"$PKG" "${3:-?}" "${4:-?}" >&2
    	}
    ;;
    And another classic to log the build duration:
    pre-build)
    	cat /proc/uptime > "$KISS_TMPDIR/_kiss_start"
    ;;
    
    post-build)
    	set +e
    	IFS=. read -r _start _ < "$KISS_TMPDIR/_kiss_start"
    	IFS=. read -r _end _ < /proc/uptime
    
    	rm -f "$KISS_TMPDIR/_kiss_start"
    
    	(
    		_s=$((_end - _start))
    		_h=$((_s / 60 / 60 % 24))
    		_m=$((_s / 60 % 60))
    
    		[ "$_h" = 0 ] || _u="${_u}${_h}h "
    		[ "$_m" = 0 ] || _u="${_u}${_m}m "
    
    		log "$PKG" "Build finished in ${_u:-${_s}s}"
    	)
    	set -e
    ;;

    By the way:

    pre-update|post-update)
    	# $2 is not $PKG for this hook
    	unset PKG
    ;;

  3. Shell functions
  4. To cd into a package directory:

    kisscd () {
        _r="$(kiss search "$@" | sed 1q)"
        [ "$_r" ] && cd "$_r"
        unset _r
    }

    To quickly view a package build file:

    kissb () {
        _r="$(kiss search "$1" | sed 1q)"
        shift
        [ "$_r" ] && less "$@" "$_r/build"
        unset _r
    }

Let me know your own useful functions.


written 2024-03-25

Home

Blog home