summaryrefslogtreecommitdiff
path: root/include/inject.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-09-10 12:29:39 +0100
committerLeah Rowe <leah@libreboot.org>2026-09-10 12:34:35 +0100
commitafdf8c7733f81ca196c70a40566ec75111c31c33 (patch)
treea4671c68d72cbf9ecc58b3f08d89aa8c8f2c7d21 /include/inject.sh
parent123639e3db0757fb3370516f7eaf50cbfae4d026 (diff)
Revert "xbmk: general code cleanup"
This reverts commit 1b65e8914c4ad1e140b573fa6bc8feead14542ad. NOTE: cleanup of xbmk_git_init was retained this "cleanup" actually made the code harder to read. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/inject.sh')
-rw-r--r--include/inject.sh61
1 files changed, 2 insertions, 59 deletions
diff --git a/include/inject.sh b/include/inject.sh
index 53128995..783e06ed 100644
--- a/include/inject.sh
+++ b/include/inject.sh
@@ -10,14 +10,10 @@ nvmutil="util/nvmutil/nvmutil"
ifdtool="elf/coreboot/default/ifdtool"
checkvars="CONFIG_GBE_BIN_PATH"
-
if [ -n "$checkvarsxbmk" ]; then
-
checkvars="$checkvars $checkvarsxbmk"
fi
-
if [ -n "$checkvarschk" ]; then
-
checkvars="$checkvars $checkvarschk"
fi
@@ -38,7 +34,6 @@ inject()
remkdir "$tmpromdel"
if [ $# -lt 1 ]; then
-
err "No options specified" "inject" "$@"
fi
@@ -49,57 +44,39 @@ inject()
xchanged=""
[ $# -gt 1 ] && case "$2" in
-
nuke)
-
new_mac=""
nuke="nuke"
;;
-
setmac)
-
if [ $# -gt 2 ]; then
-
new_mac="$3" && \
-
if [ -z "$new_mac" ]; then
-
err "Empty MAC address specified" "inject" "$@"
fi
fi
;;
-
*)
-
err "Unrecognised inject mode: '$2'" "inject" "$@" ;;
esac
if [ "$new_mac" = "keep" ]; then
-
new_mac=""
fi
check_release
-
if check_target; then
-
if ! patch_release; then
-
return 0
fi
fi
-
if [ "$xchanged" = "y" ]; then
-
remktar
fi
if [ "$xchanged" = "y" ]; then
-
printf "\n'%s' was modified\n" "$archive" 1>&2
-
else
-
printf "\n'%s' was NOT modified\n" "$archive" 1>&2
fi
@@ -109,12 +86,9 @@ inject()
check_release()
{
if [ -L "$archive" ]; then
-
err "'$archive' is a symlink" "check_release" "$@"
fi
-
if e "$archive" f missing; then
-
err "'$archive' missing" "check_release" "$@"
fi
@@ -122,39 +96,28 @@ check_release()
|| err "can't get '$archive' name" "check_release" "$@"
if [ -z "$archivename" ]; then
-
err "Can't determine archive name" "check_release" "$@"
fi
case "$archivename" in
-
*_src.tar.xz)
-
err "'$archive' is a src archive!" "check_release" "$@"
;;
-
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
-
err "'$archive' is a ROM image" "check_release" "$@"
;;
-
*.tar.xz) _stripped_prefix="${archivename#*_}"
-
board="${_stripped_prefix%.tar.xz}"
;;
-
*)
-
err "'$archive': cannot detect board" "check_release" "$@"
;;
-
esac; :
}
check_target()
{
if [ "$board" != "${board#serprog_}" ]; then
-
return 1
fi
@@ -164,7 +127,6 @@ check_target()
err "Can't read '$boarddir/target.cfg'" "check_target" "$@"
if [ -z "$tree" ]; then
-
err "tree unset in '$boarddir/target.cfg'" "check_target" "$@"
fi
@@ -173,7 +135,6 @@ check_target()
ifdtool="elf/coreboot/$tree/ifdtool"
if [ -n "$IFD_platform" ]; then
-
ifdprefix="-p $IFD_platform"
fi
}
@@ -181,7 +142,6 @@ check_target()
patch_release()
{
if [ "$nuke" != "nuke" ]; then
-
x_ ./mk download "$board"
fi
@@ -189,13 +149,10 @@ patch_release()
tmpromdir="$tmpromdel/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
-
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in "vendorhashes" "blobhashes"; do
-
if e "$tmpromdir/$_hashes" f; then
-
has_hashes="y"
hashfile="$_hashes"
@@ -204,12 +161,8 @@ patch_release()
done
if ! readkconfig; then
-
return 1
-
- elif [ -n "$new_mac" ] && \
- [ -n "$CONFIG_GBE_BIN_PATH" ]; then
-
+ elif [ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ]; then
modify_mac
fi
}
@@ -221,7 +174,6 @@ readkconfig()
fx_ scankconfig x_ find "$boarddir/config" -type f
if e "$xbtmp/cbcfg" f missing; then
-
return 1
fi
@@ -229,7 +181,6 @@ readkconfig()
err "Can't read '$xbtmp/cbcfg'" "readkconfig" "$@"
if ! setvfile "$@"; then
-
return 1
fi
}
@@ -237,7 +188,6 @@ readkconfig()
scankconfig()
{
for cbc in $checkvars; do
-
grep "$cbc" "$1" 2>/dev/null 1>>"$xbtmp/cbcfg" || :
done
}
@@ -246,11 +196,8 @@ modify_mac()
{
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbtmp/gbe"
- if [ -n "$new_mac" ] && \
- [ "$new_mac" != "restore" ]; then
-
+ if [ -n "$new_mac" ] && [ "$new_mac" != "restore" ]; then
x_ make -C util/nvmutil clean
-
x_ make -C util/nvmutil
x_ "$nvmutil" "$xbtmp/gbe" setmac "$new_mac"
@@ -259,16 +206,13 @@ modify_mac()
fx_ newmac x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
printf "\nThe following GbE NVM data will be written:\n"
-
x_ "$nvmutil" "$xbtmp/gbe" dump | grep -v "bytes read from file" || :
}
newmac()
{
if e "$1" f; then
-
xchanged="y"
-
x_ "$ifdtool" $ifdprefix -i GbE:"$xbtmp/gbe" "$1" -O "$1"
fi
}
@@ -279,7 +223,6 @@ remktar()
x_ cd "${tmpromdir%"/bin/$board"}"
printf "Re-building tar archive (please wait)\n"
-
mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'" "remktar" "$@"