general code formatting cleanup in shell scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-09-30 20:04:02 +01:00
parent 0a0defd325
commit 26fc3f1325
7 changed files with 38 additions and 69 deletions

View File

@ -37,7 +37,6 @@ handle_targets()
board="${boards%% *}" board="${boards%% *}"
configure_target configure_target
build_dependencies build_dependencies
build_target build_target
} }
@ -47,7 +46,6 @@ configure_target()
[ -d "${targetdir}" ] || \ [ -d "${targetdir}" ] || \
err "Target not defined: ${board}" err "Target not defined: ${board}"
[ -f "${targetdir}/target.cfg" ] || \ [ -f "${targetdir}/target.cfg" ] || \
err "Missing target.cfg for target: ${board}" err "Missing target.cfg for target: ${board}"
@ -93,18 +91,15 @@ configure_target()
payload_uboot="n" payload_uboot="n"
[ "${payload_uboot}" = "y" ] && [ "${uboot_config}" = "undefined" ] && \ [ "${payload_uboot}" = "y" ] && [ "${uboot_config}" = "undefined" ] && \
uboot_config="default" uboot_config="default"
[ "${blobs_required}" != "n" ] && [ "${blobs_required}" != "y" ] && \ [ "${blobs_required}" != "n" ] && [ "${blobs_required}" != "y" ] && \
blobs_required="y" blobs_required="y"
# Override all payload directives with cmdline args # Override all payload directives with cmdline args
if [ ! -z ${_payload} ]; then [ -z ${_payload} ] && return 0
printf "setting payload to: %s\n" "${_payload}" printf "setting payload to: %s\n" "${_payload}"
eval "$(setvars "n" payload_grub payload_grub_withseabios \ eval "$(setvars "n" payload_grub payload_memtest payload_seabios \
payload_seabios payload_seabios_withgrub payload_uboot \ payload_seabios_withgrub payload_uboot payload_grub_withseabios)"
payload_memtest)" eval "payload_${_payload}=y"
eval "payload_${_payload}=y"
fi
} }
build_dependencies() build_dependencies()
@ -160,10 +155,9 @@ build_dependency_grub()
[ ! -f "elf/grub/keymap_${keymap}.cfg" ] && \ [ ! -f "elf/grub/keymap_${keymap}.cfg" ] && \
rebuild_grub="y" && break rebuild_grub="y" && break
done done
if [ "${rebuild_grub}" = "y" ]; then [ "${rebuild_grub}" = "y" ] || return 0
./build grub payload || \ ./build grub payload || \
err "build_dependency_grub: cannot build grub payload" err "build_dependency_grub: cannot build grub payload"
fi
} }
build_dependency_uboot() build_dependency_uboot()
@ -176,9 +170,8 @@ build_dependency_uboot()
ubootelf="${ubdir}/u-boot.elf" ubootelf="${ubdir}/u-boot.elf"
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \ [ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \
ubootelf="${ubdir}/u-boot.bin" ubootelf="${ubdir}/u-boot.bin"
if [ ! -f "${ubootelf}" ]; then [ -f "${ubootelf}" ] && return 0
err "Could not find u-boot build for board, ${board}" err "Could not find u-boot build for board, ${board}"
fi
} }
build_target() build_target()
@ -227,18 +220,14 @@ build_roms()
"${cbfstool}" "${corebootrom}" add-payload \ "${cbfstool}" "${corebootrom}" add-payload \
-f "${memtest_bin}" -n img/memtest -c lzma || \ -f "${memtest_bin}" -n img/memtest -c lzma || \
err "build_roms: cannot add img/memtest to coreboot rom" err "build_roms: cannot add img/memtest to coreboot rom"
[ "${payload_seabios}" = "y" ] && \ [ "${payload_seabios}" = "y" ] && \
build_seabios_roms build_seabios_roms
[ "${payload_grub}" != "y" ] || \ [ "${payload_grub}" != "y" ] || \
build_grub_roms "${corebootrom}" "${initmode}" \ build_grub_roms "${corebootrom}" "${initmode}" \
"${displaymode}" "grub" || \ "${displaymode}" "grub" || \
err "build_roms: build_grub_roms failed" err "build_roms: build_grub_roms failed"
[ "${payload_uboot}" = "y" ] && return 0
if [ "${payload_uboot}" = "y" ]; then build_uboot_roms
build_uboot_roms
fi
} }
build_seabios_roms() build_seabios_roms()
@ -369,7 +358,6 @@ mkGrubRom() {
err "mkGrubRom: cannot create tmprom" err "mkGrubRom: cannot create tmprom"
cp "${target_cbrom}" "${tmprom}" || \ cp "${target_cbrom}" "${tmprom}" || \
err "mkGrubRom: cannot copy to tmprom" err "mkGrubRom: cannot copy to tmprom"
"${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw \ "${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw \
|| err "mkGrubRom: cannot add keymap.cfg to tmprom" || err "mkGrubRom: cannot add keymap.cfg to tmprom"
@ -382,18 +370,14 @@ mkSeabiosRom() {
# (a tmpfile will be made instead) # (a tmpfile will be made instead)
target_seabios_cbfs_path="${2}" # e.g. fallback/payload target_seabios_cbfs_path="${2}" # e.g. fallback/payload
target_initmode="${3}" # e.g. libgfxinit target_initmode="${3}" # e.g. libgfxinit
target_seabioself="elf/seabios/default/${target_initmode}/bios.bin.elf" target_seabioself="elf/seabios/default/${target_initmode}/bios.bin.elf"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${target_cbrom}" "${tmprom}" || \ cp "${target_cbrom}" "${tmprom}" || \
err "mkSeabiosRom: cannot copy to tmprom" err "mkSeabiosRom: cannot copy to tmprom"
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \ "${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
-n ${target_seabios_cbfs_path} -c lzma || \ -n ${target_seabios_cbfs_path} -c lzma || \
err "mkSeabiosRom: can't add payload, ${target_seabioself}, to rom" err "mkSeabiosRom: can't add payload, ${target_seabioself}, to rom"
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \ "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
|| err "mkSeabiosRom: cbfs add-int etc/ps2-keyboard-spinup 3000" || err "mkSeabiosRom: cbfs add-int etc/ps2-keyboard-spinup 3000"
@ -410,7 +394,6 @@ mkSeabiosRom() {
"${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \ "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \
err "mkSeabiosRom: cbfs add-int etc/optionroms-checksum 0" err "mkSeabiosRom: cbfs add-int etc/optionroms-checksum 0"
[ "${target_initmode}" != "libgfxinit" ] || \ [ "${target_initmode}" != "libgfxinit" ] || \
"${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \ "${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
-n vgaroms/seavgabios.bin -t raw || \ -n vgaroms/seavgabios.bin -t raw || \
@ -430,8 +413,7 @@ build_uboot_roms()
newrompath="${romdir}/uboot_payload_${board}_${initmode}.rom" newrompath="${romdir}/uboot_payload_${board}_${initmode}.rom"
moverom "${tmprom}" "${newrompath}" || \ moverom "${tmprom}" "${newrompath}" || \
err "build_roms: moverom fail (u-boot)" err "build_roms: moverom fail (u-boot)"
rm -f "${tmprom}" || \ rm -f "${tmprom}" || err "build_roms: cannot rm u-boot rom"
err "build_roms: cannot rm u-boot rom"
} }
# make a rom in /tmp/ and then print the path of that ROM # make a rom in /tmp/ and then print the path of that ROM

View File

@ -46,10 +46,9 @@ init_check()
[ ! -d "release/${version}/roms/" ] || \ [ ! -d "release/${version}/roms/" ] || \
rm -Rf "release/${version}/roms/" || \ rm -Rf "release/${version}/roms/" || \
err "init_check: !rm -Rf release/${version}/roms/" err "init_check: !rm -Rf release/${version}/roms/"
if [ ! -d "release/${version}/roms/" ]; then [ -d "release/${version}/roms/" ] && return 0
mkdir -p "release/${version}/roms/" || \ mkdir -p "release/${version}/roms/" || \
err "init_check: !mkdir -p release/${version}/roms/" err "init_check: !mkdir -p release/${version}/roms/"
fi
} }
make_archive() make_archive()
@ -161,20 +160,17 @@ strip_archive()
strip_ucode() strip_ucode()
{ {
romfile=${1} romfile=${1}
_newrom_b="${romfile%.rom}_nomicrocode.tmprom" _newrom_b="${romfile%.rom}_nomicrocode.tmprom"
cp "${romfile}" "${_newrom_b}" || \ cp "${romfile}" "${_newrom_b}" || \
err "strip_rom_image: cp \"${romfile}\" \"${_newrom_b}\"" err "strip_rom_image: cp \"${romfile}\" \"${_newrom_b}\""
microcode_present="y" microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \ "${cbfstool}" "${_newrom_b}" remove -n \
cpu_microcode_blob.bin 2>/dev/null || microcode_present="n" cpu_microcode_blob.bin 2>/dev/null || microcode_present="n"
if [ "${microcode_present}" = "n" ]; then [ "${microcode_present}" = "n" ] || return 0
printf "REMARK: '%s' already lacks microcode\n" "${romfile}" \ printf "REMARK: '%s' already lacks microcode\n" "${romfile}" 1>&2
1>&2 printf "Renaming default ROM file instead.\n" 1>&2
printf "Renaming default ROM file instead.\n" 1>&2 mv "${romfile}" "${_newrom_b}" || \
mv "${romfile}" "${_newrom_b}" || \ err "strip_rom_image: can't rename no-u ${romfile}"
err "strip_rom_image: can't rename no-u ${romfile}"
fi
} }
strip_rom_image() strip_rom_image()
@ -196,10 +192,9 @@ strip_rom_image()
err "strip_rom_images: ${1}: can't nuke ecfw2.bin" err "strip_rom_images: ${1}: can't nuke ecfw2.bin"
fi fi
# TODO: replace this board-specific hack # TODO: replace this board-specific hack
if [ "${target}" = "e6400_4mb" ]; then [ "${target}" = "e6400_4mb" ] || return 0
"${cbfstool}" "${1}" remove -n "pci10de,06eb.rom" || \ "${cbfstool}" "${1}" remove -n "pci10de,06eb.rom" || \
err "strip_rom_images: ${1}: can't nuke e6400 vga rom" err "strip_rom_images: ${1}: can't nuke e6400 vga rom"
fi
} }
main $@ main $@

