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 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'resources/scripts/download/coreboot') 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/}" -- 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 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'resources/scripts/download/coreboot') 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 -- cgit v1.2.1