inject.sh: tidy up modify_mac_addresses()

Signed-off-by: Leah Rowe <leah@libreboot.org>
25.04_branch
Leah Rowe 2025-04-12 16:43:59 +01:00
parent 67c8338acf
commit ff35a6a300
1 changed files with 14 additions and 27 deletions

View File

@ -8,6 +8,7 @@ hashfiles="vendorhashes blobhashes" # used to detect and error out
# if running on an archive that needs vendor files
dontflash="!!! AN ERROR OCCURED! Do NOT flash these images !!!"
tmpromdel="$xbmkpwd/tmp/DO_NOT_FLASH"
nvm="util/nvmutil/nvm"
cv="CONFIG_GBE_BIN_PATH CONFIG_IFD_BIN_PATH"
@ -163,43 +164,29 @@ patch_release_roms()
modify_mac_addresses()
{
[ "$nukemode" = "nuke" ] && \
$err "Cannot modify MAC addresses while nuking vendor files"
# chkvars CONFIG_GBE_BIN_PATH
[ -n "$CONFIG_GBE_BIN_PATH" ] || return 1
e "${CONFIG_GBE_BIN_PATH##*../}" f n && $err "missing gbe file"
[ "$new_mac" != "restore" ] && \
x_ make -C util/nvmutil
x_ mkdir -p tmp
[ -L "tmp/gbe" ] && $err "tmp/gbe exists but is a symlink"
[ -d "tmp/gbe" ] && $err "tmp/gbe exists but is a directory"
if [ -e "tmp/gbe" ]; then
[ -f "tmp/gbe" ] || $err "tmp/gbe exists and is not a file"
fi
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "tmp/gbe"
e tmp/gbe && x_ e tmp/gbe f
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe
[ "$new_mac" != "restore" ] && \
x_ "util/nvmutil/nvm" "tmp/gbe" setmac "$new_mac"
if [ "$new_mac" != "restore" ]; then
x_ make -C util/nvmutil
x_ "$nvm" tmp/gbe setmac "$new_mac"
fi
find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \
|| $err "'$archive' -> Can't make tmp/rom.list - $dontflash"
while read -r _xrom; do
[ -L "$_xrom" ] && continue
[ -f "$_xrom" ] || continue
"$ifdtool" $ifdprefix -i GbE:"tmp/gbe" "$_xrom" -O \
"$_xrom" || $err "'$_xrom': Can't insert new GbE file"
xchanged="y"
e "$_xrom" f && xchanged="y" && x_ \
"$ifdtool" $ifdprefix -i GbE:tmp/gbe "$_xrom" -O "$_xrom"
done < "tmp/rom.list"
printf "\nThe following GbE NVM words were written in '%s':\n" \
"$archive"
x_ util/nvmutil/nvm tmp/gbe dump | grep -v "bytes read from file" || :
printf "\nGbE NVM written to '%s':\n" "$archive"
x_ "$nvm" tmp/gbe dump | grep -v "bytes read from file" || :
[ "$new_mac" = "restore" ] && \
printf "\nNOTE: User specified setmac 'restore' argument.\n" && \
printf "Default GbE file '%s' written without running nvmutil.\n" \
printf "\nDefault GbE file '%s' written, unmodified.\n" \
"${CONFIG_GBE_BIN_PATH##*../}"; :
}