summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-05 22:16:07 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-05 22:16:07 +0100
commit106841024a5d744768734def462387648d473014 (patch)
tree5af66850a72e7f6610278b18b404f33169eab398 /script
parentcad7648a2696f9453028c98ea74aac7bde85feeb (diff)
general code cleanup in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script')
-rwxr-xr-xscript/build/boot/roms38
-rwxr-xr-xscript/build/coreboot/utils4
-rwxr-xr-xscript/handle/make/config8
3 files changed, 19 insertions, 31 deletions
diff --git a/script/build/boot/roms b/script/build/boot/roms
index 2ae3290a..f9634ce6 100755
--- a/script/build/boot/roms
+++ b/script/build/boot/roms
@@ -63,9 +63,6 @@ main()
check_target()
{
targetdir="${cfgsdir}/${board}"
-
- [ -d "${targetdir}" ] || \
- err "Target not defined: ${board}"
[ -f "${targetdir}/target.cfg" ] || \
err "Missing target.cfg for target: ${board}"
@@ -74,9 +71,8 @@ check_target()
[ -z ${grub_scan_disk} ] && \
grub_scan_disk="both"
- [ "${grub_scan_disk}" != "both" ] && \
- [ "${grub_scan_disk}" != "ata" ] && \
- [ "${grub_scan_disk}" != "ahci" ] && \
+ [ "${grub_scan_disk}" != "both" ] && [ "${grub_scan_disk}" != "ata" ] \
+ && [ "${grub_scan_disk}" != "ahci" ] && \
grub_scan_disk="both"
[ -z ${tree} ] && \
@@ -88,24 +84,20 @@ check_target()
payload_memtest="n"
[ "${payload_grub_withseabios}" = "y" ] && \
payload_grub="y"
- if [ "${payload_grub_withseabios}" = "y" ]; then
- payload_seabios="y"
- payload_seabios_withgrub="y"
- fi
+ [ "${payload_grub_withseabios}" = "y" ] && \
+ eval "$(setvars "y" payload_seabios payload_seabios_withgrub)"
[ "${payload_seabios_withgrub}" = "y" ] && \
payload_seabios="y"
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
# might have a graphics card whose vga rom coreboot doesn't execute
- if [ "${payload_grub}" != "y" ] && \
- [ "${payload_seabios}" != "y" ] && \
- [ "${payload_uboot}" != "y" ]; then
+ [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && \
+ [ "${payload_uboot}" != "y" ] && \
for configfile in "${targetdir}/config/"*; do
[ -e "${configfile}" ] || continue
err "target '${board}' defines no payload"
done
- fi
[ "${payload_uboot}" != "n" ] && [ "${payload_uboot}" != "y" ] && \
payload_uboot="n"
@@ -261,16 +253,13 @@ build_grub_roms()
{
tmprom="${1}"
payload1="${2}" # allow values: grub, seabios, seabios_withgrub
- grub_cbfs="fallback/payload"
- if [ "${payload_grub_withseabios}" = "y" ] && \
- [ "${payload1}" = "grub" ]; then
- x_ mv "$(mkSeabiosRom "${tmprom}" "seabios.elf")" "${tmprom}"
- elif [ "${payload_seabios_withgrub}" = "y" ] && \
- [ "${payload1}" != "grub" ]; then
+ grub_cbfs="fallback/payload"
+ [ "${payload1}" = "grub" ] && [ "${payload_grub_withseabios}" = "y" ] \
+ && x_ mv "$(mkSeabiosRom "${tmprom}" "seabios.elf")" "${tmprom}"
+ [ "${payload1}" != "grub" ] && [ "${payload_seabios_withgrub}" = "y" ] \
+ && grub_cbfs="img/grub2" && \
x_ mv "$(mkSeabiosRom "${tmprom}" fallback/payload)" "${tmprom}"
- grub_cbfs="img/grub2"
- fi
# we only need insert grub.elf once, for each coreboot config:
x_ "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
@@ -364,9 +353,8 @@ build_uboot_roms()
# make a rom in /tmp/ and then print the path of that ROM
mkUbootRom() {
- _cbrom="${1}" # rom to insert u-boot in. it won't be touched
- # (a tmpfile will be made instead)
- _uboot_cbfs_path="${2}" # e.g. fallback/payload
+ _cbrom="${1}"
+ _uboot_cbfs_path="${2}"
_ubdir="elf/u-boot/${board}/${uboot_config}"
_ubootelf="${_ubdir}/u-boot.elf"
diff --git a/script/build/coreboot/utils b/script/build/coreboot/utils
index 75827d86..e3d471ad 100755
--- a/script/build/coreboot/utils
+++ b/script/build/coreboot/utils
@@ -21,9 +21,9 @@ main()
build_for_mainboard() {
[ -f "config/coreboot/${1}/target.cfg" ] || \
err "build_for_mainboard ${1}: target.cfg does not exist"
- tree="undefined"
+ tree=""
. "config/coreboot/${1}/target.cfg" # source
- [ "${tree}" = "undefined" ] && \
+ [ -z ${tree} ] && \
err "build_for_mainboard ${1}: improper tree definition"
buildutils "${tree}"
}
diff --git a/script/handle/make/config b/script/handle/make/config
index cd13aca6..9d028a85 100755
--- a/script/handle/make/config
+++ b/script/handle/make/config
@@ -97,18 +97,18 @@ handle_src_tree()
target_dir="${cfgsdir}/${target}"
xx_ mkdir -p "${elfdir}/${target}"
- eval "$(setvars "undefined" arch tree)"
+ eval "$(setvars "" arch tree)"
romtype="normal"
- [ ! -f "${target_dir}/target.cfg" ] && \
+ [ -f "${target_dir}/target.cfg" ] || \
fail "handle_src_tree: ${target_dir}: missing target.cfg"
# Override the above defaults using target.cfg
. "${target_dir}/target.cfg" # source
- [ "${tree}" = "undefined" ] && \
+ [ -z ${tree} ] && \
fail "handle_src_tree: ${target_dir}: tree undefined"
- [ "${arch}" = "undefined" ] && \
+ [ -z ${arch} ] && \
fail "handle_src_tree: ${target_dir}: undefined cpu type"
codedir="${project}/${tree}"