summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorzbao <fishbaozi@gmail.com>2015-08-24 22:08:36 -0400
committerZheng Bao <zheng.bao@amd.com>2015-08-26 01:06:17 +0000
commit06e85acb4047142cd00442ce8251d30f3754bef1 (patch)
tree0fc66d46ae6ba9a7420cbe40399a087686efb0d7 /util
parentdf205067c976d917563a02fc6ebf1cff329a4097 (diff)
downloadcoreboot-06e85acb4047142cd00442ce8251d30f3754bef1.tar.gz
coreboot-06e85acb4047142cd00442ce8251d30f3754bef1.tar.bz2
coreboot-06e85acb4047142cd00442ce8251d30f3754bef1.zip
buildgcc: Move a bunch of code into a function
Refactor the code to be better understandable. Change-Id: Ia815a27f7cc83c226a32e87485d712a5fbf4168e Signed-off-by: Zheng Bao <zheng.bao@amd.com> Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: http://review.coreboot.org/11318 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util')
-rwxr-xr-xutil/crossgcc/buildgcc24
1 files changed, 14 insertions, 10 deletions
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index d645a5346cb6..f39c4b6fa9e2 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -174,6 +174,18 @@ searchtool()
false
}
+check_sum() {
+ test -z "$CHECKSUM" || \
+ test "$(cat sum/$1.cksum 2>/dev/null | sed -e 's@.*\([0-9a-f]\{40,\}\).*@\1@')" = \
+ "$($CHECKSUM tarballs/$1 2>/dev/null | sed -e 's@.*\([0-9a-f]\{40,\}\).*@\1@')"
+}
+
+compute_sum() {
+ test ! -f sum/$1.cksum && test -f tarballs/$1 && \
+ (test -z "$CHECKSUM" || $CHECKSUM tarballs/$1 > sum/$1.cksum ) && \
+ printf "(checksum created. ${RED}Note. Please upload sum/$1.cksum if the corresponding archive is upgraded.)${NC}"
+}
+
download() {
package=$1
archive="$(eval echo \$$package"_ARCHIVE")"
@@ -181,21 +193,13 @@ download() {
FILE=$(basename $archive)
printf " * $FILE "
- 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)" || (
+ test -f tarballs/$FILE && check_sum $FILE && printf "(cached)" || (
printf "(downloading from $archive)"
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})"
+ compute_sum $FILE
)
if [ ! -f tarballs/$FILE ]; then
printf "\n${RED}Failed to download $FILE.${NC}\n"