From 72f4412a52df60bd2d3f01a4c8dc138334ffe434 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 13:15:40 +0100 Subject: inject.sh: simplified fsp extraction we know that _dest is always what's set in the coreboot config, without the ../../../ in it, so just copy both files in a single function, and call the function twice. if both files are done on the first call, the second call will be skipped. if only the first file was done on the first call, running the download script again will skip the first one, and grab the second one. this also avoids having to run the decat function twice, in most cases, so it's a tiny optimisation. this optimisation only works if both fsp files (s and m) are to be extracted into the same directory, which is the case anyway, and this will always be the case. Signed-off-by: Leah Rowe --- include/inject.sh | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/inject.sh b/include/inject.sh index b0f3f502..a9d1350a 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -95,9 +95,9 @@ getfiles() # therefore, handle them separately, in case one of them is libre; if # one of them was, the path wouldn't be set. # - [ -z "$CONFIG_FSP_M_FILE" ] || fetch "fspm" "$CONFIG_FSP_FD_PATH" \ + [ -z "$CONFIG_FSP_M_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ "$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_M_FILE" copy - [ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsps" "$CONFIG_FSP_FD_PATH" \ + [ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ "$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_S_FILE" copy; : } @@ -111,14 +111,12 @@ fetch() [ "$5" = "/dev/null" ] && return 0 _dl="$XBMK_CACHE/file/$dlsum" - if [ "$dl_type" = "fspm" ] || [ "$dl_type" = "fsps" ]; then - # HACK: if grabbing fsp from coreboot, fix the path for lbmk - for _cdl in dl dl_bkup; do - eval "$_cdl=\"\${$_cdl##*../}\"; _cdp=\"\$$_cdl\"" - [ -f "$_cdp" ] || _cdp="$cbdir/$_cdp" - [ -f "$_cdp" ] && eval "$_cdl=\"$_cdp\"" - done - fi + # HACK: if grabbing fsp from coreboot, fix the path for lbmk + [ "$dl_type" = "fsp" ] && for _cdl in dl dl_bkup; do + eval "$_cdl=\"\${$_cdl##*../}\"; _cdp=\"\$$_cdl\"" + [ -f "$_cdp" ] || _cdp="$cbdir/$_cdp" + [ -f "$_cdp" ] && eval "$_cdl=\"$_cdp\"" + done; : dlop="curl" && [ $# -gt 5 ] && dlop="$6" xbmkget "$dl" "$dl_bkup" "$_dl" "$dlsum" "$dlop" @@ -205,12 +203,9 @@ apply_me11_deguard_mod() extract_archive() { - if [ $# -gt 2 ]; then - if [ "$3" = "fspm" ] || [ "$3" = "fsps" ]; then - decat_fspfd "$1" "$2" - return 0 - fi - fi + [ $# -gt 2 ] && [ "$3" = "fsp" ] && x_ python \ + "$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" split -f "$1" -o "$2" \ + -n "Fsp.fd" && return 0 innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x \ "$1" -o"$2" || unar "$1" -o "$2" || unzip "$1" -d "$2" || return 1 @@ -219,15 +214,6 @@ extract_archive() $err "!mv '${_dl}_extracted' '$2' - $dontflash"; : } -decat_fspfd() -{ - _fspfd="$1" - _fspdir="$2" - _fspsplit="$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" - - x_ $python "$_fspsplit" split -f "$_fspfd" -o "$_fspdir" -n "Fsp.fd" -} - extract_kbc1126ec() { x_ e "$kbc1126_ec_dump" f @@ -294,20 +280,9 @@ copy_tbfw() return 1 } -extract_fspm() -{ - copy_fsp M; : -} - -extract_fsps() -{ - copy_fsp S; : -} - -# this copies the fsp s/m; re-base is handled by ./mk inject -copy_fsp() +extract_fsp() { - x_ cp "$appdir/Fsp_$1.fd" "$_dest" + x_ cp "$appdir/"Fsp_*.fd "${_dest%/*}" } fail_inject() -- cgit v1.2.1