From: Andrew Hewus Fresh Subject: fw_update(8) use local patterns and dmesg for testing To: tech@openbsd.org Date: Fri, 8 Nov 2024 19:12:40 -0800 Here is a change to be used for testing changes to patterns.c. The idea is that if you are modifying the patterns you want to know what they match. Since I just committed support for listing with -l (although you could have used dry-run) it would work something like this. $ cd /usr/src/usr.sbin/fw_update $ make firmware_patterns $ ksh ./fw_update.sh -l However, sometimes your development machine isn't the same as the one you are adding firmware for. Or maybe you are testing the dmesg from the installer, but getting that dmesg is left as an exercise for the reader. $ # assuming we've done the steps above $ scp weird-machine:/var/run/dmesg.boot dmesg $ ksh ./fw_update.sh -l Comments, questions, OK? How should I document this? A comment in patterns.c? Something else? Should I use flags ("-D /path/to/dmesg" and "-P /path/to/patterns") instead of just doing it? --- fw_update.sh.1.61 Fri Nov 8 18:49:56 2024 +++ fw_update.sh Fri Nov 8 18:57:17 2024 @@ -20,15 +20,26 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin CFILE=SHA256.sig +DMESG=/var/run/dmesg.boot DESTDIR=${DESTDIR:-} FWPATTERNS="${DESTDIR}/usr/share/misc/firmware_patterns" VNAME=${VNAME:-$(sysctl -n kern.osrelease)} VERSION=${VERSION:-"${VNAME%.*}${VNAME#*.}"} +if [ "${0##*/}" = fw_update.sh ] && [ -e firmware_patterns ]; then + FWPATTERNS=$PWD/firmware_patterns + echo "Using patterns from $FWPATTERNS" >&2 + + if [ -e dmesg ]; then + DMESG=$PWD/dmesg + echo "Using dmesg from $DMESG" >&2 + fi +fi + HTTP_FWDIR="$VNAME" VTYPE=$( sed -n "/^OpenBSD $VNAME\([^ ]*\).*$/s//\1/p" \ - /var/run/dmesg.boot | sed '$!d' ) + "$DMESG" | sed '$!d' ) [ "$VTYPE" = -current ] && HTTP_FWDIR=snapshots FWURL=http://firmware.openbsd.org/firmware/${HTTP_FWDIR} @@ -251,7 +262,7 @@ ' # The dmesg can contain multiple boots, only look in the last one - _dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' /var/run/dmesg.boot )" + _dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' "$DMESG" )" grep -v '^[[:space:]]*#' "$FWPATTERNS" | while read -r _d _m; do