download/coreboot: tidy up variable names
parent
66d06afd6c
commit
bd82d90faf
|
@ -21,8 +21,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
# TODO: purge this entire file. it's terrible. re-write it more cleanly.
|
|
||||||
|
|
||||||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
|
@ -30,6 +28,8 @@ _board=""
|
||||||
cbtree=""
|
cbtree=""
|
||||||
cbrevision=""
|
cbrevision=""
|
||||||
|
|
||||||
|
cbcfgsdir="resources/coreboot"
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
if [ $# -eq 1 ] && [ "$1" = "--help" ] ; then
|
if [ $# -eq 1 ] && [ "$1" = "--help" ] ; then
|
||||||
|
@ -50,7 +50,7 @@ main()
|
||||||
|
|
||||||
fetch_coreboot_trees()
|
fetch_coreboot_trees()
|
||||||
{
|
{
|
||||||
rm -f resources/coreboot/*/seen
|
rm -f ${cbcfgsdir}/*/seen
|
||||||
|
|
||||||
printf "Downloading coreboot and (if available) applying patches\n"
|
printf "Downloading coreboot and (if available) applying patches\n"
|
||||||
|
|
||||||
|
@ -58,18 +58,18 @@ fetch_coreboot_trees()
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
boards=$@
|
boards=$@
|
||||||
else
|
else
|
||||||
for board in resources/coreboot/*; do
|
for board in ${cbcfgsdir}/*; do
|
||||||
[ ! -d "${board}" ] && continue
|
[ ! -d "${board}" ] && continue
|
||||||
boards="${boards} ${board##*/}"
|
boards="${boards} ${board##*/}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
for board in ${boards}; do
|
for board in ${boards}; do
|
||||||
rm -f resources/coreboot/*/seen
|
rm -f ${cbcfgsdir}/*/seen
|
||||||
download_coreboot_for_board "${board}"
|
download_coreboot_for_board "${board}"
|
||||||
[ -f build_error ] && break
|
[ -f build_error ] && break
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f resources/coreboot/*/seen
|
rm -f ${cbcfgsdir}/*/seen
|
||||||
}
|
}
|
||||||
|
|
||||||
download_coreboot_for_board()
|
download_coreboot_for_board()
|
||||||
|
@ -78,7 +78,7 @@ download_coreboot_for_board()
|
||||||
cbtree="undefined"
|
cbtree="undefined"
|
||||||
cbrevision="undefined"
|
cbrevision="undefined"
|
||||||
|
|
||||||
fetch_coreboot_config "${_board}"; rm -f resources/coreboot/*/seen
|
fetch_coreboot_config "${_board}"; rm -f ${cbcfgsdir}/*/seen
|
||||||
[ -f build_error ] && return 1
|
[ -f build_error ] && return 1
|
||||||
|
|
||||||
if [ -d "coreboot/${cbtree}" ]; then
|
if [ -d "coreboot/${cbtree}" ]; then
|
||||||
|
@ -97,6 +97,8 @@ download_coreboot_for_board()
|
||||||
|
|
||||||
fetch_coreboot_config()
|
fetch_coreboot_config()
|
||||||
{
|
{
|
||||||
|
_board=${1}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
cbrevision="undefined"
|
cbrevision="undefined"
|
||||||
cbtree="undefined"
|
cbtree="undefined"
|
||||||
|
@ -104,7 +106,7 @@ fetch_coreboot_config()
|
||||||
check_config_for_board "${_board}" || return 1
|
check_config_for_board "${_board}" || return 1
|
||||||
|
|
||||||
# This is to override $cbrevision and $cbtree
|
# This is to override $cbrevision and $cbtree
|
||||||
. "resources/coreboot/${_board}/board.cfg" \
|
. "${cbcfgsdir}/${_board}/board.cfg" \
|
||||||
|| touch ../build_error
|
|| touch ../build_error
|
||||||
if [ -f build_error ]; then
|
if [ -f build_error ]; then
|
||||||
printf "ERROR: download/coreboot:"
|
printf "ERROR: download/coreboot:"
|
||||||
|
@ -132,17 +134,19 @@ fetch_coreboot_config()
|
||||||
|
|
||||||
check_config_for_board()
|
check_config_for_board()
|
||||||
{
|
{
|
||||||
if [ ! -f "resources/coreboot/${1}/board.cfg" ]; then
|
_board=${1}
|
||||||
|
|
||||||
|
if [ ! -f "${cbcfgsdir}/${_board}/board.cfg" ]; then
|
||||||
printf "ERROR: download/coreboot: board.cfg does not"
|
printf "ERROR: download/coreboot: board.cfg does not"
|
||||||
printf " exist for '%s'\n" ${1}
|
printf " exist for '%s'\n" ${_board}
|
||||||
return 1
|
return 1
|
||||||
elif [ -f "resources/coreboot/${1}/seen" ]; then
|
elif [ -f "${cbcfgsdir}/${_board}/seen" ]; then
|
||||||
printf "ERROR: download/coreboot: logical loop:"
|
printf "ERROR: download/coreboot: logical loop:"
|
||||||
printf " '%s' board.cfg refers to another tree," ${1}
|
printf " '%s' board.cfg refers to another tree," ${_board}
|
||||||
printf " which ultimately refers back to '%s'." ${1}
|
printf " which ultimately refers back to '%s'." ${_board}
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
touch "resources/coreboot/${1}/seen"
|
touch "${cbcfgsdir}/${_board}/seen"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ prepare_new_coreboot_tree()
|
||||||
git reset --hard ${cbrevision} || exit 1
|
git reset --hard ${cbrevision} || exit 1
|
||||||
git submodule update --init --checkout || exit 1
|
git submodule update --init --checkout || exit 1
|
||||||
|
|
||||||
for patch in ../../resources/coreboot/${cbtree}/patches/*.patch; do
|
for patch in ../../${cbcfgsdir}/${cbtree}/patches/*.patch; do
|
||||||
[ ! -f "${patch}" ] && \
|
[ ! -f "${patch}" ] && \
|
||||||
continue
|
continue
|
||||||
if ! git am "${patch}"; then
|
if ! git am "${patch}"; then
|
||||||
|
@ -188,8 +192,8 @@ prepare_new_coreboot_tree()
|
||||||
|
|
||||||
# extra.sh can be used for anything
|
# extra.sh can be used for anything
|
||||||
# but should *only* be a last resort
|
# but should *only* be a last resort
|
||||||
if [ -f "../../resources/coreboot/${cbtree}/extra.sh" ]; then
|
if [ -f "../../${cbcfgsdir}/${cbtree}/extra.sh" ]; then
|
||||||
"../../resources/coreboot/${cbtree}/extra.sh" || \
|
"../../${cbcfgsdir}/${cbtree}/extra.sh" || \
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
@ -209,8 +213,8 @@ usage()
|
||||||
|
|
||||||
list_supported_boards()
|
list_supported_boards()
|
||||||
{
|
{
|
||||||
for _board in resources/coreboot/*; do
|
for _board in ${cbcfgsdir}/*; do
|
||||||
echo ${_board} | sed 's#resources/coreboot/##'
|
echo ${_board} | sed 's#${cbcfgsdir}/##'
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue