make nuke function more generic

i'm merging it into lbmk after this commit. in lbmk, it
will be used for deleting certain files such as u-boot's
strlcat.c. it will not be used in libreboot for deblobbing;
that's what canoeboot is for (deblobbed coreboot distro).

Signed-off-by: Leah Rowe <info@minifree.org>
audit2-merge1
Leah Rowe 2024-05-30 07:24:13 +01:00
parent 2c1f6f5e7a
commit cdce8ba70b
1 changed files with 4 additions and 4 deletions

View File

@ -197,8 +197,8 @@ nuke()
pjsrcdir="${pjsrcdir#src/}"
[ ! -f "config/$pjcfgdir/nuke.list" ] && return 0
while read -r blobfile; do
rmf="$(realpath "src/$pjsrcdir/$blobfile" 2>/dev/null)" || \
while read -r nukefile; do
rmf="$(realpath "src/$pjsrcdir/$nukefile" 2>/dev/null)" || \
continue
[ -L "$rmf" ] && continue # we will delete the actual file
[ "${rmf#"$PWD/src/$pjsrcdir"}" = "$rmf" ] && continue
@ -206,12 +206,12 @@ nuke()
rmf="${rmf#"$PWD/"}"
[ -e "$rmf" ] || continue
del="y"
rm -Rf "$rmf" || $err "$pjcfgdir/blobs: can't rm \"$blobfile\""
rm -Rf "$rmf" || $err "$nuke pjcfgdir: can't rm \"$nukefile\""
printf "nuke %s: deleted \"%s\"\n" "$pjcfgdir" "$rmf"
done < "config/$pjcfgdir/nuke.list"
[ "${del}" = "y" ] && return 0
printf "nuke %s: no defined blobs exist in dir, src/%s\n" 1>&2 \
printf "nuke %s: no defined files exist in dir, src/%s\n" 1>&2 \
"$pjcfgdir" "$pjsrcdir"
printf "(this is not an error)\n" 1>&2
}