vendor.sh: Allow restoring the default GbE file

./mk inject libreboot-YYYYMMDD_board.tar.xz setmac restore

This does the same thing as a normal setmac command, except
that it does not alter the MAC address; it is also not the
same as "keep", which skips *writing* the GbE region in-ROM.

The *restore* argument writes the default, unmodified GbE file
kept by lbmk, unmodified because nvmutil is skipped when the
user specifies this argument.

This option is useful for debugging purposes, because it can
be used to verify whether anything else is being wrongly
modified by the script; the "nuke" command can be executed
afterward, and the hash file inspected versus release.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-01-05 08:13:28 +00:00
parent ab8feff92e
commit 13b06ae130
+13 -2
View File
@@ -380,6 +380,9 @@ vendor_inject()
check_release "$archive" || \
$err "You must run this script on a release archive. - $dontflash"
[ "$new_mac" = "restore" ] && \
printf "Restoring default GbE for '$archive', board '$board'\n"
readcfg && need_files="y"
if [ "$need_files" = "y" ] || [ -n "$new_mac" ]; then
[ "$nukemode" = "nuke" ] || x_ ./mk download "$board"
@@ -714,7 +717,9 @@ modify_mac_addresses()
[ -n "$CONFIG_GBE_BIN_PATH" ] || return 1
e "${CONFIG_GBE_BIN_PATH##*../}" f n && $err "missing gbe file"
x_ make -C util/nvmutil
[ "$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"
@@ -723,7 +728,8 @@ modify_mac_addresses()
fi
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "tmp/gbe"
x_ "util/nvmutil/nvm" "tmp/gbe" setmac "$new_mac"
[ "$new_mac" != "restore" ] && \
x_ "util/nvmutil/nvm" "tmp/gbe" setmac "$new_mac"
find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \
|| $err "'$archive' -> Can't make tmp/rom.list - $dontflash"
@@ -738,4 +744,9 @@ modify_mac_addresses()
printf "\nThe following GbE NVM words were written in '%s':\n" \
"$archive"
x_ util/nvmutil/nvm tmp/gbe dump
[ "$new_mac" = "restore" ] && \
printf "\nNOTE: User specified setmac 'restore' argument.\n" && \
printf "Default GbE file '%s' written without running nvmutil.\n" \
"${CONFIG_GBE_BIN_PATH##*../}"; :
}