vendor.sh: simplify inject()

Signed-off-by: Leah Rowe <leah@libreboot.org>
audit6
Leah Rowe 2024-06-28 23:44:47 +01:00
parent ee5bab2c9a
commit f7ab70f60e
1 changed files with 18 additions and 25 deletions

View File

@ -329,6 +329,8 @@ patch_release_roms()
patch_rom() patch_rom()
{ {
rom="$1"
. "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0 . "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0
[ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \ [ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \
@ -349,7 +351,7 @@ patch_rom()
inject "sch5545_ecfw.bin" "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw inject "sch5545_ecfw.bin" "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw
[ -n "$new_mac" ] && [ "$vrelease" != "y" ] && modify_gbe "$rom" [ -n "$new_mac" ] && [ "$vrelease" != "y" ] && modify_gbe "$rom"
printf "ROM image successfully patched: %s\n" "$1" printf "ROM image successfully patched: %s\n" "$rom"
} }
inject() inject()
@ -362,33 +364,24 @@ inject()
[ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \ [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \
$err "inject $@, $rom: offset passed, but empty (not defined)" $err "inject $@, $rom: offset passed, but empty (not defined)"
[ -z "$_dest" ] && $err "inject $@, $rom: empty destination path" e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type"
[ ! -f "$_dest" ] && [ "$nukemode" != "nuke" ] && \
$err "inject_$dl_type: file missing, $_dest"
if [ "$cbfsname" = "IFD" ]; then if [ "$cbfsname" = "IFD" ]; then
if [ "$nukemode" != "nuke" ]; then [ "$nukemode" = "nuke" ] || "$ifdtool" -i $_t:$_dest "$rom" \
"$ifdtool" -i $_t:$_dest "$rom" -O "$rom" || \ -O "$rom" || $err "failed: inject '$_t' '$_dest' on '$rom'"
$err "inject: can't insert $_t ($dest) into $rom" [ "$nukemode" != "nuke" ] || "$ifdtool" --nuke $_t "$rom" \
else -O "$rom" || $err "inject $rom: can't nuke $_t in IFD"
"$ifdtool" --nuke $_t "$rom" -O "$rom" || \ return 0
$err "inject $rom: can't nuke $_t in IFD"
fi fi
else if [ "$nukemode" = "nuke" ]; then
if [ "$nukemode" != "nuke" ]; then
if [ "$_t" = "stage" ]; then # broadwell refcode
"$cbfstool" "$rom" add-stage -f "$_dest" \
-n "$cbfsname" -t stage -c lzma
else
"$cbfstool" "$rom" add -f "$_dest" \
-n "$cbfsname" -t $_t $_offset || \
$err "$rom: can't insert $_t file $_dest"
fi
else
"$cbfstool" "$rom" remove -n "$cbfsname" || \ "$cbfstool" "$rom" remove -n "$cbfsname" || \
$err "inject $rom: can't remove $cbfsname" $err "inject $rom: can't remove $cbfsname"
return 0
fi fi
fi [ "$_t" != "stage" ] || "$cbfstool" "$rom" add-stage -f \
"$_dest" -n "$cbfsname" -t stage -c lzma || $err "$rom: !add ref"
[ "$_t" = "stage" ] || "$cbfstool" "$rom" add -f "$_dest" \
-n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"
} }
modify_gbe() modify_gbe()