diff options
-rw-r--r-- | include/git.sh | 50 | ||||
-rw-r--r-- | include/inject.sh | 5 | ||||
-rw-r--r-- | include/lib.sh | 63 | ||||
-rw-r--r-- | include/mrc.sh | 3 | ||||
-rw-r--r-- | include/release.sh | 3 | ||||
-rw-r--r-- | include/tree.sh | 6 | ||||
-rw-r--r-- | include/vendor.sh | 38 | ||||
-rwxr-xr-x | mk | 2 |
8 files changed, 76 insertions, 94 deletions
diff --git a/include/git.sh b/include/git.sh index bbc5140e..b65bd196 100644 --- a/include/git.sh +++ b/include/git.sh @@ -87,6 +87,56 @@ fetch_submodule() "$mdir/${1##*/}/patches" } +# can grab from the internet, or copy locally. +# if copying locally, it can only copy a file. +xbmkget() +{ + _dlop="curl" && [ $# -gt 4 ] && _dlop="$5" + x_ mkdir -p "${3%/*}" "$XBMK_CACHE/file" + for url in "$1" "$2"; do + [ -n "$url" ] && try_file "$url" "$_dlop" "$@" && return 0 + done && err "$1 $2 $3 $4: not downloaded"; : +} + +try_file() +{ + cached="$XBMK_CACHE/file/$6" + dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum + bad_checksum "$6" "$cached" 2>/dev/null && dl_fail="y" + [ "$dl_fail" = "n" ] && e "$5" f && return 0 + + x_ rm -f "$cached" + [ "$2" = "curl" ] || [ "$2" = "copy" ] || \ + err "$3 $4 $5 $6: Unsupported dlop type: '$2'" + + try_$2 "$cached" "$@" || return 1 + + bad_checksum "$6" "$cached" && return 1 + [ "$cached" = "$5" ] || x_ cp "$cached" "$5"; : +} + +try_curl() +{ + _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" + curl --location --retry 3 -A "$_ua" "$2" -o "$1" || \ + wget --tries 3 -U "$_ua" "$2" -O "$1" || return 1; : +} + +try_copy() +{ + [ -L "$2" ] && printf "dl %s %s %s %s: '%s' is a symlink\n" \ + "$4" "$5" "$6" "$7" "$2" 1>&2 && return 1 + [ ! -f "$2" ] && printf "dl %s %s %s %s: '%s' not a file\n" \ + "$4" "$5" "$6" "$7" "$2" 1>&2 && return 1 + cp "$2" "$1" || return 1; : +} + +bad_checksum() +{ + [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1 + printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; : +} + tmpclone() { [ -d "$3" ] && return 0 diff --git a/include/inject.sh b/include/inject.sh index 890ac275..d4d20568 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -4,7 +4,6 @@ # Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org> cbcfgsdir="config/coreboot" -hashfiles="vendorhashes blobhashes" # blobhashes for backwards compatibility tmpromdel="$XBMK_CACHE/DO_NOT_FLASH" nvm="util/nvmutil/nvm" ifdtool="elf/ifdtool/default/ifdtool" @@ -14,7 +13,7 @@ cv="CONFIG_GBE_BIN_PATH" [ -n "$cvchk" ] && cv="$cv $cvchk" eval "`setvars "" archive boarddir IFD_platform ifdprefix tree new_mac \ - tmpromdir board $cv`" + tmpromdir board xchanged $cv`" inject() { @@ -92,7 +91,7 @@ patch_release() remkdir "${tmpromdir%"/bin/$board"}" x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}" - for _hashes in $hashfiles; do + for _hashes in "vendorhashes" "blobhashes"; do e "$tmpromdir/$_hashes" f && \ has_hashes="y" && hashfile="$_hashes" && break; : done diff --git a/include/lib.sh b/include/lib.sh index c69825e8..cb3ba6cc 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -29,61 +29,10 @@ mktarball() x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || err "mktarball2, $1" } -mksha512sum() -{ - ( - [ "${1%/*}" != "$1" ] && x_ cd "${1%/*}" - sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\"" - ) || err "failed to create tarball checksum" -} - rmgit() { - x_ find "$1" -name ".git" -exec rm -Rf {} + - x_ find "$1" -name ".gitmodules" -exec rm -Rf {} + -} - -# can grab from the internet, or copy locally. -# if copying locally, it can only copy a file. -xbmkget() -{ - _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" - - _dlop="curl" && [ $# -gt 4 ] && _dlop="$5" - x_ mkdir -p "${3%/*}" "$XBMK_CACHE/file" - for url in "$1" "$2"; do - [ -n "$url" ] && try_file "$url" "$_dlop" "$@" && return 0 - done && err "$1 $2 $3 $4: not downloaded"; : -} - -try_file() -{ - cached="$XBMK_CACHE/file/$6" - dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum - bad_checksum "$6" "$cached" 2>/dev/null && dl_fail="y" - [ "$dl_fail" = "n" ] && e "$5" f && return 0 - - x_ rm -f "$cached" - if [ "$2" = "curl" ]; then - curl --location --retry 3 -A "$_ua" "$1" -o "$cached" || \ - wget --tries 3 -U "$_ua" "$1" -O "$cached" || return 1 - elif [ "$2" = "copy" ]; then - [ -L "$1" ] && printf "dl %s %s %s %s: '%s' is a symlink\n" \ - "$3" "$4" "$5" "$6" "$1" 1>&2 && return 1 - [ ! -f "$1" ] && printf "dl %s %s %s %s: '%s' not a file\n" \ - "$3" "$4" "$5" "$6" "$1" 1>&2 && return 1 - cp "$1" "$cached" || return 1 - else - err "$3 $4 $5 $6: Unsupported dlop type: '$2'" - fi - bad_checksum "$6" "$cached" && return 1 - [ "$cached" = "$5" ] || x_ cp "$cached" "$5"; : -} - -bad_checksum() -{ - [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1 - printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; : + fx_ "x_ rm -Rf" x_ find "$1" -name ".git" + fx_ "x_ rm -Rf" x_ find "$1" -name ".gitmodules" } e() @@ -97,14 +46,6 @@ e() printf "%s %s\n" "$1" "$es2" 1>&2 } -mk() -{ - mk_flag="$1" || err "No argument given" - shift 1 && for mk_arg in "$@"; do - x_ ./mk $mk_flag $mk_arg - done; : -} - setvars() { _setvars="" diff --git a/include/mrc.sh b/include/mrc.sh index 3b3089fc..70c3bd3c 100644 --- a/include/mrc.sh +++ b/include/mrc.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only # Logic based on util/chromeos/crosfirmware.sh in coreboot cfc26ce278. -# Modifications in this version are Copyright 2021, 2023 and 2024 Leah Rowe. +# Modifications in this version are Copyright 2021,2023-2025 Leah Rowe. # Original copyright detailed in repo: https://review.coreboot.org/coreboot/ eval "`setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL`" @@ -9,7 +9,6 @@ eval "`setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL`" extract_mrc() { extract_shellball - x_ "$cbfstool" "$appdir/"bios.bin extract -n mrc.bin \ -f "$_dest" -r RO_SECTION diff --git a/include/release.sh b/include/release.sh index 4741b44a..0afb777f 100644 --- a/include/release.sh +++ b/include/release.sh @@ -55,7 +55,8 @@ build_release() ( x_ cd "$relsrcdir" x_ ./mk -d coreboot - mk -b coreboot pico-serprog stm32-vserprog pcsx-redux + fx_ "x_ ./mk -b" printf \ + "coreboot\npico-serprog\nstm32-vserprog\npcsx-redux\n" fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*" x_ mv bin ../roms diff --git a/include/tree.sh b/include/tree.sh index d4585b92..f44b39cc 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -39,13 +39,11 @@ trees() fi project="${OPTARG#src/}" + project="${project#config/git/}" shift 2 done [ -z "$_f" ] && err "missing flag ($flags)" - if [ -z "$project" ]; then - mk $_f $(ls -1 config/git) - return 1 - fi + [ -z "$project" ] && fx_ "x_ ./mk $_f" x_ ls -1 config/git && return 1 [ -f "config/git/$project/pkg.cfg" ] || \ err "config/git/$project/pkg.cfg missing" diff --git a/include/vendor.sh b/include/vendor.sh index 89e352a7..fb49cca5 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -39,8 +39,8 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ 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 \ nukemode cbfstoolref FSPFD_hash _7ztest ME11bootguard ME11delta xromsize \ - ME11version ME11sku ME11pch _me _metmp mfs TBFW_url_bkup TBFW_url vfile \ - TBFW_hash TBFW_size hashfile xchanged EC_url_bkup cbdir`" + ME11version ME11sku ME11pch _me _metmp mfs TBFW_url_bkup TBFW_url cbdir \ + TBFW_hash TBFW_size hashfile EC_url_bkup`" download() { @@ -215,30 +215,16 @@ extract_fsp() setvfile() { - [ -n "$vcfg" ] && check_vcfg && for c in $cvchk; do - eval "[ \"\${$c}\" = \"/dev/null\" ] && continue" - eval "[ -z \"\${$c}\" ] && continue" - getvfile "$@" && return 0 + [ -n "$vcfg" ] && for c in $cvchk; do + vcmd="[ \"\${$c}\" != \"/dev/null\" ] && [ -n \"\${$c}\" ]" + eval "$vcmd && getvfile \"\$@\" && return 0" done && return 1; : } -check_vcfg() -{ - vfile="config/vendor/$vcfg/pkg.cfg" - [ -L "$vfile" ] && err "'$archive', '$board': $vfile is a symlink"; : - [ -f "$vfile" ] || err "'$archive', '$board': $vfile missing"; : -} - getvfile() { - # valid vcfg. proceed to download files - eval "`setcfg "$vfile"`" - - bootstrap - - [ $# -gt 0 ] && getfiles - [ $# -gt 0 ] && return 0 # download - + eval "`setcfg "config/vendor/$vcfg/pkg.cfg" 1`" + bootstrap && [ $# -gt 0 ] && getfiles && return 0 # download fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" ( check_vendor_hashes ) || err "$archive: Can't verify hashes"; : } @@ -252,7 +238,7 @@ bootstrap() rmodtool="elf/cbfstool/$tree/rmodtool" x_ ./mk -f coreboot "${cbdir##*/}" - mk -b uefitool biosutilities bios_extract + fx_ "x_ ./mk -b" printf "uefitool\nbiosutilities\nbios_extract\n" [ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126" [ -n "$MRC_refcode_cbtree" ] && \ cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \ @@ -291,6 +277,14 @@ prep() x_ rm -f "$_xrom" } +mksha512sum() +{ + ( + [ "${1%/*}" != "$1" ] && x_ cd "${1%/*}" + sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\"" + ) || err "failed to create tarball checksum" +} + add_vfiles() { rom="$1" @@ -17,6 +17,7 @@ fi . "include/mrc.sh" . "include/rom.sh" . "include/release.sh" +. "include/git.sh" main() { @@ -34,7 +35,6 @@ main() main "$@" || exit 0 -. "include/git.sh" . "include/tree.sh" trees "$@" || exit 0 |