From fb7aaa78bb080a473bdf0edf449bf08045e8366c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 20 May 2025 02:58:33 +0100 Subject: vendor.sh: optimise find_me() i'm adding characters to 7ztest, which isn't being passed on through because everything runs in subshells; the next pass would default back to the original string, so a given file may be checked multiple times. fix this by mitigation; use the random string from mktemp as a suffix instead. in practice, this has not affected performance much, but it will nevertheless avoid unnecessary work by xbmk. Signed-off-by: Leah Rowe --- include/vendor.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include/vendor.sh') diff --git a/include/vendor.sh b/include/vendor.sh index 2732eade..88c3fa04 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -38,7 +38,7 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest mecleaner \ kbc1126_ec_dump MRC_refcode_cbtree _dl SCH5545EC_DL_url EC_url rom DL_url \ - nuke cbfstoolref FSPFD_hash _7ztest ME11bootguard ME11delta xromsize \ + nuke cbfstoolref FSPFD_hash ME11bootguard ME11delta xromsize \ ME11version ME11sku ME11pch _me _metmp mfs TBFW_url_bkup TBFW_url cbdir \ TBFW_hash TBFW_size hashfile EC_url_bkup FSPM_bin_hash FSPS_bin_hash \ EC_FW1_hash EC_FW2_hash ME_bin_hash MRC_bin_hash REF_bin_hash _dl_bin \ @@ -156,7 +156,6 @@ extract_intel_me() { e "$mecleaner" f not && err "$cbdir: me_cleaner missing" - _7ztest="$xbmklocal/metmp/a" _metmp="$xbmklocal/me.bin" x_ rm -f "$_metmp" "$xbmklocal/a" @@ -165,7 +164,7 @@ extract_intel_me() [ "$ME11bootguard" = "y" ] && x_ ./mk -f deguard set +u +e - x_ rm -Rf "$xbmkpwd/metmp" + x_ rm -Rf "$xbmklocal/metmp" ( fx_ find_me x_ find "$xbmkpwd/$appdir" -type f ) || : [ "$ME11bootguard" != "y" ] && x_ mv "$_metmp" "$_pre_dest" && return 0 @@ -182,14 +181,19 @@ find_me() [ -f "$_metmp" ] && exit 1 [ -L "$1" ] && return 0 - _7ztest="${_7ztest}a" && _r="-r" && [ -n "$mfs" ] && _r="" + _7x="`mktemp`" || err "find_me: can't make tmp file" + x_ rm -f "$_7x" + _7x="$xbmklocal/metmp/${_7x##*/}" + + _r="-r" + [ -n "$mfs" ] && _r="" "$mecleaner" $mfs $_r -t -O "$xbmklocal/a" -M "$_metmp" "$1" || \ "$mecleaner" $mfs $_r -t -O "$_metmp" "$1" || "$me7updateparser" \ - -O "$_metmp" "$1" || extract_archive "$1" "$_7ztest" || return 0 + -O "$_metmp" "$1" || extract_archive "$1" "$_7x" || return 0 [ -f "$_metmp" ] && exit 1 - ( fx_ find_me x_ find "$_7ztest" -type f ) || exit 1; : + ( fx_ find_me x_ find "$_7x" -type f ) || exit 1; : } extract_archive() -- cgit v1.2.1 From f6b77822835fcd775a845c825a4e6a78abaa742a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 20 May 2025 20:14:09 +0100 Subject: Revert "vendor.sh: optimise find_me()" This reverts commit fb7aaa78bb080a473bdf0edf449bf08045e8366c. it caused a few issues. will re-do later the old code isn't really broken, just inefficient, because several files are scanned twice, but in practise the overhead isn't that great The error occurs sometimes, when bruteforcing me.bin: ERROR ./mk: Unhandled error for: mv /home/user/lbmk/tmp/me.bin /home/user/lbmk/cache/tmpdl/check This revert should fix the issue, for now. --- include/vendor.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'include/vendor.sh') diff --git a/include/vendor.sh b/include/vendor.sh index 88c3fa04..2732eade 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -38,7 +38,7 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest mecleaner \ kbc1126_ec_dump MRC_refcode_cbtree _dl SCH5545EC_DL_url EC_url rom DL_url \ - nuke cbfstoolref FSPFD_hash ME11bootguard ME11delta xromsize \ + nuke cbfstoolref FSPFD_hash _7ztest ME11bootguard ME11delta xromsize \ ME11version ME11sku ME11pch _me _metmp mfs TBFW_url_bkup TBFW_url cbdir \ TBFW_hash TBFW_size hashfile EC_url_bkup FSPM_bin_hash FSPS_bin_hash \ EC_FW1_hash EC_FW2_hash ME_bin_hash MRC_bin_hash REF_bin_hash _dl_bin \ @@ -156,6 +156,7 @@ extract_intel_me() { e "$mecleaner" f not && err "$cbdir: me_cleaner missing" + _7ztest="$xbmklocal/metmp/a" _metmp="$xbmklocal/me.bin" x_ rm -f "$_metmp" "$xbmklocal/a" @@ -164,7 +165,7 @@ extract_intel_me() [ "$ME11bootguard" = "y" ] && x_ ./mk -f deguard set +u +e - x_ rm -Rf "$xbmklocal/metmp" + x_ rm -Rf "$xbmkpwd/metmp" ( fx_ find_me x_ find "$xbmkpwd/$appdir" -type f ) || : [ "$ME11bootguard" != "y" ] && x_ mv "$_metmp" "$_pre_dest" && return 0 @@ -181,19 +182,14 @@ find_me() [ -f "$_metmp" ] && exit 1 [ -L "$1" ] && return 0 - _7x="`mktemp`" || err "find_me: can't make tmp file" - x_ rm -f "$_7x" - _7x="$xbmklocal/metmp/${_7x##*/}" - - _r="-r" - [ -n "$mfs" ] && _r="" + _7ztest="${_7ztest}a" && _r="-r" && [ -n "$mfs" ] && _r="" "$mecleaner" $mfs $_r -t -O "$xbmklocal/a" -M "$_metmp" "$1" || \ "$mecleaner" $mfs $_r -t -O "$_metmp" "$1" || "$me7updateparser" \ - -O "$_metmp" "$1" || extract_archive "$1" "$_7x" || return 0 + -O "$_metmp" "$1" || extract_archive "$1" "$_7ztest" || return 0 [ -f "$_metmp" ] && exit 1 - ( fx_ find_me x_ find "$_7x" -type f ) || exit 1; : + ( fx_ find_me x_ find "$_7ztest" -type f ) || exit 1; : } extract_archive() -- cgit v1.2.1 From f9266601b8c73daf36518c71db5e5c36080f3ddf Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 22 May 2025 11:27:22 +0100 Subject: vendor.sh: add colon at the end of a for loop Signed-off-by: Leah Rowe --- include/vendor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/vendor.sh') diff --git a/include/vendor.sh b/include/vendor.sh index 2732eade..99fc7467 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -107,7 +107,7 @@ fetch() [ "$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\"" + [ -f "$_cdp" ] && eval "$_cdl=\"$_cdp\""; : done; : # download the file (from the internet) to extract from -- cgit v1.2.1