summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/init.sh37
-rw-r--r--include/inject.sh17
-rw-r--r--include/lib.sh21
-rw-r--r--include/rom.sh3
-rwxr-xr-xmk39
5 files changed, 48 insertions, 69 deletions
diff --git a/include/init.sh b/include/init.sh
index 3f813ea7..9f6e7162 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -26,10 +26,7 @@ xbmk_init()
export PWD="$xbmkpwd"
- if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then
- install_packages "$@" || exit 1
- exit 0
- fi
+ [ $# -gt 0 ] && [ "$1" = "dependencies" ] && x_ xbmkpkg "$@" && exit 0
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
@@ -40,7 +37,7 @@ xbmk_init()
done
}
-install_packages()
+xbmkpkg()
{
[ $# -lt 2 ] && $err "fewer than two arguments"
[ $# -gt 2 ] && reinstall="$3"
@@ -54,22 +51,6 @@ install_packages()
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
}
-setcfg()
-{
- [ $# -gt 1 ] && printf "e \"%s\" f missing && return %s;\n" "$1" "$2"
- [ $# -gt 1 ] || \
- printf "e \"%s\" f not && %s \"Missing config\";\n" "$1" "$err"
- printf ". \"%s\" || %s \"Could not read config\";\n" "$1" "$err"
-}
-
-chkvars()
-{
- for var in "$@"; do
- eval "[ -n \"\${$var+x}\" ] || \$err \"$var unset\""
- eval "[ -n \"\$$var\" ] || \$err \"$var unset\""
- done; :
-}
-
xbmk_set_pyver()
{
pyv="import sys; print(sys.version_info[:])"
@@ -79,11 +60,9 @@ xbmk_set_pyver()
pybin "$python" 1>/dev/null || pyver=""
[ -z "$pyver" ] || "`pybin "$python"`" -c "$pyv" 1>/dev/null \
2>/dev/null || $err "Cannot detect host Python version."
- if [ -n "$pyver" ]; then
- pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')"
- pyver="${pyver#(}"
- pyver="${pyver%,}"
- fi
+ [ -n "$pyver" ] && \
+ pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \
+ pyver="${pyver#(}" && pyver="${pyver%,}"
[ "${pyver%%.*}" = "3" ] || $err "Bad python version (must by 3.x)"; :
}
@@ -113,8 +92,7 @@ pybin()
[ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \
[ -x "$pypath/$1" ] && printf "%s/%s\n" "$pypath" "$1" && \
return 0
- done
- [ $venv -gt 0 ] && return 1
+ done && return 1
# Defer to normal command -v if not a venv
command -v "$1" 2>/dev/null || return 1
@@ -212,8 +190,7 @@ xbmk_lock()
xbmk_create_pathdirs()
{
- x_ rm -Rf "$XBMK_CACHE/xbmkpath" "$XBMK_CACHE/gnupath"
- x_ mkdir -p "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
+ remkdir "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath"
export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH"
(
# set up python v3.x in PATH, in case it's not set up correctly.
diff --git a/include/inject.sh b/include/inject.sh
index 9bfda2db..837f34c1 100644
--- a/include/inject.sh
+++ b/include/inject.sh
@@ -90,11 +90,6 @@ getfiles()
"$MRC_url_bkup" "$MRC_hash" "$CONFIG_REFCODE_BLOB_FILE"
[ -z "$CONFIG_LENOVO_TBFW_BIN" ] || fetch "tbfw" "$TBFW_url" \
"$TBFW_url_bkup" "$TBFW_hash" "$CONFIG_LENOVO_TBFW_BIN"
- #
- # in the future, we might have libre fsp-s and then fsp-m.
- # therefore, handle them separately, in case one of them is libre; if
- # one of them was, the path wouldn't be set.
- #
[ -z "$CONFIG_FSP_M_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \
"$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_M_FILE" copy
[ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \
@@ -261,20 +256,14 @@ extract_sch5545ec()
# https://pcsupport.lenovo.com/us/en/products/laptops-and-netbooks/thinkpad-t-series-laptops/thinkpad-t480-type-20l5-20l6/20l5/solutions/ht508988
extract_tbfw()
{
- chkvars TBFW_size
- fe_ copy_tbfw "$appdir" -type f -name "TBT.bin"
+ chkvars TBFW_size && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin"
[ -f "$_dest" ] || $err "$board: Could not extract tbfw"; :
}
copy_tbfw()
{
- [ -f "$1" ] || return 0
- [ -L "$1" ] && return 0
-
- x_ dd if=/dev/null of="$1" bs=1 seek=$TBFW_size
- x_ mv "$1" "$_dest"
-
- return 1
+ [ -f "$1" ] && [ ! -L "$1" ] && x_ dd if=/dev/null of="$1" bs=1 \
+ seek=$TBFW_size && x_ mv "$1" "$_dest" && return 1; :
}
extract_fsp()
diff --git a/include/lib.sh b/include/lib.sh
index d58716c3..abf4de3b 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -128,6 +128,22 @@ setvars()
printf "%s\n" "${_setvars% }"
}
+setcfg()
+{
+ [ $# -gt 1 ] && printf "e \"%s\" f missing && return %s;\n" "$1" "$2"
+ [ $# -gt 1 ] || \
+ printf "e \"%s\" f not && %s \"Missing config\";\n" "$1" "$err"
+ printf ". \"%s\" || %s \"Could not read config\";\n" "$1" "$err"
+}
+
+chkvars()
+{
+ for var in "$@"; do
+ eval "[ -n \"\${$var+x}\" ] || \$err \"$var unset\""
+ eval "[ -n \"\$$var\" ] || \$err \"$var unset\""
+ done; :
+}
+
fe_()
{
find_ex "x_" "$@"
@@ -146,18 +162,19 @@ find_ex()
$errx find "$@" 2>/dev/null | sort > "$fd" || \
$err "!find $(echo "$@") > \"$fd\""
while read -r fx; do
- "$xx" "$fx" || break; :
+ $xx "$fx" || break; :
done < "$fd"
x_ rm -f "$fd"
}
x_()
{
+ [ $# -lt 1 ] || [ -n "$1" ] || $err "Empty first arg: x_ $(echo "$@")"
[ $# -lt 1 ] || "$@" || $err "Unhandled error for: $(echo "$@")"; :
}
err_()
{
- printf "ERROR %s: %s\n" "$0" "$1" 1>&2
+ [ $# -lt 1 ] || printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || :
exit 1
}
diff --git a/include/rom.sh b/include/rom.sh
index f74912af..ec464d85 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -29,8 +29,7 @@ mkserprog()
copyps1bios()
{
- x_ rm -Rf bin/playstation
- x_ mkdir -p bin/playstation
+ remkdir "bin/playstation"
x_ cp src/pcsx-redux/src/mips/openbios/openbios.bin bin/playstation
printf "MIT License\n\nCopyright (c) 2019-2024 PCSX-Redux authors\n\n" \
diff --git a/mk b/mk
index 2020115b..5a4afadf 100755
--- a/mk
+++ b/mk
@@ -211,7 +211,9 @@ handle_defconfig()
if [ "$mode" = "distclean" ] || [ "$mode" = "crossgcc-clean" ]; then
[ -d "$srcdir" ] || return 0
fi
- [ -z "$mode" ] && $dry check_cross_compiler
+ [ -z "$mode" ] && for _xarch in $xarch; do
+ $dry check_cross_compiler "$_xarch"
+ done; :
for y in "$target_dir/config"/*; do
[ "$_f" = "-d" ] || [ -f "$y" ] || continue
@@ -277,7 +279,7 @@ check_project_hashes()
[ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
- fx_ sha512sum "$datadir" "$configdir/$tree" "$mdir" \
+ fx_ "x_ sha512sum" "$datadir" "$configdir/$tree" "$mdir" \
-type f -not -path "*/.git*/*" | awk '{print $1}' > \
"$xbmktmp/project.hash" || $err "!h $project $tree"
@@ -294,30 +296,25 @@ check_project_hashes()
check_cross_compiler()
{
- xgccargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
- for _xarch in $xarch; do
- cbdir="src/coreboot/$tree"
- [ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
- [ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
-
- x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
+ cbdir="src/coreboot/$tree"
+ [ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
+ [ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
- export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
- export CROSS_COMPILE="${xarch% *}-"
- [ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
+ x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
- xfix="${_xarch%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
+ export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
+ export CROSS_COMPILE="${xarch% *}-"
+ [ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
- # match gnat-X to gcc
- check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
+ # match gnat-X to gcc
+ check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
- # sometimes buildgcc fails for like no reason. try twice.
- make -C "$cbdir" crossgcc-$xfix $xgccargs || \
- x_ make -C "$cbdir" crossgcc-$xfix $xgccargs
+ xfix="${1%-*}" && [ "$xfix" = "x86_64" ] && xfix="x64"
+ xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
+ make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
- # we only want to mess with hostcc to build xgcc
- rm -f "$XBMK_CACHE/gnupath/"* || $err "Can't clear gnupath/"; :
- done; :
+ # we only want to mess with hostcc to build xgcc
+ remkdir "$XBMK_CACHE/gnupath"
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,