diff options
author | Leah Rowe <leah@libreboot.org> | 2024-06-25 00:12:18 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2024-06-25 00:12:18 +0100 |
commit | 4e48fa808ec123962c0203282742f9ce641a40d3 (patch) | |
tree | c964404c63110a8e89fb4d65e7c19c39d3df8e23 | |
parent | b4fb2510085dc454ec39fcc55619bd38173776ce (diff) |
lib.sh: simplify use of environment variables
don't have a separate variable for them.
just export them directly and use them directly.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x | include/git.sh | 2 | ||||
-rwxr-xr-x | include/lib.sh | 20 | ||||
-rwxr-xr-x | script/roms | 6 | ||||
-rwxr-xr-x | script/trees | 6 |
4 files changed, 15 insertions, 19 deletions
diff --git a/include/git.sh b/include/git.sh index 0c2e816c..e0eb196b 100755 --- a/include/git.sh +++ b/include/git.sh @@ -92,7 +92,7 @@ git_prep() [ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \ [ "$xtree" != "$tree" ] && link_crossgcc "$_loc" - [ "$xbmk_release" = "y" ] && [ "$_loc" != "src/$project/$project" ] \ + [ "$XBMK_RELEASE" = "y" ] && [ "$_loc" != "src/$project/$project" ] \ && rmgit "$tmpgit" move_repo "$_loc" diff --git a/include/lib.sh b/include/lib.sh index e4e33f0a..32499bc0 100755 --- a/include/lib.sh +++ b/include/lib.sh @@ -42,8 +42,8 @@ chkvars() done } -eval `setvars "" xbmk_release tmpdir _nogit version board boarddir relname \ - versiondate threads projectname projectsite aur_notice cfgsdir datadir` +eval `setvars "" tmpdir _nogit board boarddir relname versiondate projectsite \ + projectname aur_notice cfgsdir datadir version` read -r projectname < projectname || : read -r projectsite < projectsite || : @@ -104,16 +104,12 @@ fi # if "y": a coreboot target won't be built if target.cfg says release="n" # (this is used to exclude certain build targets from releases) -[ -z "${XBMK_RELEASE+x}" ] && xbmk_release="n" -[ -z "$xbmk_release" ] && xbmk_release="$XBMK_RELEASE" -[ "$xbmk_release" = "n" ] || [ "$xbmk_release" = "y" ] || xbmk_release="n" -export XBMK_RELEASE="$xbmk_release" +[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" +[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n" -[ -z "${XBMK_THREADS+x}" ] || threads="$XBMK_THREADS" -[ -z "$threads" ] && threads=1 -expr "X$threads" : "X-\{0,1\}[0123456789][0123456789]*$" \ - 1>/dev/null 2>/dev/null || threads=1 # user specified a non-integer -export XBMK_THREADS="$threads" +[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 +expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ + 1>/dev/null 2>/dev/null || export XBMK_THREADS=1 # user gave a non-integer x_() { [ $# -lt 1 ] || $@ || $err "Unhandled non-zero exit: $@"; return 0 @@ -174,7 +170,7 @@ mktarball() [ "${2%/*}" = "$2" ] || \ mkdir -p "${2%/*}" || $err "mk, !mkdir -p \"${2%/*}\"" printf "\nCreating archive: %s\n\n" "$2" - tar -c "$1" | xz -T$threads -9e > "$2" || $err "mktarball 2, $1" + tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || $err "mktarball 2, $1" mksha512sum "$2" "${2##*/}.sha512" } diff --git a/script/roms b/script/roms index 5a315202..d5eedd6a 100755 --- a/script/roms +++ b/script/roms @@ -59,7 +59,7 @@ main() [ -d "bin/$board" ] && targets="$targets, $x"; continue done - [ -n "$ser" ] && [ "$xbmk_release" = "y" ] && \ + [ -n "$ser" ] && [ "$XBMK_RELEASE" = "y" ] && \ mkrom_tarball "bin/serprog_$ser" && return 0 [ -z "$ser" ] && [ -z "$targets" ] && $err "No images were compiled" @@ -96,7 +96,7 @@ configure_target() x_ ./update trees -b coreboot $board [ -z "$tree" ] && $err "$board: tree not defined" - [ "$xbmk_release" = "y" ] && [ "$release" = "n" ] && return 1 + [ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1 [ "$board" = "$tree" ] && return 1 cbdir="src/coreboot/$tree" @@ -186,7 +186,7 @@ add_seabios_payload() cprom() { x_ mkdir -p "${1%/*}"; x_ cp "$tmprom" "$1" - [ "$xbmk_release" = "y" ] && mksha512sum "$1" "vendorhashes" && \ + [ "$XBMK_RELEASE" = "y" ] && mksha512sum "$1" "vendorhashes" && \ x_ ./vendor inject -r "$1" -b "$board" -n nuke; return 0 } diff --git a/script/trees b/script/trees index 2619892f..7f6f2f25 100755 --- a/script/trees +++ b/script/trees @@ -9,7 +9,7 @@ set -u -e . "include/lib.sh" . "include/git.sh" -cbmakeargs="UPDATED_SUBMODULES=1 CPUS=$threads" +cbmakeargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS" eval `setvars "" xarch cdir config config_name xlang mode makeargs \ listfile project target target_dir targets tree _f target1 bootstrapargs \ autoconfargs cmakedir elfdir autogenargs xtree` @@ -185,7 +185,7 @@ check_coreboot_utils() utilmode="" [ -z "$mode" ] || utilmode="clean" - x_ make -C "$utilsrcdir" $utilmode -j$threads $cbmakeargs + x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $cbmakeargs [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ] && \ x_ mkdir -p "$utilelfdir" && \ x_ cp "$utilsrcdir/$util" "elf/$util/$1" @@ -240,7 +240,7 @@ run_make_command() printf "%s\n" "${version%%-*}" > "$cdir/.coreboot-version" \ && makeargs="$makeargs $cbmakeargs" - make -C "$cdir" $mode -j$threads $makeargs || $err "!mk $cdir $mode" + make -C "$cdir" $mode -j$XBMK_THREADS $makeargs || $err "$cdir mk$mode" [ "$project" = "grub" ] && [ -z "$mode" ] && mkpayload_grub |