From 1ca09e386b34b6d2991b8b5a2157bbf4aefc0a43 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:07:27 +0300 Subject: [PATCH] download/u-boot: Support reading tree and revision from board.cfg Boards may want to specify a board-specific U-Boot revision. At the very least, pseudo-boards for u-boot-libre releases will need to specify their U-Boot versions somehow. Copy the existing mechanism from download/coreboot for specifying build info with board.cfg files. Specify the commit hash for the 'v2021.07' pseudo-board, and 'master' as the default. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 58 +++++++++++++++++++++++++++-- resources/u-boot/default/board.cfg | 2 + resources/u-boot/v2021.07/.gitkeep | 0 resources/u-boot/v2021.07/board.cfg | 2 + 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 resources/u-boot/default/board.cfg delete mode 100644 resources/u-boot/v2021.07/.gitkeep create mode 100644 resources/u-boot/v2021.07/board.cfg diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 7bd8e86..ecd35ad 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -44,12 +44,62 @@ list_supported_boards() { downloadfor() { board="${1}" - ubtree="u-boot/${board}" - uboot_revision="v2021.07" + # The loop will always exit, but this while loop is crafted + # such that a tree referencing a tree that references another tree is possible + # (and so on) + while true; do + ubrevision="undefined" + ubtree="undefined" + + if [ ! -f "resources/u-boot/${board}/board.cfg" ]; then + printf "ERROR: %s: board.cfg does not exist for '%s'\n" \ + "download/u-boot" "${board}" + return 1 + fi + + if [ -f "resources/u-boot/${board}/seen" ]; then + printf "ERROR: %s: logical loop; '%s' board.cfg refers to another tree, which ultimately refers back to '%s'.\n" \ + "download/u-boot" "${board}" "${board}" + return 1 + fi + + # This is to override $ubrevision and $ubtree + source "resources/u-boot/${board}/board.cfg" || touch build_error + if [ -f build_error ]; then + printf "ERROR: %s: problem sourcing %s/board.cfg\n" \ + "download/u-boot" "${board}" + return 1 + fi + touch "resources/u-boot/${board}/seen" + + if [ "${board}" != "${ubtree}" ]; then + board="${ubtree}" + else + if [ "${ubtree}" = "undefined" ]; then + printf "ERROR: %s: tree name undefined for '%s\n'" \ + "download/u-boot" "${board}" + return 1 + fi + + if [ "${ubrevision}" = "undefined" ]; then + printf "ERROR: %s: commit ID undefined for '%s'\n" \ + "download/u-boot" "${board}" + return 1 + fi + break + fi + done + + rm -f resources/u-boot/*/seen + + ubtree="u-boot/${ubtree}" if [ -d "${ubtree}" ]; then printf \ "REMARK: '%s' directory already exists. Skipping setup.\n" \ "${ubtree}" + if [ "${ubtree}" != "u-boot/${board}" ]; then + printf "(for board: '${board}')\n" + fi return 0 fi @@ -98,12 +148,12 @@ downloadfor() { return 1 fi - git -C "${ubtree}" reset --hard ${uboot_revision} || \ + git -C "${ubtree}" reset --hard ${ubrevision} || \ touch build_error if [ -f build_error ]; then printf \ "ERROR: %s: Unable to reset to commit ID/tag '%s' for board '%s' on tree '%s'\n" \ - "download/u-boot" "${uboot_revision}" "${1}" "${ubtree}" + "download/u-boot" "${ubrevision}" "${board}" "${ubtree}" return 1 fi } diff --git a/resources/u-boot/default/board.cfg b/resources/u-boot/default/board.cfg new file mode 100644 index 0000000..b821b35 --- /dev/null +++ b/resources/u-boot/default/board.cfg @@ -0,0 +1,2 @@ +ubtree="default" +ubrevision="master" diff --git a/resources/u-boot/v2021.07/.gitkeep b/resources/u-boot/v2021.07/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/resources/u-boot/v2021.07/board.cfg b/resources/u-boot/v2021.07/board.cfg new file mode 100644 index 0000000..4bddc10 --- /dev/null +++ b/resources/u-boot/v2021.07/board.cfg @@ -0,0 +1,2 @@ +ubtree="v2021.07" +ubrevision="840658b093976390e9537724f802281c9c8439f5" # v2021.07