diff options
author | Leah Rowe <leah@libreboot.org> | 2025-01-02 23:52:45 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-01-02 23:52:45 +0000 |
commit | 0cf58c22734b19293f4cbef83add59b031ca1773 (patch) | |
tree | 484a35f40cbf8fb400d0901c3cbd3baf22088bff | |
parent | 8276560cc998e8eb1f935cbbe7551d2fbdc65d39 (diff) |
fix lbmk shellcheck errors
There was also a condition in run_make_command that is now
an OR, where it was an AND, on script/trees, to fix the use
of mixed (and erroneous) OR/AND operators.
I'm planning a much more invasive audit than this. These are
light fixes, intended for Libreboot 20241206 rev8.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x | build | 4 | ||||
-rw-r--r-- | include/git.sh | 13 | ||||
-rw-r--r-- | include/lib.sh | 17 | ||||
-rw-r--r-- | include/mrc.sh | 2 | ||||
-rw-r--r-- | include/rom.sh | 16 | ||||
-rw-r--r-- | include/vendor.sh | 31 | ||||
-rwxr-xr-x | script/trees | 33 |
7 files changed, 62 insertions, 54 deletions
@@ -14,7 +14,7 @@ fi . "include/vendor.sh" . "include/mrc.sh" -eval `setvars "" vdir src_dirname srcdir mode xp ser` +eval "`setvars "" vdir src_dirname srcdir mode xp ser`" err="fail" main() @@ -48,7 +48,7 @@ git_init() { [ -L ".git" ] && return 1 [ -e ".git" ] && return 0 - eval `setvars "$(date -Rud @$versiondate)" cdate _nogit` + eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`" git init || return 1 git add -A . || return 1 diff --git a/include/git.sh b/include/git.sh index aaeabcd4..fb0b2b42 100644 --- a/include/git.sh +++ b/include/git.sh @@ -2,8 +2,8 @@ # Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org> # Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com> -eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \ - depend subfile_bkup repofail` +eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \ + depend subfile_bkup repofail`" fetch_targets() { @@ -18,8 +18,8 @@ fetch_targets() fetch_project() { - eval `setvars "" xtree tree_depend` - eval `setcfg "config/git/$project/pkg.cfg"` + eval "`setvars "" xtree tree_depend`" + eval "`setcfg "config/git/$project/pkg.cfg"`" chkvars url @@ -71,7 +71,8 @@ prep_submodules() fetch_submodule() { mcfgdir="$mdir/${1##*/}" - eval `setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st` + eval "`setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup \ + st`" [ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \ $err "! . $mcfgdir/module.cfg" @@ -103,7 +104,7 @@ tmpclone() mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo" if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then - git clone $1 "$repodir" || git clone $2 "$repodir" || \ + git clone "$1" "$repodir" || git clone $2 "$repodir" || \ $err "!clone $1 $2 $repodir $4 $5" # elif [ -d "$repodir" ] && [ $# -lt 6 ]; then git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \ diff --git a/include/lib.sh b/include/lib.sh index 5a32d592..790f4fe9 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -33,23 +33,23 @@ err_() setvars() { _setvars="" && [ $# -lt 2 ] && $err "setvars: too few arguments" - val="$1" && shift 1 && for var in $@; do + val="$1" && shift 1 && for var in "$@"; do _setvars="$var=\"$val\"; $_setvars" done; printf "%s\n" "${_setvars% }" } chkvars() { - for var in $@; do + for var in "$@"; do eval "[ -n "\${$var+x}" ] || \$err \"$var unset\"" eval "[ -n "\$$var" ] || \$err \"$var unset\"" done; return 0 } -eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \ - aur_notice configdir datadir version relname reinstall` +eval "`setvars "" _nogit board reinstall versiondate projectsite projectname \ + aur_notice configdir datadir version relname xbmk_parent`" for fv in projectname projectsite version versiondate; do - eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :" + eval "[ ! -f \"$fv\" ] || read -r $fv < \"$fv\" || :" done; chkvars projectname projectsite setcfg() @@ -75,12 +75,13 @@ install_packages() [ $# -lt 2 ] && $err "fewer than two arguments" [ $# -gt 2 ] && reinstall="$3" - eval `setcfg "config/dependencies/$2"` + eval "`setcfg "config/dependencies/$2"`" + chkvars pkg_add pkglist $pkg_add $pkglist || $err "Cannot install packages" [ -n "$aur_notice" ] && \ - printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; return 0 + printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; : } if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then install_packages "$@" || exit 1 @@ -267,7 +268,7 @@ cbfs() mk() { mk_flag="$1" || $err "No argument given" - shift 1 && for mk_arg in $@; do + shift 1 && for mk_arg in "$@"; do ./mk $mk_flag $mk_arg || $err "./mk $mk_flag $mk_arg"; : done; : } diff --git a/include/mrc.sh b/include/mrc.sh index 2e00d9f9..f5db2ff0 100644 --- a/include/mrc.sh +++ b/include/mrc.sh @@ -4,7 +4,7 @@ # Modifications in this version are Copyright 2021, 2023 and 2024 Leah Rowe. # Original copyright detailed in repo: https://review.coreboot.org/coreboot/ -eval `setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL` +eval "`setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL`" extract_mrc() { diff --git a/include/rom.sh b/include/rom.sh index a53a6d8c..6c1d2b05 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -43,8 +43,9 @@ copyps1bios() mkpayload_grub() { - eval `setvars "" grub_modules grub_install_modules` - $dry eval `setcfg "$grubdata/module/$tree"` + eval "`setvars "" grub_modules grub_install_modules`" + $dry eval "`setcfg "$grubdata/module/$tree"`" + $dry chkvars grub_modules grub_install_modules $dry x_ rm -f "$srcdir/grub.elf"; $dry \ "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \ @@ -62,7 +63,7 @@ mkvendorfiles() printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ $err "!mk $srcdir .coreboot-version" [ -z "$mode" ] && [ "$target" != "$tree" ] && \ - x_ ./mk download $target; return 0 + x_ ./mk download "$target"; return 0 } cook_coreboot_config() @@ -113,7 +114,8 @@ mkcorebootbin() if [ "$payload_uboot_i386" = "y" ] || \ [ "$payload_uboot_amd64" = "y" ]; then - printf "'$target' has x86 U-Boot; assuming SeaBIOS=y\n" 1>&2 + printf "'%s' has x86 U-Boot; assuming SeaBIOS=y\n" \ + "$target" 1>&2 payload_seabios="y" fi @@ -204,10 +206,12 @@ mkseagrub() add_uboot() { if [ "$displaymode" = "txtmode" ]; then - printf "cb/$target: Cannot use U-Boot in text mode\n" 1>&2 + printf "cb/%s: Cannot use U-Boot in text mode\n" \ + "$target" 1>&2 return 0 elif [ "$initmode" = "normal" ]; then - printf "cb/$target: Cannot use U-Boot in normal initmode\n" 1>&2 + printf "cb/%s: Cannot use U-Boot in normal initmode\n" \ + "$target" 1>&2 return 0 fi diff --git a/include/vendor.sh b/include/vendor.sh index 29b991cd..15d4e5cb 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -26,14 +26,14 @@ cv="CONFIG_HAVE_ME_BIN CONFIG_ME_BIN_PATH CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \ CONFIG_FSP_S_FILE CONFIG_FSP_S_CBFS CONFIG_FSP_M_CBFS CONFIG_FSP_USE_REPO \ CONFIG_FSP_FULL_FD" -eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ +eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest tree \ mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \ archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref FSPFD_hash \ _7ztest ME11bootguard ME11delta ME11version ME11sku ME11pch tmpromdir \ IFD_platform ifdprefix cdir sdir _me _metmp mfs TBFW_url_bkup TBFW_url \ - TBFW_hash TBFW_size hashfile has_hashes xromsize xchanged $cv` + TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup $cv`" vendor_download() { @@ -58,14 +58,14 @@ readkconfig() done done < "$TMPDIR/vendorcfg.list" - eval `setcfg "$TMPDIR/tmpcbcfg"` + eval "`setcfg "$TMPDIR/tmpcbcfg"`" for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \ CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \ CONFIG_LENOVO_TBFW_BIN CONFIG_FSP_M_FILE CONFIG_FSP_S_FILE; do eval "[ \"\${$c}\" = \"/dev/null\" ] && continue" eval "[ -z \"\${$c}\" ] && continue" - eval `setcfg "config/vendor/$vcfg/pkg.cfg"`; return 0 + eval "`setcfg "config/vendor/$vcfg/pkg.cfg"`"; return 0 done printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1 } @@ -77,7 +77,7 @@ bootstrap() [ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126" [ -n "$MRC_refcode_cbtree" ] && \ cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \ - x_ ./mk -d coreboot $MRC_refcode_cbtree; return 0 + x_ ./mk -d coreboot "$MRC_refcode_cbtree"; return 0 } getfiles() @@ -345,7 +345,7 @@ vendor_inject() remkdir "$tmpromdel" set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash" - eval `setvars "" nukemode new_mac xchanged` + eval "`setvars "" nukemode new_mac xchanged`" archive="$1"; [ $# -gt 1 ] && case "$2" in @@ -359,7 +359,7 @@ vendor_inject() check_release "$archive" || \ $err "You must run this script on a release archive. - $dontflash" if readcfg; then - [ "$nukemode" = "nuke" ] || x_ ./mk download $board + [ "$nukemode" = "nuke" ] || x_ ./mk download "$board" patch_release_roms else printf "Tarball '%s' (board '%s) doesn't need vendorfiles.\n" \ @@ -407,7 +407,7 @@ readcfg() [ "$board" = "serprog_pico" ]; then return 1 fi; boarddir="$cbcfgsdir/$board" - eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree + eval "`setcfg "$boarddir/target.cfg"`"; chkvars vcfg tree cbdir="src/coreboot/$tree" cbfstool="elf/cbfstool/$tree/cbfstool" @@ -418,7 +418,7 @@ readcfg() ifdtool="elf/ifdtool/$tree/ifdtool" [ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform" - x_ ./mk -d coreboot $tree + x_ ./mk -d coreboot "$tree" } patch_release_roms() @@ -454,7 +454,7 @@ patch_release_roms() printf "Make sure you inserted vendor files: %s\n" \ "$vguide" > "$tmpromdir/README.md" || : else - printf "Skipping vendorfiles on '$archive'" + printf "Skipping vendorfiles on '%s'\n" "$archive" 1>&2 fi ( @@ -471,7 +471,7 @@ patch_release_roms() if [ -n "$new_mac" ]; then if ! modify_mac_addresses; then - printf "\nNo GbE region defined for '$board'\n" \ + printf "\nNo GbE region defined for '%s'\n" "$board" \ 1>&2 printf "Therefore, changing the MAC is impossible.\n" \ 1>&2 @@ -596,17 +596,17 @@ patch_rom() inject() { - [ $# -lt 3 ] && $err "$@, $rom: usage: inject name path type (offset)" + [ $# -lt 3 ] && $err "$*, $rom: usage: inject name path type (offset)" [ "$2" = "/dev/null" ] && return 0 - eval `setvars "" cbfsname _dest _t _offset` + eval "`setvars "" cbfsname _dest _t _offset`" cbfsname="$1"; _dest="${2##*../}"; _t="$3" if [ "$_t" = "fsp" ]; then [ $# -gt 3 ] && _offset="$4" else [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \ - $err "inject $@, $rom: offset given but empty (undefined)" + $err "inject $*, $rom: offset given but empty (undefined)" fi e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type" @@ -666,6 +666,7 @@ modify_mac_addresses() "$_xrom" || $err "'$_xrom': Can't insert new GbE file" xchanged="y" done < "tmp/rom.list" - printf "\nThe following GbE NVM words were written in '$archive':\n" + printf "\nThe following GbE NVM words were written in '%s':\n" \ + "$archive" x_ util/nvmutil/nvm tmp/gbe dump } diff --git a/script/trees b/script/trees index a3ea1e6f..e674282c 100755 --- a/script/trees +++ b/script/trees @@ -11,13 +11,13 @@ set -u -e XBMKPATH="$PATH" -eval `setvars "" xarch srcdir premake cmakedir xlang mode makeargs elfdir cmd \ +eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \ project target target_dir targets xtree _f release bootstrapargs mkhelper \ autoconfargs listfile autogenargs btype tree rev tree_depend build_depend \ defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \ - gnatver gnatfull gccdir gnatdir`; badhash="n" + gnatver gnatfull gccdir cmakedir`"; badhash="n" -tree() +main() { while getopts f:b:m:u:c:x:s:l:n:d: option; do [ -n "$_f" ] && $err "only one flag is permitted" @@ -53,7 +53,7 @@ tree() e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && \ x_ touch "$mkhelpercfg" - targets="$@"; cmd="build_targets $targets" + targets="$*"; cmd="build_targets $targets" singletree "$project" && cmd="build_project" remkdir "${tmpgit%/*}" @@ -115,14 +115,15 @@ handle_defconfig() configure_project() { - eval `setvars "" xarch xlang build_depend autoconfargs xtree postmake \ + eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \ tree_depend makeargs btype mkhelper bootstrapargs premake release \ - cleanargs` + xarch xlang`" _tcfg="$1/target.cfg"; badhash="n"; [ -f "$_tcfg" ] || btype="auto" - [ -f "$datadir/mkhelper.cfg" ] && eval `setcfg "$datadir/mkhelper.cfg"` + [ -f "$datadir/mkhelper.cfg" ] && \ + eval "`setcfg "$datadir/mkhelper.cfg"`" while [ -f "$_tcfg" ] || [ "$cmd" != "build_project" ]; do - eval `setvars "" rev tree`; eval `setcfg "$_tcfg"` + eval "`setvars "" rev tree`"; eval "`setcfg "$_tcfg"`" printf "Loading %s config: %s\n" "$project" "$_tcfg" [ "$_f" = "-d" ] && build_depend="" # dry run @@ -140,7 +141,7 @@ configure_project() [ -n "$tree" ] && mdir="$mdir/$tree" [ -f "CHANGELOG" ] || check_project_hashes - [ "$mode" = "fetch" ] || x_ ./mk -f "$project" $target + [ "$mode" = "fetch" ] || x_ ./mk -f "$project" "$target" [ "$mode" = "fetch" ] || return 0 [ -f "CHANGELOG" ] && return 1; fetch_${cmd#build_}; return 1 } @@ -198,7 +199,7 @@ check_cross_compiler() [ "$project" != "coreboot" ] && cbdir="src/coreboot/default" [ -n "$xtree" ] && cbdir="src/coreboot/$xtree" - x_ ./mk -f coreboot ${cbdir#src/coreboot/} + x_ ./mk -f coreboot "${cbdir#src/coreboot/}" export PATH="$PWD/$cbdir/util/crossgcc/xgcc/bin:$PATH" export CROSS_COMPILE="${xarch% *}-" @@ -234,16 +235,16 @@ check_gnu_path() eval "[ \"\$$_gnuarg\" = \"gnat\" ] && continue" $err "check_gnu_path: Invalid argument \"$_gnuarg\"" done - command -v $1 1>/dev/null || $err "Host '$1' unavailable" + command -v "$1" 1>/dev/null || $err "Host '$1' unavailable" - eval `setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir` + eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`" gnu_setver "$1" "$1" || $err "Command '$1' unavailable." gnu_setver "$2" "$2" || : eval "[ -z \"\$$1ver\" ] && $err \"Cannot detect host '$1' version\"" [ "$gnatfull" = "$gccfull" ] && return 0 - eval "$1dir="$(dirname "$(command -v $1)")"" + eval "$1dir=\"$(dirname "$(command -v "$1")")\"" eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\"" for _gnubin in "$_gnudir/$2-"*; do [ -f "$_gnubin" ] || continue @@ -266,7 +267,7 @@ check_gnu_path() gnu_setver() { eval "$2 --version 1>/dev/null 2>/dev/null || return 1" - eval "$1ver=\"`$2 --version 2>/dev/null | head -n1`\"" + eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\"" eval "$1ver=\"\${$1ver##* }\"" eval "$1full=\"\$$1ver\"" eval "$1ver=\"\${$1ver%%.*}\""; : @@ -316,7 +317,7 @@ run_make_command() $dry make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs || $err "!$mode" [ -z "$mkhelper" ] || [ -n "$mode" ] || $mkhelper || $err "!$mkhelper" - [ "$mode" = "clean" ] && \ + [ "$mode" != "clean" ] || \ $dry make -C "$srcdir" $cleanargs distclean || :; : } @@ -352,6 +353,6 @@ copy_elf() done < "$listfile"; x_ make clean -C "$srcdir" $cleanargs } -tree "$@" || exit 0 +main "$@" || exit 0 . "$mkhelpercfg" $cmd |