summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-07-30 11:58:11 +0100
committerLeah Rowe <leah@libreboot.org>2026-07-30 11:58:11 +0100
commit1b65e8914c4ad1e140b573fa6bc8feead14542ad (patch)
treeeb2039c59c0d99ff39f9a548fc7c3efc61dfe87e /include
parent72238d22b508013c0d158746e82456c67ca96166 (diff)
xbmk: general code cleanupHEADmaster
make the code much easier to read i also cleaned up the recent git identity check Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/chromebook.sh12
-rw-r--r--include/get.sh109
-rw-r--r--include/init.sh173
-rw-r--r--include/inject.sh61
-rw-r--r--include/lib.sh59
-rw-r--r--include/mrc.sh9
-rw-r--r--include/release.sh29
-rw-r--r--include/rom.sh181
-rw-r--r--include/tree.sh223
-rw-r--r--include/vendor.sh224
10 files changed, 928 insertions, 152 deletions
diff --git a/include/chromebook.sh b/include/chromebook.sh
index 0b8b50f1..b67ebf0f 100644
--- a/include/chromebook.sh
+++ b/include/chromebook.sh
@@ -32,11 +32,13 @@ mr_edk2tree="chromebook" # tree name in xbmk
prep_mr_import()
{
if [ -f "$xbmkpwd/CHANGELOG" ]; then
+
err "Project import disabled on releases" "prep_mr_import" "$@"
fi
mr_tmpdir="`mktemp -d || err "can't make mrtmpdir"`" || \
err "can't make mrtmpdir" "prep_mr_coreboot" "$@"
+
x_ remkdir "$mr_tmpdir"
x_ prep_mx_edk2conf
@@ -64,6 +66,7 @@ prep_mr_projects()
{
x_ prep_mr "coreboot" "$mr_cbrepo" "$mr_cbbranch" "$mr_cbrev" \
"$mr_cbrevbase" "$mr_cbtree"
+
x_ prep_mr "edk2" "$mr_edk2repo" "$mr_edk2branch" "$mr_edk2rev" \
"$mr_edk2revbase" "$mr_edk2tree"
}
@@ -81,6 +84,7 @@ prep_mr()
x_ prep_mr_clone "$@"
x_ prep_mr_patch "$@"
+
x_ prep_mr_file "config/$1/$6/target.cfg" \
"$spdx" \
"" \
@@ -104,10 +108,13 @@ prep_mr_patch()
mx_patchdir="config/$1/$6/patches"
x_ remkdir "$mx_patchdir"
+
if [ "$4" != "$5" ]; then
+
x_ git -C "$mr_tmpclone" format-patch $5..$4
x_ mv "$mr_tmpclone"/*.patch "$mx_patchdir"
fi
+
# if no patches were created, rmdir will succeed
rmdir "$mx_patchdir" 1>/dev/null 2>/dev/null || :
}
@@ -119,10 +126,11 @@ prep_mr_file()
x_ rm -f "$mr_filename"
- while [ $# -gt 0 ]
- do
+ while [ $# -gt 0 ]; do
+
printf "%s\n" "$1" >> "$mr_filename" || \
err "Can't write '$1' to '$mr_filename'" prep_mr_file "$@"
+
shift 1
done
diff --git a/include/get.sh b/include/get.sh
index 3e25ea3f..8ce26e39 100644
--- a/include/get.sh
+++ b/include/get.sh
@@ -20,6 +20,7 @@ tmpgitcache="$xbtmp/tmpgit"
fetch_targets()
{
if [ -d "src/$project/$tree" ]; then
+
return 0
fi
@@ -35,16 +36,22 @@ fetch_project()
err "Can't read config 'config/git/$project/pkg.cfg'" \
"fetch_project" "@"
- if [ -z "$url" ] || [ -z "$bkup_url" ]; then
+ if [ -z "$url" ] || \
+ [ -z "$bkup_url" ]; then
+
err "url/bkup_url not both set 'config/git/$project/pkg.cfg'" \
"fetch_project" "$@"
fi
if [ -n "$xgcctree" ]; then
+
x_ ./mk -f coreboot "$xgcctree"
fi
+
if [ -n "$depend" ]; then
+
for d in $depend ; do
+
x_ ./mk -f $d
done
fi
@@ -55,12 +62,14 @@ fetch_project()
clone_project()
{
if ! singletree "$project"; then
+
return 0
fi
loc="src/$project"
if [ -d "$loc" ]; then
+
return 0
fi
@@ -76,15 +85,20 @@ git_prep()
_loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
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
+
+ if singletree "$project" || \
+ [ $# -gt 4 ]; then
+
dx_ fetch_submodule "$mdir/module.list"
fi
if [ "$_loc" != "${_loc%/*}" ]; then
+
x_ xbmkdir "${_loc%/*}"
fi
@@ -105,41 +119,59 @@ fetch_submodule()
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
+ if [ -n "$subgit" ] || \
+ [ -n "$subgit_bkup" ]; then
+
st="$st git"
fi
- if [ -n "$subcurl" ] || [ -n "$subcurl_bkup" ]; then
+
+ if [ -n "$subcurl" ] || \
+ [ -n "$subcurl_bkup" ]; then
+
st="$st curl"
fi
st="${st# }"
+
if [ "$st" = "git curl" ]; then
+
err "$mdir: git+curl defined" "fetch_submodule" "$@"
fi
if [ -z "$st" ]; then
+
return 0
fi
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
+
+ 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"
+
xbget "$st" "$subgit" "$subgit_bkup" "$tmpgit/$1" \
"$subhash" "$mdir/${1##*/}/patches"
else
+
xbget "$st" "$subcurl" "$subcurl_bkup" "$tmpgit/$1" \
"$subhash" "$mdir/${1##*/}/patches"
fi
@@ -151,30 +183,41 @@ fetch_submodule()
xbget()
{
- if [ "$1" != "curl" ] && [ "$1" != "copy" ] && [ "$1" != "git" ]; then
+ if [ "$1" != "curl" ] && \
+ [ "$1" != "copy" ] && \
+ [ "$1" != "git" ]; then
+
err "Bad dlop (arg 1)" "xbget" "$@"
fi
- for url in "$2" "$3"
- do
+ for url in "$2" "$3"; do
+
if [ -z "$url" ]; then
+
err "empty URL given in" "xbget" "$@"
+
elif ! try_fetch "$url" "$@"; then
+
continue
fi
case "$1" in
+
git)
+
if [ ! -d "$4" ]; then
continue
fi
;;
+
*)
+
if [ ! -f "$4" ]; then
continue
fi
;;
esac
+
return 0 # successful download/copy
done
@@ -184,11 +227,15 @@ xbget()
try_fetch()
{
if [ "$2" = "git" ]; then
+
if ! try_fetch_git "$@"; then
+
return 1
fi
else
+
if ! try_fetch_file "$@"; then
+
return 1
fi
fi
@@ -201,27 +248,34 @@ try_fetch_git()
# directories becomes cache/mirror/foo.example.com/repo
if [ "$XBMK_CACHE_MIRROR" = "y" ]; then
+
cached="mirror"
else
+
cached="clone"
fi
+
cached="$cached/${1#*://}"
cached="$XBMK_CACHE/$cached"
x_ xbmkdir "${5%/*}" "${cached%/*}"
if ! try_$2 "$cached" "$@"; then
+
return 1
elif [ ! -d "$cached" ]; then
+
return 1
fi
if [ ! -d "$5" ]; then
+
tmpclone "$cached" "$5" "$6" "$7" || \
err "Can't clone final repo" "try_fetch" "$@"; :
fi
if [ ! -d "$5" ]; then
+
return 1
fi
}
@@ -234,11 +288,14 @@ try_fetch_file()
x_ xbmkdir "${5%/*}" "${cached%/*}"
if bad_checksum "$6" "$cached" 2>/dev/null; then
+
x_ rm -f "$cached"
fi
if [ ! -f "$cached" ]; then
+
if ! try_$2 "$cached" "$@"; then
+
return 1
fi
fi
@@ -250,39 +307,50 @@ try_fetch_file()
fi
if [ ! -f "$cached" ]; then
+
return 1
+
elif bad_checksum "$6" "$cached"; then
- x_ rm -f "$cached"
+ x_ rm -f "$cached"
return 1
fi
if [ "$cached" != "$5" ]; then
+
x_ cp "$cached" "$5"
fi
if bad_checksum "$6" "$5"; then
- x_ rm -f "$5"
+ x_ rm -f "$5"
return 1
+
elif [ ! -f "$5" ]; then
+
return 1
fi
}
try_curl()
{
- _ua=""
+ ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
case "$2" in
+
https://www.supermicro.com/*)
- _ua="curl/8.6.0";;
+
+ ua="curl/8.6.0"
+ ;;
+
*)
- _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0";;
+ :
+ ;;
+
esac
- ( x_ curl --location --retry 3 -A "$_ua" "$2" -o "$1" ) \
- || ( x_ wget --tries 3 -U "$_ua" "$2" -O "$1" ) \
+ ( x_ curl --location --retry 3 -A "$ua" "$2" -o "$1" ) \
+ || ( x_ wget --tries 3 -U "$ua" "$2" -O "$1" ) \
|| return 1; :
}
@@ -299,10 +367,13 @@ try_git()
x_ rm -Rf "$tmpgitcache"
if [ ! -d "$gitdest" ]; then
+
if [ "$XBMK_CACHE_MIRROR" = "y" ]; then
+
( x_ git clone --mirror "$2" "$tmpgitcache" ) || \
return 1
else
+
( x_ git clone "$2" "$tmpgitcache" ) || return 1
fi
@@ -312,6 +383,7 @@ try_git()
if git -C "$gitdest" show "$7" 1>/dev/null 2>/dev/null && \
[ "$forcepull" != "y" ]; then
+
# don't try to pull the latest changes if the given target
# revision already exists locally. this saves a lot of time
# during release builds, and reduces the chance that we will
@@ -321,9 +393,11 @@ try_git()
fi
if [ "$XBMK_CACHE_MIRROR" = "y" ]; then
+
( x_ git -C "$gitdest" fetch ) || :; :
( x_ git -C "$gitdest" update-server-info ) || :; :
else
+
( x_ git -C "$gitdest" pull --all ) || :; :
fi
}
@@ -331,17 +405,22 @@ try_git()
bad_checksum()
{
if e "$2" f missing; then
+
return 0
fi
build_sbase
+
csum="$(x_ "$sha512sum" "$2" | awk '{print $1}')" || \
err "!sha512 '$2' $1" bad_checksum "$@"
if [ "$csum" = "$1" ]; then
+
return 1
else
+
x_ rm -f "$2"
+
printf "BAD SHA512 %s, '%s'; need %s\n" "$csum" "$2" "$1" 1>&2
fi
}
diff --git a/include/init.sh b/include/init.sh
index 5675f035..3ca7efeb 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -47,8 +47,8 @@ xbmk_init()
sha512sum="$xbmkpwd/util/sbase/sha512sum"
if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then
- x_ xbmkpkg "$@"
+ x_ xbmkpkg "$@"
exit 0
fi
@@ -56,6 +56,7 @@ xbmk_init()
err "suid check failed" "xbmk_init" "$@"
if [ "$(id -u)" = "0" ]; then
+
err "this command as root is not permitted" "xbmk_init" "$@"
fi
@@ -63,11 +64,14 @@ xbmk_init()
x_ xbmkdir "$basetmp"
if [ ! -e "cache" ]; then
+
x_ xbmkdir "cache"
fi
for init_cmd in get_version set_env set_threads git_init child_exec; do
+
if ! xbmk_$init_cmd "$@"; then
+
break
fi
done
@@ -78,19 +82,24 @@ xbmkpkg()
xchk xbmkpkg "$@"
if [ $# -gt 2 ]; then
+
reinstall="$3"
fi
. "config/dependencies/$2" || \
err "Can't read 'config/dependencies/$2'" "xbmkpkg" "$@"
- if [ -z "$pkg_add" ] || [ -z "$pkglist" ]; then
+ if [ -z "$pkg_add" ] || \
+ [ -z "$pkglist" ]; then
+
err "pkg_add/pkglist not both set" "xbmkpkg" "$@"
fi
if [ "$2" == "gentoo" ]; then
- if [ -z "$pkg_use" ] || [ -z "$pkg_use_file" ]; then
+ if [ -z "$pkg_use" ] || \
+ [ -z "$pkg_use_file" ]; then
+
err "pkg_use/pkg_use_file not both set" "xbmkpkg" "$@"
fi
@@ -98,6 +107,7 @@ xbmkpkg()
printf "Writing into %s" "$pkg_use_file..."
if [ ! -d "`dirname $pkg_use_file`" ]; then
+
x_ mkdir -p "`dirname $pkg_use_file`"
fi
@@ -107,6 +117,7 @@ xbmkpkg()
x_ $pkg_add $pkglist
if [ -n "$aur_notice" ]; then
+
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2
fi
}
@@ -114,31 +125,45 @@ xbmkpkg()
xbmk_get_version()
{
if [ -f ".version" ]; then
+
read -r version < ".version" || \
err "can't read version file" "xbmk_get_version" "$@"
fi
+
if [ -f ".versiondate" ]; then
+
read -r versiondate < ".versiondate" || \
err "can't read versiondate" xbmk_get_version "$@"
fi
- if [ -f ".version" ] && [ -z "$version" ]; then
+ if [ -f ".version" ] && \
+ [ -z "$version" ]; then
+
err "version not set" "xbmk_get_version" "$@"
fi
- if [ -f ".versiondate" ] && [ -z "$versiondate" ]; then
+
+ if [ -f ".versiondate" ] && \
+ [ -z "$versiondate" ]; then
+
err "versiondate not set" "xbmk_get_version" "$@"
fi
- if [ ! -e ".git" ] && [ ! -f ".version" ]; then
+ if [ ! -e ".git" ] && \
+ [ ! -f ".version" ]; then
+
version="unknown"
fi
- if [ ! -e ".git" ] && [ ! -f ".versiondate" ]; then
+
+ if [ ! -e ".git" ] && \
+ [ ! -f ".versiondate" ]; then
+
versiondate="1716415872"
fi
xbmk_sanitize_version
if [ -n "$version" ]; then
+
relname="$projectname-$version"
fi
}
@@ -153,19 +178,26 @@ xbmk_set_env()
xbmkpath="$PATH"
# unify all temporary files/directories in a single TMPDIR
- if [ -n "${TMPDIR+x}" ] && [ "${TMPDIR%_*}" != "$basetmp/xbmk" ]; then
+
+ if [ -n "${TMPDIR+x}" ] && \
+ [ "${TMPDIR%_*}" != "$basetmp/xbmk" ]; then
+
unset TMPDIR
fi
+
if [ -n "${TMPDIR+x}" ]; then
+
export TMPDIR="$TMPDIR"
xbtmp="$TMPDIR"
fi
+
if [ -n "${TMPDIR+x}" ]; then
+
is_child="y"
fi
- if [ "$is_child" = "y" ]
- then
+ if [ "$is_child" = "y" ]; then
+
# child instance of xbmk, so we stop init after this point
# and execute the given user command upon return:
@@ -173,6 +205,7 @@ xbmk_set_env()
return 1
else
+
# parent instance of xbmk, so we continue initialising.
# a parent instance of xbmk never processes its own
# command directly; instead, it calls a child instance
@@ -189,12 +222,17 @@ xbmk_child_set_env()
xbmk_child_set_tmp
if [ -z "${XBMK_CACHE+x}" ]; then
+
err "XBMK_CACHE unset on child" "xbmk_set_env" "$@"
fi
+
if [ -z "${XBMK_THREADS+x}" ]; then
+
xbmk_set_threads; :
fi
+
if [ -z "${XBMK_CACHE_MIRROR+x}" ]; then
+
xbmk_set_mirror
fi
}
@@ -212,6 +250,7 @@ xbmk_child_set_tmp()
err "can't read '$xbmklock'" "xbmk_child_set_tmp" "$@"
if [ "$locktmp" != "$xbtmpchk" ]; then
+
badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'"
printf "bad TMPDIR init, '%s': %s\n" "$TMPDIR" "$badtmp" 1>&2
@@ -219,6 +258,7 @@ xbmk_child_set_tmp()
fi
xbtmp="$xbtmpchk"
+
export TMPDIR="$xbtmpchk"
}
@@ -236,11 +276,13 @@ xbmk_parent_set_env()
x_ chmod -w "$xbmklock"
xbmk_parent_set_export
+
xbmk_set_version
remkdir "$xbtmp" "$xbtmp/gnupath" "$xbtmp/xbmkpath"
xbmk_set_pyver
+
xbmk_set_mirror
}
@@ -255,7 +297,9 @@ xbmk_parent_check_tmp()
x_ touch "$xbmklist"
for xtmpdir in "$basetmp"/xbmk_*; do
+
if [ -e "$xtmpdir" ]; then
+
printf "%s\n" "$xtmpdir" >> "$xbmklist" || \
err "can't write '$xtmpdir' to '$xbmklist'" \
"xbmk_parent_check_tmp" "$@"; :
@@ -263,14 +307,19 @@ xbmk_parent_check_tmp()
done
# set up a unified temporary directory, for common deletion later:
+
export TMPDIR="`x_ mktemp -d -t xbmk_XXXXXXXX`" || \
err "can't export TMPDIR" "xbmk_parent_check_tmp" "$@"
+
xbtmp="$TMPDIR"
while read -r xtmpdir; do
+
if [ "$xtmpdir" = "$xbtmp" ]; then
+
err "pre-existing '$xbtmp'" "xbmk_parent_check_tmp" "$@"
fi
+
done < "$xbmklist" || \
err "Can't read xbmklist: '$xbmklist'" "xbmk_parent_check_tmp" "$@"
@@ -281,7 +330,9 @@ xbmk_parent_set_export()
{
export XBMK_CACHE="$xbmkpwd/cache"
- if [ -e "$XBMK_CACHE" ] && [ ! -d "$XBMK_CACHE" ]; then
+ if [ -e "$XBMK_CACHE" ] && \
+ [ ! -d "$XBMK_CACHE" ]; then
+
err "cachedir '$XBMK_CACHE' is a file" \
"xbmk_parent_set_export" "$@"
fi
@@ -293,12 +344,17 @@ xbmk_parent_set_export()
# (this is used to exclude certain build targets from releases)
if [ -z "${XBMK_RELEASE+x}" ]; then
+
export XBMK_RELEASE="n"
fi
+
if [ "$XBMK_RELEASE" = "Y" ]; then
+
export XBMK_RELEASE="y"
fi
+
if [ "$XBMK_RELEASE" != "y" ]; then
+
export XBMK_RELEASE="n"
fi
}
@@ -306,10 +362,13 @@ xbmk_parent_set_export()
xbmk_set_threads()
{
if [ -z "${XBMK_THREADS+x}" ]; then
+
export XBMK_THREADS=1
fi
+
if ! expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null; then
+
export XBMK_THREADS=1
fi
}
@@ -317,54 +376,74 @@ xbmk_set_threads()
xbmk_set_version()
{
version_="$version"
+
if [ -e ".git" ]; then
+
version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || \
version="$version_"
fi
versiondate_="$versiondate"
+
if [ -e ".git" ]; then
+
versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
fi
- if [ -z "$version" ] || [ -z "$versiondate" ]; then
+ if [ -z "$version" ] || \
+ [ -z "$versiondate" ]; then
+
err "version and/or versiondate unset" "xbmk_set_version" "$@"
fi
update_xbmkver "."
relname="$projectname-$version"
+
export LOCALVERSION="-$projectname-${version%%-*}"
}
xbmk_set_pyver()
{
- python="python3"
pyver="2"
+ python="python3"
pyv="import sys; print(sys.version_info[:])"
if ! pybin python3 1>/dev/null; then
+
python="python"
fi
+
if [ "$python" = "python3" ]; then
+
pyver="3"
fi
+
if ! pybin "$python" 1>/dev/null; then
+
pyver=""
fi
+
if [ -n "$pyver" ]; then
+
"`x_ pybin "$python"`" -c "$pyv" 1>/dev/null \
2>/dev/null || \
err "Can't detect Python version." "xbmk_set_pyver" "$@"
fi
+
if [ -n "$pyver" ]; then
+
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')"
+
pyver="${pyver#(}"
+
pyver="${pyver%,}"
fi
+
if [ "${pyver%%.*}" != "3" ]; then
+
err "Bad python version (must by 3.x)" "xbmk_set_pyver" "$@"
fi
@@ -388,11 +467,16 @@ pybin()
py="import sys; quit(1) if sys.prefix == sys.base_prefix else quit(0)"
venv=1
+
if ! command -v "$1" 1>/dev/null 2>/dev/null; then
+
venv=0
fi
+
if [ $venv -gt 0 ]; then
+
if ! "$1" -c "$py" 1>/dev/null 2>/dev/null; then
+
venv=0
fi
fi
@@ -400,11 +484,14 @@ pybin()
# ideally, don't rely on PATH or hardcoded paths if python venv.
# use the *real*, direct executable linked to by the venv symlink:
- if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then
+ if [ $venv -gt 0 ] && \
+ [ -L "`command -v "$1" 2>/dev/null`" ]; then
+
pypath="$(findpath \
"$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)"
- if [ -e "$pypath" ] && [ ! -d "$pypath" ] && \
+ if [ -e "$pypath" ] && \
+ [ ! -d "$pypath" ] && \
[ -x "$pypath" ]; then
printf "%s\n" "$pypath"
@@ -416,17 +503,22 @@ pybin()
# if python venv: fall back to common PATH directories for checking:
[ $venv -gt 0 ] && for pypath in "/usr/local/bin" "/usr/bin"; do
- if [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \
+
+ if [ -e "$pypath/$1" ] && \
+ ! -d "$pypath/$1" ] && \
[ -x "$pypath/$1" ]; then
printf "%s/%s\n" "$pypath" "$1"
return 0
fi
+
done && return 1
- # Defer to normal command -v if not a venv
+ # Defer to normal command -v if not a venv:
+
if ! command -v "$1" 2>/dev/null; then
+
return 1
fi
}
@@ -442,51 +534,39 @@ xbmk_set_mirror()
# appreciate it, so it should only be used for development or archival
if [ -z "${XBMK_CACHE_MIRROR+x}" ]; then
+
export XBMK_CACHE_MIRROR="n"
fi
+
if [ "$XBMK_CACHE_MIRROR" != "y" ]; then
+
export XBMK_CACHE_MIRROR="n"
fi
}
xbmk_git_init()
{
- for gitarg in "user.name" "user.email"; do
- if [ "${2-}" != "-b" ]; then
-
- # we only need git name/email set for building
- # coreboot. this is a bit of a hack, but it should
- # make xbmk a bit easier to use for example when
- # someone only wants to run ./mk inject
-
- break
- fi
- if [ $# -gt 2 ] && [ "$3" != "coreboot" ]; then
+ # the git identity check is only needed for: ./mk -b coreboot [args]
- # we still might run -b sometimes, for e.g.
- # dependencies of ./mk inject. if -b is used
- # but it's not for coreboot, don't check.
+ [ "${2-}" = "-b" ] && [ "${3-}" = "coreboot" ] && \
+ for gitarg in "user.name" "user.email"; do
- # coreboot is a multi-tree project, so the third
- # argument will always be coreboot, when building
- # with -b.
-
- # we only need the git name/email check when
- # doing ./mk -b coreboot
-
- break
- fi
gitcmd="git config --includes $gitarg"
+
if ! $gitcmd 1>/dev/null 2>/dev/null; then
+
err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" \
"xbmk_git_init" "$@"
fi
done
if [ -L ".git" ]; then
+
err "'$xbmkpwd/.git' is a symlink" "xbmk_git_init" "$@"
fi
+
if [ -e ".git" ]; then
+
return 0
fi
@@ -500,10 +580,13 @@ xbmk_git_init()
err "can't get date" "xbmk_git_init" "$@"
x_ git init 1>/dev/null 2>/dev/null
+
x_ git add -A . 1>/dev/null 2>/dev/null
+
x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
commit -m "$projectname $version" --date "$cdate" \
--author="xbmk <xbmk@example.com>" 1>/dev/null 2>/dev/null
+
x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
tag -a "$version" -m "$projectname $version" \
1>/dev/null 2>/dev/null; :
@@ -513,10 +596,14 @@ xbmk_child_exec()
{
xbmk_rval=0
- ( x_ ./mk "$@" ) || xbmk_rval=1
+ ( x_ ./mk "$@" ) \
+ || xbmk_rval=1
+
+ ( x_ rm -Rf "$xbtmp" ) \
+ || xbmk_rval=1
- ( x_ rm -Rf "$xbtmp" ) || xbmk_rval=1
- ( x_ rm -f "$xbmklock" ) || xbmk_rval=1
+ ( x_ rm -f "$xbmklock" ) \
+ || xbmk_rval=1
exit $xbmk_rval
}
diff --git a/include/inject.sh b/include/inject.sh
index 783e06ed..53128995 100644
--- a/include/inject.sh
+++ b/include/inject.sh
@@ -10,10 +10,14 @@ nvmutil="util/nvmutil/nvmutil"
ifdtool="elf/coreboot/default/ifdtool"
checkvars="CONFIG_GBE_BIN_PATH"
+
if [ -n "$checkvarsxbmk" ]; then
+
checkvars="$checkvars $checkvarsxbmk"
fi
+
if [ -n "$checkvarschk" ]; then
+
checkvars="$checkvars $checkvarschk"
fi
@@ -34,6 +38,7 @@ inject()
remkdir "$tmpromdel"
if [ $# -lt 1 ]; then
+
err "No options specified" "inject" "$@"
fi
@@ -44,39 +49,57 @@ inject()
xchanged=""
[ $# -gt 1 ] && case "$2" in
+
nuke)
+
new_mac=""
nuke="nuke"
;;
+
setmac)
+
if [ $# -gt 2 ]; then
+
new_mac="$3" && \
+
if [ -z "$new_mac" ]; then
+
err "Empty MAC address specified" "inject" "$@"
fi
fi
;;
+
*)
+
err "Unrecognised inject mode: '$2'" "inject" "$@" ;;
esac
if [ "$new_mac" = "keep" ]; then
+
new_mac=""
fi
check_release
+
if check_target; then
+
if ! patch_release; then
+
return 0
fi
fi
+
if [ "$xchanged" = "y" ]; then
+
remktar
fi
if [ "$xchanged" = "y" ]; then
+
printf "\n'%s' was modified\n" "$archive" 1>&2
+
else
+
printf "\n'%s' was NOT modified\n" "$archive" 1>&2
fi
@@ -86,9 +109,12 @@ inject()
check_release()
{
if [ -L "$archive" ]; then
+
err "'$archive' is a symlink" "check_release" "$@"
fi
+
if e "$archive" f missing; then
+
err "'$archive' missing" "check_release" "$@"
fi
@@ -96,28 +122,39 @@ check_release()
|| err "can't get '$archive' name" "check_release" "$@"
if [ -z "$archivename" ]; then
+
err "Can't determine archive name" "check_release" "$@"
fi
case "$archivename" in
+
*_src.tar.xz)
+
err "'$archive' is a src archive!" "check_release" "$@"
;;
+
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
+
err "'$archive' is a ROM image" "check_release" "$@"
;;
+
*.tar.xz) _stripped_prefix="${archivename#*_}"
+
board="${_stripped_prefix%.tar.xz}"
;;
+
*)
+
err "'$archive': cannot detect board" "check_release" "$@"
;;
+
esac; :
}
check_target()
{
if [ "$board" != "${board#serprog_}" ]; then
+
return 1
fi
@@ -127,6 +164,7 @@ check_target()
err "Can't read '$boarddir/target.cfg'" "check_target" "$@"
if [ -z "$tree" ]; then
+
err "tree unset in '$boarddir/target.cfg'" "check_target" "$@"
fi
@@ -135,6 +173,7 @@ check_target()
ifdtool="elf/coreboot/$tree/ifdtool"
if [ -n "$IFD_platform" ]; then
+
ifdprefix="-p $IFD_platform"
fi
}
@@ -142,6 +181,7 @@ check_target()
patch_release()
{
if [ "$nuke" != "nuke" ]; then
+
x_ ./mk download "$board"
fi
@@ -149,10 +189,13 @@ patch_release()
tmpromdir="$tmpromdel/bin/$board"
remkdir "${tmpromdir%"/bin/$board"}"
+
x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}"
for _hashes in "vendorhashes" "blobhashes"; do
+
if e "$tmpromdir/$_hashes" f; then
+
has_hashes="y"
hashfile="$_hashes"
@@ -161,8 +204,12 @@ patch_release()
done
if ! readkconfig; then
+
return 1
- elif [ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ]; then
+
+ elif [ -n "$new_mac" ] && \
+ [ -n "$CONFIG_GBE_BIN_PATH" ]; then
+
modify_mac
fi
}
@@ -174,6 +221,7 @@ readkconfig()
fx_ scankconfig x_ find "$boarddir/config" -type f
if e "$xbtmp/cbcfg" f missing; then
+
return 1
fi
@@ -181,6 +229,7 @@ readkconfig()
err "Can't read '$xbtmp/cbcfg'" "readkconfig" "$@"
if ! setvfile "$@"; then
+
return 1
fi
}
@@ -188,6 +237,7 @@ readkconfig()
scankconfig()
{
for cbc in $checkvars; do
+
grep "$cbc" "$1" 2>/dev/null 1>>"$xbtmp/cbcfg" || :
done
}
@@ -196,8 +246,11 @@ modify_mac()
{
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbtmp/gbe"
- if [ -n "$new_mac" ] && [ "$new_mac" != "restore" ]; then
+ if [ -n "$new_mac" ] && \
+ [ "$new_mac" != "restore" ]; then
+
x_ make -C util/nvmutil clean
+
x_ make -C util/nvmutil
x_ "$nvmutil" "$xbtmp/gbe" setmac "$new_mac"
@@ -206,13 +259,16 @@ modify_mac()
fx_ newmac x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
printf "\nThe following GbE NVM data will be written:\n"
+
x_ "$nvmutil" "$xbtmp/gbe" dump | grep -v "bytes read from file" || :
}
newmac()
{
if e "$1" f; then
+
xchanged="y"
+
x_ "$ifdtool" $ifdprefix -i GbE:"$xbtmp/gbe" "$1" -O "$1"
fi
}
@@ -223,6 +279,7 @@ remktar()
x_ cd "${tmpromdir%"/bin/$board"}"
printf "Re-building tar archive (please wait)\n"
+
mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'" "remktar" "$@"
diff --git a/include/lib.sh b/include/lib.sh
index 812341f4..0c7d9ba2 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -11,6 +11,7 @@ rmodtool="elf/coreboot/default/rmodtool"
mkrom_tarball()
{
update_xbmkver "$1"
+
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
x_ rm -Rf "$1"
@@ -30,6 +31,7 @@ update_xbmkver()
xbmk_sanitize_version()
{
if [ -z "$version" ]; then
+
return 0
fi
@@ -42,6 +44,7 @@ xbmk_sanitize_version()
version="${version#-}"
if [ -z "$version" ]; then
+
err "'version' empty after sanitization" \
"xbmk_sanitize_version" "$@"
fi
@@ -52,6 +55,7 @@ mktarball()
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
if [ "${2%/*}" != "$2" ]; then
+
x_ xbmkdir "${2%/*}"
fi
@@ -64,6 +68,7 @@ e()
es_t="e"
if [ $# -gt 1 ]; then
+
es_t="$2"
fi
@@ -71,6 +76,7 @@ e()
estr="[ -$es_t \"\$1\" ] || return 1"
if [ $# -gt 2 ]; then
+
estr="[ -$es_t \"\$1\" ] && return 1"
es2="missing"
fi
@@ -85,14 +91,18 @@ setvars()
_setvars=""
if [ $# -lt 2 ]; then
+
return 0
fi
val="$1"
+
shift 1
while [ $# -gt 0 ]; do
+
printf "%s=\"%s\"\n" "$1" "$val"
+
shift 1
done
}
@@ -108,14 +118,16 @@ singletree()
findpath()
{
if [ $# -lt 1 ]; then
+
err "findpath: No arguments provided" "findpath" "$@"
fi
- while [ $# -gt 0 ]
- do
+ while [ $# -gt 0 ]; do
+
found="`readlink -f "$1" 2>/dev/null`" || return 1; :
if [ -z "$found" ]; then
+
found="`realpath "$1" 2>/dev/null`" || \
return 1
fi
@@ -143,6 +155,7 @@ unpad_one_byte()
err "can't increment file size" "unpad_one_byte" "$@"
if [ $xromsize -lt 524288 ]; then
+
err "too small, $xromsize: $1" "unpad_one_byte" "$@"
fi
@@ -150,12 +163,14 @@ unpad_one_byte()
err "can't make tmp file" "unpad_one_byte" "$@"
x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1
+
x_ mv "$unpaddedfile" "$1"
}
build_sbase()
{
if [ ! -f "$sha512sum" ]; then
+
x_ make -C "$xbmkpwd/util/sbase"
fi
}
@@ -163,14 +178,16 @@ build_sbase()
remkdir()
{
x_ rm -Rf "$@"
+
x_ xbmkdir "$@"
}
xbmkdir()
{
- while [ $# -gt 0 ]
- do
+ while [ $# -gt 0 ]; do
+
if [ ! -d "$1" ]; then
+
x_ mkdir -p "$1"
fi
@@ -181,12 +198,14 @@ xbmkdir()
fx_()
{
xchk fx_ "$@"
+
xcmd="$1"
xfile="`mktemp || err "can't create tmpfile"`" || \
err "can't make tmpfile" "fx_" "$@"
x_ rm -f "$xfile"
+
x_ touch "$xfile"
shift 1
@@ -195,6 +214,7 @@ fx_()
err "can't sort to '$xfile'" "fx_" "$xcmd" "$@"
dx_ "$xcmd" "$xfile" || :
+
x_ rm -f "$xfile"
}
@@ -203,21 +223,30 @@ dx_()
xchk dx_ "$@"
if [ ! -f "$2" ]; then
+
return 0
fi
while read -r fx; do
+
$1 "$fx" || return 1; :
- done < "$2" || err "cannot read '$2'" "dx_" "$@"; :
+
+ done < "$2" \
+ || err "cannot read '$2'" "dx_" "$@"; :
}
x_()
{
if [ $# -lt 1 ]; then
+
return 0
+
elif [ -z "$1" ]; then
+
err "Empty first arg" "x_" "$@"
+
else
+
"$@" || err "Unhandled error" "x_" "$@"
fi
}
@@ -225,8 +254,12 @@ x_()
xchk()
{
if [ $# -lt 3 ]; then
+
err "$1 needs at least two arguments" "xchk" "$@"
- elif [ -z "$2" ] || [ -z "$3" ]; then
+
+ elif [ -z "$2" ] || \
+ [ -z "$3" ]; then
+
err "arguments must not be empty" "xchk" "$@"
fi
}
@@ -234,12 +267,19 @@ xchk()
err()
{
if [ $# -eq 1 ]; then
+
printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || :
+
elif [ $# -gt 1 ]; then
+
printf "ERROR %s: %s: in command with args: " "$0" "$1" 1>&2
+
shift 1
+
xprintf "$@" 1>&2
+
else
+
printf "ERROR, but no arguments provided to err\n" 1>&2
fi
@@ -249,16 +289,23 @@ err()
xprintf()
{
xprintfargs=0
+
while [ $# -gt 0 ]; do
+
printf "\"%s\"" "$1"
+
if [ $# -gt 1 ]; then
+
printf " "
fi
xprintfargs=1
+
shift 1
done
+
if [ $xprintfargs -gt 0 ]; then
+
printf "\n"
fi
}
diff --git a/include/mrc.sh b/include/mrc.sh
index 9c50af5c..1f3a1c9d 100644
--- a/include/mrc.sh
+++ b/include/mrc.sh
@@ -19,6 +19,7 @@ extract_refcode()
# cbfstool from coreboot 4.11_branch, the tree used by ASUS KGPE-D16:
if [ -z "$cbfstoolref" ]; then
+
err "cbfstoolref not set" "extract_refcode" "$@"
fi
@@ -27,8 +28,10 @@ extract_refcode()
x_ "$cbfstoolref" "$appdir/bios.bin" extract \
-m x86 -n fallback/refcode -f "$appdir/ref" -r RO_SECTION
- # enable the Intel GbE device, if told by offset MRC_refcode_gbe
+ # enable the Intel GbE device, if told by offset MRC_refcode_gbe:
+
if [ -n "$MRC_refcode_gbe" ]; then
+
x_ dd if="config/ifd/hp820g2/1.bin" of="$appdir/ref" bs=1 \
seek=$MRC_refcode_gbe count=1 conv=notrunc; :
fi
@@ -39,8 +42,11 @@ extract_refcode()
extract_mrc()
{
if [ -z "$MRC_board" ]; then
+
err "MRC_board unset" "extract_mrc" "$@"
+
elif [ -z "$CONFIG_MRC_FILE" ]; then
+
err "CONFIG_MRC_FILE unset" "extract_mrc" "$@"
fi
@@ -48,6 +54,7 @@ extract_mrc()
(
x_ cd "$appdir"
+
extract_partition "${MRC_url##*/}"
extract_archive "$SHELLBALL" .
diff --git a/include/release.sh b/include/release.sh
index e9017a05..e3e02686 100644
--- a/include/release.sh
+++ b/include/release.sh
@@ -14,45 +14,58 @@ release()
reldir="release"
- while getopts m: option
- do
+ while getopts m: option; do
+
if [ -z "$OPTARG" ]; then
+
err "empty argument not allowed" "release" "$@"
fi
case "$option" in
+
m)
relmode="$OPTARG"
;;
+
*)
err "invalid option '-$option'" "release" "$@"
;;
+
esac
done
reldest="$reldir/$version"
+
if [ -e "$reldest" ]; then
+
err "already exists: \"$reldest\"" "release" "$@"
fi
vdir="`mktemp -d || err "can't make vdir"`" || \
err "can't make tmp vdir" "release" "$@"
+
vdir="$vdir/$version"
rsrc="$vdir/${relname}_src"
remkdir "$vdir"
+
x_ git clone . "$rsrc"
+
update_xbmkver "$rsrc"
prep_release src
prep_release tarball
+
if [ "$relmode" != "src" ]; then
+
prep_release bin
fi
+
x_ rm -Rf "$rsrc"
x_ xbmkdir "$reldir"
+
x_ mv "$vdir" "$reldir"
x_ rm -Rf "${vdir%"/$version"}"
@@ -63,8 +76,11 @@ prep_release()
{
(
if [ "$1" != "tarball" ]; then
+
x_ cd "$rsrc"
+
if [ ! -e "cache" ]; then
+
x_ ln -s "$XBMK_CACHE" "cache"
fi
fi
@@ -83,15 +99,18 @@ prep_release_src()
fx_ "x_ rm -Rf" x_ find . -name ".git"
fx_ "x_ rm -Rf" x_ find . -name ".gitmodules"
+ # delete unwanted files from the release
( fx_ nuke x_ find config -type f -name "nuke.list" ) || \
err "can't prune project files" "prep_release_src" "$@"; :
}
+# delete unwanted files from the release
nuke()
{
r="$rsrc/src/${1#config/}"
if [ -d "${r%/*}" ]; then
+
x_ cd "${r%/*}"
dx_ "x_ rm -Rf" "$rsrc/$1"
@@ -105,7 +124,9 @@ prep_release_tarball()
err "can't create '$rsrc/CHANGELOG'" "prep_release_tarball" "$@"
x_ rm -f "$rsrc/lock" "$rsrc/cache"
+
x_ rm -Rf "$rsrc/xbmkwd" "$rsrc/util/sbase"
+
x_ mv "$rsrc/util/sbase2" "$rsrc/util/sbase"
(
@@ -118,10 +139,12 @@ prep_release_tarball()
prep_release_bin()
{
x_ ./mk -d coreboot
-
x_ ./mk -b coreboot
+
x_ ./mk -b pico-serprog
+
x_ ./mk -b stm32-vserprog
+
x_ ./mk -b pcsx-redux
fx_ mkrom_tarball x_ find bin -maxdepth 1 -type d -name "serprog_*"
diff --git a/include/rom.sh b/include/rom.sh
index 6f0e3529..5a751fe3 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -11,15 +11,21 @@ grubdata="config/data/grub"
buildser()
{
if [ "$1" = "pico" ]; then
+
x_ cmake -DPICO_BOARD="$2" \
-DPICO_SDK_PATH="$picosdk" -B "$sersrc/build" "$sersrc"
+
x_ cmake --build "$sersrc/build"
+
elif [ "$1" = "stm32" ]; then
+
x_ make -C "$sersrc" libopencm3-just-make BOARD=$2
+
x_ make -C "$sersrc" BOARD=$2
fi
x_ xbmkdir "bin/serprog_$1"
+
x_ mv "$serx" "bin/serprog_$1/serprog_$2.${serx##*.}"
}
@@ -63,7 +69,9 @@ mkpayload_grub()
corebootpremake()
{
- if [ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ]; then
+ if [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$release" = "n" ]; then
+
return 0
fi
@@ -75,14 +83,18 @@ corebootpremake()
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
err "!mk $srcdir .coreboot-version" "corebootpremake" "$@"
- if [ -z "$mode" ] && [ "$target" != "$tree" ]; then
+ if [ -z "$mode" ] && \
+ [ "$target" != "$tree" ]; then
+
x_ ./mk download "$target"
fi
}
cook_coreboot_config()
{
- if [ -z "$mode" ] && [ -f "$srcdir/.config" ]; then
+ if [ -z "$mode" ] && \
+ [ -f "$srcdir/.config" ]; then
+
printf "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || \
err "can't cook '$srcdir'" "cook_coreboot_config" "$@"
fi
@@ -91,9 +103,12 @@ cook_coreboot_config()
check_coreboot_util()
{
if [ "$badhash" = "y" ]; then
+
x_ rm -f "elf/coreboot/$tree/$1"
fi
+
if e "elf/coreboot/$tree/$1" f; then
+
return 0
fi
@@ -101,26 +116,33 @@ check_coreboot_util()
utilsrcdir="src/coreboot/$tree/util/$1"
utilmode=""
+
if [ -n "$mode" ]; then
+
utilmode="clean"
fi
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
if [ -n "$mode" ]; then
- # TODO: is this rm command needed?
+ # TODO: is this rm command needed?
x_ rm -Rf "$utilelfdir"
return 0
- elif [ -n "$mode" ] || [ -f "$utilelfdir/$1" ]; then
+
+ elif [ -n "$mode" ] || \
+ [ -f "$utilelfdir/$1" ]; then
+
return 0
fi
x_ xbmkdir "$utilelfdir"
+
x_ cp "$utilsrcdir/$1" "$utilelfdir"
if [ "$1" = "cbfstool" ]; then
+
x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
fi
}
@@ -137,7 +159,9 @@ coreboot_pad_one_byte()
mkcorebootbin()
{
- if [ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ]; then
+ if [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$release" = "n" ]; then
+
return 0
fi
@@ -148,7 +172,9 @@ mkcorebootbin()
check_coreboot_util ifdtool
for y in "$target_dir/config"/*; do
+
defconfig="$y"
+
mkcorebootbin_real
done
@@ -158,6 +184,7 @@ mkcorebootbin()
mkcorebootbin_real()
{
if [ "$target" = "$tree" ]; then
+
return 0
fi
@@ -165,21 +192,28 @@ mkcorebootbin_real()
initmode="${defconfig##*/}"
displaymode="${initmode##*_}"
+
if [ "$displaymode" = "$initmode" ]; then
+
# blank it for "normal" or "fspgop" configs:
displaymode=""
fi
+
initmode="${initmode%%_*}"
+
cbfstool="elf/coreboot/$tree/cbfstool"
# cbfstool option backends, if they exist
cbfscfg="config/coreboot/$target/cbfs.cfg"
elfrom="elf/coreboot/$tree/$target/$initmode"
+
if [ -n "$displaymode" ]; then
+
elfrom="${elfrom}_$displaymode"
fi
+
elfrom="$elfrom/coreboot.rom"
$if_not_dry_build \
@@ -188,48 +222,69 @@ mkcorebootbin_real()
$if_not_dry_build \
unpad_one_byte "$tmprom"
- if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "amd64" ] && \
- [ "$payload_uboot" != "i386" ] && [ "$payload_uboot" != "arm64" ]
- then
+ if [ -n "$payload_uboot" ] && \
+ [ "$payload_uboot" != "amd64" ] && \
+ [ "$payload_uboot" != "i386" ] && \
+ [ "$payload_uboot" != "arm64" ]; then
+
err "'$target' defines bad u-boot type '$payload_uboot'" \
"mkcorebootbin_real" "$@"
fi
- if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "arm64" ]; then
+ if [ -n "$payload_uboot" ] && \
+ [ "$payload_uboot" != "arm64" ]; then
+
payload_seabios="y"
fi
if [ -z "$uboot_config" ]; then
+
uboot_config="default"
fi
+
if [ "$payload_grub" = "y" ]; then
+
payload_seabios="y"
fi
- if [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ]; then
+
+ if [ "$payload_seabios" = "y" ] && \
+ [ "$payload_uboot" = "arm64" ]; then
+
$if_not_dry_build \
err "$target: U-Boot arm / SeaBIOS/GRUB both enabled" \
"mkcorebootbin_real" "$@"
fi
if [ -z "$grub_scan_disk" ]; then
+
grub_scan_disk="nvme ahci ata"
fi
+
if [ -z "$grubtree" ]; then
+
grubtree="default"
fi
+
grubelf="elf/grub/$grubtree/$grubtree/payload/grub.elf"
if [ "$payload_memtest" != "y" ]; then
+
payload_memtest="n"
fi
+
if [ "$(uname -m)" != "x86_64" ]; then
+
payload_memtest="n"
fi
- if [ "$payload_grubsea" = "y" ] && [ "$initmode" = "normal" ]; then
+ if [ "$payload_grubsea" = "y" ] && \
+ [ "$initmode" = "normal" ]; then
+
payload_grubsea="n"
fi
+
if [ "$payload_grub" != "y" ]; then
+
payload_grubsea="n"
fi
@@ -237,20 +292,29 @@ mkcorebootbin_real()
return 0
if [ -f "$cbfscfg" ]; then
+
dx_ add_cbfs_option "$cbfscfg"
fi
if grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then
+
if [ "$payload_seabios" = "y" ]; then
+
pname="seabios"
+
add_seabios
fi
+
if [ "$payload_uboot" = "arm64" ]; then
+
pname="uboot"
+
add_uboot
fi
else
+
pname="custom"
+
cprom
fi; :
}
@@ -262,9 +326,12 @@ add_cbfs_option()
# TODO: input sanitization (currently mitigated by careful config)
op_name="`printf "%s\n" "$1" | awk '{print $1}'`"
+
op_arg="`printf "%s\n" "$1" | awk '{print $2}'`"
- if [ -z "$op_name" ] || [ -z "$op_arg" ]; then
+ if [ -z "$op_name" ] || \
+ [ -z "$op_arg" ]; then
+
return 0
fi
@@ -283,7 +350,9 @@ add_cbfs_option()
add_seabios()
{
- if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "arm64" ]; then
+ if [ -n "$payload_uboot" ] && \
+ [ "$payload_uboot" != "arm64" ]; then
+
# we must add u-boot first, because it's added as a flat
# binary at a specific offset for secondary program loader
@@ -292,11 +361,16 @@ add_seabios()
fi
_seabioself="elf/seabios/default/default/$initmode/bios.bin.elf"
- [ "$initmode" = "fspgop" ] && \
+
+ if [ "$initmode" = "fspgop" ]; then
+
_seabioself="elf/seabios/default/default/libgfxinit/bios.bin.elf"
+ fi
_seaname="fallback/payload"
+
if [ "$payload_grubsea" = "y" ]; then
+
_seaname="seabios.elf"
fi
@@ -305,27 +379,39 @@ add_seabios()
x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
opexec="2"
+
if [ "$initmode" = "vgarom" ]; then
+
opexec="0"
fi
+
x_ "$cbfstool" "$tmprom" add-int -i $opexec -n etc/pci-optionrom-exec
x_ "$cbfstool" "$tmprom" add-int -i 0 -n etc/optionroms-checksum
- if [ "$initmode" = "libgfxinit" ] || [ "$initmode" = "fspgop" ]; then
+
+ if [ "$initmode" = "libgfxinit" ] || \
+ [ "$initmode" = "fspgop" ]; then
+
cbfs "$tmprom" "$seavgabiosrom" vgaroms/seavgabios.bin raw
fi
if [ "$payload_memtest" = "y" ]; then
+
# because why not have memtest?
+ # we can have it. we are entitled to it.
+ # so we shall have it, yes. having memtest86+
+ # in your boot flash makes you a better person.
cbfs "$tmprom" "elf/memtest86plus/memtest.bin" img/memtest
fi
if [ "$payload_grub" = "y" ]; then
+
add_grub
fi
if [ "$payload_grubsea" != "y" ]; then
+
# ROM image where SeaBIOS doesn't load grub/u-boot first.
# U-Boot/GRUB available in ESC menu if enabled for the board
@@ -338,13 +424,18 @@ add_seabios()
if [ "$payload_uboot" = "amd64" ] && \
[ "$displaymode" != "txtmode" ] && \
- [ "$initmode" != "normal" ] && [ "$payload_grubsea" != "y" ]; then
+ [ "$initmode" != "normal" ] && \
+ [ "$payload_grubsea" != "y" ]; then
+
pname="seauboot"
+
cprom "seauboot"
fi
if [ "$payload_grub" = "y" ]; then
+
pname="seagrub"
+
mkseagrub
fi
}
@@ -353,7 +444,9 @@ add_grub()
{
# path in CBFS for the GRUB payload
_grubname="img/grub2"
+
if [ "$payload_grubsea" = "y" ]; then
+
_grubname="fallback/payload"
fi
@@ -365,7 +458,9 @@ add_grub()
cbfs "$tmprom" "$xbtmp/tmpcfg" scan.cfg raw
- if [ "$initmode" != "normal" ] && [ "$displaymode" != "txtmode" ]; then
+ if [ "$initmode" != "normal" ] && \
+ [ "$displaymode" != "txtmode" ]; then
+
cbfs "$tmprom" "$grubdata/background/background1280x800.png" \
"background.png" raw
fi
@@ -374,8 +469,10 @@ add_grub()
mkseagrub()
{
if [ "$payload_grubsea" = "y" ]; then
+
pname="grub"
else
+
cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
fi
@@ -385,10 +482,13 @@ mkseagrub()
add_uboot()
{
if [ "$displaymode" = "txtmode" ]; then
+
printf "cb/%s: Can't use U-Boot in text mode\n" "$target" 1>&2
return 0
+
elif [ "$initmode" = "normal" ]; then
+
printf "cb/%s: Can't use U-Boot in normal initmode\n" \
"$target" 1>&2
@@ -406,17 +506,22 @@ add_uboot()
# override for x86/x86_64 targets:
if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "arm64" ]; then
+
ubcbfsargs="-l 0x1110000 -e 0x1110000" # 64-bit and 32-bit
# on 64-bit, 0x1120000 is the SPL, with a stub that
# loads it, located at 0x1110000
ubpath="img/u-boot" # 64-bit
+
ubtree="x86_64"
ubtarget="amd64coreboot"
- if [ "$payload_uboot" = "i386" ]
- then
- ubpath="u-boot" # 32-bit
+ if [ "$payload_uboot" = "i386" ]; then
+
+ # override for 32-bit
+
+ ubpath="u-boot"
+
ubtree="x86"
ubtarget="i386coreboot"; :
fi
@@ -425,20 +530,29 @@ add_uboot()
ubdir="elf/u-boot/$ubtree/$ubtarget/$uboot_config"
# aarch64 targets:
+
ubootelf="$ubdir/u-boot.elf"
+
if [ ! -f "$ubootelf" ]; then
+
ubootelf="$ubdir/u-boot"
fi
# override for x86/x86_64 targets:
+
if [ "$payload_uboot" = "i386" ]; then
+
ubootelf="$ubdir/u-boot-dtb.bin"
+
elif [ "$payload_uboot" = "amd64" ]; then
+
ubootelf="$ubdir/u-boot-x86-with-spl.bin" # EFI-compatible
fi
cbfs "$tmprom" "$ubootelf" "$ubpath" $ubcbfsargs
+
if [ "$payload_seabios" != "y" ]; then
+
cprom
fi
}
@@ -453,9 +567,13 @@ cprom()
newrom="bin/$target/${pname}_${target}_$initmode.rom"
if [ -n "$displaymode" ]; then
+
newrom="${newrom%.rom}_$displaymode.rom"
fi
- if [ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ]; then
+
+ if [ $# -gt 0 ] && \
+ [ "${1%.gkb}" != "$1" ]; then
+
tmpnew="${1##*/}"
newrom="${newrom%.rom}_${tmpnew%.gkb}.rom"
fi
@@ -463,14 +581,18 @@ cprom()
irom="$tmprom"
if [ $# -gt 0 ]; then
+
irom="$(mktemp || err "!mk irom, $(echo "$@")")" || \
err "can't copy rom" "cprom" "$@"
x_ cp "$tmprom" "$irom" && cpcmd="mv"
if [ "${1%.gkb}" != "$1" ]; then
+
cbfs "$irom" "$grubdata/keymap/$tmpnew" keymap.gkb raw
+
elif [ "$1" = "seauboot" ]; then
+
cbfs "$irom" "$grubdata/bootorder_uboot" bootorder raw
fi
fi
@@ -478,6 +600,7 @@ cprom()
printf "Creating new %s image: '%s'\n" "$projectname" "$newrom"
x_ xbmkdir "bin/$target"
+
x_ $cpcmd "$irom" "$newrom"
}
@@ -486,10 +609,15 @@ cbfs()
ccmd="add-payload"
lzma="-c lzma"
- if [ $# -gt 3 ] && [ $# -lt 5 ]; then
+ if [ $# -gt 3 ] && \
+ [ $# -lt 5 ]; then
+
ccmd="add"
lzma="-t $4"
- elif [ $# -gt 4 ] && [ "$5" = "0x1110000" ]; then
+
+ elif [ $# -gt 4 ] && \
+ [ "$5" = "0x1110000" ]; then
+
ccmd="add-flat-binary" && \
lzma="-c lzma -l 0x1110000 -e 0x1110000"
fi
@@ -504,11 +632,14 @@ mkcoreboottar()
$if_dry_build \
return 0
- if [ "$target" = "$tree" ] || [ "$XBMK_RELEASE" != "y" ] || \
+ if [ "$target" = "$tree" ] || \
+ [ "$XBMK_RELEASE" != "y" ] || \
[ "$release" = "n" ]; then
+
return 0
fi
mkrom_tarball "bin/$target"
+
x_ ./mk inject "bin/${relname}_${target}.tar.xz" nuke
}
diff --git a/include/tree.sh b/include/tree.sh
index 8496a49a..b72da495 100644
--- a/include/tree.sh
+++ b/include/tree.sh
@@ -57,9 +57,10 @@ trees()
{
flags="f:F:b:m:u:c:x:s:l:n:d:"
- while getopts $flags option
- do
+ while getopts $flags option; do
+
if [ -n "$flag" ]; then
+
err "only one flag is permitted" "trees" "$@"
fi
@@ -69,6 +70,7 @@ trees()
# ./mk -m coreboot does: make menuconfig -C src/coreboot/tree
case "$flag" in
+
-d)
# -d is similar to -b, except that
# a large number of operations will be
@@ -79,13 +81,20 @@ trees()
if_dry_build=""
if_not_dry_build=":"
;;
+
-b) : ;;
+
-u) mode="oldconfig" ;;
+
-m) mode="menuconfig" ;;
+
-c) mode="distclean" ;;
+
-x) mode="crossgcc-clean" ;;
+
-f|-F) # download source code for a project
# macros. colon means false.
+
if_do_make=":"
if_dry_build=""
if_not_do_make=""
@@ -96,13 +105,19 @@ trees()
forcepull="y"
fi
;;
+
-s) mode="savedefconfig" ;;
+
-l) mode="olddefconfig" ;;
+
-n) mode="nconfig" ;;
+
*) err "invalid option '-$option'" "trees" "$@" ;;
+
esac
if [ -z "${OPTARG+x}" ]; then
+
shift 1
break
@@ -115,13 +130,17 @@ trees()
done
if [ -z "$flag" ]; then
+
err "missing flag ($flags)" "trees" "$@"
+
elif [ -z "$project" ]; then
+
fx_ "x_ ./mk $flag" x_ ls -1 config/git
return 1
elif [ ! -f "config/git/$project/pkg.cfg" ]; then
+
err "config/git/$project/pkg.cfg missing" "trees" "$@"
fi
@@ -132,19 +151,26 @@ trees()
dest_dir="$elfdir"
listfile="$datadir/build.list"
+
if [ ! -f "$listfile" ]; then
+
listfile="" # build.list is optional on all projects
fi
mkhelpercfg="$datadir/mkhelper.cfg"
+
if e "$mkhelpercfg" f missing; then
+
mkhelpercfg="$xbtmp/mkhelper.cfg"
+
x_ touch "$mkhelpercfg"
fi
targets="$*"
cmd="build_targets $targets"
+
if singletree "$project"; then
+
cmd="build_project"
fi
@@ -154,22 +180,29 @@ trees()
build_project()
{
if ! configure_project "$configdir"; then
+
return 0
+
elif [ -f "$listfile" ]; then
+
if ! $if_not_dry_build elfcheck; then
+
return 0
fi
fi
if [ "$mode" = "distclean" ]; then
+
mode="clean"
fi
if ! run_make_command; then
+
return 0
fi
if [ -z "$mode" ]; then
+
$if_not_dry_build \
copy_elf; :
fi
@@ -178,18 +211,22 @@ build_project()
build_targets()
{
if [ ! -d "$configdir" ]; then
+
err "directory '$configdir' doesn't exist" "build_targets" "$@"
+
elif [ $# -lt 1 ]; then
+
targets="$(ls -1 "$configdir")" || \
err "'$configdir': can't list targets" "build_targets" "$@"
fi
- for x in $targets
- do
+ for x in $targets; do
+
unset CROSS_COMPILE
export PATH="$xbmkpath"
if [ "$x" = "list" ]; then
+
x_ ls -1 "config/$project"
listfile=""
@@ -204,6 +241,7 @@ build_targets()
x_ handle_defconfig
if [ -z "$mode" ]; then
+
x_ $postmake
fi
done; :
@@ -214,39 +252,54 @@ handle_defconfig()
target_dir="$configdir/$target"
if [ ! -f "CHANGELOG" ]; then
+
fetch_project "$project"
fi
+
if ! configure_project "$target_dir"; then
+
return 0
fi
if [ -z "$tree" ]; then
+
err "$configdir: 'tree' not set" "handle_defconfig" "$@"
fi
srcdir="src/$project/$tree"
- if [ "$mode" = "${mode%clean}" ] && [ ! -d "$srcdir" ]; then
+ if [ "$mode" = "${mode%clean}" ] && \
+ [ ! -d "$srcdir" ]; then
+
return 0
fi
- for y in "$target_dir/config"/*
- do
- if [ "$flag" != "-d" ] && [ ! -f "$y" ]; then
+ for y in "$target_dir/config"/*; do
+
+ if [ "$flag" != "-d" ] && \
+ [ ! -f "$y" ]; then
+
continue
+
elif [ "$flag" != "-d" ]; then
+
defconfig="$y"
fi
if [ -z "$mode" ]; then
+
check_defconfig || continue; :
fi
if [ -z "$mode" ]; then
+
for _xarch in $xarch; do
+
$if_dry_build \
break
+
if [ -n "$_xarch" ]; then
+
check_cross_compiler "$_xarch"
fi
done; :
@@ -255,6 +308,7 @@ handle_defconfig()
handle_makefile
if [ -z "$mode" ]; then
+
$if_not_dry_build \
copy_elf
fi
@@ -263,7 +317,7 @@ handle_defconfig()
configure_project()
{
- _tcfg="$1/target.cfg"
+ tcfg="$1/target.cfg"
autoconfargs=""
badhash=""
@@ -281,13 +335,15 @@ configure_project()
xgcctree=""
xlang=""
- if [ ! -f "$_tcfg" ]; then
+ if [ ! -f "$tcfg" ]; then
+
buildtype="auto"
fi
# globally initialise all variables for a source tree / target:
if e "$datadir/mkhelper.cfg" f; then
+
. "$datadir/mkhelper.cfg" || \
err "Can't read '$datadir/mkhelper.cfg'" \
"configure_project" "$@"
@@ -295,8 +351,9 @@ configure_project()
# override target/tree specific variables from per-target config:
- while e "$_tcfg" f || [ "$cmd" != "build_project" ]
- do
+ while e "$tcfg" f || \
+ [ "$cmd" != "build_project" ]; do
+
# TODO: implement infinite loop detection here, caused
# by project targets pointing to other targets/trees
# when then ultimate point back repeatedly; this is
@@ -304,59 +361,78 @@ configure_project()
# temporary files per tree/target name could be created
# per iteration, and then checked the next time
- printf "Loading %s config: %s\n" "$project" "$_tcfg"
+ printf "Loading %s config: %s\n" "$project" "$tcfg"
rev=""
tree=""
- . "$_tcfg" || \
- err "Can't read '$_tcfg'" "configure_project" "$@"
+ . "$tcfg" || \
+ err "Can't read '$tcfg'" "configure_project" "$@"
if [ "$flag" = "-d" ]; then
+
build_depend="" # dry run
fi
+
if [ "$cmd" = "build_project" ]; then
+
# single-tree, so it can't be a target pointing
# to a main source tree
break
fi
+
$if_do_make \
break
- if [ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ]
+
+ if [ "${tcfg%/*/target.cfg}" = "${tcfg%"/$tree/target.cfg"}" ]
then
+
# we have found the main source tree that
# a given target uses; no need to continue
break
+
else
- _tcfg="${_tcfg%/*/target.cfg}/$tree/target.cfg"
+
+ tcfg="${tcfg%/*/target.cfg}/$tree/target.cfg"
fi
done
- if [ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ]; then
+ if [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$release" = "n" ]; then
+
return 1
fi
- if [ -n "$buildtype" ] && [ "${mode%config}" != "$mode" ]; then
+
+ if [ -n "$buildtype" ] && \
+ [ "${mode%config}" != "$mode" ]; then
+
return 1
fi
if [ -z "$mode" ]; then
+
$if_not_dry_build \
build_dependencies
fi
mdir="$xbmkpwd/config/submodule/$project"
+
if [ -n "$tree" ]; then
+
mdir="$mdir/$tree"
fi
if [ ! -f "CHANGELOG" ]; then
+
delete_old_project_files
+
$if_not_do_make \
fetch_${cmd#build_}
fi
+
$if_not_do_make \
return 1
@@ -368,20 +444,25 @@ configure_project()
build_dependencies()
{
- for bd in $build_depend
- do
+ for bd in $build_depend; do
+
bd_project="${bd%%/*}"
bd_tree="${bd##*/}"
if [ -z "$bd_project" ]; then
+
$if_not_dry_build \
err "$project/$tree: !bd '$bd'" \
"build_dependencies" "$@"
fi
+
if [ "${bd##*/}" = "$bd" ]; then
+
bd_tree=""
fi
+
if [ -n "$bd_project" ]; then
+
$if_not_dry_build \
x_ ./mk -b $bd_project $bd_tree; :
fi
@@ -401,13 +482,16 @@ delete_old_project_files()
# delete an entire source tree along with its builds:
if ! project_up_to_date hash "$tree" badhash "$datadir" \
"$configdir/$tree" "$mdir"; then
+
x_ rm -Rf "src/$project/$tree" "elf/$project/$tree"
fi
x_ cp "$xbtmp/new.hash" "$XBMK_CACHE/hash/$project$tree"
- if singletree "$project" || [ -z "$target" ] || [ "$target" = "$tree" ]
- then
+ if singletree "$project" || \
+ [ -z "$target" ] || \
+ [ "$target" = "$tree" ]; then
+
return 0
fi
@@ -417,6 +501,7 @@ delete_old_project_files()
if ! project_up_to_date tghash "$target" badtghash "$configdir/$target"
then
+
x_ rm -Rf "elf/$project/$tree/$target"
fi
@@ -437,6 +522,7 @@ project_up_to_date()
x_ xbmkdir "$XBMK_CACHE/$hashdir"
if [ -f "$XBMK_CACHE/$hashdir/$project$hashname" ]; then
+
read -r old_hash < "$XBMK_CACHE/$hashdir/$project$hashname" \
|| err \
"$hashdir: err '$XBMK_CACHE/$hashdir/$project$hashname'" \
@@ -445,6 +531,7 @@ project_up_to_date()
fi
build_sbase
+
fx_ "x_ util/sbase/sha512sum" find "$@" -type f -not -path \
"*/.git*/*" | awk '{print $1}' > "$xbtmp/tmp.hash" || \
err "!h $project $hashdir" \
@@ -456,6 +543,7 @@ project_up_to_date()
if [ "$hash" != "$old_hash" ] || \
[ ! -f "$XBMK_CACHE/$hashdir/$project$hashname" ]; then
+
eval "$badhashvar=\"y\""
fi
@@ -471,15 +559,19 @@ check_cross_compiler()
cbdir="src/coreboot/$tree"
if [ "$project" != "coreboot" ]; then
+
cbdir="src/coreboot/default"
fi
+
if [ -n "$xgcctree" ]; then
+
cbdir="src/coreboot/$xgcctree"
fi
xfix="${1%-*}"
if [ "$xfix" = "x86_64" ]; then
+
xfix="x64"
fi
@@ -487,39 +579,55 @@ check_cross_compiler()
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
+
x_ xbmkdir "elf/coreboot/$tree" # TODO: is this needed?
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
+
export CROSS_COMPILE="${xarch% *}-"
if [ -n "$xlang" ]; then
+
export BUILD_LANGUAGES="$xlang"
fi
if [ -f "$xgccfile" ]; then
+
# skip the build, because a build already exists:
return 0
fi
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
+
+ # try twice because xgcc sometimes fails for, like, no reason
+ #
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
# this tells subsequent runs that the build was already done:
+ #
x_ touch "$xgccfile"
# reset hostcc in PATH:
+ #
remkdir "$xbtmp/gnupath"
}
+# host toolchain version correction:
+
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
+# note that this was implemented for debian trixie-testing, but this same
+# issue will likely occur in future distros, including newer debian testing
+# releases. this just matches up the versions of each toolchain component.
+
check_gnu_path()
{
if ! command -v "$1" 1>/dev/null; then
+
err "Host '$1' unavailable" "check_gnu_path" "$@"
fi
@@ -531,8 +639,11 @@ check_gnu_path()
gnatver=""
if host_gcc_gnat_match "$@"; then
+
return 0
+
elif ! match_gcc_gnat_versions "$@"; then
+
return 1
fi
}
@@ -542,39 +653,47 @@ check_gnu_path()
host_gcc_gnat_match()
{
if ! gnu_setver "$1" "$1"; then
+
err "Command '$1' unavailable." "check_gnu_path" "$@"
fi
+
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
if [ "$gnatfull" != "$gccfull" ]; then
- # non-matching gcc/gnat versions
+
+ # non-matching host gcc/gnat versions
return 1
fi
}
-# find all gcc/gnat versions, matching them up in PATH:
+# find all host gcc/gnat versions, matching them up in PATH:
match_gcc_gnat_versions()
{
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
+
eval "_gnudir=\"\$$1dir\""
eval "_gnuver=\"\$$1ver\""
- for _bin in "$_gnudir/$2-"*
- do
+ for _bin in "$_gnudir/$2-"*; do
+
if [ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ]
then
+
_gnuver="${_bin#"$_gnudir/$2-"}"
break
fi
done
if ! gnu_setver "$2" "$_gnudir/$2-$_gnuver"; then
+
return 1
+
elif [ "$gnatfull" != "$gccfull" ]; then
+
return 1
fi
@@ -593,10 +712,12 @@ link_gcc_gnat_versions()
x_ cd "$xbtmp/gnupath"
- for _gnubin in "$_gnudir/$2"*"-$_gnuver"
- do
+ for _gnubin in "$_gnudir/$2"*"-$_gnuver"; do
+
_gnuutil="${_gnubin##*/}"
+
if [ -e "$_gnubin" ]; then
+
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
fi
done
@@ -617,6 +738,7 @@ gnu_setver()
check_defconfig()
{
if [ ! -f "$defconfig" ]; then
+
$if_not_dry_build \
err "$project/$target: no config" "check_defconfig" "$@"
fi
@@ -627,7 +749,9 @@ check_defconfig()
$if_dry_build \
return 0
+
if ! elfcheck; then
+
return 1
fi
}
@@ -636,17 +760,23 @@ elfcheck()
{
# TODO: *STILL* very hacky check. do it properly (based on build.list)
+ # extremely hacky check that glues the entire universe together
+
+ # beware demons
+
( fx_ "eval exit 1 && err" find "$dest_dir" -type f ) || return 1; :
}
handle_makefile()
{
if $if_not_dry_build check_makefile "$srcdir"; then
+
$if_not_dry_build \
x_ make -C "$srcdir" $cleanargs clean
fi
if [ -f "$defconfig" ]; then
+
x_ cp "$defconfig" "$srcdir/.config"
fi
@@ -656,16 +786,20 @@ handle_makefile()
_copy=".config"
if [ "$mode" = "savedefconfig" ]; then
+
_copy="defconfig"
fi
if [ "${mode%config}" != "$mode" ]; then
+
$if_not_dry_build \
x_ cp "$srcdir/$_copy" "$defconfig"; :
fi
- if [ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
+ if [ -e "$srcdir/.git" ] && \
+ [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ]; then
+
$if_not_dry_build \
x_ git -C "$srcdir" $cleanargs clean -fdx; :
fi
@@ -678,12 +812,16 @@ run_make_command()
fi
if $if_not_dry_build check_cmake "$srcdir"; then
+
if [ -z "$mode" ]; then
+
$if_not_dry_build \
check_autoconf "$srcdir"
fi
fi
+
if ! $if_not_dry_build check_makefile "$srcdir"; then
+
return 1
fi
@@ -691,17 +829,22 @@ run_make_command()
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
if [ -z "$mode" ]; then
+
x_ $mkhelper
fi
if ! check_makefile "$srcdir"; then
+
return 0
fi
if [ "$mode" = "clean" ]; then
+
$if_dry_build \
return 0
+
if ! make -C "$srcdir" $cleanargs distclean; then
+
x_ make -C "$srcdir" $cleanargs clean
fi
fi
@@ -711,13 +854,18 @@ check_cmake()
{
$if_dry_build \
return 0
+
if [ ! -n "$cmakedir" ]; then
return 0
+
elif ! check_makefile "$1"; then
+
if ! cmake -B "$1" "$1/$cmakedir"; then
+
x_ check_makefile "$1"
fi
fi
+
x_ check_makefile "$1"; :
}
@@ -727,12 +875,17 @@ check_autoconf()
x_ cd "$1"
if [ -f "bootstrap" ]; then
+
x_ ./bootstrap $bootstrapargs
fi
+
if [ -f "autogen.sh" ]; then
+
x_ ./autogen.sh $autogenargs
fi
+
if [ -f "configure" ]; then
+
x_ ./configure $autoconfargs; :
fi
@@ -741,7 +894,8 @@ check_autoconf()
check_makefile()
{
- if [ ! -f "$1/Makefile" ] && [ ! -f "$1/makefile" ] && \
+ if [ ! -f "$1/Makefile" ] && \
+ [ ! -f "$1/makefile" ] && \
[ ! -f "$1/GNUmakefile" ]; then
return 1
@@ -751,13 +905,16 @@ check_makefile()
copy_elf()
{
if [ -f "$listfile" ]; then
+
x_ xbmkdir "$dest_dir"
fi
if [ -f "$listfile" ]; then
- while read -r f
- do
+
+ while read -r f; do
+
if [ -f "$srcdir/$f" ]; then
+
x_ cp "$srcdir/$f" "$dest_dir"
fi
diff --git a/include/vendor.sh b/include/vendor.sh
index 8076d9ab..8075b6d8 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -101,6 +101,7 @@ XBMKmecleaner=""
download()
{
if [ $# -lt 1 ]; then
+
err "No argument given" "download" "$@"
fi
@@ -108,6 +109,7 @@ download()
board="$1"
if check_target; then
+
readkconfig download
fi
}
@@ -115,44 +117,63 @@ download()
getfiles()
{
if [ -n "$CONFIG_HAVE_ME_BIN" ];then
+
fetch intel_me "$DL_url" "$DL_url_bkup" "$DL_hash" \
"$CONFIG_ME_BIN_PATH" curl "$ME_bin_hash"
fi
+
if [ -n "$CONFIG_INCLUDE_SMSC_SCH5545_EC_FW" ]; then
+
fetch sch5545ec "$SCH5545EC_DL_url" "$SCH5545EC_DL_url_bkup" \
"$SCH5545EC_DL_hash" "$CONFIG_SMSC_SCH5545_EC_FW_FILE" \
"curl" "$SCH5545EC_bin_hash"
fi
+
if [ -n "$CONFIG_KBC1126_FW1" ]; then
+
fetch kbc1126ec "$EC_url" "$EC_url_bkup" "$EC_hash" \
"$CONFIG_KBC1126_FW1" curl "$EC_FW1_hash"
fi
+
if [ -n "$CONFIG_KBC1126_FW2" ]; then
+
fetch kbc1126ec "$EC_url" "$EC_url_bkup" "$EC_hash" \
"$CONFIG_KBC1126_FW2" curl "$EC_FW2_hash"
fi
+
if [ -n "$CONFIG_VGA_BIOS_FILE" ]; then
+
fetch e6400vga "$E6400_VGA_DL_url" "$E6400_VGA_DL_url_bkup" \
"$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE" "curl" \
"$E6400_VGA_bin_hash"
fi
+
if [ -n "$CONFIG_HAVE_MRC" ]; then
+
fetch "mrc" "$MRC_url" "$MRC_url_bkup" "$MRC_hash" \
"$CONFIG_MRC_FILE" "curl" "$MRC_bin_hash"
fi
+
if [ -n "$CONFIG_REFCODE_BLOB_FILE" ]; then
+
fetch "refcode" "$MRC_url" "$MRC_url_bkup" "$MRC_hash" \
"$CONFIG_REFCODE_BLOB_FILE" "curl" "$REF_bin_hash"
fi
+
if [ -n "$CONFIG_LENOVO_TBFW_BIN" ]; then
+
fetch "tbfw" "$TBFW_url" "$TBFW_url_bkup" "$TBFW_hash" \
"$CONFIG_LENOVO_TBFW_BIN" "curl" "$TBFW_bin_hash"
fi
+
if [ -n "$CONFIG_FSP_M_FILE" ]; then
+
fetch "fsp" "$CONFIG_FSP_FD_PATH" "$CONFIG_FSP_FD_PATH" \
"$FSPFD_hash" "$CONFIG_FSP_M_FILE" "copy" "$FSPM_bin_hash"
fi
+
if [ -n "$CONFIG_FSP_S_FILE" ]; then
+
fetch "fsp" "$CONFIG_FSP_FD_PATH" "$CONFIG_FSP_FD_PATH" \
"$FSPFD_hash" "$CONFIG_FSP_S_FILE" "copy" "$FSPS_bin_hash"
fi
@@ -170,6 +191,7 @@ fetch()
binsum="$7"
if [ -z "$binsum" ]; then
+
err "binsum is empty (no checksum)" "fetch" "$@"
fi
@@ -177,23 +199,29 @@ fetch()
_dl_bin="$XBMK_CACHE/file/$binsum" # extracted file e.g. me.bin
if [ "$5" = "/dev/null" ]; then
+
return 0
fi
# an extracted vendor file will be placed in pre_dest first, for
- # verifying its checksum. if it matches, it is later moved to _dest
+ # verifying its checksum. if it matches, it is later moved to _dest:
+
remkdir "${_pre_dest%/*}" "$appdir"
- # HACK: if grabbing fsp from coreboot, fix the path for lbmk
- if [ "$dl_type" = "fsp" ]
- then
+ # HACK: if grabbing fsp from coreboot, fix the path for lbmk:
+
+ if [ "$dl_type" = "fsp" ]; then
+
dl="${dl##*../}"
_cdp="$dl"
if [ ! -f "$_cdp" ]; then
+
_cdp="$cbdir/$_cdp"
fi
+
if [ -f "$_cdp" ]; then
+
dl="$_cdp"
fi
@@ -201,9 +229,12 @@ fetch()
_cdp="$dl_bkup"
if [ ! -f "$_cdp" ]; then
+
_cdp="$cbdir/$_cdp"
fi
+
if [ -f "$_cdp" ]; then
+
dl_bkup="$_cdp"; :
fi
fi
@@ -216,39 +247,50 @@ fetch()
# skip extraction if a cached extracted file exists:
( xbget copy "$_dl_bin" "$_dl_bin" "$_dest" "$binsum" 2>/dev/null ) || :
+
if [ -f "$_dest" ]; then
+
return 0
fi
x_ xbmkdir "${_dest%/*}"
if [ "$dl_type" != "fsp" ]; then
+
extract_archive "$_dl" "$appdir" || \
[ "$dl_type" = "e6400vga" ] || \
err "$_dest $dl_type: !extract" "fetch" "$@"
fi
x_ extract_$dl_type "$_dl" "$appdir"
+
set -u -e
# some functions don't output directly to the given file, _pre_dest.
# instead, they put multiple files there, but we need the one matching
# the given hashsum. So, search for a matching file via bruteforce:
+
( fx_ "mkdst $binsum" x_ find "${_pre_dest%/*}" -type f ) || :
if ! bad_checksum "$binsum" "$_dest"; then
+
if [ -f "$_dest" ]; then
+
return 0
fi
fi
if [ -z "$binsum" ]; then
+
printf "'%s': checksum undefined\n" "$_dest" 1>&2
fi
if [ -L "$_dest" ]; then
+
printf "WARNING: '%s' is a link!\n" "$_dest" 1>&2
+
else
+
x_ rm -f "$_dest"
fi
@@ -258,8 +300,11 @@ fetch()
mkdst()
{
if bad_checksum "$1" "$2" 2>/dev/null; then
+
x_ rm -f "$2"
+
else
+
x_ mv "$2" "$_dl_bin"
x_ cp "$_dl_bin" "$_dest"
@@ -270,10 +315,12 @@ mkdst()
extract_intel_me()
{
if e "$mecleaner" f missing; then
+
err "$cbdir: me_cleaner missing" "extract_intel_me" "$@"
fi
mfs=""
+
_7ztest="$xbtmp/metmp/a"
_metmp="$xbtmp/me.bin"
@@ -281,17 +328,26 @@ extract_intel_me()
x_ rm -Rf "$_7ztest"
# maintain compatibility with older configs
- # because in the past, shrink was assumed
+ # because in the past, shrink was assumed:
+
if [ -z "$MEshrink" ]; then
+
MEshrink="y"
fi
- if [ "$MEshrink" != "y" ] && [ "$MEshrink" != "n" ]; then
+
+ if [ "$MEshrink" != "y" ] && \
+ [ "$MEshrink" != "n" ]; then
+
err "MEshrink set badly on '$board' vendor config"
fi
if [ "$ME11bootguard" = "y" ]; then
- if [ -z "$ME11delta" ] || [ -z "$ME11version" ] || \
- [ -z "$ME11sku" ] || [ -z "$ME11pch" ]; then
+
+ if [ -z "$ME11delta" ] || \
+ [ -z "$ME11version" ] || \
+ [ -z "$ME11sku" ] || \
+ [ -z "$ME11pch" ]; then
+
err "$board: ME11delta/ME11version/ME11sku/ME11pch" \
"extract_intel_me" "$@"
fi
@@ -306,8 +362,11 @@ extract_intel_me()
set -u -e
if [ "$ME11bootguard" != "y" ]; then
+
x_ mv "$_metmp" "$_pre_dest"
+
else
+
( apply_deguard_hack ) || \
err "deguard error on '$_dest'" "extract_intel_me" "$@"; :
fi
@@ -318,10 +377,13 @@ extract_intel_me()
find_me()
{
if [ -f "$_metmp" ]; then
+
# we found me.bin, so we stop searching
exit 1
+
elif [ -L "$1" ]; then
+
return 0
fi
@@ -333,15 +395,21 @@ find_me()
_trunc="-t" # -t: truncate the ME size
if [ "$ME11bootguard" = "y" ]; then
+
mfs="--whitelist MFS"
fi
+
if [ "$MEclean" = "n" ]; then
+
MEshrink="n"
_keep="-k" # keep ME modules, don't delete anything
mfs="" # no MFS whitelist needed, due to -r:
fi
- if [ "$MEclean" = "n" ] || [ "$MEshrink" != "y" ]; then
+
+ if [ "$MEclean" = "n" ] || \
+ [ "$MEshrink" != "y" ]; then
+
# MEclean can still be y, this just means don't shrink,
# so deleted modules would become padded space. this
# could also be used alongside --whitelist, if
@@ -350,38 +418,57 @@ find_me()
_r="" # don't re-locate ME modules
_trunc="" # don't shrink the me.bin file size
fi
+
if [ "$MEcheck" = "n" ]; then
+
_pass="-p" # skip fptr check
fi
+
if [ -n "$mfs" ]; then
+
_r="" # cannot re-locate modules if using --whitelist MFS
fi
if "$mecleaner" $mfs $_r $_keep $_pass $_trunc -O "$xbtmp/a" \
- -M "$_metmp" "$1" || [ -f "$_metmp" ]; then
+ -M "$_metmp" "$1" \
+ || \
+ [ -f "$_metmp" ]; then
+
# me.bin extracted from a full image with ifd, then shrunk
:
- elif "$mecleaner" $mfs $_r $_pass $_keep $_trunc -O "$_metmp" "$1" || \
+
+ elif "$mecleaner" $mfs $_r $_pass $_keep $_trunc -O "$_metmp" "$1" \
+ || \
[ -f "$_metmp" ]; then
+
# me.bin image already present, and we shrunk it
:
+
elif "$me7updateparser" $_keep -O "$_metmp" "$1"; then
+
# thinkpad sandybridge me.bin image e.g. x220/t420
:
+
elif extract_archive "$1" "$_7ztest"; then
+
# scan newly extracted archive within extracted archive
:
+
else
+
# could not extract anything, so we'll try the next file
return 0
fi
if [ -f "$_metmp" ]; then
+
# we found me.bin, so we stop searching
exit 1
else
+
# if the subshell does exit 1, we found me.bin, so exit 1
+
( fx_ find_me x_ find "$_7ztest" -type f ) || exit 1; :
fi
}
@@ -398,20 +485,32 @@ apply_deguard_hack()
extract_archive()
{
if innoextract "$1" -d "$2"; then
+
:
+
elif python "$pfs_extract" "$1" -e; then
+
:
+
elif 7z x "$1" -o"$2"; then
+
:
+
elif "$bsdtar" -C "$2" -xf "$1"; then
+
:
+
elif "$bsdunzip" "$1" -d "$2"; then
+
:
+
else
+
return 1
fi
if [ -d "${_dl}_extracted" ]; then
+
x_ cp -R "${_dl}_extracted" "$2"
fi
}
@@ -433,22 +532,33 @@ extract_kbc1126ec_dump()
x_ cd "$appdir/"
if mv Rompaq/68*.BIN ec.bin; then
+
:
+
elif unar -D ROM.CAB Rom.bin; then
+
:
+
elif unar -D Rom.CAB Rom.bin; then
+
:
+
elif unar -D 68*.CAB Rom.bin; then
+
:
+
else
+
err "!kbc1126 unar" "extract_kbc1126ec" "$@"
fi
if [ ! -f "ec.bin" ]; then
+
x_ mv Rom.bin ec.bin
fi
if x_ e ec.bin f; then
+
x_ "$kbc1126_ec_dump" ec.bin
fi
}
@@ -457,7 +567,9 @@ extract_e6400vga()
{
set +u +e
- if [ -z "$E6400_VGA_offset" ] || [ -z "$E6400_VGA_romname" ]; then
+ if [ -z "$E6400_VGA_offset" ] || \
+ [ -z "$E6400_VGA_romname" ]; then
+
err "$board: E6400_VGA_romname/E6400_VGA_offset unset" \
"extract_e6400vga" "$@"
fi
@@ -465,9 +577,12 @@ extract_e6400vga()
tail -c +$E6400_VGA_offset "$_dl" | gunzip > "$appdir/bios.bin" || :
(
+
x_ cd "$appdir"
x_ e "bios.bin" f
+
"$e6400_unpack" bios.bin || printf "TODO: fix dell extract util\n"
+
) || err "can't extract e6400 vga rom" "extract_e6400vga" "$@"
x_ cp "$appdir/$E6400_VGA_romname" "$_pre_dest"
@@ -484,6 +599,7 @@ extract_sch5545ec()
_sch5545ec_fw="$_sch5545ec_fw/0 Raw section/body.bin" # <-- this!
x_ "$uefiextract" "$_bios"
+
x_ cp "$_sch5545ec_fw" "$_pre_dest"
}
@@ -492,6 +608,7 @@ extract_sch5545ec()
extract_tbfw()
{
if [ -z "$TBFW_size" ]; then
+
err "$board: TBFW_size unset" "extract_tbfw" "$@"
fi
@@ -500,7 +617,9 @@ extract_tbfw()
copytb()
{
- if [ -f "$1" ] && [ ! -L "$1" ]; then
+ if [ -f "$1" ] && \
+ [ ! -L "$1" ]; then
+
x_ dd if=/dev/null of="$1" bs=1 seek=$TBFW_size
x_ mv "$1" "$_pre_dest"
@@ -516,24 +635,29 @@ extract_fsp()
setvfile()
{
- [ -n "$vcfg" ] && for c in $checkvarschk
- do
+ [ -n "$vcfg" ] && for c in $checkvarschk; do
+
do_getvfile="n"
+
vcmd="[ \"\${$c}\" != \"/dev/null\" ] && [ -n \"\${$c}\" ]"
eval "$vcmd && do_getvfile=\"y\""
if [ "$do_getvfile" = "y" ]; then
+
if getvfile "$@"; then
+
return 0
fi
fi
+
done && return 1; :
}
getvfile()
{
if e "config/vendor/$vcfg/pkg.cfg" f missing; then
+
return 1
fi
@@ -543,13 +667,16 @@ getvfile()
bootstrap
if [ $# -gt 0 ]; then
+
# download vendor files
getfiles
else
+
# inject vendor files
fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
+
( check_vendor_hashes ) || \
err "$archive: Can't verify hashes" "getvfile" "$@"; :
fi
@@ -564,7 +691,9 @@ bootstrap()
rmodtool="elf/coreboot/$tree/rmodtool"
mecleaner="$xbmkpwd/$cbdir/util/me_cleaner/me_cleaner.py"
+
if [ "$XBMKmecleaner" = "y" ]; then
+
mecleaner="$xbmkpwd/src/me_cleaner/me_cleaner.py"
fi
@@ -577,10 +706,12 @@ bootstrap()
x_ ./mk -b libarchive # for bsdtar and bsdunzip
if [ -d "${kbc1126_ec_dump%/*}" ]; then
+
x_ make -C "$cbdir/util/kbc1126"
fi
if [ -n "$MRC_refcode_cbtree" ]; then
+
cbfstoolref="elf/coreboot/$MRC_refcode_cbtree/cbfstool"
x_ ./mk -d coreboot "$MRC_refcode_cbtree"; :
fi
@@ -593,20 +724,23 @@ prep()
_xromnew="${_xrom%/*}/${_xromname#"$vfix"}"
if [ "$nuke" = "nuke" ]; then
+
_xromnew="${_xrom%/*}/$vfix${_xrom##*/}"
fi
if e "$_xrom" f missing; then
+
return 0
fi
if [ -z "${_xromname#"$vfix"}" ]; then
+
err "$_xromname / $vfix: name match" "prep" "$@"
fi
# Remove the prefix and 1-byte pad
- if [ "${_xromname#"$vfix"}" != "$_xromname" ] \
- && [ "$nuke" != "nuke" ]; then
+ if [ "${_xromname#"$vfix"}" != "$_xromname" ] && \
+ [ "$nuke" != "nuke" ]; then
unpad_one_byte "$_xrom"
x_ mv "$_xrom" "$_xromnew"
@@ -615,10 +749,12 @@ prep()
fi
if [ "$nuke" = "nuke" ]; then
+
( mksha512 "$_xrom" "vendorhashes" ) || err; :
fi
if ! add_vfiles "$_xrom"; then
+
# no need to insert files. we will later
# still process MAC addresses as required
@@ -626,7 +762,9 @@ prep()
fi
if [ "$nuke" = "nuke" ]; then
+
pad_one_byte "$_xrom"
+
x_ mv "$_xrom" "$_xromnew"
fi
}
@@ -636,6 +774,7 @@ mksha512()
build_sbase
if [ "${1%/*}" != "$1" ]; then
+
x_ cd "${1%/*}"
fi
@@ -648,46 +787,68 @@ add_vfiles()
rom="$1"
if [ "$has_hashes" != "y" ] && [ "$nuke" != "nuke" ]; then
+
printf "'%s' has no hash file. Skipping.\n" "$archive" 1>&2
return 1
+
elif [ "$has_hashes" = "y" ] && [ "$nuke" = "nuke" ]; then
+
printf "'%s' has a hash file. Skipping nuke.\n" "$archive" 1>&2
return 1
fi
if [ -n "$CONFIG_HAVE_REFCODE_BLOB" ]; then
+
vfile "fallback/refcode" "$CONFIG_REFCODE_BLOB_FILE" "stage"
fi
+
if [ "$CONFIG_HAVE_MRC" = "y" ]; then
+
vfile "mrc.bin" "$CONFIG_MRC_FILE" "mrc" "0xfffa0000"
fi
+
if [ "$CONFIG_HAVE_ME_BIN" = "y" ]; then
+
vfile IFD "$CONFIG_ME_BIN_PATH" me
fi
+
if [ -n "$CONFIG_KBC1126_FW1" ]; then
+
vfile ecfw1.bin "$CONFIG_KBC1126_FW1" raw \
"$CONFIG_KBC1126_FW1_OFFSET"
fi
+
if [ -n "$CONFIG_KBC1126_FW2" ]; then
+
vfile ecfw2.bin "$CONFIG_KBC1126_FW2" raw \
"$CONFIG_KBC1126_FW2_OFFSET"
fi
+
if [ -n "$CONFIG_VGA_BIOS_FILE" ] && [ -n "$CONFIG_VGA_BIOS_ID" ]; then
+
vfile "pci$CONFIG_VGA_BIOS_ID.rom" "$CONFIG_VGA_BIOS_FILE" \
optionrom
fi
+
if [ "$CONFIG_INCLUDE_SMSC_SCH5545_EC_FW" = "y" ] && \
[ -n "$CONFIG_SMSC_SCH5545_EC_FW_FILE" ]; then
+
vfile sch5545_ecfw.bin "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw
fi
- if [ -z "$CONFIG_FSP_USE_REPO" ] && [ -z "$CONFIG_FSP_FULL_FD" ] && \
+
+ if [ -z "$CONFIG_FSP_USE_REPO" ] && \
+ [ -z "$CONFIG_FSP_FULL_FD" ] && \
[ -n "$CONFIG_FSP_M_FILE" ]; then
+
vfile "$CONFIG_FSP_M_CBFS" "$CONFIG_FSP_M_FILE" fsp --xip
fi
- if [ -z "$CONFIG_FSP_USE_REPO" ] && [ -z "$CONFIG_FSP_FULL_FD" ] && \
+
+ if [ -z "$CONFIG_FSP_USE_REPO" ] && \
+ [ -z "$CONFIG_FSP_FULL_FD" ] && \
[ -n "$CONFIG_FSP_S_FILE" ]; then
+
vfile "$CONFIG_FSP_S_CBFS" "$CONFIG_FSP_S_FILE" fsp
fi
@@ -699,6 +860,7 @@ add_vfiles()
vfile()
{
if [ "$2" = "/dev/null" ]; then
+
return 0
fi
@@ -708,34 +870,50 @@ vfile()
_offset=""
- if [ "$blobtype" = "fsp" ] && [ $# -gt 3 ]; then
+ if [ "$blobtype" = "fsp" ] && \
+ [ $# -gt 3 ]; then
+
_offset="$4"
- elif [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ]; then
+
+ elif [ $# -gt 3 ] && \
+ _offset="-b $4" && [ -z "$4" ]; then
+
err "$rom: offset given but empty (undefined)" "vfile" "$@"
fi
if [ "$nuke" != "nuke" ]; then
+
x_ e "$_dest" f
fi
if [ "$cbfsname" = "IFD" ]; then
+
if [ "$nuke" = "nuke" ]; then
+
x_ "$ifdtool" $ifdprefix --nuke $blobtype "$rom" \
-O "$rom"
else
+
x_ "$ifdtool" $ifdprefix -i $blobtype:$_dest "$rom" \
-O "$rom"
fi
+
elif [ "$nuke" = "nuke" ]; then
+
x_ "$cbfstool" "$rom" remove -n "$cbfsname"
+
elif [ "$blobtype" = "stage" ]; then
+
# the only stage we handle is refcode
x_ rm -f "$xbtmp/refcode"
+
x_ "$rmodtool" -i "$_dest" -o "$xbtmp/refcode"
x_ "$cbfstool" "$rom" add-stage -f "$xbtmp/refcode" \
-n "$cbfsname" -t stage
+
else
+
x_ "$cbfstool" "$rom" add -f "$_dest" -n "$cbfsname" \
-t $blobtype $_offset
fi
@@ -750,7 +928,9 @@ check_vendor_hashes()
x_ cd "$tmpromdir"
- if [ "$has_hashes" != "n" ] && [ "$nuke" != "nuke" ]; then
+ if [ "$has_hashes" != "n" ] && \
+ [ "$nuke" != "nuke" ]; then
+
( x_ "$sha512sum" -c "$hashfile" ) || \
x_ sha1sum -c "$hashfile"
fi