xbmk: don't call mkdir. use xbmkdir (new function)

xbmkdir checks if a directory exists, before running
mkdir, and then still uses -p

i was testing xbmk on arch linux today, and noticed
that it errored out when a directory already exists.

i'm mitigating against buggy or differently behaving
mkdir implementations this way, by wrapping around
it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-10-04 22:36:11 +01:00
parent f358cfaa55
commit c1d6cd22c2
8 changed files with 33 additions and 21 deletions
+19 -7
View File
@@ -8,12 +8,6 @@
cbfstool="elf/coreboot/default/cbfstool"
rmodtool="elf/coreboot/default/rmodtool"
remkdir()
{
x_ rm -Rf "$@"
x_ mkdir -p "$@"
}
mkrom_tarball()
{
update_xbmkver "$1"
@@ -58,7 +52,7 @@ mktarball()
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
if [ "${2%/*}" != "$2" ]; then
x_ mkdir -p "${2%/*}"
x_ xbmkdir "${2%/*}"
fi
x_ tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || \
@@ -169,6 +163,24 @@ build_sbase()
fi
}
remkdir()
{
x_ rm -Rf "$@"
x_ xbmkdir "$@"
}
xbmkdir()
{
while [ $# -gt 0 ]
do
if [ ! -d "$1" ]; then
x_ mkdir -p "$1"
fi
shift 1
done
}
fx_()
{
xchk fx_ "$@"