mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-15 08:20:59 +02:00
lbmk: unified PWD handling (work directory)
instead of running pwd all the time, run it once in lib.sh, and export PWD. for lbmk-specific use of PWD, use xbmkpwd, which contains the value of PWD as was set by the pwd utility in lib.sh. many parts of lbmk rely on pwd, and it *must* be correct. this change adds basic error handling, since pwd can in fact return errors in some cases. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -7,4 +7,4 @@ serx="$sersrc/build/pico_serprog.uf2"
|
||||
picosdk="src/pico-sdk"
|
||||
serdir="$picosdk/src/boards/include/boards"
|
||||
premake="mkserprog pico"
|
||||
picotool="`pwd`/src/picotool/xbmkbin"
|
||||
picotool="$xbmkpwd/src/picotool/xbmkbin"
|
||||
|
||||
+4
-2
@@ -5,6 +5,8 @@
|
||||
eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
|
||||
depend subfile_bkup repofail`"
|
||||
|
||||
tmpgit="$xbmkpwd/tmp/gitclone"
|
||||
|
||||
fetch_targets()
|
||||
{
|
||||
[ -n "$tree_depend" ] && [ "$tree_depend" != "$tree" ] && \
|
||||
@@ -12,7 +14,7 @@ fetch_targets()
|
||||
e "src/$project/$tree" d && return 0
|
||||
|
||||
printf "Creating %s tree %s\n" "$project" "$tree"
|
||||
git_prep "$loc" "$loc" "`pwd`/$configdir/$tree/patches" \
|
||||
git_prep "$loc" "$loc" "$xbmkpwd/$configdir/$tree/patches" \
|
||||
"src/$project/$tree" u
|
||||
nuke "$project/$tree" "$project/$tree"
|
||||
}
|
||||
@@ -43,7 +45,7 @@ clone_project()
|
||||
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
|
||||
|
||||
e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
|
||||
"$url" "$bkup_url" "`pwd`/config/$project/patches" "$loc"; :
|
||||
"$url" "$bkup_url" "$xbmkpwd/config/$project/patches" "$loc"; :
|
||||
}
|
||||
|
||||
git_prep()
|
||||
|
||||
+9
-7
@@ -15,7 +15,6 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
|
||||
ifdtool="elf/ifdtool/default/ifdtool"
|
||||
cbfstool="elf/cbfstool/default/cbfstool"
|
||||
rmodtool="elf/cbfstool/default/rmodtool"
|
||||
tmpgit="`pwd`/tmp/gitclone"
|
||||
grubdata="config/data/grub"
|
||||
err="err_"
|
||||
|
||||
@@ -25,6 +24,9 @@ err_()
|
||||
exit 1
|
||||
}
|
||||
|
||||
xbmkpwd=`pwd` || $err "Cannot generate PWD"
|
||||
export PWD="$xbmkpwd"
|
||||
|
||||
setvars()
|
||||
{
|
||||
_setvars="" && [ $# -lt 2 ] && $err "setvars: too few arguments"
|
||||
@@ -106,18 +108,18 @@ 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"
|
||||
|
||||
# XBMK_CACHE is a directory, for caching downloads and git repositories
|
||||
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="`pwd`/cache"
|
||||
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="`pwd`/cache"
|
||||
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "`pwd`/cache" ] && \
|
||||
$err "cachedir is default, `pwd`/cache, but it exists and is a symlink"
|
||||
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="`pwd`/cache"
|
||||
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
|
||||
[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
|
||||
[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$xbmkpwd/cache" ] && \
|
||||
$err "cachedir is default, $xbmkpwd/cache, but it exists and is a symlink"
|
||||
[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$xbmkpwd/cache"
|
||||
[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
|
||||
|
||||
# unify all temporary files/directories in a single TMPDIR
|
||||
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || unset TMPDIR
|
||||
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR"
|
||||
if [ -z "${TMPDIR+x}" ]; then
|
||||
[ -f "lock" ] && $err "`pwd`/lock exists. Is a build running?"
|
||||
[ -f "lock" ] && $err "$xbmkpwd/lock exists. Is a build running?"
|
||||
export TMPDIR="/tmp"
|
||||
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
|
||||
touch lock || $err "cannot create 'lock' file"
|
||||
|
||||
+10
-10
@@ -3,10 +3,10 @@
|
||||
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
||||
# Copyright (c) 2023-2025 Leah Rowe <leah@libreboot.org>
|
||||
|
||||
e6400_unpack="`pwd`/src/bios_extract/dell_inspiron_1100_unpacker.py"
|
||||
me7updateparser="`pwd`/util/me7_update_parser/me7_update_parser.py"
|
||||
pfs_extract="`pwd`/src/biosutilities/Dell_PFS_Extract.py"
|
||||
uefiextract="`pwd`/elf/uefitool/uefiextract"
|
||||
e6400_unpack="$xbmkpwd/src/bios_extract/dell_inspiron_1100_unpacker.py"
|
||||
me7updateparser="$xbmkpwd/util/me7_update_parser/me7_update_parser.py"
|
||||
pfs_extract="$xbmkpwd/src/biosutilities/Dell_PFS_Extract.py"
|
||||
uefiextract="$xbmkpwd/elf/uefitool/uefiextract"
|
||||
vendir="vendorfiles"
|
||||
appdir="$vendir/app"
|
||||
cbcfgsdir="config/coreboot"
|
||||
@@ -14,7 +14,7 @@ hashfiles="vendorhashes blobhashes" # blobhashes for backwards compatibility
|
||||
dontflash="!!! AN ERROR OCCURED! Please DO NOT flash if injection failed. !!!"
|
||||
vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_FILES_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
|
||||
vguide="https://libreboot.org/docs/install/ivy_has_common.html"
|
||||
tmpromdel="`pwd`/tmp/DO_NOT_FLASH"
|
||||
tmpromdel="$xbmkpwd/tmp/DO_NOT_FLASH"
|
||||
|
||||
cv="CONFIG_HAVE_ME_BIN CONFIG_ME_BIN_PATH CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \
|
||||
CONFIG_SMSC_SCH5545_EC_FW_FILE CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \
|
||||
@@ -152,9 +152,9 @@ extract_intel_me()
|
||||
{
|
||||
e "$mecleaner" f not && $err "$cbdir: me_cleaner missing. $dontflash"
|
||||
|
||||
cdir="`pwd`/$appdir"
|
||||
_me="`pwd`/$_dest"
|
||||
_metmp="`pwd`/tmp/me.bin"
|
||||
cdir="$xbmkpwd/$appdir"
|
||||
_me="$xbmkpwd/$_dest"
|
||||
_metmp="$xbmkpwd/tmp/me.bin"
|
||||
|
||||
mfs="" && [ "$ME11bootguard" = "y" ] && mfs="--whitelist MFS" && \
|
||||
chkvars ME11delta ME11version ME11sku ME11pch
|
||||
@@ -489,8 +489,8 @@ readcfg()
|
||||
cbdir="src/coreboot/$tree"
|
||||
cbfstool="elf/cbfstool/$tree/cbfstool"
|
||||
rmodtool="elf/cbfstool/$tree/rmodtool"
|
||||
mecleaner="`pwd`/$cbdir/util/me_cleaner/me_cleaner.py"
|
||||
kbc1126_ec_dump="`pwd`/$cbdir/util/kbc1126/kbc1126_ec_dump"
|
||||
mecleaner="$xbmkpwd/$cbdir/util/me_cleaner/me_cleaner.py"
|
||||
kbc1126_ec_dump="$xbmkpwd/$cbdir/util/kbc1126/kbc1126_ec_dump"
|
||||
cbfstool="elf/cbfstool/$tree/cbfstool"
|
||||
ifdtool="elf/ifdtool/$tree/ifdtool"
|
||||
[ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"; :
|
||||
|
||||
+2
-2
@@ -174,7 +174,7 @@ configure_project()
|
||||
[ -z "$btype" ] || [ "${mode%config}" = "$mode" ] || return 1
|
||||
[ -z "$mode" ] && build_dependencies
|
||||
|
||||
mdir="`pwd`/config/submodule/$project"
|
||||
mdir="$xbmkpwd/config/submodule/$project"
|
||||
[ -n "$tree" ] && mdir="$mdir/$tree"
|
||||
[ -f "CHANGELOG" ] || check_project_hashes
|
||||
|
||||
@@ -245,7 +245,7 @@ check_cross_compiler()
|
||||
|
||||
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
|
||||
|
||||
export PATH="`pwd`/$cbdir/util/crossgcc/xgcc/bin:$PATH"
|
||||
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
|
||||
export CROSS_COMPILE="${xarch% *}-"
|
||||
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user