modify/coreboot: cleaner coding style

similar to the previous revision
fsdg20230625
Leah Rowe 2023-05-13 04:09:06 +01:00
parent 174d3af7a6
commit 71cac86634
1 changed files with 56 additions and 64 deletions

View File

@ -1,9 +1,8 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# helper script: modify coreboot configs (run make menuconfig) # helper script: modify coreboot configs (run make menuconfig)
# #
# Copyright (C) 2021 Leah Rowe <info@minifree.org> # Copyright (C) 2021, 2023 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com> # Copyright (C) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -20,54 +19,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# This script assumes that the working directory is the root
# of git or release archive
[ "x${DEBUG+set}" = 'xset' ] && set -v [ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e set -u -e
main()
{
printf "Modifying coreboot configs\n" printf "Modifying coreboot configs\n"
# Build ROM images for supported boards
modifyconf() {
board="$1"
if [ -f "resources/coreboot/${board}/board.cfg" ]; then
cbtree="undefined"
. "resources/coreboot/${board}/board.cfg" # source
if [ "${cbtree}" = "undefined" ]; then
return 0
fi
if [ ! -d "coreboot/${cbtree}" ]; then
./download coreboot ${cbtree}
fi
for cbcfg in resources/coreboot/${board}/config/*; do
if [ ! -f ${cbcfg} ]; then
continue
fi
(
cd coreboot/${cbtree}/
rm -f .config*
make distclean
)
mv $cbcfg coreboot/${cbtree}/.config
(
cd coreboot/${cbtree}/
make menuconfig
)
mv coreboot/${cbtree}/.config $cbcfg
rm -f coreboot/${cbtree}/.config*
(
cd coreboot/${cbtree}/
make distclean
)
done
else
printf "\nmodify/config/coreboot: no board.cfg for: %s\n" "${board}"
fi
}
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
for board in "${@}"; do for board in ${@}; do
modifyconf "${board}" modifyconf "${board}"
done done
else else
@ -78,6 +38,38 @@ else
modifyconf "${board##*/}" modifyconf "${board##*/}"
done done
fi fi
}
printf "\n\n" # Build ROM images for supported boards
modifyconf() {
board="$1"
if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
printf "\nmodify/config/coreboot: no board.cfg for: %s\n" \
"${board}"
fi
cbtree=""
. "resources/coreboot/${board}/board.cfg" # source
if [ -z ${cbtree} ]; then
return 0
fi
cbdir="coreboot/${cbtree}"
if [ ! -d "${cbdir}" ]; then
./download coreboot ${cbtree}
fi
for cbcfg in resources/coreboot/${board}/config/*; do
if [ ! -f ${cbcfg} ]; then
continue
fi
make distclean -BC "${cbdir}"
mv "${cbcfg}" "${cbdir}/.config"
make menuconfig -BC "${cbdir}"
mv "${cbdir}/.config" "${cbcfg}"
make distclean -BC "${cbdir}"
done
}
main $@