general code cleanup in shell scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-05 22:16:07 +01:00
parent cad7648a26
commit 106841024a
3 changed files with 19 additions and 31 deletions

View File

@ -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"

View File

@ -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}"
}

View File

@ -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}"