inject.sh: bring in sync with lbmk 0f931b508a8
see lbmk commit: 0f931b508a8eb34e70b2ed3628ac4fe74f22b8e8 from 10 May 2025 The lbmk version of inject.sh also contained logic to download vendor files, which cbmk doesn't and won't support. This made merging patches between the two projects harder, so lbmk's version has been modified to mostly only include the MAC address related code on inject.sh, just like the Canoeboot one. On lbmk, extra functionality for vendor files is now provided on include/vendor.sh, which cbmk lacks (and will never have). With a few minor alterations, this script is now very much in sync with the lbmk version. In fact, just to provide the point, here is the diff between lbmk's version of inject.sh, compared to the version in cbmk introduced by this commit. Observe: (< is a subtracted line, and > is an added line. So the < shows what was removed from lbmk's version when adding to cbmk, and the > lines show what cbmk added to its version). yes me cbmk$ colordiff ../lbmk/include/inject.sh include/inject.sh 89,90d88 < [ -n "$vcfg" ] && check_vcfg < 94,95d91 < mecleaner="$xbmkpwd/$cbdir/util/me_cleaner/me_cleaner.py" < kbc1126_ec_dump="$xbmkpwd/$cbdir/util/kbc1126/kbc1126_ec_dump" 103,104d98 < [ "$nukemode" = "nuke" ] || x_ ./mk download "$board" < 112,113c106,107 < e "$tmpromdir/$_hashes" f && \ < has_hashes="y" && hashfile="$_hashes" && break; : --- > e "$tmpromdir/$_hashes" f && err \ > "'$archive': vendorfile insertion unsupported" 118,120d111 < fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" < ( check_vendor_hashes ) || err "Can't verify hashes for '$archive'"; : < 129d119 < setvfile && return 1; : Signed-off-by: Leah Rowe <leah@libreboot.org>25.06_branch
parent
a170ab4118
commit
2acdfefdf9
|
@ -16,7 +16,7 @@ xbmkpath="$PATH"
|
|||
|
||||
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
|
||||
datadir version xbmkpwd relname xbmkpwd xbmktmp python pyver xbmklocal \
|
||||
xbmklock`"
|
||||
xbmklock cvxbmk cvchk`"
|
||||
|
||||
xbmk_init()
|
||||
{
|
||||
|
|
|
@ -4,68 +4,81 @@
|
|||
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
|
||||
|
||||
cbcfgsdir="config/coreboot"
|
||||
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 !!!"
|
||||
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_FILES_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
|
||||
tmpromdel="$xbmklocal/DO_NOT_FLASH"
|
||||
nvm="util/nvmutil/nvm"
|
||||
ifdtool="elf/ifdtool/default/ifdtool"
|
||||
|
||||
cv="CONFIG_GBE_BIN_PATH"
|
||||
[ -n "$cvxbmk" ] && cv="$cv $cvxbmk"
|
||||
[ -n "$cvchk" ] && cv="$cv $cvchk"
|
||||
|
||||
eval "`setvars "" archive boarddir cbdir IFD_platform ifdprefix tree new_mac \
|
||||
tmpromdir $cv`"
|
||||
|
||||
inject()
|
||||
{
|
||||
remkdir "$tmpromdel"
|
||||
|
||||
set +u +e
|
||||
[ $# -lt 1 ] && err "No options specified. - $dontflash"
|
||||
eval "`setvars "" new_mac xchanged`"
|
||||
eval "`setvars "" nukemode new_mac xchanged`"
|
||||
|
||||
archive="$1";
|
||||
new_mac="xx:xx:xx:xx:xx:xx"
|
||||
|
||||
[ $# -gt 1 ] && case "$2" in
|
||||
nuke)
|
||||
new_mac=""
|
||||
nukemode="nuke" ;;
|
||||
setmac)
|
||||
[ $# -gt 2 ] && new_mac="$3" && \
|
||||
[ -z "$new_mac" ] && err "Empty MAC address specified" ;;
|
||||
*) err "Unrecognised inject mode: '$2'"
|
||||
*)
|
||||
err "Unrecognised inject mode: '$2'"
|
||||
esac
|
||||
[ "$new_mac" = "keep" ] && new_mac=""
|
||||
|
||||
[ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \
|
||||
x_ make -C util/nvmutil clean && x_ make -C util/nvmutil
|
||||
|
||||
check_release "$archive" || err "'$archive' is not a release archive"
|
||||
check_release
|
||||
check_target && patch_release
|
||||
|
||||
if readcfg && readkconfig; then
|
||||
patch_release_roms
|
||||
fi
|
||||
[ "$xchanged" = "y" ] && remktar
|
||||
|
||||
[ "$xchanged" != "y" ] && printf "\n'%s' *NOT* modified.\n" "$archive"
|
||||
[ "$xchanged" = "y" ] && printf "\n'%s' %s.\n" "$archive" "$xtype"; :
|
||||
xnot=" NOT" && [ "$xchanged" = "y" ] && xnot=""
|
||||
printf "\n'%s' was%s modified\n" "$archive" "$xnot" 1>&2
|
||||
|
||||
x_ rm -Rf "$tmpromdel"
|
||||
}
|
||||
|
||||
check_release()
|
||||
{
|
||||
[ -L "$archive" ] && err "'$archive' is a symlink. $dontflash"
|
||||
e "$archive" f missing && return 1
|
||||
e "$archive" f missing && err "'$archive' missing"
|
||||
|
||||
archivename="`basename "$archive"`"
|
||||
archivename="`basename "$archive"`" || err "Can't get '$archive' name"
|
||||
[ -z "$archivename" ] && err "Can't determine archive name. $dontflash"
|
||||
|
||||
case "$archivename" in
|
||||
*_src.tar.xz)
|
||||
err "'$archive' is a src archive, silly!" ;;
|
||||
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
|
||||
return 1 ;;
|
||||
err "'$archive' is a ROM image (it must be a tarball)" ;;
|
||||
*.tar.xz) _stripped_prefix="${archivename#*_}"
|
||||
board="${_stripped_prefix%.tar.xz}" ;;
|
||||
*) err "'$archive': could not detect board type - $dontflash"
|
||||
*)
|
||||
err "'$archive': could not detect board type - $dontflash"
|
||||
esac; :
|
||||
}
|
||||
|
||||
readcfg()
|
||||
check_target()
|
||||
{
|
||||
if [ "$board" = "serprog_rp2040" ] || [ "$board" = "serprog_stm32" ] \
|
||||
|| [ "$board" = "serprog_pico" ]; then
|
||||
printf "'%s' is a serprog firmware archive.\n" "$archive" 1>&2
|
||||
return 1
|
||||
fi
|
||||
boarddir="$cbcfgsdir/$board"
|
||||
|
@ -81,6 +94,24 @@ readcfg()
|
|||
[ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"; :
|
||||
}
|
||||
|
||||
patch_release()
|
||||
{
|
||||
has_hashes="n"
|
||||
tmpromdir="$xbmklocal/DO_NOT_FLASH/bin/$board"
|
||||
|
||||
remkdir "${tmpromdir%"/bin/$board"}"
|
||||
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
|
||||
|
||||
for _hashes in $hashfiles; do
|
||||
e "$tmpromdir/$_hashes" f && err \
|
||||
"'$archive': vendorfile insertion unsupported"
|
||||
done
|
||||
|
||||
readkconfig || exit 0
|
||||
|
||||
[ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ] && modify_mac; :
|
||||
}
|
||||
|
||||
readkconfig()
|
||||
{
|
||||
x_ rm -f "$xbmktmp/cbcfg"
|
||||
|
@ -95,31 +126,6 @@ scankconfig()
|
|||
done
|
||||
}
|
||||
|
||||
patch_release_roms()
|
||||
{
|
||||
tmpromdir="$xbmklocal/DO_NOT_FLASH/bin/$board"
|
||||
|
||||
remkdir "${tmpromdir%"/bin/$board"}"
|
||||
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
|
||||
|
||||
for _hashes in $hashfiles; do
|
||||
e "$tmpromdir/$_hashes" f && err \
|
||||
"'$archive': vendorfile insertion unsupported; $dontflash"
|
||||
done
|
||||
|
||||
[ -z "$new_mac" ] || [ -z "$CONFIG_GBE_BIN_PATH" ] || modify_mac
|
||||
|
||||
[ "$xchanged" = "y" ] || rm -Rf "$tmpromdel" || :
|
||||
[ "$xchanged" = "y" ] || return 0
|
||||
(
|
||||
x_ cd "${tmpromdir%"/bin/$board"}"
|
||||
mkrom_tarball "bin/$board"
|
||||
) || err "Cannot re-generate '$archive' - $dontflash"
|
||||
|
||||
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
|
||||
"$archive" || err "'$archive' -> Can't overwrite - $dontflash"; :
|
||||
}
|
||||
|
||||
modify_mac()
|
||||
{
|
||||
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbmklocal/gbe"
|
||||
|
@ -134,3 +140,14 @@ newmac()
|
|||
e "$1" f && xchanged="y" && x_ \
|
||||
"$ifdtool" $ifdprefix -i GbE:"$xbmklocal/gbe" "$1" -O "$1"; :
|
||||
}
|
||||
|
||||
remktar()
|
||||
{
|
||||
(
|
||||
x_ cd "${tmpromdir%"/bin/$board"}"
|
||||
mkrom_tarball "bin/$board"
|
||||
) || err "Cannot re-generate '$archive' - $dontflash"
|
||||
|
||||
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
|
||||
"$archive" || err "'$archive' -> Can't overwrite"; :
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue