On Thu, May 08, 2025 at 07:37:01AM +0000, Mikolaj Kucharski wrote:
> Hi.
>
> I was testing fw_update -a and fw_update -da today and noticed that I
> had leftover files from a firware which was deleted:
>
> /etc/firmware/brcmfmac43430a0-sdio.ONDA-V80 PLUS.txt
> /etc/firmware/brcmfmac43455-sdio.MINIX-NEO Z83-4.txt
>
> I think the reason the files are kept, when the bwfm firmware is
> uninstalled:
>
> # ls -1 /var/db/pkg/ | grep -c bwfm
> 0
>
> is the whitespace in those filenames. Not sure is it easier to fix
> fw_update script or rename the files in the bwfm-firmware package.
It's pretty easy to fix fw_update.
Apparently was not thinking when I wrote it.
Comments, OK?
Index: fw_update.sh
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v
diff -u -p -r1.64 fw_update.sh
--- fw_update.sh 22 Mar 2025 19:51:29 -0000 1.64
+++ fw_update.sh 9 May 2025 00:27:38 -0000
@@ -431,7 +431,7 @@ remove_files() {
}
delete_firmware() {
- local _cwd _pkg="$1" _pkgdir="${DESTDIR}/var/db/pkg"
+ local _cwd _pkg="$1" _pkgdir="${DESTDIR}/var/db/pkg" _remove _l
# TODO: Check hash for files before deleting
((VERBOSE > 2)) && echo -n "Uninstall $_pkg ..."
@@ -445,13 +445,13 @@ delete_firmware() {
sET -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}"
- while read -r _c _g; do
- case $_c in
- @cwd) _cwd="${DESTDIR}$_g"
+ while read -r _l; do
+ case ${_l%% *} in
+ @cwd) _cwd="${DESTDIR}${_l#* }"
;;
@*) continue
;;
- *) set -A _remove -- "$_cwd/$_c" "${_remove[@]}"
+ *) set -A _remove -- "$_cwd/$_l" "${_remove[@]}"
;;
esac
done < "${_pkgdir}/${_pkg}/+CONTENTS"