More blogs about KISS are good. I hope this will give you some ideas for your system.
My $KISS_HOOK
file begins with:
as well as a copy of PKG=$2
DEST=$3
KISS_TMPDIR=${KISS_TMPDIR:-/tmp}
case $1 in
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.
Note that I call 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
} || :
;;
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.
I also have a patched build-fail)
printf "\a"
log "$PKG" "Dropped into subshell"
sh >/dev/tty
;;
kiss
which can continue and finish a build that was stopped in this way.
One to set my terminal title, a classic.
And another classic to log the build duration:
queue-status)
# Set the terminal title
[ -t 2 ] && {
printf '\033]0;kiss: %s (%d/%d)\a' \
"$PKG" "${3:-?}" "${4:-?}" >&2
}
;;
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
;;
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