xbmk: much more verbose error messages

use the new functionality in err(), whereby a given
function name and arguments can be provided, for
debugging purposes.

something similar was already done in a few places,
and replaced with this unified functionality.

this patch will make xbmk much easier to debug, under
fault conditions.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-09-13 13:27:47 +01:00
parent 7bed68f5b7
commit 995963baf4
10 changed files with 185 additions and 112 deletions
+9 -6
View File
@@ -63,7 +63,8 @@ fetch_submodule()
eval "$_seval; then st=\"\$st \$xt\"; fi" eval "$_seval; then st=\"\$st \$xt\"; fi"
done done
st="${st# }" && [ "$st" = "git curl" ] && err "$mdir: git+curl defined" st="${st# }" && [ "$st" = "git curl" ] && \
err "$mdir: git+curl defined" fetch_submodule "$@"
[ -z "$st" ] && return 0 # subgit/subcurl not defined [ -z "$st" ] && return 0 # subgit/subcurl not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash" chkvars "sub${st}" "sub${st}_bkup" "subhash"
@@ -75,7 +76,7 @@ fetch_submodule()
xbget() xbget()
{ {
[ "$1" = "curl" ] || [ "$1" = "copy" ] || [ "$1" = "git" ] || \ [ "$1" = "curl" ] || [ "$1" = "copy" ] || [ "$1" = "git" ] || \
err "Bad dlop (arg 1): xbget $*" err "Bad dlop (arg 1)" xbget "$@"
for url in "$2" "$3"; do for url in "$2" "$3"; do
[ -n "$url" ] || err "empty URL given in: xbget $*" [ -n "$url" ] || err "empty URL given in: xbget $*"
@@ -86,7 +87,7 @@ xbget()
esac esac
return 0 # successful download/copy return 0 # successful download/copy
done done
err "$1 $2 $3 $4: not downloaded"; : err "failed to download file/repository" xbget "$@"; :
} }
try_file() try_file()
@@ -108,7 +109,7 @@ try_file()
if [ "$2" = "git" ]; then if [ "$2" = "git" ]; then
[ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || \ [ -d "$5" ] || tmpclone "$cached" "$5" "$6" "$7" || \
err "Can't clone final repo in command: try_file $*"; : err "Can't clone final repo" try_file "$@"; :
else else
bad_checksum "$6" "$cached" && x_ rm -f "$cached" && return 1 bad_checksum "$6" "$cached" && x_ rm -f "$cached" && return 1
[ "$cached" != "$5" ] && x_ cp "$cached" "$5" [ "$cached" != "$5" ] && x_ cp "$cached" "$5"
@@ -133,7 +134,8 @@ try_copy()
try_git() try_git()
{ {
gitdest="$(findpath "$1" || err "Can't get readpath for '$1'")" || err gitdest="$(findpath "$1" || err "Can't get findpath for '$1'")" || \
err "failed findpath for '$1'" try_get "$@"
x_ rm -Rf "$tmpgitcache" x_ rm -Rf "$tmpgitcache"
[ -d "$gitdest" ] || ( x_ git clone "$2" "$tmpgitcache" ) || return 1 [ -d "$gitdest" ] || ( x_ git clone "$2" "$tmpgitcache" ) || return 1
@@ -150,7 +152,8 @@ try_git()
bad_checksum() bad_checksum()
{ {
e "$2" f missing && return 0 e "$2" f missing && return 0
csum="$(x_ sha512sum "$2" | awk '{print $1}')" || err "!sha512 '$2' $1" csum="$(x_ sha512sum "$2" | awk '{print $1}')" || \
err "!sha512 '$2' $1" bad_checksum "$@"
[ "$csum" = "$1" ] && return 1; x_ rm -f "$2" [ "$csum" = "$1" ] && return 1; x_ rm -f "$2"
printf "BAD SHA512 %s, '%s'; need '%s'\n" "$csum" "$2" "$1" 1>&2 printf "BAD SHA512 %s, '%s'; need '%s'\n" "$csum" "$2" "$1" 1>&2
} }
+45 -25
View File
@@ -19,7 +19,7 @@ eval "$(setvars "" _nogit board reinstall versiondate aur_notice configdir \
xbmk_init() xbmk_init()
{ {
xbmkpwd="$(pwd || err "Cannot generate PWD")" || err xbmkpwd="$(pwd || err "Cannot generate PWD")" || err "!" xbmk_init "$@"
xbmklock="$xbmkpwd/lock" xbmklock="$xbmkpwd/lock"
basetmp="$xbmkpwd/xbmkwd" basetmp="$xbmkpwd/xbmkwd"
@@ -28,8 +28,9 @@ xbmk_init()
[ $# -gt 0 ] && [ "$1" = "dependencies" ] && x_ xbmkpkg "$@" && exit 0 [ $# -gt 0 ] && [ "$1" = "dependencies" ] && x_ xbmkpkg "$@" && exit 0
id -u 1>/dev/null 2>/dev/null || err "suid check failed (id -u)" id -u 1>/dev/null 2>/dev/null || err "suid check failed" xbmk_init "$@"
[ "$(id -u)" != "0" ] || err "this command as root is not permitted" [ "$(id -u)" != "0" ] || \
err "this command as root is not permitted" xbmk_init "$@"
for init_cmd in get_version set_env set_threads git_init child_exec; do for init_cmd in get_version set_env set_threads git_init child_exec; do
xbmk_$init_cmd "$@" || break xbmk_$init_cmd "$@" || break
@@ -38,7 +39,7 @@ xbmk_init()
xbmkpkg() xbmkpkg()
{ {
[ $# -lt 2 ] && err "fewer than two arguments" xchk xbmkpkg "$@"
[ $# -gt 2 ] && reinstall="$3" [ $# -gt 2 ] && reinstall="$3"
eval "$(setcfg "config/dependencies/$2")" eval "$(setcfg "config/dependencies/$2")"
@@ -52,8 +53,10 @@ xbmkpkg()
xbmk_get_version() xbmk_get_version()
{ {
[ ! -f ".version" ] || read -r version < ".version" || err [ ! -f ".version" ] || read -r version < ".version" || \
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || err err "can't read version file" xbmk_get_version "$@"
[ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || \
err "can't read versiondate" xbmk_get_version "$@"
[ ! -f ".version" ] || chkvars version [ ! -f ".version" ] || chkvars version
[ ! -f ".versiondate" ] || chkvars versiondate [ ! -f ".versiondate" ] || chkvars versiondate
@@ -74,7 +77,8 @@ xbmk_set_env()
if [ "$is_child" = "y" ]; then if [ "$is_child" = "y" ]; then
xbmk_child_set_tmp xbmk_child_set_tmp
[ -z "${XBMK_CACHE+x}" ] && err "XBMK_CACHE unset on child" [ -z "${XBMK_CACHE+x}" ] && \
err "XBMK_CACHE unset on child" xbmk_set_env "$@"
[ -z "${XBMK_THREADS+x}" ] && xbmk_set_threads; : [ -z "${XBMK_THREADS+x}" ] && xbmk_set_threads; :
return 1 return 1
fi fi
@@ -83,7 +87,7 @@ xbmk_set_env()
xbmk_parent_check_tmp xbmk_parent_check_tmp
printf "%s\n" "$xbtmp" > "$xbmklock" || \ printf "%s\n" "$xbtmp" > "$xbmklock" || \
err "cannot create '$xbmklock'"; : err "cannot create '$xbmklock'" xbmk_set_env "$@"; :
x_ chmod -w "$xbmklock" x_ chmod -w "$xbmklock"
xbmk_parent_set_export xbmk_parent_set_export
@@ -99,7 +103,8 @@ xbmk_child_set_tmp()
[ -z "${TMPDIR+x}" ] && export TMPDIR="$basetmp" [ -z "${TMPDIR+x}" ] && export TMPDIR="$basetmp"
# extremely pedantic safety checks on TMPDIR # extremely pedantic safety checks on TMPDIR
xbtmpchk="$(findpath "$TMPDIR" || err "!findpath $TMPDIR")" || err xbtmpchk="$(findpath "$TMPDIR" || err "!findpath $TMPDIR")" || \
err "!findpath '$TMPDIR'" xbmk_child_set_tmp "$@"
[ "$xbtmpchk" = "${xbtmpchk#"$basetmp/"}" ] && \ [ "$xbtmpchk" = "${xbtmpchk#"$basetmp/"}" ] && \
badtmp="not a subdirectory in $basetmp" badtmp="not a subdirectory in $basetmp"
[ -z "$badtmp" ] && xbtmpname="${xbtmpchk#"$basetmp/"}" && \ [ -z "$badtmp" ] && xbtmpname="${xbtmpchk#"$basetmp/"}" && \
@@ -112,7 +117,8 @@ xbmk_child_set_tmp()
if [ -z "$badtmp" ]; then if [ -z "$badtmp" ]; then
# final check: check if TMPDIR changed # final check: check if TMPDIR changed
locktmp="" locktmp=""
read -r locktmp < "$xbmklock" || err "!read $xbmklock" read -r locktmp < "$xbmklock" || \
err "can't read '$xbmklock'" xbmk_child_set_tmp "$@"
[ "$locktmp" = "$xbtmpchk" ] || \ [ "$locktmp" = "$xbtmpchk" ] || \
badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'" badtmp="TMPDIR '$xbtmpchk' changed; was '$locktmp'"
fi fi
@@ -130,23 +136,28 @@ xbmk_parent_check_tmp()
{ {
export TMPDIR="$basetmp" export TMPDIR="$basetmp"
xbmklist="$(mktemp || err "can't make tmplist")" || err xbmklist="$(mktemp || err "can't make tmplist")" || \
err "can't make tmplist" xbmk_parent_check_tmp "$@"
x_ rm -f "$xbmklist" x_ rm -f "$xbmklist"
x_ touch "$xbmklist" x_ touch "$xbmklist"
for xtmpdir in "$basetmp"/xbmk_*; do for xtmpdir in "$basetmp"/xbmk_*; do
[ -e "$xtmpdir" ] || continue [ -e "$xtmpdir" ] || continue
printf "%s\n" "$xtmpdir" >> "$xbmklist" || \ printf "%s\n" "$xtmpdir" >> "$xbmklist" || \
err "can't write '$xtmpdir' to file: '$xbmklist'"; : err "can't write '$xtmpdir' to file: '$xbmklist'" \
xbmk_parent_check_tmp "$@"; :
done done
# set up a unified temporary directory, for common deletion later: # set up a unified temporary directory, for common deletion later:
export TMPDIR="$(x_ mktemp -d -t xbmk_XXXXXXXX)" || err export TMPDIR="$(x_ mktemp -d -t xbmk_XXXXXXXX)" || \
err "can't export TMPDIR" xbmk_parent_check_tmp "$@"
xbtmp="$TMPDIR" xbtmp="$TMPDIR"
while read -r xtmpdir; do while read -r xtmpdir; do
[ "$xtmpdir" = "$xbtmp" ] && err \ [ "$xtmpdir" = "$xbtmp" ] && err \
"'$xbtmp' existed previously (possible race condition)"; : "'$xbtmp' existed previously (possible race condition)" \
done < "$xbmklist" || err "Couldn't read xbmklist: '$xbmklist'" xbmk_parent_check_tmp "$@"; :
done < "$xbmklist" || err "Couldn't read xbmklist: '$xbmklist'" \
xbmk_parent_check_tmp "$@"
x_ rm -f "$xbmklist" x_ rm -f "$xbmklist"
} }
@@ -154,9 +165,11 @@ xbmk_parent_set_export()
{ {
export XBMK_CACHE="$xbmkpwd/cache" export XBMK_CACHE="$xbmkpwd/cache"
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \ [ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
err "cachedir '$xbmkpwd/cache' is a symlink" err "cachedir '$xbmkpwd/cache' is a symlink" \
xbmk_parent_set_export "$@"
[ ! -e "$XBMK_CACHE" ] || \ [ ! -e "$XBMK_CACHE" ] || \
[ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file"; : [ -d "$XBMK_CACHE" ] || err "cachedir '$XBMK_CACHE' is a file" \
xbmk_parent_set_export "$@"; :
export PATH="$xbtmp/xbmkpath:$xbtmp/gnupath:$PATH" export PATH="$xbtmp/xbmkpath:$xbtmp/gnupath:$PATH"
xbmkpath="$PATH" xbmkpath="$PATH"
@@ -199,18 +212,22 @@ xbmk_set_pyver()
pyver="2" && [ "$python" = "python3" ] && pyver="3" pyver="2" && [ "$python" = "python3" ] && pyver="3"
pybin "$python" 1>/dev/null || pyver="" pybin "$python" 1>/dev/null || pyver=""
[ -z "$pyver" ] || "$(x_ pybin "$python")" -c "$pyv" 1>/dev/null \ [ -z "$pyver" ] || "$(x_ pybin "$python")" -c "$pyv" 1>/dev/null \
2>/dev/null || err "Cannot detect host Python version." 2>/dev/null || err "Cannot detect host Python version." \
xbmk_set_pyver "$@"
[ -n "$pyver" ] && \ [ -n "$pyver" ] && \
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \ pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \
pyver="${pyver#(}" && pyver="${pyver%,}" pyver="${pyver#(}" && pyver="${pyver%,}"
[ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)" [ "${pyver%%.*}" = "3" ] || err "Bad python version (must by 3.x)" \
xbmk_set_pyver "$@"
( (
# set up python v3.x in PATH, in case it's not set up correctly. # set up python v3.x in PATH, in case it's not set up correctly.
# see code above that detected the correct python3 command. # see code above that detected the correct python3 command.
x_ cd "$xbtmp/xbmkpath" x_ cd "$xbtmp/xbmkpath"
x_ ln -s "$(x_ pybin "$python")" python || err x_ ln -s "$(x_ pybin "$python")" python || err "can't make symlink" \
) || err "Can't set up python symlink in $xbtmp/xbmkpath"; : xbmk_set_pyver "$@"
) || err "Can't set up python symlink in $xbtmp/xbmkpath" \
xbmk_set_pyver "$@"; :
} }
# Use direct path, to prevent a hang if Python is using a virtual environment, # Use direct path, to prevent a hang if Python is using a virtual environment,
@@ -248,17 +265,20 @@ xbmk_git_init()
{ {
for gitarg in "--global user.name" "--global user.email"; do for gitarg in "--global user.name" "--global user.email"; do
gitcmd="git config $gitarg"; $gitcmd 1>/dev/null 2>/dev/null \ gitcmd="git config $gitarg"; $gitcmd 1>/dev/null 2>/dev/null \
|| err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" || err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" \
"xbmk_git_init" "$@"
done done
[ -L ".git" ] && err "'$xbmkpwd/.git' is a symlink" [ -L ".git" ] && err "'$xbmkpwd/.git' is a symlink" \
"xbmk_git_init" "$@"
[ -e ".git" ] && return 0 [ -e ".git" ] && return 0
x_ date --version | grep "GNU coreutils" 1>/dev/null 2>/dev/null || \ x_ date --version | grep "GNU coreutils" 1>/dev/null 2>/dev/null || \
err "Non-GNU date implementation; current use relies on GNU date" err "Non-GNU date implementation; current use relies on GNU date" \
"xbmk_git_init" "$@"
eval "$(setvars "$(x_ date -Rud @$versiondate)" cdate _nogit || err)" \ eval "$(setvars "$(x_ date -Rud @$versiondate)" cdate _nogit || err)" \
err err "can't get date" "xbmk_git_init" "$@"
x_ git init 1>/dev/null 2>/dev/null x_ git init 1>/dev/null 2>/dev/null
x_ git add -A . 1>/dev/null 2>/dev/null x_ git add -A . 1>/dev/null 2>/dev/null
+15 -12
View File
@@ -19,7 +19,7 @@ inject()
{ {
remkdir "$tmpromdel" remkdir "$tmpromdel"
[ $# -lt 1 ] && err "No options specified" [ $# -lt 1 ] && err "No options specified" "inject" "$@"
eval "$(setvars "" nuke new_mac xchanged)" eval "$(setvars "" nuke new_mac xchanged)"
archive="$1"; archive="$1";
@@ -31,9 +31,10 @@ inject()
nuke="nuke" ;; nuke="nuke" ;;
setmac) setmac)
[ $# -gt 2 ] && new_mac="$3" && \ [ $# -gt 2 ] && new_mac="$3" && \
[ -z "$new_mac" ] && err "Empty MAC address specified" ;; [ -z "$new_mac" ] && \
err "Empty MAC address specified" "inject" "$@" ;;
*) *)
err "Unrecognised inject mode: '$2'" ;; err "Unrecognised inject mode: '$2'" "inject" "$@" ;;
esac esac
[ "$new_mac" = "keep" ] && new_mac="" [ "$new_mac" = "keep" ] && new_mac=""
@@ -50,22 +51,23 @@ inject()
check_release() check_release()
{ {
[ -L "$archive" ] && err "'$archive' is a symlink" [ -L "$archive" ] && err "'$archive' is a symlink" "check_release" "$@"
e "$archive" f missing && err "'$archive' missing" e "$archive" f missing && err "'$archive' missing" "check_release" "$@"
archivename="$(basename "$archive" || err "Can't get '$archive' name")" \ archivename="$(basename "$archive" || err "Can't get '$archive' name")" \
|| err || err "can't get '$archive' name" "check_release" "$@"
[ -z "$archivename" ] && err "Can't determine archive name" [ -z "$archivename" ] && \
err "Can't determine archive name" "check_release" "$@"
case "$archivename" in case "$archivename" in
*_src.tar.xz) *_src.tar.xz)
err "'$archive' is a src archive, silly!" ;; err "'$archive' is a src archive!" "check_release" "$@" ;;
grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*) grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*)
err "'$archive' is a ROM image (it must be a tarball)" ;; err "'$archive' is a ROM image" "check_release" "$@" ;;
*.tar.xz) _stripped_prefix="${archivename#*_}" *.tar.xz) _stripped_prefix="${archivename#*_}"
board="${_stripped_prefix%.tar.xz}" ;; board="${_stripped_prefix%.tar.xz}" ;;
*) *)
err "'$archive': could not detect board type" ;; err "'$archive': cannot detect board" "check_release" "$@" ;;
esac; : esac; :
} }
@@ -141,8 +143,9 @@ remktar()
x_ cd "${tmpromdir%"/bin/$board"}" x_ cd "${tmpromdir%"/bin/$board"}"
printf "Re-building tar archive (please wait)\n" printf "Re-building tar archive (please wait)\n"
mkrom_tarball "bin/$board" 1>/dev/null mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'" ) || err "Cannot re-generate '$archive'" "remktar" "$@"
mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \ mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \
"$archive" || err "'$archive' -> Can't overwrite"; : "$archive" || \
err "'$archive' -> Can't overwrite" "remktar" "$@"; :
} }
+30 -19
View File
@@ -24,8 +24,10 @@ update_xbmkver()
{ {
xbmk_sanitize_version xbmk_sanitize_version
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"; : printf "%s\n" "$version" > "$1/.version" || \
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"; : err "can't write '$1'" "update_xbmkver" "$@"; :
printf "%s\n" "$versiondate" > "$1/.versiondate" || \
err "can't write '$versiondate'" "update_xbmkver" "$@"; :
} }
xbmk_sanitize_version() xbmk_sanitize_version()
@@ -39,14 +41,16 @@ xbmk_sanitize_version()
version="$(printf "%s\n" "$version" | sed -e 's/\//-/g')" version="$(printf "%s\n" "$version" | sed -e 's/\//-/g')"
version="${version#-}" version="${version#-}"
[ -n "$version" ] || err "'version' empty after sanitization"; : [ -n "$version" ] || err "'version' empty after sanitization" \
"xbmk_sanitize_version" "$@"; :
} }
mktarball() mktarball()
{ {
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1" printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
[ "${2%/*}" = "$2" ] || x_ mkdir -p "${2%/*}" [ "${2%/*}" = "$2" ] || x_ mkdir -p "${2%/*}"
x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || err "mktarball2, $1" x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || \
err "can't make tarball '$1'" "mktarball" "$@"
} }
e() e()
@@ -79,8 +83,8 @@ setcfg()
{ {
[ $# -gt 1 ] && printf "e \"%s\" f missing && return %s;\n" "$1" "$2" [ $# -gt 1 ] && printf "e \"%s\" f missing && return %s;\n" "$1" "$2"
[ $# -gt 1 ] || \ [ $# -gt 1 ] || \
printf "e \"%s\" f not && err \"Missing config\";\n" "$1" printf "e \"%s\" f not && err \"Missing config '$1'\";\n" "$1"
printf ". \"%s\" || err \"Could not read config\";\n" "$1" printf ". \"%s\" || err \"Could not read config '$1'\";\n" "$1"
} }
chkvars() chkvars()
@@ -101,7 +105,7 @@ singletree()
findpath() findpath()
{ {
[ $# -gt 0 ] || err "findpath: No arguments provided" [ $# -gt 0 ] || err "findpath: No arguments provided" "findpath" "$@"
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
found="$(readlink -f "$1" 2>/dev/null)" || return 1; : found="$(readlink -f "$1" 2>/dev/null)" || return 1; :
[ -n "$found" ] || found="$(realpath "$1" 2>/dev/null)" || \ [ -n "$found" ] || found="$(realpath "$1" 2>/dev/null)" || \
@@ -113,17 +117,22 @@ findpath()
pad_one_byte() pad_one_byte()
{ {
paddedfile="$(mktemp || err "mktemp pad_one_byte")" || err paddedfile="$(mktemp || err "mktemp pad_one_byte")" || \
x_ cat "$1" config/data/coreboot/0 > "$paddedfile" || err "!pad $1"; : err "can't make tmp file" "pad_one_byte" "$@"
x_ cat "$1" config/data/coreboot/0 > "$paddedfile" || \
err "could not pad file '$paddedfile'" "pad_one_byte" "$1"; :
x_ mv "$paddedfile" "$1" x_ mv "$paddedfile" "$1"
} }
unpad_one_byte() unpad_one_byte()
{ {
xromsize="$(expr $(stat -c '%s' "$1") - 1)" || err "!int" xromsize="$(expr $(stat -c '%s' "$1") - 1)" || \
[ $xromsize -lt 524288 ] && err "too small, $xromsize: $1" err "can't increment file size" "unpad_one_byte" "$@"
[ $xromsize -lt 524288 ] && \
err "too small, $xromsize: $1" "unpad_one_byte" "$@"
unpaddedfile="$(mktemp || err "mktemp unpad_one_byte")" || err unpaddedfile="$(mktemp || err "mktemp unpad_one_byte")" || \
err "can't make tmp file" "unpad_one_byte" "$@"
x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1 x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1
x_ mv "$unpaddedfile" "$1" x_ mv "$unpaddedfile" "$1"
} }
@@ -131,10 +140,12 @@ unpad_one_byte()
fx_() fx_()
{ {
xchk fx_ "$@" xchk fx_ "$@"
fd="$(mktemp || err "can't create tmpfile")" || err fd="$(mktemp || err "can't create tmpfile")" || \
err "can't make tmpfile" "fx_" "$@"
x_ rm -f "$fd" && x_ touch "$fd" x_ rm -f "$fd" && x_ touch "$fd"
xx="$1" && shift 1 xx="$1" && shift 1
"$@" 2>/dev/null | sort 1>"$fd" 2>/dev/null || err "FATAL: !sort fx_" "$@" 2>/dev/null | sort 1>"$fd" 2>/dev/null || \
err "can't sort to '$fd'" "fx_" "$xx" "$@"
dx_ "$xx" "$fd" || : dx_ "$xx" "$fd" || :
x_ rm -f "$fd" x_ rm -f "$fd"
} }
@@ -144,20 +155,20 @@ dx_()
xchk dx_ "$@" xchk dx_ "$@"
[ ! -f "$2" ] || while read -r fx; do [ ! -f "$2" ] || while read -r fx; do
$1 "$fx" || return 1; : $1 "$fx" || return 1; :
done < "$2" || err "dx_ $*: cannot read '$2'"; : done < "$2" || err "cannot read '$2'" "dx_" "$@"; :
} }
x_() x_()
{ {
[ $# -lt 1 ] || [ -n "$1" ] || err "Empty first arg" "$@" [ $# -lt 1 ] || [ -n "$1" ] || err "Empty first arg" "x_" "$@"
[ $# -lt 1 ] || "$@" || err "Unhandled error" "$@" [ $# -lt 1 ] || "$@" || err "Unhandled error" "x_" "$@"
} }
xchk() xchk()
{ {
[ $# -lt 3 ] && err "$1 needs at least two arguments" "$@" [ $# -lt 3 ] && err "$1 needs at least two arguments" "xchk" "$@"
if [ -z "$2" ] || [ -z "$3" ]; then if [ -z "$2" ] || [ -z "$3" ]; then
err "arguments must not be empty in $1: \"$2\" \"$3\" " err "arguments must not be empty" "xchk" "$@"
fi fi
} }
+3 -2
View File
@@ -35,7 +35,7 @@ extract_mrc()
x_ cd "$appdir" x_ cd "$appdir"
extract_partition "${MRC_url##*/}" extract_partition "${MRC_url##*/}"
extract_archive "$SHELLBALL" . extract_archive "$SHELLBALL" .
) || err "mrc download/extract failure" ) || err "mrc download/extract failure" "extract_mrc" "$@"
x_ "$cbfstool" "$appdir/"bios.bin extract -n mrc.bin \ x_ "$cbfstool" "$appdir/"bios.bin extract -n mrc.bin \
-f "${_pre_dest%/*}/mrc.bin" -r RO_SECTION -f "${_pre_dest%/*}/mrc.bin" -r RO_SECTION
@@ -54,5 +54,6 @@ extract_partition()
count=$(( $SIZE / 1024 )) count=$(( $SIZE / 1024 ))
printf "cd /usr/sbin\ndump chromeos-firmwareupdate %s\nquit" \ printf "cd /usr/sbin\ndump chromeos-firmwareupdate %s\nquit" \
"$SHELLBALL" | debugfs "root-a.ext2" || err "!extract shellball" "$SHELLBALL" | debugfs "root-a.ext2" || \
err "!extract shellball" "extract_partition" "$@"
} }
+10 -7
View File
@@ -10,18 +10,20 @@ release()
reldir="release" reldir="release"
while getopts m: option; do while getopts m: option; do
[ -z "$OPTARG" ] && err "empty argument not allowed" [ -z "$OPTARG" ] && \
err "empty argument not allowed" "release" "$@"
case "$option" in case "$option" in
m) relmode="$OPTARG" ;; m) relmode="$OPTARG" ;;
*) err "invalid option '-$option'" ;; *) err "invalid option '-$option'" "release" "$@" ;;
esac esac
done done
reldest="$reldir/$version" reldest="$reldir/$version"
[ -e "$reldest" ] && \ [ -e "$reldest" ] && \
err "already exists: \"$reldest\"" err "already exists: \"$reldest\"" "release" "$@"
vdir="$(mktemp -d || err "can't make vdir")" || err vdir="$(mktemp -d || err "can't make vdir")" || \
err "can't make tmp vdir" "release" "$@"
vdir="$vdir/$version" vdir="$vdir/$version"
rsrc="$vdir/${relname}_src" rsrc="$vdir/${relname}_src"
@@ -47,7 +49,7 @@ prep_release()
( (
[ "$1" = "tarball" ] || x_ cd "$rsrc" [ "$1" = "tarball" ] || x_ cd "$rsrc"
prep_release_$1 prep_release_$1
) || err "can't prep release $1" ) || err "can't prep release $1" "prep_release" "$@"
} }
prep_release_src() prep_release_src()
@@ -68,13 +70,14 @@ nuke()
prep_release_tarball() prep_release_tarball()
{ {
git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \ git log --graph --pretty=format:'%Cred%h%Creset %s %Creset' \
--abbrev-commit > "$rsrc/CHANGELOG" || err "!log $rsrc" --abbrev-commit > "$rsrc/CHANGELOG" || \
err "can't create '$rsrc/CHANGELOG'" "prep_release_tarball" "$@"
x_ rm -f "$rsrc/lock" x_ rm -f "$rsrc/lock"
x_ rm -Rf "$rsrc/cache" "$rsrc/xbmkwd" x_ rm -Rf "$rsrc/cache" "$rsrc/xbmkwd"
( (
x_ cd "${rsrc%/*}" x_ cd "${rsrc%/*}"
x_ mktarball "${rsrc##*/}" "${rsrc##*/}.tar.xz" x_ mktarball "${rsrc##*/}" "${rsrc##*/}.tar.xz"
) || err "can't create src tarball"; : ) || err "can't create src tarball" "prep_release_tarball" "$@"; :
} }
prep_release_bin() prep_release_bin()
+21 -9
View File
@@ -26,8 +26,10 @@ copyps1bios()
x_ cp src/pcsx-redux/src/mips/openbios/openbios.bin bin/playstation x_ cp src/pcsx-redux/src/mips/openbios/openbios.bin bin/playstation
printf "MIT License\n\nCopyright (c) 2019-2025 PCSX-Redux authors\n\n" \ printf "MIT License\n\nCopyright (c) 2019-2025 PCSX-Redux authors\n\n" \
> bin/playstation/COPYING.txt || err "!pcsx-redux copyright" > bin/playstation/COPYING.txt || \
x_ cat config/snippet/mit >>bin/playstation/COPYING.txt || err "!pcsx MIT" err "can't write PCSX Redux copyright info" "copyps1bios" "$@"
x_ cat config/snippet/mit >>bin/playstation/COPYING.txt || \
err "can't copy MIT license snippet" "copyps1bios" "$@"
} }
mkpayload_grub() mkpayload_grub()
@@ -47,15 +49,21 @@ corebootpremake()
{ {
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 0; : [ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 0; :
[ -n "$mode" ] || [ ! -f "$srcdir/.config" ] || $dry printf \ $dry cook_coreboot_config
"CONFIG_CCACHE=y\n" >> "$srcdir/.config" || err "$srcdir: !cook"; :
fx_ check_coreboot_util printf "cbfstool\nifdtool\n" fx_ check_coreboot_util printf "cbfstool\nifdtool\n"
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
err "!mk $srcdir .coreboot-version" err "!mk $srcdir .coreboot-version" "corebootpremake" "$@"
[ -z "$mode" ] && [ "$target" != "$tree" ] && \ [ -z "$mode" ] && [ "$target" != "$tree" ] && \
x_ ./mk download "$target"; : x_ ./mk download "$target"; :
} }
cook_coreboot_config()
{
[ -n "$mode" ] || [ ! -f "$srcdir/.config" ] || printf \
"CONFIG_CCACHE=y\n" >> "$srcdir/.config" || \
err "can't cook config in '$srcdir'" "cook_coreboot_config" "$@"; :
}
check_coreboot_util() check_coreboot_util()
{ {
[ "$badhash" = "y" ] && x_ rm -f "elf/coreboot/$tree/$1" [ "$badhash" = "y" ] && x_ rm -f "elf/coreboot/$tree/$1"
@@ -116,7 +124,8 @@ mkcorebootbin_real()
[ -z "$payload_uboot" ] || [ "$payload_uboot" = "amd64" ] || \ [ -z "$payload_uboot" ] || [ "$payload_uboot" = "amd64" ] || \
[ "$payload_uboot" = "i386" ] || [ "$payload_uboot" = "arm64" ] \ [ "$payload_uboot" = "i386" ] || [ "$payload_uboot" = "arm64" ] \
|| err "'$target' defines bad u-boot type '$payload_uboot'" || err "'$target' defines bad u-boot type '$payload_uboot'" \
"mkcorebootbin_real" "$@"
[ -z "$payload_uboot" ] || [ "$payload_uboot" = "arm64" ] || \ [ -z "$payload_uboot" ] || [ "$payload_uboot" = "arm64" ] || \
payload_seabios="y" payload_seabios="y"
@@ -124,7 +133,8 @@ mkcorebootbin_real()
[ -n "$uboot_config" ] || uboot_config="default" [ -n "$uboot_config" ] || uboot_config="default"
[ "$payload_grub" = "y" ] && payload_seabios="y" [ "$payload_grub" = "y" ] && payload_seabios="y"
[ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ] && \ [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ] && \
$dry err "$target: U-Boot(arm64) and SeaBIOS/GRUB both enabled." $dry err "$target: U-Boot(arm64) and SeaBIOS/GRUB both enabled." \
"mkcorebootbin_real" "$@"
[ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata"
@@ -185,7 +195,8 @@ add_grub()
_grubname="fallback/payload" _grubname="fallback/payload"
cbfs "$tmprom" "$grubelf" "$_grubname" cbfs "$tmprom" "$grubelf" "$_grubname"
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \ printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
> "$xbtmp/tmpcfg" || err "$target: !insert scandisk" > "$xbtmp/tmpcfg" || \
err "$target: !insert scandisk" "add_grub" "$@"
cbfs "$tmprom" "$xbtmp/tmpcfg" scan.cfg raw cbfs "$tmprom" "$xbtmp/tmpcfg" scan.cfg raw
[ "$initmode" != "normal" ] && [ "$displaymode" != "txtmode" ] && \ [ "$initmode" != "normal" ] && [ "$displaymode" != "txtmode" ] && \
cbfs "$tmprom" "$grubdata/background/background1280x800.png" \ cbfs "$tmprom" "$grubdata/background/background1280x800.png" \
@@ -256,7 +267,8 @@ cprom()
newrom="${newrom%.rom}_${tmpnew%.gkb}.rom" newrom="${newrom%.rom}_${tmpnew%.gkb}.rom"
irom="$tmprom" irom="$tmprom"
[ $# -lt 1 ] || irom="$(mktemp || err "!mk irom, $(echo "$@")")" || err [ $# -lt 1 ] || irom="$(mktemp || err "!mk irom, $(echo "$@")")" || \
err "can't copy rom" "cprom" "$@"
[ $# -gt 0 ] && x_ cp "$tmprom" "$irom" && cpcmd="mv" [ $# -gt 0 ] && x_ cp "$tmprom" "$irom" && cpcmd="mv"
[ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ] && \ [ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ] && \
+31 -19
View File
@@ -14,7 +14,7 @@ trees()
flags="f:b:m:u:c:x:s:l:n:d:" flags="f:b:m:u:c:x:s:l:n:d:"
while getopts $flags option; do while getopts $flags option; do
[ -n "$_f" ] && err "only one flag is permitted" [ -n "$_f" ] && err "only one flag is permitted" "trees" "$@"
_f="$1" _f="$1"
case "$_f" in case "$_f" in
@@ -30,7 +30,7 @@ trees()
-s) mode="savedefconfig" ;; -s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;; -l) mode="olddefconfig" ;;
-n) mode="nconfig" ;; -n) mode="nconfig" ;;
*) err "invalid option '-$option'" ;; *) err "invalid option '-$option'" "trees" "$@" ;;
esac esac
if [ -z "${OPTARG+x}" ]; then if [ -z "${OPTARG+x}" ]; then
@@ -42,11 +42,11 @@ trees()
project="${project#config/git/}" project="${project#config/git/}"
shift 2 shift 2
done done
[ -z "$_f" ] && err "missing flag ($flags)" [ -z "$_f" ] && err "missing flag ($flags)" "trees" "$@"
[ -z "$project" ] && fx_ "x_ ./mk $_f" x_ ls -1 config/git && return 1 [ -z "$project" ] && fx_ "x_ ./mk $_f" x_ ls -1 config/git && return 1
[ -f "config/git/$project/pkg.cfg" ] || \ [ -f "config/git/$project/pkg.cfg" ] || \
err "config/git/$project/pkg.cfg missing" err "config/git/$project/pkg.cfg missing" "$trees" "$@"
for d in "elf" "config/data" "config" "src"; do for d in "elf" "config/data" "config" "src"; do
eval "${d#*/}dir=\"$d/$project\"" eval "${d#*/}dir=\"$d/$project\""
@@ -82,8 +82,10 @@ build_project()
build_targets() build_targets()
{ {
[ -d "$configdir" ] || err "directory, $configdir, does not exist" [ -d "$configdir" ] || \
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || err "!o $configdir" err "directory, $configdir, does not exist" "build_targets" "$@"
[ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || \
err "can't fetch targets in '$configdir'" "build_targets" "$@"
for x in $targets; do for x in $targets; do
unset CROSS_COMPILE unset CROSS_COMPILE
@@ -168,7 +170,8 @@ build_dependencies()
for bd in $build_depend; do for bd in $build_depend; do
bd_p="${bd%%/*}" bd_p="${bd%%/*}"
bd_t="${bd##*/}" bd_t="${bd##*/}"
[ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'" [ -z "$bd_p" ] && $dry err "$project/$tree: !bd '$bd'" \
"build_dependencies" "$@"
[ "${bd##*/}" = "$bd" ] && bd_t="" [ "${bd##*/}" = "$bd" ] && bd_t=""
[ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; : [ -z "$bd_p" ] || $dry x_ ./mk -b $bd_p $bd_t; :
done; : done; :
@@ -201,20 +204,24 @@ project_up_to_date()
[ ! -f "$XBMK_CACHE/$hashdir/$project$hashname" ] || \ [ ! -f "$XBMK_CACHE/$hashdir/$project$hashname" ] || \
read -r old_hash < "$XBMK_CACHE/$hashdir/$project$hashname" || \ read -r old_hash < "$XBMK_CACHE/$hashdir/$project$hashname" || \
err "$hashdir: read err '$XBMK_CACHE/$hashdir/$project$hashname'" err "$hashdir: read err '$XBMK_CACHE/$hashdir/$project$hashname'" \
"project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@"
fx_ "x_ sha512sum" find "$@" -type f -not -path "*/.git*/*" | awk \ fx_ "x_ sha512sum" find "$@" -type f -not -path "*/.git*/*" | awk \
'{print $1}' > "$xbtmp/tmp.hash" || err "!h $project $hashdir" '{print $1}' > "$xbtmp/tmp.hash" || err "!h $project $hashdir" \
"project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@"
hash="$(x_ sha512sum "$xbtmp/tmp.hash" | awk '{print $1}' || \ hash="$(x_ sha512sum "$xbtmp/tmp.hash" | awk '{print $1}' || \
err)" || err "$hashname: Can't read sha512 of '$xbtmp/tmp.hash'" err)" || err "$hashname: Can't read sha512 of '$xbtmp/tmp.hash'" \
"project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@"
[ "$hash" != "$old_hash" ] && eval "$badhashvar=\"y\"" [ "$hash" != "$old_hash" ] && eval "$badhashvar=\"y\""
[ -f "$XBMK_CACHE/$hashdir/$project$hashname" ] || \ [ -f "$XBMK_CACHE/$hashdir/$project$hashname" ] || \
eval "$badhashvar=\"y\"" eval "$badhashvar=\"y\""
printf "%s\n" "$hash" > "$xbtmp/new.hash" || \ printf "%s\n" "$hash" > "$xbtmp/new.hash" || \
err "!mkhash $xbtmp/new.hash ($hashdir $hashname $badhashvar)" err "!mkhash $xbtmp/new.hash ($hashdir $hashname $badhashvar)" \
"project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@"
eval "[ \"\$$badhashvar\" = \"y\" ] && return 1"; : eval "[ \"\$$badhashvar\" = \"y\" ] && return 1"; :
} }
@@ -250,10 +257,12 @@ check_cross_compiler()
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental" # gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path() check_gnu_path()
{ {
command -v "$1" 1>/dev/null || err "Host '$1' unavailable" command -v "$1" 1>/dev/null || \
err "Host '$1' unavailable" "check_gnu_path" "$@"
eval "$(setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir)" eval "$(setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir)"
x_ gnu_setver "$1" "$1" || err "Command '$1' unavailable." x_ gnu_setver "$1" "$1" || \
err "Command '$1' unavailable." "check_gnu_path" "$@"
gnu_setver "$2" "$2" || : gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\"" eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
@@ -275,7 +284,8 @@ check_gnu_path()
_gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \ _gnuutil="${_gnubin##*/}" && [ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}" x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"
done done
) || err "Cannot create $2-$_gnuver link in $_gnudir"; : ) || err "Cannot symlink '$2-$_gnuver' in '$_gnudir'" \
"check_gnu_path" "$@"; :
} }
gnu_setver() gnu_setver()
@@ -289,7 +299,8 @@ gnu_setver()
check_defconfig() check_defconfig()
{ {
[ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig" [ -f "$defconfig" ] || $dry err "$project/$target: missing defconfig" \
"check_defconfig" "$@"
dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}" dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}"
$dry elfcheck || return 1; : # skip build if a previous one exists $dry elfcheck || return 1; : # skip build if a previous one exists
@@ -308,7 +319,7 @@ handle_makefile()
[ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config" [ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config"
run_make_command || err "handle_makefile $srcdir: no makefile!" run_make_command || err "no makefile!" "handle_makefile" "$@"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig" _copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
[ "${mode%config}" = "$mode" ] || \ [ "${mode%config}" = "$mode" ] || \
@@ -350,7 +361,7 @@ check_autoconf()
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs [ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs [ -f "autogen.sh" ] && x_ ./autogen.sh $autogenargs
[ -f "configure" ] && x_ ./configure $autoconfargs; : [ -f "configure" ] && x_ ./configure $autoconfargs; :
) || err "can't bootstrap project: $1"; : ) || err "can't bootstrap project: $1" "check_autoconf" "$@"; :
} }
check_makefile() check_makefile()
@@ -364,6 +375,7 @@ copy_elf()
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" [ -f "$listfile" ] && x_ mkdir -p "$dest_dir"
[ ! -f "$listfile" ] || while read -r f; do [ ! -f "$listfile" ] || while read -r f; do
[ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"; : [ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"; :
done < "$listfile" || err "copy_elf $*: cannot read '$listfile'"; : done < "$listfile" || err "cannot read '$listfile'" "copy_elf" "$@"; :
x_ make clean -C "$srcdir" $cleanargs ( x_ make clean -C "$srcdir" $cleanargs ) || \
err "can't make-clean '$srcdir'" "copy_elf" "$@"; :
} }
+20 -12
View File
@@ -45,7 +45,7 @@ eval "$(setvars "" has_hashes EC_hash DL_hash _pre_dest MRC_refcode_gbe vcfg \
download() download()
{ {
[ $# -gt 0 ] || err "No argument given" [ $# -gt 0 ] || err "No argument given" "download" "$@"
export PATH="$PATH:/sbin" export PATH="$PATH:/sbin"
board="$1" && check_target && readkconfig download board="$1" && check_target && readkconfig download
} }
@@ -116,7 +116,8 @@ fetch()
x_ mkdir -p "${_dest%/*}" x_ mkdir -p "${_dest%/*}"
[ "$dl_type" = "fsp" ] || extract_archive "$_dl" "$appdir" || \ [ "$dl_type" = "fsp" ] || extract_archive "$_dl" "$appdir" || \
[ "$dl_type" = "e6400vga" ] || err "$_dest $dl_type: !extract" [ "$dl_type" = "e6400vga" ] || \
err "$_dest $dl_type: !extract" "fetch" "$@"
x_ extract_$dl_type "$_dl" "$appdir" x_ extract_$dl_type "$_dl" "$appdir"
set -u -e set -u -e
@@ -130,7 +131,8 @@ fetch()
[ -z "$binsum" ] && printf "'%s': checksum undefined\n" "$_dest" 1>&2 [ -z "$binsum" ] && printf "'%s': checksum undefined\n" "$_dest" 1>&2
[ -L "$_dest" ] && printf "WARNING: '%s' is a link!\n" "$_dest" 1>&2 [ -L "$_dest" ] && printf "WARNING: '%s' is a link!\n" "$_dest" 1>&2
[ -L "$_dest" ] || x_ rm -f "$_dest" [ -L "$_dest" ] || x_ rm -f "$_dest"
err "Could not safely extract '$_dest', for board '$board'" err "Could not safely extract '$_dest', for board '$board'" \
"fetch" "$@"
} }
mkdst() mkdst()
@@ -143,7 +145,8 @@ mkdst()
extract_intel_me() extract_intel_me()
{ {
e "$mecleaner" f not && err "$cbdir: me_cleaner missing" e "$mecleaner" f not && err "$cbdir: me_cleaner missing" \
"extract_intel_me" "$@"
_7ztest="$xbtmp/metmp/a" _7ztest="$xbtmp/metmp/a"
_metmp="$xbtmp/me.bin" _metmp="$xbtmp/me.bin"
@@ -158,7 +161,8 @@ extract_intel_me()
set -u -e set -u -e
[ "$ME11bootguard" != "y" ] && x_ mv "$_metmp" "$_pre_dest" && return 0 [ "$ME11bootguard" != "y" ] && x_ mv "$_metmp" "$_pre_dest" && return 0
( apply_deguard_hack ) || err "Error running deguard for $_dest"; : ( apply_deguard_hack ) || err "Error running deguard on '$_dest'" \
"extract_intel_me" "$@"; :
} }
find_me() find_me()
@@ -196,10 +200,11 @@ extract_kbc1126ec()
( (
x_ cd "$appdir/" x_ cd "$appdir/"
mv Rompaq/68*.BIN ec.bin || unar -D ROM.CAB Rom.bin || unar -D \ mv Rompaq/68*.BIN ec.bin || unar -D ROM.CAB Rom.bin || unar -D \
Rom.CAB Rom.bin || unar -D 68*.CAB Rom.bin || err "!kbc1126 unar" Rom.CAB Rom.bin || unar -D 68*.CAB Rom.bin || \
err "!kbc1126 unar" "extract_kbc1126ec" "$@"
[ -f "ec.bin" ] || x_ mv Rom.bin ec.bin [ -f "ec.bin" ] || x_ mv Rom.bin ec.bin
x_ e ec.bin f && x_ "$kbc1126_ec_dump" ec.bin x_ e ec.bin f && x_ "$kbc1126_ec_dump" ec.bin
) || err "$board: can't extract kbc1126 ec firmware" ) || err "$board: can't extract kbc1126 fw" "extract_kbc1126ec" "$@"
x_ e "$appdir/ec.bin.fw1" f && x_ e "$appdir/ec.bin.fw2" f x_ e "$appdir/ec.bin.fw1" f && x_ e "$appdir/ec.bin.fw2" f
x_ cp "$appdir/"ec.bin.fw* "${_pre_dest%/*}/" x_ cp "$appdir/"ec.bin.fw* "${_pre_dest%/*}/"
@@ -214,7 +219,7 @@ extract_e6400vga()
x_ cd "$appdir" x_ cd "$appdir"
x_ e "bios.bin" f x_ e "bios.bin" f
"$e6400_unpack" bios.bin || printf "TODO: fix dell extract util\n" "$e6400_unpack" bios.bin || printf "TODO: fix dell extract util\n"
) || err "can't extract e6400 vga rom" ) || err "can't extract e6400 vga rom" "extract_e6400vga" "$@"
x_ cp "$appdir/$E6400_VGA_romname" "$_pre_dest" x_ cp "$appdir/$E6400_VGA_romname" "$_pre_dest"
} }
@@ -264,7 +269,8 @@ getvfile()
eval "$(setcfg "config/vendor/$vcfg/pkg.cfg" 1)" eval "$(setcfg "config/vendor/$vcfg/pkg.cfg" 1)"
bootstrap && [ $# -gt 0 ] && getfiles && return 0 # download bootstrap && [ $# -gt 0 ] && getfiles && return 0 # download
fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" fx_ prep x_ find "$tmpromdir" -maxdepth 1 -type f -name "*.rom"
( check_vendor_hashes ) || err "$archive: Can't verify hashes"; : ( check_vendor_hashes ) || \
err "$archive: Can't verify hashes" "getvfile" "$@"; :
} }
bootstrap() bootstrap()
@@ -291,7 +297,8 @@ prep()
[ "$nuke" = "nuke" ] && _xromnew="${_xrom%/*}/$vfix${_xrom##*/}" [ "$nuke" = "nuke" ] && _xromnew="${_xrom%/*}/$vfix${_xrom##*/}"
e "$_xrom" f missing && return 0 e "$_xrom" f missing && return 0
[ -z "${_xromname#"$vfix"}" ] && err "$_xromname / $vfix: name match" [ -z "${_xromname#"$vfix"}" ] && \
err "$_xromname / $vfix: name match" "prep" "$@"
# Remove the prefix and 1-byte pad # Remove the prefix and 1-byte pad
[ "$nuke" != "nuke" ] && [ "${_xromname#"$vfix"}" != "$_xromname" ] \ [ "$nuke" != "nuke" ] && [ "${_xromname#"$vfix"}" != "$_xromname" ] \
@@ -309,7 +316,8 @@ prep()
mksha512() mksha512()
{ {
[ "${1%/*}" != "$1" ] && x_ cd "${1%/*}" [ "${1%/*}" != "$1" ] && x_ cd "${1%/*}"
sha512sum ./"${1##*/}" >> "$2" || err "!sha512sum \"$1\" > \"$2\"" sha512sum ./"${1##*/}" >> "$2" || \
err "!sha512sum \"$1\" > \"$2\"" "mksha512" "$@"
} }
add_vfiles() add_vfiles()
@@ -362,7 +370,7 @@ vfile()
if [ "$_t" = "fsp" ] && [ $# -gt 3 ]; then if [ "$_t" = "fsp" ] && [ $# -gt 3 ]; then
_offset="$4" _offset="$4"
elif [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ]; then elif [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ]; then
err "vfile $*, $rom: offset given but empty (undefined)" err "$rom: offset given but empty (undefined)" "vfile" "$@"
fi fi
[ "$nuke" = "nuke" ] || x_ e "$_dest" f [ "$nuke" = "nuke" ] || x_ e "$_dest" f
+1 -1
View File
@@ -30,7 +30,7 @@ main()
version) printf "%s\nWebsite: %s\n" "$relname" "$projectsite" ;; version) printf "%s\nWebsite: %s\n" "$relname" "$projectsite" ;;
release|download|inject) $cmd "$@" ;; release|download|inject) $cmd "$@" ;;
-*) return 1 ;; -*) return 1 ;;
*) err "bad command" ;; *) err "bad command" main "$@" ;;
esac esac
set -u -e # some commands disable them. turn them on! set -u -e # some commands disable them. turn them on!
} }