summaryrefslogtreecommitdiff
path: root/script/build
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-01 06:33:43 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-01 22:47:02 +0100
commit8c03b886c4d4b9bcfb1cb30b3704b8af561c2f45 (patch)
tree828eb1ad589300517e9a41581eee4b5d9605d3e8 /script/build
parent5f914a4d00da5ab9324c55eaecc40aa2ee000f63 (diff)
Greatly simplify error handling in shell scripts
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build')
-rwxr-xr-xscript/build/boot/roms3
-rwxr-xr-xscript/build/boot/roms_helper131
-rwxr-xr-xscript/build/coreboot/utils31
-rwxr-xr-xscript/build/fw/serprog26
-rwxr-xr-xscript/build/grub/payload17
-rwxr-xr-xscript/build/grub/utils20
-rwxr-xr-xscript/build/release/roms92
-rwxr-xr-xscript/build/release/src92
8 files changed, 149 insertions, 263 deletions
diff --git a/script/build/boot/roms b/script/build/boot/roms
index edecfc6b..48d55e27 100755
--- a/script/build/boot/roms
+++ b/script/build/boot/roms
@@ -41,8 +41,7 @@ build_bootroms()
{
opts="${_displaymode} ${_payload} ${_keyboard}"
for x in ${boards}; do
- ./build boot roms_helper ${opts} ${x} || \
- err "handle_targets ${opts} ${x}: build error"
+ x_ ./build boot roms_helper ${opts} ${x}
[ -d "bin/${x}" ] && targets="${x} ${targets}"
done
}
diff --git a/script/build/boot/roms_helper b/script/build/boot/roms_helper
index 09b08125..2d185b7d 100755
--- a/script/build/boot/roms_helper
+++ b/script/build/boot/roms_helper
@@ -110,16 +110,15 @@ build_dependencies()
cbfstool="cbutils/${tree}/cbfstool"
cbrom="${cbdir}/build/coreboot.rom"
- ./build coreboot utils ${tree} || err "cannot build cbutils/${tree}"
+ x_ ./build coreboot utils ${tree}
build_dependency_seabios
memtest_bin="memtest86plus/build${arch#*_}/memtest.bin"
[ "${payload_memtest}" != "y" ] || [ -f "${memtest_bin}" ] || \
- ./handle make file -b ${memtest_bin%/*} || \
- err "cannot build memtest86+"
+ x_ ./handle make file -b ${memtest_bin%/*}
- rm -f "${romdir}"/* || err "cannot: rm -f \"${romdir}\"/*"
+ x_ rm -f "${romdir}/"*
build_dependency_grub
build_dependency_uboot
@@ -133,8 +132,7 @@ build_dependency_seabios()
|| [ ! -f elf/seabios/default/libgfxinit/bios.bin.elf ] \
|| [ ! -f elf/seabios/default/vgarom/bios.bin.elf ] \
|| [ ! -f elf/seabios/default/normal/bios.bin.elf ]; then
- ./handle make config -b seabios || \
- err "cannot build seabios"
+ x_ ./handle make config -b seabios
fi
}
@@ -155,16 +153,14 @@ build_dependency_grub()
rebuild_grub="y" && break
done
[ "${rebuild_grub}" = "y" ] || return 0
- ./build grub payload || \
- err "build_dependency_grub: cannot build grub payload"
+ x_ ./build grub payload
}
build_dependency_uboot()
{
[ "${payload_uboot}" = "y" ] || return 0
- ./handle make config -b u-boot ${board} || \
- err "cannot build u-boot target: ${board}"
+ x_ ./handle make config -b u-boot ${board}
ubdir="elf/u-boot/${board}/${uboot_config}"
ubootelf="${ubdir}/u-boot.elf"
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \
@@ -187,7 +183,7 @@ build_target()
[ "$displaymode" != "txtmode" ] && continue
cbcfg="${targetdir}/config/${initmode}_${displaymode}"
[ "${initmode}" = "normal" ] && cbcfg="${cbcfg%_*}"
- build_roms "${cbcfg}"
+ build_roms "${cbcfg}"
done
done
}
@@ -201,26 +197,22 @@ build_roms()
"${cbcfg}" "${board}" "${displaymode}" "${initmode}" \
1>&2 && return 0
- ./handle make config -b coreboot ${board} || \
- err "build_roms: cannot build coreboot for target: ${board}"
+ x_ ./handle make config -b coreboot ${board}
_cbrom="elf/coreboot/${board}/${initmode}_${displaymode}"
[ "${initmode}" = "normal" ] && \
_cbrom="${_cbrom%_${displaymode}}"
_cbrom="${_cbrom}/coreboot.rom"
cbrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)"
- cp "${_cbrom}" "${cbrom}" || \
- err "build_roms: cannot copy rom"
+ x_ cp "${_cbrom}" "${cbrom}"
[ "${payload_memtest}" != "y" ] || \
- "${cbfstool}" "${cbrom}" add-payload \
- -f "${memtest_bin}" -n img/memtest -c lzma || \
- err "build_roms: cannot add img/memtest to coreboot rom"
+ x_ "${cbfstool}" "${cbrom}" add-payload \
+ -f "${memtest_bin}" -n img/memtest -c lzma
[ "${payload_seabios}" = "y" ] && \
build_seabios_roms
[ "${payload_grub}" != "y" ] || \
- build_grub_roms "${cbrom}" "grub" || \
- err "build_roms: build_grub_roms failed"
+ x_ build_grub_roms "${cbrom}" "grub"
[ "${payload_uboot}" = "y" ] || return 0
build_uboot_roms
}
@@ -229,68 +221,57 @@ build_seabios_roms()
{
if [ "${payload_seabios_withgrub}" = "y" ]; then
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
- cp "${cbrom}" "${tmprom}" || \
- err "build_seabios_roms: cannot copy to tmprom"
- build_grub_roms "${tmprom}" "seabios_withgrub" || \
- err "build_roms: cannot build grub roms, seabios w/grub"
- rm -f "${tmprom}" || err "build_roms: can't remove tmprom"
+ x_ cp "${cbrom}" "${tmprom}"
+ x_ build_grub_roms "${tmprom}" "seabios_withgrub"
+ x_ rm -f "${tmprom}"
else
t=$(mkSeabiosRom "${cbrom}" "fallback/payload") || \
err "build_seabios_roms: cannot build tmprom"
newrom="${romdir}/seabios_${board}_${initmode}_${displaymode}"
[ "${initmode}" = "normal" ] && newrom="${romdir}/seabios" \
&& newrom="${newrom}_${board}_${initmode}"
- moverom "${t}" "${newrom}.rom" || \
- err "build_roms: cannot copy rom"
- rm -f "${t}" || err "cannot rm ${t}"
+ x_ moverom "${t}" "${newrom}.rom"
+ x_ rm -f "${t}"
fi
-
}
# Make separate ROM images with GRUB payload, for each supported keymap
-build_grub_roms() {
+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
- mv "$(mkSeabiosRom "${tmprom}" "seabios.elf")" "${tmprom}" || \
- err "build_grub_roms: cannot move tmp rom (seabios.elf)"
+ x_ mv "$(mkSeabiosRom "${tmprom}" "seabios.elf")" "${tmprom}"
elif [ "${payload_seabios_withgrub}" = "y" ] && \
[ "${payload1}" != "grub" ]; then
- mv "$(mkSeabiosRom "${tmprom}" fallback/payload)" "${tmprom}" \
- || err "build_grub_roms: cannot move SeaBIOS ROM to tmprom"
+ x_ mv "$(mkSeabiosRom "${tmprom}" fallback/payload)" "${tmprom}"
grub_cbfs="img/grub2"
fi
# we only need insert grub.elf once, for each coreboot config:
- "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" -n ${grub_cbfs} \
- -c lzma || err "build_grub_roms: cannot add grub payload to tmprom"
+ x_ "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
+ -n ${grub_cbfs} -c lzma
# we only need insert background.png once, for each coreboot config:
if [ "${displaymode}" = "vesafb" ] || \
[ "${displaymode}" = "corebootfb" ]; then
backgroundfile="config/grub/background/${grub_background}"
- "${cbfstool}" "${tmprom}" add -f ${backgroundfile} \
- -n background.png -t raw || \
- err "build_grub_roms: cannot add background.png to tmprom"
-
+ x_ "${cbfstool}" "${tmprom}" add -f ${backgroundfile} \
+ -n background.png -t raw
fi
tmpcfg=$(mktemp -t coreboot_rom.XXXXXXXXXX) ||
err "build_grub_roms: cannot create temporary scan.cfg"
- printf "set grub_scan_disk=\"%s\"\n" "${grub_scan_disk}" > \
- "${tmpcfg}" || err "build_grub_roms: cannot create scan.cfg"
+ x_ printf "set grub_scan_disk=\"%s\"\n" "${grub_scan_disk}" >"${tmpcfg}"
[ "${grub_scan_disk}" = "both" ] || \
- "${cbfstool}" "${tmprom}" add -f "${tmpcfg}" -n scan.cfg -t \
- raw || err "build_grub_roms: can't insert scan.cfg"
- printf "set timeout=%s\n" "${grub_timeout}" > "${tmpcfg}" || \
- err "build_grub_roms: can't create timeout.cfg"
- [ -z "${grub_timeout}" ] || \
- "${cbfstool}" "${tmprom}" add -f "${tmpcfg}" -n timeout.cfg \
- -t raw || err "build_grub_roms: can't insert timeout.cfg"
- rm -f "${tmpcfg}" || err "build_grub_roms: can't delete tmpcfg"
+ x_ "${cbfstool}" "${tmprom}" add -f "${tmpcfg}" -n scan.cfg -t raw
+ x_ printf "set timeout=%s\n" "${grub_timeout}" > "${tmpcfg}"
+ [ -z "${grub_timeout}" ] || x_ "${cbfstool}" "${tmprom}" add \
+ -f "${tmpcfg}" -n timeout.cfg -t raw
+ x_ rm -f "${tmpcfg}"
keymaps=""
for kmapfile in "${kmapdir}"/*; do
@@ -309,9 +290,8 @@ build_grub_roms() {
[ "${initmode}" = "normal" ] && \
newrom="${romdir}/${payload1}_${board}_" && \
newrom="${newrom}${initmode}_${keymap}.rom"
- moverom "${tmpgrubrom}" "${newrom}" || \
- err "build_grub_roms, moverom"
- rm -f "${tmpgrubrom}" || err "rm tmpgrubrom, build_grub_roms"
+ x_ moverom "${tmpgrubrom}" "${newrom}"
+ x_ rm -f "${tmpgrubrom}"
done
}
@@ -324,9 +304,8 @@ mkGrubRom() {
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) || \
err "mkGrubRom: cannot create tmprom"
- cp "${_cbrom}" "${tmprom}" || err "mkGrubRom: cannot copy to tmprom"
- "${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw \
- || err "mkGrubRom: cannot add keymap.cfg to tmprom"
+ x_ cp "${_cbrom}" "${tmprom}"
+ x_ "${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw
printf "%s\n" "${tmprom}"
}
@@ -339,23 +318,17 @@ mkSeabiosRom() {
_seabioself="elf/seabios/default/${initmode}/bios.bin.elf"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
- cp "${_cbrom}" "${tmprom}" || \
- err "mkSeabiosRom: cannot copy to tmprom"
- "${cbfstool}" "${tmprom}" add-payload -f "${_seabioself}" \
- -n ${_seabios_cbfs_path} -c lzma || \
- err "mkSeabiosRom: can't add payload, ${_seabioself}, to rom"
- "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
- || err "mkSeabiosRom: cbfs add-int etc/ps2-keyboard-spinup 3000"
+ x_ cp "${_cbrom}" "${tmprom}"
+ x_ "${cbfstool}" "${tmprom}" add-payload -f "${_seabioself}" \
+ -n ${_seabios_cbfs_path} -c lzma
+ x_ "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup
z="2"; [ "${initmode}" = "vgarom" ] && z="0"
- "${cbfstool}" "${tmprom}" add-int -i $z -n etc/pci-optionrom-exec || \
- err "mkSeabiosRom: cbfs add-int etc/pci-optionrom-exec 0"
- "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \
- err "mkSeabiosRom: cbfs add-int etc/optionroms-checksum 0"
+ x_ "${cbfstool}" "${tmprom}" add-int -i $z -n etc/pci-optionrom-exec
+ x_ "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum
[ "${initmode}" != "libgfxinit" ] || \
- "${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
- -n vgaroms/seavgabios.bin -t raw || \
- err "mkSeabiosRom: cbfs add-raw vgaroms/seavgabios.bin"
+ x_ "${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
+ -n vgaroms/seavgabios.bin -t raw
printf "%s\n" "${tmprom}"
}
@@ -366,9 +339,8 @@ build_uboot_roms()
newrom="${romdir}/uboot_payload_${board}_${initmode}_${displaymode}.rom"
[ "${initmode}" = "normal" ] && \
newrom="${romdir}/uboot_payload_${board}_${initmode}.rom"
- moverom "${tmprom}" "${newrom}" || \
- err "build_roms: moverom fail (u-boot)"
- rm -f "${tmprom}" || err "build_roms: cannot rm u-boot rom"
+ x_ moverom "${tmprom}" "${newrom}"
+ x_ rm -f "${tmprom}"
}
# make a rom in /tmp/ and then print the path of that ROM
@@ -384,11 +356,9 @@ mkUbootRom() {
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
- cp "${_cbrom}" "${tmprom}" || \
- err "mkUbootRom: cannot copy to tmprom"
- "${cbfstool}" "${tmprom}" add-payload -f "${_ubootelf}" \
- -n ${_uboot_cbfs_path} -c lzma || \
- err "mkUbootRom: cannot add u-boot to tmprom"
+ x_ cp "${_cbrom}" "${tmprom}"
+ x_ "${cbfstool}" "${tmprom}" add-payload -f "${_ubootelf}" \
+ -n ${_uboot_cbfs_path} -c lzma
printf "%s\n" "${tmprom}"
}
@@ -401,10 +371,9 @@ moverom() {
printf "Creating target image: %s\n" "${newrom}"
- [ -d "${newrom%/*}" ] || mkdir -p "${newrom%/*}/" || \
- err "moverom: cannot create rom directory: \"${newrom%/*}\""
+ [ -d "${newrom%/*}" ] || x_ mkdir -p "${newrom%/*}/"
[ "${blobs_required}" = "n" ] && newrom="${newrom%.rom}_noblobs.rom"
- cp "${rompath}" "${newrom}" || err "moverom: can't copy rom"
+ x_ cp "${rompath}" "${newrom}"
}
main $@
diff --git a/script/build/coreboot/utils b/script/build/coreboot/utils
index 8498897a..9dddc440 100755
--- a/script/build/coreboot/utils
+++ b/script/build/coreboot/utils
@@ -13,14 +13,12 @@ main()
if [ $# -gt 0 ]; then
for board in "${@}"; do
- build_for_mainboard ${board} || \
- err "cannot build cbutils for target, ${board}"
+ x_ build_for_mainboard ${board}
done
else
for boarddir in config/coreboot/*; do
[ ! -d "${boarddir}" ] && continue
- build_for_mainboard ${boarddir##*/} || \
- err "cannot build cbutils for target, ${board}"
+ x_ build_for_mainboard ${boarddir##*/}
done
fi
}
@@ -28,36 +26,29 @@ main()
build_for_mainboard() {
board="${1}"
[ -d "config/coreboot/${board}" ] || \
- err "build_for_mainboard ${board}: boarddir does not exist"
+ err "build_for_mainboard ${board}: boarddir does not exist"
[ -f "config/coreboot/${board}/target.cfg" ] || \
- err "build_for_mainboard ${board}: target.cfg does not exist"
+ err "build_for_mainboard ${board}: target.cfg does not exist"
tree="undefined"
. "config/coreboot/${board}/target.cfg" # source
[ "${tree}" = "undefined" ] && \
- err "build_for_mainboard: improper tree definition for '${board}'"
+ err "build_for_mainboard ${board}: improper tree definition"
buildutils "${tree}"
}
buildutils() {
tree="${1}"
[ -d "coreboot/${tree}/" ] || \
- ./update project trees coreboot $tree || \
- err "buildutils: cannot fetch ${tree}"
+ x_ ./update project trees coreboot ${tree}
for util in cbfstool ifdtool; do
[ -f "cbutils/${tree}/${util}" ] && continue
- [ -d "cbutils/${tree}" ] || \
- mkdir -p "cbutils/${tree}" || \
- err "buildutils: can't mkdir cbutils/${tree}"
+ [ -d "cbutils/${tree}" ] || x_ mkdir -p "cbutils/${tree}"
utildir="coreboot/${tree}/util/${util}"
- make distclean -C "${utildir}" || \
- err "buildutils: cannot clean ${utildir}"
- make -j$(nproc) -C "${utildir}" || \
- err "buildutils: cannot build ${utildir}"
- cp "${utildir}/${util}" "cbutils/${tree}" || \
- err "buildutils: can't cp ${util} cbutils/${tree}/"
- make distclean -C "${utildir}" || \
- err "buildutils: can't clean ${utildir}"
+ x_ make distclean -C "${utildir}"
+ x_ make -j$(nproc) -C "${utildir}"
+ x_ cp "${utildir}/${util}" "cbutils/${tree}"
+ x_ make distclean -C "${utildir}"
done
}
diff --git a/script/build/fw/serprog b/script/build/fw/serprog
index 211948ac..cdbf07e1 100755
--- a/script/build/fw/serprog
+++ b/script/build/fw/serprog
@@ -28,8 +28,7 @@ main()
else
err "${usage}"
fi
- mkdir -p "bin/serprog_${platform}" || \
- err "can't create dir: bin/serprog_${platform}"
+ x_ mkdir -p "bin/serprog_${platform}"
if [ $# -gt 1 ] ; then
if [ "${2}" = "list" ] ; then
@@ -47,20 +46,18 @@ main()
fetch_repo()
{
- ./update project repo "${1}" || err "fetch ${1} failed!\n"
+ x_ ./update project repo "${1}"
}
build_rp2040_rom()
{
board=${1}
printf "Building pico-serprog for ${board}\n"
- cmake -DPICO_BOARD="${board}" -DPICO_SDK_PATH="${pico_sdk_dir}" \
- -B "${pico_src_dir}/build" "${pico_src_dir}" \
- || err "can't cmake ${pico_src_dir}"
- cmake --build "${pico_src_dir}/build"
- mv ${pico_src_dir}/build/pico_serprog.uf2 \
- bin/serprog_rp2040/serprog_${board}.uf2 \
- || err "${board} serprog build failed!"
+ x_ cmake -DPICO_BOARD="${board}" -DPICO_SDK_PATH="${pico_sdk_dir}" \
+ -B "${pico_src_dir}/build" "${pico_src_dir}"
+ x_ cmake --build "${pico_src_dir}/build"
+ x_ mv ${pico_src_dir}/build/pico_serprog.uf2 \
+ bin/serprog_rp2040/serprog_${board}.uf2
printf "output to bin/serprog_rp2040/serprog_${board}.uf2\n"
}
@@ -68,11 +65,10 @@ build_stm32_rom()
{
board=${1}
printf "Building stm32-vserprog for ${board}\n"
- make -C ${stm32_src_dir} libopencm3-just-make BOARD=${board}
- make -C ${stm32_src_dir} BOARD=${board}
- mv ${stm32_src_dir}/stm32-vserprog.hex \
- bin/serprog_stm32/serprog_${board}.hex \
- || err "${board} serprog build failed!"
+ x_ make -C ${stm32_src_dir} libopencm3-just-make BOARD=${board}
+ x_ make -C ${stm32_src_dir} BOARD=${board}
+ x_ mv ${stm32_src_dir}/stm32-vserprog.hex \
+ bin/serprog_stm32/serprog_${board}.hex
printf "output to bin/serprog_stm32/serprog_${board}.hex\n"
}
diff --git a/script/build/grub/payload b/script/build/grub/payload
index 6f4c421a..a1bb3554 100755
--- a/script/build/grub/payload
+++ b/script/build/grub/payload
@@ -22,16 +22,12 @@ main()
handle_dependencies()
{
[ -d "grub/" ] || \
- ./update project repo grub || \
- err "handle_dependencies: cannot fetch grub"
+ x_ ./update project repo grub
[ -f "grub/grub-mkstandalone" ] || \
- ./build grub utils || \
- err "handle_dependencies: cannot build grub utils"
+ x_ ./build grub utils
[ -d "${elfdir}" ] || \
- mkdir -p "${elfdir}" || \
- err "handle_dependencies: cannot mkdir ${elfdir}"
- rm -f "${elfdir}/"* || \
- err "handle_dependencies: cannot rm inside: ${elfdir}/"
+ x_ mkdir -p "${elfdir}"
+ x_ rm -f "${elfdir}/"*
}
build_keymap_configs()
@@ -40,9 +36,8 @@ build_keymap_configs()
[ -f "${keylayoutfile}" ] || continue
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}"
- printf "keymap %s\n" "${keymap}" > \
- "${elfdir}/keymap_${keymap}.cfg" || \
- err "mk_keymap: can't make ${elfdir}/keymap_${keymap}.cfg"
+ x_ printf "keymap %s\n" "${keymap}" > \
+ "${elfdir}/keymap_${keymap}.cfg"
done
}
diff --git a/script/build/grub/utils b/script/build/grub/utils
index 3c463e6d..edb78bb1 100755
--- a/script/build/grub/utils
+++ b/script/build/grub/utils
@@ -10,25 +10,19 @@ set -u -e
main()
{
- [ -d "grub/" ] || ./update project repo grub || err "cannot fetch grub"
+ [ -d "grub/" ] || x_ ./update project repo grub
build_grub
}
build_grub()
{
(
- cd grub/ || \
- err "build_grub: cd"
- [ ! -d Makefile ] || make distclean || \
- err "build_grub: make-distclean"
- ./bootstrap --gnulib-srcdir=gnulib/ --no-git || \
- err "build_grub: gnulib bootstrap"
- ./autogen.sh || \
- err "build_grub: autogen.sh"
- ./configure --with-platform=coreboot || \
- err "build_grub: autoconf"
- make -j$(nproc) FS_PAYLOAD_MODULES="" || \
- err "build_grub: make"
+ x_ cd grub/
+ [ ! -d Makefile ] || x_ make distclean
+ x_ ./bootstrap --gnulib-srcdir=gnulib/ --no-git
+ x_ ./autogen.sh
+ x_ ./configure --with-platform=coreboot
+ x_ make -j$(nproc) FS_PAYLOAD_MODULES=""
)
}
diff --git a/script/build/release/roms b/script/build/release/roms
index 026f4eae..50560f98 100755
--- a/script/build/release/roms
+++ b/script/build/release/roms
@@ -38,41 +38,33 @@ init_check()
[ ! -d "bin/" ] && \
err "init_check: no ROMs built yet (error)"
[ -d "release/" ] || \
- mkdir -p release/ || \
- err "init_check: !mkdir -p release/"
+ x_ mkdir -p release/
[ -d "release/${version}/" ] || \
- mkdir -p "release/${version}/" || \
- err "init_check: !mkdir -p release/${version}/"
+ x_ mkdir -p "release/${version}/"
[ ! -d "release/${version}/roms/" ] || \
- rm -Rf "release/${version}/roms/" || \
- err "init_check: !rm -Rf release/${version}/roms/"
+ x_ rm -Rf "release/${version}/roms/"
[ -d "release/${version}/roms/" ] && return 0
- mkdir -p "release/${version}/roms/" || \
- err "init_check: !mkdir -p release/${version}/roms/"
+ x_ mkdir -p "release/${version}/roms/"
}
make_archive()
{
builddir="${1}"
- romdir="tmp/romdir" || \
- err "make_archive: cannot create tmpdir"
- rm -Rf "${romdir}" || err "make_archive: can't remove tmpdir"
+ romdir="tmp/romdir"
+ x_ rm -Rf "${romdir}"
target="${builddir##*/}"
if [ ! -f "config/coreboot/${target}/target.cfg" ]; then
# No config, just make a tarball
tarball=release/${version}/roms/${target}_${version}.tar.xz
- tar -c "${builddir}" | xz -T0 -6 > ${tarball} || \
- (rm ${tarball}
- err "make_archive: cannot make \"${tarball}\"")
+ x_ tar -c "${builddir}" | xz -T0 -6 > ${tarball} || \
+ x_ rm -f ${tarball}
return 0
fi
romdir="${romdir}/bin/${target}"
- mkdir -p "${romdir}" || \
- err "make_archive: can't mkdir tmpdir"
- cp "${builddir}"/* "${romdir}" || \
- err "make_archive: cannot copy ROM images directory -> ${romdir}"
+ x_ mkdir -p "${romdir}"
+ x_ cp "${builddir}"/* "${romdir}"
printf "%s\n" "${target}"
@@ -97,24 +89,18 @@ make_archive()
printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" \
"${version}" "${projectname}" "${version}" "${target##*/}"
- printf "%s\n" "${version}" > "${romdir}/version" || \
- err "make_archive: can't create ${romdir}/version"
- printf "%s\n" "${versiondate}" > "${romdir}/versiondate" || \
- err "make_archive: can't create ${romdir}/versiondate"
- printf "%s\n" "${projectname}" > "${romdir}/projectname" || \
- err "make_archive: can't create ${romdir}/projectname"
+ x_ printf "%s\n" "${version}" > "${romdir}/version"
+ x_ printf "%s\n" "${versiondate}" > "${romdir}/versiondate"
+ x_ printf "%s\n" "${projectname}" > "${romdir}/projectname"
archivename="${projectname}-${version}_${target##*/}"
f="release/${version}/roms/${archivename}"
(
- cd "${romdir%/bin/${target}}" || err "make_archive: can't cd to tmpdir"
- tar -c "bin/${target}/" | xz -T0 -9e > "${archivename}.tar.xz" || \
- err "make_archive:cant make ${projectname}-${version}_${target##*/}"
+ x_ cd "${romdir%/bin/${target}}"
+ x_ tar -c "bin/${target}/" | xz -T0 -9e > "${archivename}.tar.xz"
)
- mv "${romdir%/bin/${target}}/${archivename}.tar.xz" "${f}.tar.xz" || \
- err "make_archive: can't copy tarball"
- rm -Rf "${romdir%/bin/${target}}" || \
- err "make_archive: can't delete tmpdir"
+ x_ mv "${romdir%/bin/${target}}/${archivename}.tar.xz" "${f}.tar.xz"
+ x_ rm -Rf "${romdir%/bin/${target}}"
}
strip_archive()
@@ -122,10 +108,8 @@ strip_archive()
romdir=${1}
[ -d "coreboot/${tree}" ] || \
- ./update project trees coreboot ${tree} || \
- err "strip_archive: coreboot/${tree}: can't fetch source"
- ./build coreboot utils ${tree} || \
- err "strip_archive: coreboot/${tree}: can't build utils"
+ x_ ./update project trees coreboot ${tree}
+ x_ ./build coreboot utils ${tree}
if [ "${microcode_required}" = "n" ]; then
for romfile in "${romdir}"/*.rom; do
@@ -134,21 +118,17 @@ strip_archive()
done
for romfile in "${romdir}"/*.tmprom; do
[ -f "${romfile}" ] || continue
- mv "${romfile}" "${romfile%.tmprom}.rom" || \
- err "can't make no-u rom: ${romfile%.tmprom}.rom"
+ x_ mv "${romfile}" "${romfile%.tmprom}.rom"
done
fi
# Hash the rom before removing blobs
- rm -f "${romdir}/blobhashes" || \
- err "strip_archive: !rm -f ${blobdir}/blobhashes"
- touch "${romdir}/blobhashes" || \
- err "strip_archive: !touch ${blobdir}/blobhashes"
+ x_ rm -f "${romdir}/blobhashes"
+ x_ touch "${romdir}/blobhashes"
(
- cd "${romdir}" || err "strip_archive: !cd ${romdir}"
- sha512sum *.rom >> blobhashes || \
- err "strip_archive: ${romdir}: !sha512sum *.rom >> blobhashes"
+ x_ cd "${romdir}"
+ x_ sha512sum *.rom >> blobhashes
)
for romfile in "${romdir}"/*.rom; do
@@ -161,40 +141,32 @@ strip_ucode()
{
romfile=${1}
_newrom_b="${romfile%.rom}_nomicrocode.tmprom"
- cp "${romfile}" "${_newrom_b}" || \
- err "strip_rom_image: cp \"${romfile}\" \"${_newrom_b}\""
+ x_ cp "${romfile}" "${_newrom_b}"
microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \
cpu_microcode_blob.bin 2>/dev/null || microcode_present="n"
[ "${microcode_present}" = "n" ] || return 0
printf "REMARK: '%s' already lacks microcode\n" "${romfile}" 1>&2
printf "Renaming default ROM file instead.\n" 1>&2
- mv "${romfile}" "${_newrom_b}" || \
- err "strip_rom_image: can't rename no-u ${romfile}"
+ x_ mv "${romfile}" "${_newrom_b}"
}
strip_rom_image()
{
[ -f "${1}" ] || return 0
[ "${CONFIG_HAVE_ME_BIN}" != "y" ] || \
- "${ifdtool}" --nuke me "${1}" -O "${1}" || \
- err "strip_rom_images: ${1}: cannot nuke Intel ME"
+ x_ "${ifdtool}" --nuke me "${1}" -O "${1}"
[ "${CONFIG_HAVE_MRC}" != "y" ] || \
- "${cbfstool}" "${1}" remove -n mrc.bin || \
- err "strip_rom_images: ${1}: cannot nuke mrc.bin"
+ x_ "${cbfstool}" "${1}" remove -n mrc.bin
[ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \
- "${cbfstool}" "${1}" remove -n sch5545_ecfw.bin || \
- err "strip_rom_images: ${1}: can't nuke sch5545ec fw"
+ x_ "${cbfstool}" "${1}" remove -n sch5545_ecfw.bin
if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
- "${cbfstool}" "${1}" remove -n ecfw1.bin || \
- err "strip_rom_images: ${1}: can't nuke ecfw1.bin"
- "${cbfstool}" "${1}" remove -n ecfw2.bin || \
- err "strip_rom_images: ${1}: can't nuke ecfw2.bin"
+ x_ "${cbfstool}" "${1}" remove -n ecfw1.bin
+ x_ "${cbfstool}" "${1}" remove -n ecfw2.bin
fi
# TODO: replace this board-specific hack
[ "${target}" = "e6400_4mb" ] || return 0
- "${cbfstool}" "${1}" remove -n "pci10de,06eb.rom" || \
- err "strip_rom_images: ${1}: can't nuke e6400 vga rom"
+ x_ "${cbfstool}" "${1}" remove -n "pci10de,06eb.rom"
}
main $@
diff --git a/script/build/release/src b/script/build/release/src
index 74854879..736276b4 100755
--- a/script/build/release/src
+++ b/script/build/release/src
@@ -45,31 +45,23 @@ create_release_directory()
dirname="${projectname}-${version}_src"
srcdir="${reldir}/${dirname}"
- [ -d "release/" ] || mkdir -p release/ || \
- err "create_release_directory: !mkdir -p release/"
- [ -d "${reldir}/" ] || mkdir -p "${reldir}/" || \
- err "create_release_directory: !mkdir -p ${reldir}/"
- [ ! -d "${srcdir}/" ] || rm -Rf "${srcdir}/" || \
- err "create_release_directory: !rm -Rf ${srcdir}/"
+ [ -d "release/" ] || x_ mkdir -p release/
+ [ -d "${reldir}/" ] || x_ mkdir -p "${reldir}/"
+ [ ! -d "${srcdir}/" ] || x_ rm -Rf "${srcdir}/"
[ ! -f "${srcdir}.tar.xz" ] || \
- rm -f "${srcdir}.tar.xz/" || \
- err "create_release_directory: !rm -f ${srcdir}.tar.xz/"
+ x_ rm -f "${srcdir}.tar.xz/"
- mkdir -p "${srcdir}/" || \
- err "create_release_directory: !mkdir -p ${srcdir}/"
- printf "%s" "${version}" > "${srcdir}"/version || \
- err "create_release_directory: ${srcdir}/version: can't create file"
+ x_ mkdir -p "${srcdir}/"
+ x_ printf "%s" "${version}" > "${srcdir}"/version
}
download_modules()
{
for modname in ${trees_fetch_list}; do
- [ -d "${modname}" ] || ./update project trees ${modname} || \
- err "download_modules: couldn't download ${modname} trees"
+ [ -d "${modname}" ] || x_ ./update project trees ${modname}
done
for modname in ${simple_fetch_list} ${download_only_list}; do
- [ -d "${modname}/" ] || ./update project repo ${modname} || \
- err "download_modules: couldn't download ${modname} repo"
+ [ -d "${modname}/" ] || x_ ./update project repo ${modname}
done
}
@@ -80,34 +72,27 @@ copy_files()
for subdir in "${dir}"/*; do
[ -d "${subdir}" ] || continue
[ "${subdir##*/}" = "${dir}" ] && continue
- mkdir -p "${srcdir}/${dir}" || \
- err "copy_files: !mkdir -p ${srcdir}/${dir}"
+ x_ mkdir -p "${srcdir}/${dir}"
[ ! -d "${srcdir}/${dir}/${subdir##*/}" ] || \
- rm -Rf "${srcdir}/${dir}/${subdir##*/}" || \
- err "copy_f:can't rm ${srcdir}/${dir}/${subdir##*/}"
- cp -R "${subdir}" "${srcdir}/${dir}/${subdir##*/}" || \
- err "copy_f:can't cp ${srcdir}/${dir}/${subdir##*/}"
+ x_ rm -Rf "${srcdir}/${dir}/${subdir##*/}"
+ x_ cp -R "${subdir}" "${srcdir}/${dir}/${subdir##*/}"
done
done
for dir in ${simple_fetch_list} ${dirlist}; do
- cp -R "${dir}/" "${srcdir}/" || \
- err "copy_files: !cp -R ${dir}/ ${srcdir}/"
+ x_ cp -R "${dir}/" "${srcdir}/"
done
for i in ${filelist}; do
if [ ! -f "${i}" ]; then
- rm -Rf "${srcdir}" || \
- err "copy_files: !rm -Rf ${srcdir}"
+ x_ rm -Rf "${srcdir}"
err "copy_files: file '${i}' does not exist"
fi
- cp "${i}" "${srcdir}/" || \
- err "copy_files: !cp ${i} ${srcdir}/"
+ x_ cp "${i}" "${srcdir}/"
done
(
- cd "${srcdir}/" || err "copy_files: can't enter dir: ${srcdir}/"
+ x_ cd "${srcdir}/"
for i in ${linklist}; do
- ln -s lbmk "${i}" || \
- err "copy_files: cannot create symlink: ${i} -> lbmk"
+ x_ ln -s lbmk "${i}"
done
)
}
@@ -115,55 +100,40 @@ copy_files()
purge_files()
{
(
- cd "${srcdir}/" || err "purge_files 3: !cd ${srcdir}/"
+ x_ cd "${srcdir}/"
[ ! -d "coreboot/default/util/kbc1126" ] || \
- ./handle make file -c "coreboot/default/util/kbc1126" || \
- err "purge_files 1: default/util/kbc1126: ! make clean"
- ./handle make config -x coreboot || \
- err "purge_files: coreboot: cannot clean crossgcc files"
+ x_ ./handle make file -c "coreboot/default/util/kbc1126"
+ x_ ./handle make config -x coreboot
for p in u-boot seabios coreboot; do
- ./handle make config -c "${p}" || \
- err "purge_files: ${p}: cannot clean the source trees"
+ x_ ./handle make config -c "${p}"
done
for p in bios_extract flashrom grub uefitool; do
- ./handle make file -c "${p}" || \
- err "purge_files: !./handle make file -c ${p}"
+ x_ ./handle make file -c "${p}"
done
for p in "stm32-vserprog" "stm32-vserprog/libopencm3"; do
- ./handle make file -c "util-fw/${p}" || \
- err "purge_files !./handle make file util-fw/${p}"
+ x_ ./handle make file -c "util-fw/${p}"
done
for p in 32 64; do
- ./handle make file -c "memtest86plus/build${p}" || \
- err "purge_files: cannot clean memtest86+ build${p}"
+ x_ ./handle make file -c "memtest86plus/build${p}"
done
for p in "nvmutil" "spkmodem_recv" "e6400-flash-unlock"; do
- make clean -C "util/${p}" || \
- err "purge_files 2: !make clean -C ${util}/p"
+ x_ make clean -C "util/${p}"
done
for p in ${trees_fetch_list}; do
- rm -Rf "${p}/${p}" "${p}"/*/.git* || \
- err "purge_files 1: cannot clean ${p} project files"
+ x_ rm -Rf "${p}/${p}" "${p}"/*/.git*
done
- rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
- */*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git* || \
- err "purge_files rm-rf2: can't purge .git files/directories"
- rm -Rf cbutils || err "purge_files: can't remove ${srcdir}/cbutils/"
- rm -Rf elf || err "purge_files: can't remove ${srcdir}/elf/"
- rm -Rf util-fw/rp2040/pico-serprog/build || \
- err "purge_files: can't remove pico-serprog/build"
+ x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
+ */*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*
+ x_ rm -Rf cbutils elf util-fw/rp2040/pico-serprog/build
)
}
create_release_archive()
{
(
- cd "${reldir}/" || \
- err "create_release_archive 4: !cd ${reldir}/"
- tar -c "${dirname}/" | xz -T0 -9e >"${dirname}.tar.xz" || \
- err "create_release_archive: can't create ${dirname}.tar.xz"
- rm -Rf "${dirname}/" || \
- err "create_release_archive 5: !rm -Rf ${dirname}/"
+ x_ cd "${reldir}/"
+ x_ tar -c "${dirname}/" | xz -T0 -9e >"${dirname}.tar.xz"
+ x_ rm -Rf "${dirname}/"
)
}