summaryrefslogtreecommitdiff
path: root/include/lib.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-29 15:48:49 +0100
committerLeah Rowe <leah@libreboot.org>2026-03-29 16:08:00 +0100
commite54862fcccca0325da8ae2879c1fa965267d3df0 (patch)
tree337f39085fc382cb56781dea4c329672d45e08a2 /include/lib.sh
parent8657d084d2ae61a4cb06b5bc63223a92bfb5beb0 (diff)
lbmk: use mkhtemp in libreboot's build system
i added a fake -t option, which doesn't actually read optarg, so that -t usage can just override the normal template. mkhtemp isn't ready for distros yet, but it's ready for lbmk. i hacked the makefile to also copy the binary to mktemp, and i set PATH in lbmk so that this binary is used insttead of the one on your system. that way, upstream projects use it. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/lib.sh')
-rw-r--r--include/lib.sh32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/lib.sh b/include/lib.sh
index 812341f4..9526dfc7 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -128,7 +128,7 @@ findpath()
pad_one_byte()
{
- paddedfile="`mktemp || err "mktemp pad_one_byte"`" || \
+ paddedfile="`"$mkhtemp" || err ""$mkhtemp" pad_one_byte"`" || \
err "can't make tmp file" "pad_one_byte" "$@"
x_ cat "$1" config/data/coreboot/0 > "$paddedfile" || \
@@ -146,17 +146,39 @@ unpad_one_byte()
err "too small, $xromsize: $1" "unpad_one_byte" "$@"
fi
- unpaddedfile="`mktemp || err "mktemp unpad_one_byte"`" || \
+ unpaddedfile="`"$mkhtemp" || err ""$mkhtemp" 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()
+# certain utils in lbmk are needed
+# BEFORE sha512sum-based verification
+# can be done, and before TMPDIR
+# generation can be done. these are:
+# sha512sum and "$mkhtemp". we will use:
+# libreboot's own mkhtemp and:
+# suckless sbase's sha512sum
+#
+bootstrap_utils()
+{
+ bootstrap_sbase
+ bootstrap_mkhtemp
+}
+bootstrap_sbase()
{
if [ ! -f "$sha512sum" ]; then
- x_ make -C "$xbmkpwd/util/sbase"
+ ( x_ make -C "$xbmkpwd/util/sbase" 1>/dev/null 2>/dev/null ) || \
+ err "can't build sbase"
+ fi
+}
+bootstrap_mkhtemp()
+{
+ if [ ! -f "$mkhtemp" ]; then
+ ( x_ make -C "$xbmkpwd/util/libreboot-utils" 1>/dev/null \
+ 2>/dev/null) || \
+ err "could not build mkhtemp"
fi
}
@@ -183,7 +205,7 @@ fx_()
xchk fx_ "$@"
xcmd="$1"
- xfile="`mktemp || err "can't create tmpfile"`" || \
+ xfile="`"$mkhtemp" || err "can't create tmpfile"`" || \
err "can't make tmpfile" "fx_" "$@"
x_ rm -f "$xfile"