summaryrefslogtreecommitdiff
path: root/util/crossgcc/buildgcc
diff options
context:
space:
mode:
authorzbao <fishbaozi@gmail.com>2015-04-30 04:44:07 +0800
committerPatrick Georgi <pgeorgi@google.com>2015-05-04 14:56:21 +0200
commit939dc8492ae80858575db3e808baf18f5ab651a0 (patch)
treef64b49083c866c69ca0c4dcf713a2883360c763c /util/crossgcc/buildgcc
parent6548ae9f99beba89f3dcf5c7b0c86c75d5c0ab5c (diff)
downloadcoreboot-939dc8492ae80858575db3e808baf18f5ab651a0.tar.xz
crossgcc: Re-download the archive if it is incomplete
If the buildgcc is interrupt by Ctrl-C, probably part of an archive is downloaded. If we run buildgcc again, the incomplete archive would be considered as cached file and skipped. We check file hashes to see if the file is complete. If test is failed, we need to delete the partially-downloaded file and download it again. sha1sum is quite different among the distributions. Only Linux, Cygwin, Darwin have been tested. Once new archive is deployed, a new checksum would be created, which should be uploaded along with the script buildgcc. Change-Id: Ibb1aa25a0374f774e1e643fe5e698de7bf7cc418 Signed-off-by: Zheng Bao <zheng.bao@amd.com> Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: http://review.coreboot.org/4511 Tested-by: build bot (Jenkins) Reviewed-by: Idwer Vollering <vidwer@gmail.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/crossgcc/buildgcc')
-rwxr-xr-xutil/crossgcc/buildgcc41
1 files changed, 40 insertions, 1 deletions
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index a29a338d9c..02a7d82cfa 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -125,6 +125,26 @@ searchtool()
fi
fi
fi
+ if [ "`echo $1 | cut -b -3`" = "sha" ]; then
+ if [ $UNAME = "FreeBSD" ]; then
+ if test -x "`which sha1 2>/dev/null`"; then
+ echo sha1
+ return
+ fi
+ fi
+ if [ $UNAME = "NetBSD" ]; then
+ if test -x "`which cksum 2>/dev/null`"; then
+ echo cksum -a `echo $1 | sed -e 's,sum,,'`
+ return
+ fi
+ fi
+ if [ $UNAME = "Darwin" ]; then
+ if test -x "`which openssl 2>/dev/null`"; then
+ echo openssl `echo $1 | sed -e 's,sum,,'`
+ return
+ fi
+ fi
+ fi
printf "${RED}ERROR:${red} Missing tool: Please install $1 (eg using your OS packaging system)${NC}\n" >&2
[ -z "$3" ] && exit 1
false
@@ -151,6 +171,10 @@ wait_for_build() {
true
}
+SHA1SUM=`searchtool sha1sum`
+SHA512SUM=`searchtool sha512sum`
+CHECKSUM=$SHA1SUM
+
cleanup()
{
printf "Cleaning up temporary files... "
@@ -295,10 +319,25 @@ for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
$IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
FILE=`basename $ARCHIVE`
printf " * $FILE "
- test -f tarballs/$FILE && printf "(cached)" || (
+
+ ##create the sum
+ #test -f sum/$FILE.cksum || (
+ # $CHECKSUM tarballs/$FILE > sum/$FILE.cksum
+ # continue
+ #)
+
+ test -f tarballs/$FILE && \
+ (test -z "$CHECKSUM" || \
+ test "`cat sum/$FILE.cksum 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,'`" = "`$CHECKSUM tarballs/$FILE 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,'`" ) && \
+ printf "(cached)" || (
printf "(downloading)"
+ rm -f tarballs/$FILE
cd tarballs
wget --no-check-certificate -q $ARCHIVE
+ cd ..
+ test ! -f sum/$FILE.cksum && test -f tarballs/$FILE && \
+ (test -z "$CHECKSUM" || $CHECKSUM tarballs/$FILE > sum/$FILE.cksum ) && \
+ printf "(checksum created. ${RED}Note. Please upload sum/$FILE.cksum if the corresponding archive is upgraded.${NC})"
)
test -f tarballs/$FILE || \
printf "\n${RED}Failed to download $FILE.${NC}\n"