From 8dd1a24504ac438e9a8a0826b531976d9bc72067 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 18:33:23 +0300 Subject: download/u-boot: Prepare files per board instead of per revision The U-Boot download script is designed to help with releasing u-boot-libre and it can only prepare a generic U-Boot v2021.07 tree. However, we will need to build board-specific versions of U-Boot to be able to use it as a coreboot payload effectively. As a first step toward that, make the download script prepare per-board copies of U-Boot v2021.07. Then, add a 'v2021.07' pseudo-board for the u-boot-libre release script to work on. The u-boot-libre deblob script hash ends up chaning due to copying my author attribution from the download script, update its hash. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 135 +++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 59 deletions(-) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index bd0258c0..7bd8e86d 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -4,6 +4,7 @@ # # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe # Copyright (C) 2021 Denis 'GNUtoo' Carikli +# Copyright (C) 2022 Alper Nebi Yasak # # 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 @@ -32,33 +33,38 @@ deleteblobs="true" # This script handles the internet, and Git. Both are inherently unreliable. [[ -f build_error ]] && rm -f build_error -# Make sure that older revision are first as code uses that order to -# find the latest supported revision. -supported_uboot_revisions=" \ - v2021.07 \ -" +list_supported_boards() { + for board in resources/u-boot/*; do + if [ -d ${board} ]; then + echo "${board#resources/u-boot/}" + fi + done +} downloadfor() { + board="${1}" + + ubtree="u-boot/${board}" uboot_revision="v2021.07" - uboot_dir="u-boot/u-boot" - if [ -d "${uboot_dir}" ]; then + if [ -d "${ubtree}" ]; then printf \ "REMARK: '%s' directory already exists. Skipping setup.\n" \ - "${uboot_dir}" + "${ubtree}" return 0 fi - if [ ! -d "${uboot_dir}" ]; then - mkdir -p "${uboot_dir}" + if [ ! -d "u-boot" ]; then + mkdir -p "u-boot" fi - if [ ! -d "${uboot_dir}" ]; then - printf \ - "ERROR: '%s' directory not created. Check file system permissions\n" \ - "${uboot_dir}" + if [ ! -d "u-boot" ]; then + printf \ + "ERROR: '%s' directory not created. Check file system permissions\n" \ + "u-boot" return 1 fi + uboot_dir="u-boot/u-boot" if [ ! -d "${uboot_dir}/.git" ] && [ -d "${uboot_dir}" ]; then rm -Rf "${uboot_dir}" fi @@ -84,12 +90,20 @@ downloadfor() { fi fi - git -C "${uboot_dir}" reset --hard ${uboot_revision} || \ + cp -R "${uboot_dir}" "${ubtree}" || touch build_error + if [ -f build_error ]; then + printf "ERROR: %s: Unable to copy directory. Check file system permissions or free space.\n" \ + "download/u-boot" + rm -Rf "${ubtree}/" + return 1 + fi + + git -C "${ubtree}" reset --hard ${uboot_revision} || \ 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}" "${uboot_dir}" + "download/u-boot" "${uboot_revision}" "${1}" "${ubtree}" return 1 fi } @@ -162,53 +176,54 @@ usage() printf "Usage:\n" printf "\t%s # %s\n" \ "${progname}" \ - "Download latest u-boot git revision and deblob it" - printf "\t%s [revision] # %s\n" \ + "Download and deblob u-boot for all boards" + printf "\t%s [board] # %s\n" \ "${progname}" \ - "Download given u-boot git revision and deblob it" + "Download and deblob u-boot for the given board" printf "\t%s --blobs-list # %s\n" \ "${progname}" \ - "Print the path of the blobs.list file for the latest supported u-boot revision" - printf "\t%s --blobs-list [revision] # %s\n" \ + "Print the path of the generic blobs.list file" + printf "\t%s --blobs-list [board] # %s\n" \ "${progname}" \ - "Print the path of the blobs.list file for the given u-boot revision" + "Print the path of the blobs.list file for the given board" printf "\t%s --gen-deblob-script # %s\n" \ "${progname}" \ - "Print the path of the generated deblob script for the latest supported u-boot revision" - printf "\t%s --gen-deblob-script [revision] # %s\n" \ + "Print the path of a generated generic deblob script" + printf "\t%s --gen-deblob-script [board] # %s\n" \ "${progname}" \ - "Print the path of the generated deblob script for the given u-boot revision" - printf "\t%s --list-revisions # %s\n" \ + "Print the path of a generated deblob script for the given board" + printf "\t%s --list-boards # %s\n" \ "${progname}" \ - "List supported u-boot revisions" + "List supported boards" printf "\t%s --help # %s\n" \ "${progname}" \ "Prints this help" } -download_uboot_revision() +download_uboot_board() { - git_revision="$1" + board="${1}" + ubtree="u-boot/${board}" printf "Downloading u-boot " printf "and (if exist in build system) applying patches\n" - downloadfor "${git_revision}" + downloadfor "${board}" rm -f "build_error" printf "\n\n" if [ "${deleteblobs}" = "true" ]; then - blobslist="resources/u-boot/default/blobs.list" + blobslist="$(print_blobs_list_path "${board}")" for blob_path in $(strip_comments "${blobslist}"); do if echo "${blob_path}" | \ grep '/$' 2>&1 >/dev/null ; then printf "Deleting blob directory: '%s/%s'\n" \ - "${uboot_dir}" "${blob_path}" - rm -rf "${uboot_dir}/${blob_path}" + "${ubtree}" "${blob_path}" + rm -rf "${ubtree}/${blob_path}" else printf "Deleting blob file: '%s/%s'\n" \ - "${uboot_dir}" "${blob_path}" - rm -f "${uboot_dir}/${blob_path}" + "${ubtree}" "${blob_path}" + rm -f "${ubtree}/${blob_path}" fi done fi @@ -216,72 +231,74 @@ download_uboot_revision() print_blobs_list_path() { - printf "resources/u-boot/default/blobs.list\n" + board="$1" + + if [ -f "resources/u-boot/${board}/blobs.list" ]; then + printf "resources/u-boot/${board}/blobs.list\n" + else + printf "resources/u-boot/default/blobs.list\n" + fi } print_deblob_script_path() { - version="$1" + board="$1" path="$(mktemp)" - generate_deblob_script "$(print_blobs_list_path ${version})" "${path}" + generate_deblob_script "$(print_blobs_list_path ${board})" "${path}" printf "%s\n" ${path} } if [ $# -eq 0 ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - download_uboot_revision "${latest_revision}" + for board in $(list_supported_boards); do + download_uboot_board "${board}" + done exit 0 elif [ $# -eq 1 -a "$1" == "--help" ] ; then usage exit 0 -elif [ $# -eq 1 -a "$1" == "--list-revisions" ] ; then - for revision in ${supported_uboot_revisions} ; do - printf "${revision}\n" - done +elif [ $# -eq 1 -a "$1" == "--list-boards" ] ; then + list_supported_boards exit 0 elif [ $# -eq 1 -a "$1" == "--blobs-list" ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - print_blobs_list_path "${latest_revision}" + print_blobs_list_path "default" exit 0 elif [ $# -eq 2 -a "$1" == "--blobs-list" ] ; then found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$2" ] ; then + for board in $(list_supported_boards) ; do + if [ "${board}" = "$2" ] ; then print_blobs_list_path "$2" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${2}' is not supported\n" exit 1 elif [ $# -eq 1 -a "$1" == "--gen-deblob-script" ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - print_deblob_script_path "${latest_revision}" + print_deblob_script_path "default" exit 0 elif [ $# -eq 2 -a "$1" == "--gen-deblob-script" ] ; then found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$2" ] ; then + for board in $(list_supported_boards) ; do + if [ "$board" = "$2" ] ; then print_deblob_script_path "$2" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${2}' is not supported\n" exit 1 elif [ $# -eq 1 ] ; then - found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$1" ] ; then - download_uboot_revision "$1" + for board in $(list_supported_boards) ; do + if [ "$board" = "$1" ] ; then + download_uboot_board "$1" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${1}' is not supported\n" exit 1 fi -- cgit v1.2.1 From 7b552bd29992e423755e0306ea115f726854cbf0 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:07:27 +0300 Subject: 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 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 7bd8e86d..ecd35adc 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 } -- cgit v1.2.1 From 0aeb69b5ad276f4ca466e8a9aff203f004e32bf7 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:26:44 +0300 Subject: download/u-boot: Use GitHub mirror as fallback The coreboot download script uses GitHub as a fallback if the upstream coreboot is unavailable, use a similar fallback for U-Boot as well. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index ecd35adc..4e5a77c0 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -124,6 +124,12 @@ downloadfor() { git clone https://source.denx.de/u-boot/u-boot.git \ "${uboot_dir}" || \ rm -Rf "${uboot_dir}" + if [ ! -d "${uboot_dir}" ]; then + printf "WARNING: Upstream failed. Trying backup github repository:\n" + git clone https://github.com/u-boot/u-boot.git \ + "${uboot_dir}" || \ + rm -Rf coreboot + fi if [ ! -d "${uboot_dir}" ]; then printf \ "ERROR: %s: Problem with git-clone. Network issue?\n" \ -- cgit v1.2.1 From 454364ccb8c14738f88b7b51c26258c548a17305 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:28:22 +0300 Subject: download/u-boot: Try to update submodules as in coreboot script The coreboot download script tries to update submodules, since coreboot does use git submodules to retrieve and compile the projects it depends on. Although U-Boot doesn't use submodules, try to update them anyway to match the coreboot download script. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 4e5a77c0..86be55b9 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -162,6 +162,13 @@ downloadfor() { "download/u-boot" "${ubrevision}" "${board}" "${ubtree}" return 1 fi + + git -C "${ubtree}" submodule update --init || touch build_error + if [ -f build_error ]; then + printf "ERROR: %s: Unable to update submodules for tree '%s'\n" \ + "${ubtree}" + return 1 + fi } strip_comments() -- cgit v1.2.1 From eae6b35dabdeba336aaa3ecc3fdc22a23b16d98a Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:31:37 +0300 Subject: download/u-boot: Support applying patches from board dirs Boards may need different sets of patches to be applied to their U-Boot builds, copy the existing mechanism from the coreboot download script to the U-Boot download script. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 86be55b9..212a5a21 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -169,6 +169,20 @@ downloadfor() { "${ubtree}" return 1 fi + + for patch in resources/u-boot/${board}/patches/*.patch; do + if [ ! -f "${patch}" ]; then + continue + fi + + git -C "${ubtree}" am "$(pwd)/${patch}" || touch build_error + if [ -f build_error ]; then + printf "ERROR: %s: Unable to apply patch '%s' for board '%s' on tree '%s'" \ + "download/u-boot" "${patch}" "${board}" "${ubtree}" + git -C "${ubtree}" am --abort + return 1 + fi + done } strip_comments() -- cgit v1.2.1 From 820b8e706eb42b8f7138c16bc17cf6b6eba26a09 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 25 Aug 2022 20:32:40 +0300 Subject: download/u-boot: Support running extra commands from board dirs Although it's unlikely, boards might want to run extra commands after the board-specific U-Boot directories are prepared. Copy the existing mechanism for that from the coreboot download script to the U-Boot one. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 212a5a21..025ff66e 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -183,6 +183,21 @@ downloadfor() { return 1 fi done + + # extra.sh could be used to patch submodules, if you wanted to + # It's impossible to predict what submodules will be available, and + # it's rare that you'd want to patch them, so this is handled by + # extra.sh on a per-board basis + # In fact, extra.sh can be used for anything you want. + if [ -f "resources/u-boot/${board}/extra.sh" ]; then + "resources/u-boot/${board}/extra.sh" || touch build_error + if [ -f build_error ]; then + return 1 + fi + return 0 + else + return 0 + fi } strip_comments() -- cgit v1.2.1 From 270272eb61083f0bfa3d3899fe1dc62718123028 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 27 Aug 2022 15:11:19 +0300 Subject: download/u-boot: Remove .git folders as well The coreboot download removes .git folders as they still contain the removed blobs, remove those in the U-Boot version as well. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/u-boot | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 025ff66e..b1a42b58 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -305,6 +305,7 @@ download_uboot_board() printf "\n\n" if [ "${deleteblobs}" = "true" ]; then + rm -rf "${ubtree}"/.git* "${ubtree}"/*/.git* blobslist="$(print_blobs_list_path "${board}")" for blob_path in $(strip_comments "${blobslist}"); do if echo "${blob_path}" | \ @@ -345,6 +346,11 @@ if [ $# -eq 0 ] ; then for board in $(list_supported_boards); do download_uboot_board "${board}" done + + if [ "${deleteblobs}" = "true" ]; then + rm -rf u-boot/u-boot/ u-boot/.git* + fi + exit 0 elif [ $# -eq 1 -a "$1" == "--help" ] ; then usage @@ -390,6 +396,10 @@ elif [ $# -eq 1 ] ; then fi done + if [ "${deleteblobs}" = "true" ]; then + rm -rf u-boot/u-boot/ u-boot/.git* + fi + printf "Error: Board '${1}' is not supported\n" exit 1 -- cgit v1.2.1 From ef39e05bb5df505774b42a8739c3e7e57d43dd36 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 27 Aug 2022 15:27:48 +0300 Subject: download: Allow keeping .git dirs with NODELETE=git Keeping the git repositories is useful while development, e.g. to avoid git cloning repositories over and over again while debugging download scripts. Setting the NODELETE environment variable keeps the blobs and the git repositories. Allow a slightly finer-tuned version of this where we can keep only the git-related files by setting the variable to "git". Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/coreboot | 15 +++++++++++---- resources/scripts/download/u-boot | 16 +++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/coreboot b/resources/scripts/download/coreboot index 21fe0781..965c00f6 100755 --- a/resources/scripts/download/coreboot +++ b/resources/scripts/download/coreboot @@ -3,6 +3,7 @@ # helper script: download coreboot # # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe +# Copyright (C) 2022 Alper Nebi Yasak # # 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 @@ -64,8 +65,12 @@ fi # set this when you want to modify each coreboot tree # for example, you want to test custom patches # NODELETE= ./download coreboot +deletegit="true" deleteblobs="true" -[ "x${NODELETE+set}" = 'xset' ] && deleteblobs="false" +if [ "x${NODELETE+set}" = 'xset' ]; then + [ "x${NODELETE:-all}" = "xgit" ] && deletegit="false" + [ "x${NODELETE:-all}" = "xall" ] && deleteblobs="false" && deletegit="false" +fi # Error handling is extreme in this script. # This script handles the internet, and Git. Both are inherently unreliable. @@ -239,9 +244,11 @@ rm -f resources/coreboot/*/seen rm -f "build_error" printf "\n\n" if [ "${deleteblobs}" = "true" ]; then - rm -Rf coreboot/coreboot/ - rm -Rf coreboot/.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git* - rm -Rf coreboot/*/util/nvidia/cbootimage/.git* + if [ "${deletegit}" = "true" ]; then + rm -Rf coreboot/coreboot/ + rm -Rf coreboot/.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git* + rm -Rf coreboot/*/util/nvidia/cbootimage/.git* + fi for cbdir in coreboot/*; do if [ ! -d "${cbdir}" ]; then continue; fi cbtree="${cbdir##coreboot/}" diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index b1a42b58..2e086337 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -25,9 +25,13 @@ set -u -e # set this when you want to modify each u-boot tree # for example, you want to test custom patches -# NODELETE= ./download coreboot +# NODELETE= ./download u-boot +deletegit="true" deleteblobs="true" -[ "x${NODELETE+set}" = 'xset' ] && deleteblobs="false" +if [ "x${NODELETE+set}" = 'xset' ]; then + [ "x${NODELETE:-all}" = "xgit" ] && deletegit="false" + [ "x${NODELETE:-all}" = "xall" ] && deleteblobs="false" && deletegit="false" +fi # Error handling is extreme in this script. # This script handles the internet, and Git. Both are inherently unreliable. @@ -305,7 +309,9 @@ download_uboot_board() printf "\n\n" if [ "${deleteblobs}" = "true" ]; then - rm -rf "${ubtree}"/.git* "${ubtree}"/*/.git* + if [ "${deletegit}" = "true" ]; then + rm -rf "${ubtree}"/.git* "${ubtree}"/*/.git* + fi blobslist="$(print_blobs_list_path "${board}")" for blob_path in $(strip_comments "${blobslist}"); do if echo "${blob_path}" | \ @@ -347,7 +353,7 @@ if [ $# -eq 0 ] ; then download_uboot_board "${board}" done - if [ "${deleteblobs}" = "true" ]; then + if [ "${deletegit}" = "true" ]; then rm -rf u-boot/u-boot/ u-boot/.git* fi @@ -396,7 +402,7 @@ elif [ $# -eq 1 ] ; then fi done - if [ "${deleteblobs}" = "true" ]; then + if [ "${deletegit}" = "true" ]; then rm -rf u-boot/u-boot/ u-boot/.git* fi -- cgit v1.2.1 From cf295741650aaffcb03866ab15a0c7175c3dc882 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 27 Aug 2022 16:39:47 +0300 Subject: download: Use shallow clones for big projects Downloading coreboot and U-Boot takes quite the disk space and bandwith. We don't need to download entire repos, only the revisions that we are interested in. Use the --depth=1 option to only download the files we need. Since the initial clones may not have our target revision, always try to fetch it. Signed-off-by: Alper Nebi Yasak --- resources/scripts/download/coreboot | 18 +++++++++--------- resources/scripts/download/u-boot | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/coreboot b/resources/scripts/download/coreboot index 965c00f6..80fff097 100755 --- a/resources/scripts/download/coreboot +++ b/resources/scripts/download/coreboot @@ -152,21 +152,21 @@ downloadfor() { if [ ! -d coreboot ]; then printf "Download coreboot from upstream:\n" - git clone https://review.coreboot.org/coreboot || rm -Rf coreboot + git clone --depth=1 https://review.coreboot.org/coreboot || rm -Rf coreboot if [ ! -d coreboot ]; then printf "WARNING: Upstream failed. Trying backup github repository:\n" - git clone https://github.com/coreboot/coreboot.git || rm -Rf coreboot + git clone --depth=1 https://github.com/coreboot/coreboot.git || rm -Rf coreboot fi if [ ! -d coreboot ]; then printf "ERROR: download/coreboot: Problem with git-clone. Network issue?\n" cd ../; return 1 fi - else - ( cd coreboot/; git pull || touch ../build_error ) - if [ -f ../build_error ]; then - printf "ERROR: download/coreboot: Problem with git-pull. Network issue?\n" - cd ../; return 1 - fi + fi + + ( cd coreboot/; git fetch --depth=1 origin "${cbrevision}" || touch ../build_error ) + if [ -f ../build_error ]; then + printf "ERROR: download/coreboot: Problem with git-fetch. Network issue?\n" + cd ../; return 1 fi cp -R coreboot "${cbtree}" || touch ../build_error @@ -184,7 +184,7 @@ downloadfor() { cd ../../; return 1 fi - git submodule update --init || touch ../../build_error + git submodule update --init --depth=1 || touch ../../build_error if [ -f ../../build_error ]; then printf "ERROR: download/coreboot: Unable to update submodules for tree '%s'\n" "${cbtree}" cd ../../; return 1 diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index 2e086337..5fc80868 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -125,12 +125,12 @@ downloadfor() { if [ ! -d "${uboot_dir}" ]; then printf "Download u-boot from upstream:\n" - git clone https://source.denx.de/u-boot/u-boot.git \ + git clone --depth=1 https://source.denx.de/u-boot/u-boot.git \ "${uboot_dir}" || \ rm -Rf "${uboot_dir}" if [ ! -d "${uboot_dir}" ]; then printf "WARNING: Upstream failed. Trying backup github repository:\n" - git clone https://github.com/u-boot/u-boot.git \ + git clone --depth=1 https://github.com/u-boot/u-boot.git \ "${uboot_dir}" || \ rm -Rf coreboot fi @@ -140,14 +140,14 @@ downloadfor() { "download/u-boot" return 1 fi - else - git -C "${uboot_dir}" pull || touch build_error - if [ -f build_error ]; then - printf \ - "ERROR: %s: Problem with git-pull. Network issue?\n" \ - "download/u-boot" - return 1 - fi + fi + + git -C "${uboot_dir}" fetch --depth=1 origin "${ubrevision}" || touch build_error + if [ -f build_error ]; then + printf \ + "ERROR: %s: Problem with git-fetch. Network issue?\n" \ + "download/u-boot" + return 1 fi cp -R "${uboot_dir}" "${ubtree}" || touch build_error @@ -167,7 +167,7 @@ downloadfor() { return 1 fi - git -C "${ubtree}" submodule update --init || touch build_error + git -C "${ubtree}" submodule update --init --depth=1 || touch build_error if [ -f build_error ]; then printf "ERROR: %s: Unable to update submodules for tree '%s'\n" \ "${ubtree}" -- cgit v1.2.1