View File

@ -36,7 +36,6 @@ main()
purge_files purge_files
create_release_archive create_release_archive
printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}" printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}"
} }
@ -116,9 +115,7 @@ copy_files()
purge_files() purge_files()
{ {
( (
cd "${srcdir}/" || \ cd "${srcdir}/" || err "purge_files 3: !cd ${srcdir}/"
err "purge_files 3: !cd ${srcdir}/"
[ ! -d "coreboot/default/util/kbc1126" ] || \ [ ! -d "coreboot/default/util/kbc1126" ] || \
./handle make file -c "coreboot/default/util/kbc1126" || \ ./handle make file -c "coreboot/default/util/kbc1126" || \
err "purge_files 1: default/util/kbc1126: ! make clean" err "purge_files 1: default/util/kbc1126: ! make clean"
@ -128,7 +125,6 @@ purge_files()
./handle make config -c "${p}" || \ ./handle make config -c "${p}" || \
err "purge_files: ${p}: cannot clean the source trees" err "purge_files: ${p}: cannot clean the source trees"
done done
for p in bios_extract flashrom grub uefitool; do for p in bios_extract flashrom grub uefitool; do
./handle make file -c "${p}" || \ ./handle make file -c "${p}" || \
err "purge_files: !./handle make file -c ${p}" err "purge_files: !./handle make file -c ${p}"

View File

@ -71,9 +71,8 @@ handle_targets()
handle_defconfig || fail "error handling config file" handle_defconfig || fail "error handling config file"
done done
if [ "${mode}" = "all" ]; then [ "${mode}" = "all" ] || return 0
printf "Done! The files are stored under %s/\n\n" "${elfdir}" printf "Done! The files are stored under %s/\n\n" "${elfdir}"
fi
} }
handle_defconfig() handle_defconfig()

View File

@ -34,13 +34,12 @@ handle_dependencies()
[ -d "${project}" ] || \ [ -d "${project}" ] || \
err "handle_dependencies: ${project%/*} not downloaded" err "handle_dependencies: ${project%/*} not downloaded"
if [ "${project}" = "uefitool" ]; then [ "${project}" = "uefitool" ] || return 0 # TODO: remove hardcoding
( (
cd uefitool || err "handle_dependencies: !cd uefitool" cd uefitool || err "handle_dependencies: !cd uefitool"
cmake UEFIExtract/ || [ -f Makefile ] || \ cmake UEFIExtract/ || [ -f Makefile ] || \
err "handle_dependencies: !cmake UEFIExtract/" err "handle_dependencies: !cmake UEFIExtract/"
) )
fi
} }
run_make_command() run_make_command()

