use the new coding style in scripts
there were stragglers left over from the last audit, and these stragglers still exist even after all the major re-factoring as of late the new style is: bsd-like coding style and error handling. verbose yet simple error handling. we use an "err" function in a way reminiscent of most C programs that you see in openbsd base (err.h) this style is very clean, resulting in readable code Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
4c6c7d1088
commit
8f4f0e00ec
|
@ -24,26 +24,36 @@
|
|||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||
set -u -e
|
||||
|
||||
# clean coreboot utilities (dependencies for 'build'):
|
||||
. "include/err.sh"
|
||||
|
||||
printf "Cleaning the previous build of coreboot and its utilities\n"
|
||||
main()
|
||||
{
|
||||
printf "Cleaning the previous build of coreboot and its utilities\n"
|
||||
|
||||
rm -Rf cbutils
|
||||
rm -Rf cbutils || err "cannot remove cbutils/"
|
||||
[ ! -d "coreboot/" ] && exit 0
|
||||
|
||||
[ ! -d "coreboot/" ] && exit 0
|
||||
clean_cbutils
|
||||
}
|
||||
|
||||
for tree in coreboot/*; do
|
||||
[ "${tree##*/}" = "coreboot" ] && continue
|
||||
[ -d "${tree}" ] || continue
|
||||
clean_cbutils()
|
||||
{
|
||||
for tree in coreboot/*; do
|
||||
[ "${tree##*/}" = "coreboot" ] && continue
|
||||
[ -d "${tree}" ] || continue
|
||||
|
||||
# Clean coreboot, of course
|
||||
make -C "${tree}/" distclean
|
||||
# Clean coreboot, of course
|
||||
make -C "${tree}/" distclean || \
|
||||
err "cannot distclean coreboot tree, ${tree}"
|
||||
|
||||
# Clean its utilities as well
|
||||
for util in cbfstool ifdtool nvramtool cbmem; do
|
||||
make distclean -C "${tree}/util/${util}/"
|
||||
# Clean its utilities as well
|
||||
for util in cbfstool ifdtool nvramtool cbmem; do
|
||||
make distclean -C "${tree}/util/${util}/" || \
|
||||
err "cannot clean util, ${util}, at ${tree}"
|
||||
done
|
||||
make distclean -C "${tree}/payloads/libpayload/" || \
|
||||
err "cannot distclean libpayload, at ${tree}"
|
||||
done
|
||||
make distclean -C "${tree}/payloads/libpayload/"
|
||||
done
|
||||
}
|
||||
|
||||
printf "\n\n"
|
||||
main $@
|
||||
|
|
|
@ -29,9 +29,14 @@ main()
|
|||
printf "Cleaning crossgcc builds in all coreboot archives\n"
|
||||
[ ! -d "coreboot/" ] && exit 0
|
||||
|
||||
clean_crossgcc
|
||||
}
|
||||
|
||||
clean_crossgcc()
|
||||
{
|
||||
for board in coreboot/*; do
|
||||
[ -d "${board}" ] || continue
|
||||
[ "${board##*/}" = "coreboot" ] && continue
|
||||
[ ! -d "${board}" ] && continue
|
||||
make -C "${board}/" crossgcc-clean || err "make-clean"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# helper script: clean the dependencies that were built in seabios
|
||||
#
|
||||
# Copyright (C) 2015, 2020, 2021 Leah Rowe <info@minifree.org>
|
||||
# Copyright (C) 2015,2020,2021,2023 Leah Rowe <info@minifree.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -26,13 +26,22 @@ set -u -e
|
|||
# clean bucts
|
||||
# --------------------------------------------------------
|
||||
|
||||
printf "Cleaning the previous builds of seabios\n"
|
||||
main()
|
||||
{
|
||||
[ ! -d "elf/seabios" ] || rm -Rf elf/seabios || \
|
||||
err "cannot remove elf/seabios"
|
||||
[ ! -d "seabios/" ] && exit 0
|
||||
|
||||
[ ! -d "elf/seabios" ] || rm -Rf elf/seabios || err "cannot remove elf/seabios"
|
||||
[ ! -d "seabios/" ] && exit 0
|
||||
clean_seabios
|
||||
}
|
||||
|
||||
for x in seabios/*; do
|
||||
[ "${x}" = "seabios/seabios" ] && continue
|
||||
[ ! -d "${x}" ] && continue
|
||||
make -C "${x}" distclean || err "cannot distclean tree, ${x}"
|
||||
done
|
||||
clean_seabios()
|
||||
{
|
||||
for x in seabios/*; do
|
||||
[ ! -d "${x}" ] && continue
|
||||
[ "${x}" = "seabios/seabios" ] && continue
|
||||
make -C "${x}" distclean || err "cannot distclean tree, ${x}"
|
||||
done
|
||||
}
|
||||
|
||||
main $@
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# helper script: clean the u-boot builds
|
||||
#
|
||||
# Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe <info@minifree.org>
|
||||
# Copyright (C) 2014-2016, 2020, 2023 Leah Rowe <info@minifree.org>
|
||||
# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
|
||||
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
||||
#
|
||||
|
@ -23,17 +23,28 @@
|
|||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||
set -u -e
|
||||
|
||||
printf "Cleaning u-boot builds for all boards\n"
|
||||
. "include/err.sh"
|
||||
|
||||
for board in u-boot/*; do
|
||||
if [ "${board##*/}" = "u-boot" ] || [ ! -d "${board}" ]; then
|
||||
continue
|
||||
fi
|
||||
main()
|
||||
{
|
||||
printf "Cleaning u-boot builds for all boards\n"
|
||||
clean_uboot
|
||||
}
|
||||
|
||||
make -C "${board}/" distclean
|
||||
clean_uboot()
|
||||
{
|
||||
for board in u-boot/*; do
|
||||
if [ "${board##*/}" = "u-boot" ] || [ ! -d "${board}" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
[ -e "${board}/.git" ] && \
|
||||
git -C "${board}" clean -fdx
|
||||
done
|
||||
make -C "${board}/" distclean || \
|
||||
err "cannot distclean u-boot dir, ${board}"
|
||||
|
||||
printf "\n\n"
|
||||
[ ! -e "${board}/.git" ] || \
|
||||
git -C "${board}" clean -fdx || \
|
||||
err "cannot clean u-boot git repo, ${board}"
|
||||
done
|
||||
}
|
||||
|
||||
main $@
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||
set -u -e
|
||||
|
||||
printf "Building coreboot utils\n"
|
||||
. "include/err.sh"
|
||||
|
||||
main()
|
||||
{
|
||||
printf "Building coreboot utils\n"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
for board in "${@}"; do
|
||||
build_for_mainboard ${board} || \
|
||||
|
@ -45,28 +47,28 @@ build_for_mainboard() {
|
|||
[ -f "resources/coreboot/${board}/target.cfg" ] || continue
|
||||
tree="undefined"
|
||||
. "resources/coreboot/${board}/target.cfg" # source
|
||||
if [ "${tree}" = "undefined" ]; then
|
||||
printf "build/cbutils: improper tree definition for '%s'" \
|
||||
"${board}"
|
||||
return 1
|
||||
fi
|
||||
buildutils "${tree}" || return 1
|
||||
[ "${tree}" = "undefined" ] && \
|
||||
err "build/cbutils: improper tree definition for '${board}'"
|
||||
buildutils "${tree}"
|
||||
}
|
||||
|
||||
buildutils() {
|
||||
tree="${1}"
|
||||
[ -d "coreboot/${tree}/" ] || \
|
||||
./fetch_trees coreboot $tree || return 1
|
||||
./fetch_trees coreboot $tree || \
|
||||
err "cannot fetch ${tree}"
|
||||
for util in cbfstool ifdtool; do
|
||||
[ -f "cbutils/${tree}/${util}" ] && continue
|
||||
[ -d "cbutils/${tree}" ] || \
|
||||
mkdir -p "cbutils/${tree}" || return 1
|
||||
mkdir -p "cbutils/${tree}" || \
|
||||
err "cannot create directory, cbutils/${tree}"
|
||||
|
||||
utildir="coreboot/${tree}/util/${util}"
|
||||
make distclean -C "${utildir}" || return 1
|
||||
make -j$(nproc) -C "${utildir}" || return 1
|
||||
mv "${utildir}/${util}" "cbutils/${tree}" || return 1
|
||||
make distclean -C "${utildir}" || return 1
|
||||
make distclean -C "${utildir}" || err "cannot clean ${utildir}"
|
||||
make -j$(nproc) -C "${utildir}" || err "cannot build ${utildir}"
|
||||
cp "${utildir}/${util}" "cbutils/${tree}" || \
|
||||
err "cannot copy util, ${util}, to cbutils/${tree}/"
|
||||
make distclean -C "${utildir}" || err "can't clean ${utildir}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||
set -u -e
|
||||
|
||||
. "include/err.sh"
|
||||
|
||||
grubcfgsdir="resources/grub"
|
||||
keymap=""
|
||||
|
||||
|
@ -30,26 +32,29 @@ main()
|
|||
{
|
||||
printf "Creating GRUB payloads and configuration files\n"
|
||||
|
||||
[ ! -d "grub/" ] && \
|
||||
./fetch grub
|
||||
[ ! -f "grub/grub-mkstandalone" ] && \
|
||||
./build grub utils
|
||||
[ ! -d "elf/" ] && \
|
||||
mkdir -p elf/
|
||||
[ ! -d "elf/grub" ] && \
|
||||
mkdir -p elf/grub/
|
||||
|
||||
rm -f elf/grub/*
|
||||
handle_dependencies
|
||||
|
||||
# Separate GRUB payload per keymap to save space in ROM.
|
||||
|
||||
for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
|
||||
[ -f "${keylayoutfile}" ] || continue
|
||||
build_grub_payloads "${keylayoutfile}"
|
||||
done
|
||||
|
||||
printf "Done! Check elf/grub/ to see the files.\n\n"
|
||||
}
|
||||
|
||||
handle_dependencies()
|
||||
{
|
||||
[ -d "grub/" ] || \
|
||||
./fetch grub || err "cannot fetch grub"
|
||||
[ -f "grub/grub-mkstandalone" ] || \
|
||||
./build grub utils || err "cannot build grub utils"
|
||||
[ -d "elf/grub" ] || \
|
||||
mkdir -p elf/grub || err "cannot create directory, elf/grub"
|
||||
|
||||
rm -f elf/grub/* || err "cannot delete files in directory, elf/grub/"
|
||||
}
|
||||
|
||||
build_grub_payloads()
|
||||
{
|
||||
keylayoutfile=${1}
|
||||
|
@ -79,15 +84,16 @@ build_grub_elf()
|
|||
--fonts= --themes= --locales= \
|
||||
--modules="${grub_modules}" \
|
||||
--install-modules="${grub_install_modules}" \
|
||||
${gcfg} ${grubk}
|
||||
${gcfg} ${grubk} || \
|
||||
err "cannot create grub payload (grub-mkstandalone)"
|
||||
}
|
||||
|
||||
create_grub_config()
|
||||
{
|
||||
sed "s/usqwerty/${keymap}/" < ${grubcfgsdir}/config/grub.cfg \
|
||||
> elf/grub/grub_${keymap}.cfg
|
||||
> elf/grub/grub_${keymap}.cfg || err "sed failed: grub.cfg"
|
||||
sed "s/grubtest.cfg/grub.cfg/" < elf/grub/grub_${keymap}.cfg \
|
||||
> elf/grub/grub_${keymap}_test.cfg
|
||||
> elf/grub/grub_${keymap}_test.cfg || err "sed failed: grubtest.cfg"
|
||||
}
|
||||
|
||||
main $@
|
||||
|
|
|
@ -46,8 +46,14 @@ main()
|
|||
[ -z "${project}" ] && err "project name not specified"
|
||||
[ "${project}" = "ich9utils" ] && project="util/ich9utils"
|
||||
|
||||
[ -d "${project}" ] || ./fetch "${project%/*}" \
|
||||
|| err "Cannot download project, ${project%/*}"
|
||||
handle_dependencies
|
||||
run_make_command
|
||||
}
|
||||
|
||||
handle_dependencies()
|
||||
{
|
||||
[ -d "${project}" ] || ./fetch "${project%/*}" || \
|
||||
err "Cannot download project, ${project%/*}"
|
||||
[ -d "${project}" ] || err "Project, ${project%/*}, not downloaded"
|
||||
|
||||
if [ "${project}" = "uefitool" ]; then
|
||||
|
@ -56,6 +62,10 @@ main()
|
|||
cmake UEFIExtract/ || err "cannot cmake UEFIExtract"
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
run_make_command()
|
||||
{
|
||||
[ ! -z "${mode}" ] || \
|
||||
make -C "${project}" || err "'make' failed (${project})"
|
||||
[ -z "${mode}" ] || \
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#
|
||||
|
||||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||
set -u -e
|
||||
set -u
|
||||
|
||||
version="version-unknown"
|
||||
[ -f version ] && version="$(cat version)"
|
||||
|
|
Loading…
Reference in New Issue