mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
@@ -35,7 +35,7 @@ prep_mr_import()
|
||||
err "Project import disabled on releases" "prep_mr_import" "$@"
|
||||
fi
|
||||
|
||||
mr_tmpdir="`mktemp -d || err "can't make mrtmpdir"`" || \
|
||||
mr_tmpdir="`"$mkhtemp" -d || err "can't make mrtmpdir"`" || \
|
||||
err "can't make mrtmpdir" "prep_mr_coreboot" "$@"
|
||||
x_ remkdir "$mr_tmpdir"
|
||||
|
||||
|
||||
+2
-2
@@ -334,7 +334,7 @@ bad_checksum()
|
||||
return 0
|
||||
fi
|
||||
|
||||
build_sbase
|
||||
bootstrap_utils
|
||||
csum="$(x_ "$sha512sum" "$2" | awk '{print $1}')" || \
|
||||
err "!sha512 '$2' $1" bad_checksum "$@"
|
||||
|
||||
@@ -355,7 +355,7 @@ tmpclone()
|
||||
return 0
|
||||
fi
|
||||
|
||||
tmpclone_patchlist="`mktemp || err "Can't create tmp patch list"`" || \
|
||||
tmpclone_patchlist="`"$mkhtemp" || err "Can't create tmp patch list"`" || \
|
||||
err "Can't create tmp patch list" "tmpclone" "$@"
|
||||
|
||||
x_ find "$4" -type f | sort > "$tmpclone_patchlist" || \
|
||||
|
||||
+6
-3
@@ -17,6 +17,7 @@ if [ -z "${PATH+x}" ]; then
|
||||
fi
|
||||
|
||||
sha512sum="util/sbase/sha512sum"
|
||||
mkhtemp="util/libreboot-utils/mkhtemp"
|
||||
|
||||
aur_notice=""
|
||||
basetmp=""
|
||||
@@ -231,7 +232,9 @@ xbmk_parent_check_tmp()
|
||||
{
|
||||
export TMPDIR="$basetmp"
|
||||
|
||||
xbmklist="`mktemp || err "can't make tmplist"`" || \
|
||||
bootstrap_mkhtemp
|
||||
|
||||
xbmklist="`"$mkhtemp" || err "can't make tmplist"`" || \
|
||||
err "can't make tmplist" xbmk_parent_check_tmp "$@"
|
||||
|
||||
x_ rm -f "$xbmklist"
|
||||
@@ -246,7 +249,7 @@ xbmk_parent_check_tmp()
|
||||
done
|
||||
|
||||
# set up a unified temporary directory, for common deletion later:
|
||||
export TMPDIR="`x_ mktemp -d -t xbmk_XXXXXXXX`" || \
|
||||
export TMPDIR="`x_ "$mkhtemp" -d -t xbmk_XXXXXXXX`" || \
|
||||
err "can't export TMPDIR" "xbmk_parent_check_tmp" "$@"
|
||||
xbtmp="$TMPDIR"
|
||||
|
||||
@@ -269,7 +272,7 @@ xbmk_parent_set_export()
|
||||
"xbmk_parent_set_export" "$@"
|
||||
fi
|
||||
|
||||
export PATH="$xbtmp/xbmkpath:$xbtmp/gnupath:$PATH"
|
||||
export PATH="$xbmkpwd/util/libreboot-utils:$xbtmp/xbmkpath:$xbtmp/gnupath:$PATH"
|
||||
xbmkpath="$PATH"
|
||||
|
||||
# if "y": a coreboot target won't be built if target.cfg says release=n
|
||||
|
||||
+27
-5
@@ -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"
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ release()
|
||||
err "already exists: \"$reldest\"" "release" "$@"
|
||||
fi
|
||||
|
||||
vdir="`mktemp -d || err "can't make vdir"`" || \
|
||||
vdir="`"$mkhtemp" -d || err "can't make vdir"`" || \
|
||||
err "can't make tmp vdir" "release" "$@"
|
||||
vdir="$vdir/$version"
|
||||
|
||||
|
||||
+1
-1
@@ -463,7 +463,7 @@ cprom()
|
||||
irom="$tmprom"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
irom="$(mktemp || err "!mk irom, $(echo "$@")")" || \
|
||||
irom="$("$mkhtemp" || err "!mk irom, $(echo "$@")")" || \
|
||||
err "can't copy rom" "cprom" "$@"
|
||||
|
||||
x_ cp "$tmprom" "$irom" && cpcmd="mv"
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ project_up_to_date()
|
||||
"$@"
|
||||
fi
|
||||
|
||||
build_sbase
|
||||
bootstrap_utils
|
||||
fx_ "x_ util/sbase/sha512sum" find "$@" -type f -not -path \
|
||||
"*/.git*/*" | awk '{print $1}' > "$xbtmp/tmp.hash" || \
|
||||
err "!h $project $hashdir" \
|
||||
|
||||
+2
-2
@@ -633,7 +633,7 @@ prep()
|
||||
|
||||
mksha512()
|
||||
{
|
||||
build_sbase
|
||||
bootstrap_utils
|
||||
|
||||
if [ "${1%/*}" != "$1" ]; then
|
||||
x_ cd "${1%/*}"
|
||||
@@ -746,7 +746,7 @@ vfile()
|
||||
# must be called from a subshell
|
||||
check_vendor_hashes()
|
||||
{
|
||||
build_sbase
|
||||
bootstrap_utils
|
||||
|
||||
x_ cd "$tmpromdir"
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ $(PROG): $(OBJS_NVMUTIL)
|
||||
|
||||
$(PROGMKH): $(OBJS_MKHTEMP)
|
||||
$(CC_MODE) $(OBJS_MKHTEMP) -o $(PROGMKH) $(LDFLAGS)
|
||||
cp -r mkhtemp mktemp
|
||||
chmod 755 mktemp
|
||||
|
||||
$(PROGLOT): $(OBJS_LOTTERY)
|
||||
$(CC_MODE) $(OBJS_LOTTERY) -o $(PROGLOT) $(LDFLAGS)
|
||||
|
||||
@@ -68,7 +68,7 @@ main(int argc, char *argv[])
|
||||
xpledgex("stdio flock rpath wpath cpath", NULL);
|
||||
|
||||
while ((c =
|
||||
getopt(argc, argv, "qdp:")) != -1) {
|
||||
getopt(argc, argv, "qdp:t")) != -1) {
|
||||
|
||||
switch (c) {
|
||||
case 'd':
|
||||
@@ -83,6 +83,12 @@ main(int argc, char *argv[])
|
||||
/* (exit status unchanged) */
|
||||
break;
|
||||
|
||||
case 't':
|
||||
break; /* not supported yet. TODO */
|
||||
/* configured above without optarg,
|
||||
* so that it is treated as a normal
|
||||
* template string */
|
||||
|
||||
default:
|
||||
goto err_usage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user