site

bvnf.space sources
Log | Files | Refs

commit 104b46e4d122545c1e57cb3f3573cb524e303c7e
parent 6d8e315d48c51889c89585fce77d95c00e466b7d
Author: phoebos <ben@bvnf.space>
Date:   Sun, 31 Mar 2024 23:23:16 +0100

blog: new post

Diffstat:
Ablog/010-kiss-misc.html | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+), 0 deletions(-)

diff --git a/blog/010-kiss-misc.html b/blog/010-kiss-misc.html @@ -0,0 +1,108 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1"/> + <title>KISS tips and tricks</title> + <link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAPH/AAAAAP//AAD/AP8AACH/C0NSTkcAAAAAMS4wSAAAAAIwPwAAAAJATwAAAAJQXwAAAAJgbwAAAAJwfwAAAAKAjwAAAAKQnwAAAAKgrwAAAAKwvwAAAALAzwAAAALQ3wAAAALg7wAh+QQF//8EACwAAAAAEAAQAAACOJQFqTp9j5p00IApq8X0rTtBSQCQYIeUZGBmh7qyp8fGpGvV8PyqPt9bJUKiBUYT4SBPRMuH0SgAADs="/> + <link rel="stylesheet" href="/style.css" type="text/css"/> + <style type="text/css"> + body {font-family: sans-serif;} + </style> +</head> +<body> +<h1>KISS tips and tricks</h1> +<p>More blogs about <a href="//kisscommunity.bvnf.space/">KISS</a> are good. I hope this will give you some ideas for your system.</p> + +<ol> +<h2><li>Hooks</li></h2> +<p>My <code>$KISS_HOOK</code> file begins with: +<code><pre>PKG=$2 +DEST=$3 +KISS_TMPDIR=${KISS_TMPDIR:-/tmp} + +case $1 in</pre></code> as well as a copy of <code>log()</code> from kiss itself.</p> + +<p>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. + +<code><pre>post-install) + man="$(kiss mani "$PKG" | grep '/usr/share/man/man./.')" || : + # shellcheck disable=2086 + [ "$man" ] &amp;&amp; { + log "$PKG" "Updating manpage database" + makewhatis -d /usr/share/man $man + } +;;</pre></code></p> + +<p>This is probably the most useful one - gives me a shell in the build directory if something goes wrong. +<code><pre>build-fail) + printf "\a" + log "$PKG" "Dropped into subshell" + sh &gt;/dev/tty +;;</pre></code>I also have a patched <code>kiss</code> which can continue and finish a build that was stopped in this way.</p> + + <p>One to set my terminal title, a classic. +<code><pre>queue-status) + # Set the terminal title + [ -t 2 ] &amp;&amp; { + printf '\033]0;kiss: %s (%d/%d)\a' \ + "$PKG" "${3:-?}" "${4:-?}" &gt;&amp;2 + } +;;</pre></code> + +And another classic to log the build duration: +<code><pre>pre-build) + cat /proc/uptime &gt; "$KISS_TMPDIR/_kiss_start" +;; + +post-build) + set +e + IFS=. read -r _start _ &lt; "$KISS_TMPDIR/_kiss_start" + IFS=. read -r _end _ &lt; /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 +;;</pre></code></p> + +<p>By the way: +<code><pre>pre-update|post-update) + # $2 is not $PKG for this hook + unset PKG +;;</pre></code></p> + +<h2><li>Shell functions</li></h2> +<p>To <code>cd</code> into a package directory: +<code><pre>kisscd () { + _r="$(kiss search "$@" | sed 1q)" + [ "$_r" ] &amp;&amp; cd "$_r" + unset _r +}</pre></code></p> +<p>To quickly view a package build file: +<code><pre>kissb () { + _r="$(kiss search "$1" | sed 1q)" + shift + [ "$_r" ] &amp;&amp; less "$@" "$_r/build" + unset _r +}</pre></code></p> +</ol> + +<p>Let me know your own useful functions.</p> + +<hr /> +<p>written 2024-03-25</p> + +<p><a href="../">Home</a></p> +<p><a href="./">Blog home</a></p> +</body> +</html>