View File

@ -74,10 +74,9 @@ download_blobs()
fetch "e6400vga" "${E6400_VGA_DL_url}" \ fetch "e6400vga" "${E6400_VGA_DL_url}" \
"${E6400_VGA_DL_url_bkup}" "${E6400_VGA_DL_hash}" \ "${E6400_VGA_DL_url_bkup}" "${E6400_VGA_DL_hash}" \
"${CONFIG_VGA_BIOS_FILE}" "${CONFIG_VGA_BIOS_FILE}"
if [ ! -z "${CONFIG_HAVE_MRC}" ]; then [ -z "${CONFIG_HAVE_MRC}" ] && return 0
fetch "mrc" "${MRC_url}" "${MRC_url_bkup}" "${MRC_hash}" \ fetch "mrc" "${MRC_url}" "${MRC_url_bkup}" "${MRC_hash}" \
"${CONFIG_MRC_FILE}" "${CONFIG_MRC_FILE}"
fi
} }
extract_intel_me() extract_intel_me()

View File

@ -53,9 +53,8 @@ check_board()
fi fi
boarddir="${cbcfgsdir}/${board}" boarddir="${cbcfgsdir}/${board}"
if [ ! -d "${boarddir}" ]; then [ -d "${boarddir}" ] && return 0
err "check_board: board ${board} not found" err "check_board: board ${board} not found"
fi
} }
check_release() check_release()