summaryrefslogtreecommitdiff
path: root/include/vendor.sh
diff options
context:
space:
mode:
Diffstat (limited to 'include/vendor.sh')
-rw-r--r--include/vendor.sh56
1 files changed, 48 insertions, 8 deletions
diff --git a/include/vendor.sh b/include/vendor.sh
index cefed456..bde245d9 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -12,7 +12,7 @@ appdir="$vendir/app"
cbcfgsdir="config/coreboot"
hashfiles="vendorhashes blobhashes" # blobhashes for backwards compatibility
dontflash="!!! AN ERROR OCCURED! Please DO NOT flash if injection failed. !!!"
-vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_BLOBS_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
+vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_FILES_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
vguide="https://libreboot.org/docs/install/ivy_has_common.html"
tmpromdel="$PWD/tmp/DO_NOT_FLASH"
@@ -33,7 +33,8 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref FSPFD_hash \
_7ztest ME11bootguard ME11delta ME11version ME11sku ME11pch tmpromdir \
IFD_platform ifdprefix cdir sdir _me _metmp mfs TBFW_url_bkup TBFW_url \
- TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup need_files $cv`"
+ TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup need_files \
+ vfile $cv`"
vendor_download()
{
@@ -65,7 +66,7 @@ readkconfig()
CONFIG_LENOVO_TBFW_BIN CONFIG_FSP_M_FILE CONFIG_FSP_S_FILE; do
eval "[ \"\${$c}\" = \"/dev/null\" ] && continue"
eval "[ -z \"\${$c}\" ] && continue"
- eval "`setcfg "config/vendor/$vcfg/pkg.cfg"`"; return 0
+ eval "`setcfg "$vfile"`"; return 0
done
printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1
}
@@ -348,18 +349,40 @@ vendor_inject()
set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash"
eval "`setvars "" nukemode new_mac xchanged`"
+ # randomise the MAC address by default
+ # TODO: support setting CBFS MAC address for GA-G41M-ES2L
+ new_mac="??:??:??:??:??:??"
+
archive="$1";
[ $# -gt 1 ] && case "$2" in
- nuke) nukemode="nuke" ;;
+ nuke)
+ new_mac=""
+ nukemode="nuke" ;;
setmac)
- new_mac="??:??:??:??:??:??"
- [ $# -gt 2 ] && new_mac="$3" ;;
+ [ $# -gt 2 ] && new_mac="$3" && \
+ [ -z "$new_mac" ] && $err \
+ "You set an empty MAC address string" ;;
*) $err "Unrecognised inject mode: '$2'"
esac
+ # allow the user to skip setting MAC addresses.
+ # if new_mac is empty, this script skips running nvmutil
+ [ "$new_mac" = "keep" ] && new_mac=""
+
+ # we don't allow the *user* to clear new_mac, in the setmac
+ # command, in case the build system is being integrated with
+ # another, where setmac is relied upon and is being set
+ # explicitly. this is a preventative error handle, as a courtes
+ # to that hypothetical user e.g. Linux distro package maintainer
+ # integrating this build system into their distro. if they used
+ # a variable for that, and they forgot to initialise it, they'll know.
+
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"
@@ -387,6 +410,10 @@ vendor_inject()
&& printf "DO NOT flash images from '%s'\n" \
"$archive" 1>&2
+ [ "$need_files" = "n" ] && printf \
+ "Board '%s' doesn't use vendorfiles, so none were inserted.\n" \
+ "$board"
+
#
# catch-all error handler, for libreboot release opsec:
#
@@ -441,6 +468,9 @@ readcfg()
x_ ./mk -d coreboot "$tree" # even if vendorfiles not used, see: setmac
[ -z "$vcfg" ] && return 1
+ vfile="config/vendor/$vcfg/pkg.cfg"
+ [ -L "$vfile" ] && $err "'$archive', '$board': $vfile is a symlink"
+ [ -f "$vfile" ] || $err "'$archive', '$board': $vfile doesn't exist"
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
@@ -508,6 +538,8 @@ patch_release_roms()
1>&2
printf "This board probably lacks Intel ethernet.\n" \
1>&2
+ printf "(or it's pre-IFD Intel with Intel GbE NIC)\n" \
+ 1>&2
fi
fi
@@ -689,7 +721,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"
@@ -698,7 +732,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"
@@ -713,4 +748,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##*../}"; :
}