lib.sh: simplified TMPDIR handling
Signed-off-by: Leah Rowe <leah@libreboot.org>audit6
parent
671893a802
commit
fac74cd60a
8
build
8
build
|
@ -125,16 +125,16 @@ fetch_trees()
|
||||||
|
|
||||||
fail()
|
fail()
|
||||||
{
|
{
|
||||||
tmp_cleanup || printf "WARNING: can't rm tmpfiles: %s\n" "$tmpdir" 1>&2
|
tmp_cleanup || printf "WARNING: can't rm tmpfiles: %s\n" "$TMPDIR" 1>&2
|
||||||
err_ "${1}"
|
err_ "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_cleanup()
|
tmp_cleanup()
|
||||||
{
|
{
|
||||||
[ "$tmpdir_was_set" = "n" ] || return 0
|
[ "$xbmk_parent" = "y" ] || return 0
|
||||||
rm -Rf "$tmpdir" || return 1
|
rm -Rf "$TMPDIR" || return 1
|
||||||
rm -f lock || return 1
|
rm -f lock || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
tmp_cleanup || err_ "can't rm tmpdir upon non-zero exit: $tmpdir"
|
tmp_cleanup || err_ "can't rm TMPDIR upon non-zero exit: $TMPDIR"
|
||||||
|
|
|
@ -10,7 +10,6 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
|
||||||
kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \
|
kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \
|
||||||
if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool."
|
if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool."
|
||||||
|
|
||||||
tmpdir_was_set="y"
|
|
||||||
cbdir="src/coreboot/default"
|
cbdir="src/coreboot/default"
|
||||||
cbelfdir="elf/coreboot_nopayload_DO_NOT_FLASH"
|
cbelfdir="elf/coreboot_nopayload_DO_NOT_FLASH"
|
||||||
ifdtool="elf/ifdtool/default/ifdtool"
|
ifdtool="elf/ifdtool/default/ifdtool"
|
||||||
|
@ -39,8 +38,8 @@ chkvars()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
eval `setvars "" tmpdir _nogit board boarddir relname versiondate projectsite \
|
eval `setvars "" _nogit board boarddir relname versiondate projectsite \
|
||||||
projectname aur_notice cfgsdir datadir version`
|
projectname aur_notice cfgsdir datadir version xbmk_parent`
|
||||||
|
|
||||||
for fv in projectname projectsite version versiondate; do
|
for fv in projectname projectsite version versiondate; do
|
||||||
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
|
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
|
||||||
|
@ -82,19 +81,15 @@ install_packages()
|
||||||
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
|
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"
|
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
|
||||||
|
|
||||||
[ -z "${TMPDIR+x}" ] && tmpdir_was_set="n"
|
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || unset TMPDIR
|
||||||
if [ "$tmpdir_was_set" = "y" ]; then
|
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR"
|
||||||
[ "${TMPDIR%_*}" = "/tmp/xbmk" ] || tmpdir_was_set="n"
|
|
||||||
fi
|
if [ -z "${TMPDIR+x}" ]; then
|
||||||
if [ "$tmpdir_was_set" = "n" ]; then
|
|
||||||
[ -f "lock" ] && $err "$PWD/lock exists. Is a build running?"
|
[ -f "lock" ] && $err "$PWD/lock exists. Is a build running?"
|
||||||
export TMPDIR="/tmp"
|
export TMPDIR="/tmp"
|
||||||
tmpdir="$(mktemp -d -t xbmk_XXXXXXXX)"
|
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
|
||||||
export TMPDIR="$tmpdir"
|
|
||||||
touch lock || $err "cannot create 'lock' file"
|
touch lock || $err "cannot create 'lock' file"
|
||||||
else
|
xbmk_parent="y"
|
||||||
export TMPDIR="$TMPDIR"
|
|
||||||
tmpdir="$TMPDIR"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if "y": a coreboot target won't be built if target.cfg says release="n"
|
# if "y": a coreboot target won't be built if target.cfg says release="n"
|
||||||
|
|
|
@ -41,10 +41,10 @@ getcfg()
|
||||||
|
|
||||||
[ -z "$vcfg" ] && printf "%s: vcfg unset\n" "$board" 1>&2 && return 1
|
[ -z "$vcfg" ] && printf "%s: vcfg unset\n" "$board" 1>&2 && return 1
|
||||||
|
|
||||||
check_defconfig "$boarddir" 1>"$tmpdir/vendorcfg.list" && return 1
|
check_defconfig "$boarddir" 1>"$TMPDIR/vendorcfg.list" && return 1
|
||||||
while read -r cbcfgfile; do
|
while read -r cbcfgfile; do
|
||||||
set +u +e; . "$cbcfgfile" 2>/dev/null; set -u -e
|
set +u +e; . "$cbcfgfile" 2>/dev/null; set -u -e
|
||||||
done < "$tmpdir/vendorcfg.list"
|
done < "$TMPDIR/vendorcfg.list"
|
||||||
|
|
||||||
[ -z "$tree" ] && $err "getcfg $boarddir: tree undefined"
|
[ -z "$tree" ] && $err "getcfg $boarddir: tree undefined"
|
||||||
cbdir="src/coreboot/$tree"
|
cbdir="src/coreboot/$tree"
|
||||||
|
|
10
script/roms
10
script/roms
|
@ -10,7 +10,7 @@ set -u -e
|
||||||
|
|
||||||
. "include/lib.sh"
|
. "include/lib.sh"
|
||||||
|
|
||||||
tmprom="$tmpdir/rom"
|
tmprom="$TMPDIR/rom"
|
||||||
|
|
||||||
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
||||||
cfgsdir="config/coreboot"
|
cfgsdir="config/coreboot"
|
||||||
|
@ -49,8 +49,8 @@ main()
|
||||||
config/coreboot)" || $err "can't list coreboot boards"
|
config/coreboot)" || $err "can't list coreboot boards"
|
||||||
|
|
||||||
[ -n "$ser" ] && \
|
[ -n "$ser" ] && \
|
||||||
eval "serlist \"\$${ser}dir\" > \"\$tmpdir/ser\" || $err \"!ser\""
|
eval "serlist \"\$${ser}dir\" > \"\$TMPDIR/ser\" || $err \"!ser\""
|
||||||
[ -n "$ser" ] && [ -z "$boards" ] && boards="$(cat "$tmpdir/ser")"
|
[ -n "$ser" ] && [ -z "$boards" ] && boards="$(cat "$TMPDIR/ser")"
|
||||||
|
|
||||||
for x in $boards; do
|
for x in $boards; do
|
||||||
[ -n "$ser" ] && mkserprogfw "$ser" "$x"
|
[ -n "$ser" ] && mkserprogfw "$ser" "$x"
|
||||||
|
@ -173,8 +173,8 @@ add_seabios_payload()
|
||||||
x_ ./update trees -b grub $grubtree
|
x_ ./update trees -b grub $grubtree
|
||||||
cbfs "$tmprom" "$grubelf" "img/grub2"
|
cbfs "$tmprom" "$grubelf" "img/grub2"
|
||||||
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
|
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
|
||||||
> "$tmpdir/tmpcfg" || $err "$board: !insert scandisk"
|
> "$TMPDIR/tmpcfg" || $err "$board: !insert scandisk"
|
||||||
cbfs "$tmprom" "$tmpdir/tmpcfg" scan.cfg raw
|
cbfs "$tmprom" "$TMPDIR/tmpcfg" scan.cfg raw
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "$payload_memtest" = "y" ] && x_ ./update trees -b memtest86plus && \
|
[ "$payload_memtest" = "y" ] && x_ ./update trees -b memtest86plus && \
|
||||||
|
|
Loading…
Reference in New Issue