diff options
Diffstat (limited to 'include/get.sh')
-rw-r--r-- | include/get.sh | 82 |
1 files changed, 68 insertions, 14 deletions
diff --git a/include/get.sh b/include/get.sh index 9b1c69b4..3c30b6d3 100644 --- a/include/get.sh +++ b/include/get.sh @@ -3,8 +3,15 @@ # Copyright (c) 2020-2021,2023-2025 Leah Rowe <leah@libreboot.org> # Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com> -eval "`setvars "" loc url bkup_url subcurl subhash subgit subgit_bkup \ - depend subcurl_bkup`" +depend="" +loc="" +url="" +bkup_url="" +subgit="" +subgit_bkup="" +subcurl="" +subcurl_bkup="" +subhash="" tmpgit="$xbtmp/gitclone" tmpgitcache="$xbtmp/tmpgit" @@ -20,14 +27,19 @@ fetch_targets() fetch_project() { - xtree="" + xgcctree="" - eval "`setcfg "config/git/$project/pkg.cfg"`" + . "config/git/$project/pkg.cfg" || \ + err "Can't read config 'config/git/$project/pkg.cfg'" \ + "fetch_project" "@" - chkvars url bkup_url + if [ -z "$url" ] || [ -z "$bkup_url" ]; then + err "url/bkup_url not both set 'config/git/$project/pkg.cfg'" \ + "fetch_project" "$@" + fi - if [ -n "$xtree" ]; then - x_ ./mk -f coreboot "$xtree" + if [ -n "$xgcctree" ]; then + x_ ./mk -f coreboot "$xgcctree" fi if [ -n "$depend" ]; then for d in $depend ; do @@ -59,7 +71,9 @@ git_prep() _patchdir="$3" _loc="$4" # $1 and $2 are gitrepo and gitrepo_backup - chkvars rev + if [ -z "$rev" ]; then + err "$project/$tree: rev not set" "git_prep" "$@" + fi xbget git "$1" "$2" "$tmpgit" "$rev" "$_patchdir" if singletree "$project" || [ $# -gt 4 ]; then @@ -76,10 +90,18 @@ fetch_submodule() { mcfgdir="$mdir/${1##*/}" - eval \ - "`setvars "" subhash subgit subgit_bkup subcurl subcurl_bkup st`" + subhash="" + subgit="" + subgit_bkup="" + subcurl="" + subcurl_bkup="" + st="" - eval "`setcfg "$mcfgdir/module.cfg" 0`" + if e "$mcfgdir/module.cfg" f missing; then + return 0 + fi + . "$mcfgdir/module.cfg" || \ + err "Can't read '$mcfgdir/module.cfg'" "fetch_submodules" "$@" if [ -n "$subgit" ] || [ -n "$subgit_bkup" ]; then st="$st git" @@ -97,7 +119,16 @@ fetch_submodule() return 0 fi - chkvars "sub${st}" "sub${st}_bkup" "subhash" + if [ "$st" = "curl" ]; then + if [ -z "$subcurl" ] || [ -z "$subcurl_bkup" ]; then + err "subcurl/subcurl_bkup not both set" \ + "fetch_submodule" "$@" + fi + elif [ -z "$subgit" ] || [ -z "$subgit_bkup" ]; then + err "subgit/subgit_bkup not both set" "fetch_submodule" "$@" + elif [ -z "$subhash" ]; then + err "subhash not set" "fetch_submodule" "$@" + fi if [ "$st" = "git" ]; then x_ rm -Rf "$tmpgit/$1" @@ -212,6 +243,7 @@ try_fetch_file() return 1 elif bad_checksum "$6" "$cached"; then x_ rm -f "$cached" + return 1 fi @@ -221,6 +253,7 @@ try_fetch_file() if bad_checksum "$6" "$5"; then x_ rm -f "$5" + return 1 elif [ ! -f "$5" ]; then return 1 @@ -280,7 +313,8 @@ bad_checksum() return 0 fi - csum="$(x_ sha512sum "$2" | awk '{print $1}')" || \ + build_sbase + csum="$(x_ "$sha512sum" "$2" | awk '{print $1}')" || \ err "!sha512 '$2' $1" bad_checksum "$@" if [ "$csum" = "$1" ]; then @@ -295,5 +329,25 @@ tmpclone() { ( x_ git clone "$1" "$2" ) || return 1 ( x_ git -C "$2" reset --hard "$3" ) || return 1 - ( fx_ "eval x_ git -C \"$2\" am" find "$4" -type f ) || return 1; : + + if [ ! -d "$4" ]; then + return 0 + fi + + tmpclone_patchlist="`mktemp || err "Can't create tmp patch list"`" || \ + err "Can't create tmp patch list" "tmpclone" "$@" + + x_ find "$4" -type f | sort > "$tmpclone_patchlist" || \ + err "Can't write patch names to '$tmpclone_patchlist'" \ + "tmpclone" "$@" + + while read -r tmpclone_patch; do + + ( x_ git -C "$2" am "$tmpclone_patch" ) || \ + err "Can't apply '$tmpclone_patch'" "tmpclone" "$@"; : + + done < "$tmpclone_patchlist" || \ + err "Can't read '$tmpclone_patchlist'" "tmpclone" "$@" + + x_ rm -f "$tmpclone_patchlist" } |