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>
This commit is contained in:
@@ -174,6 +174,18 @@ searchtool()
|
|||||||
false
|
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() {
|
download() {
|
||||||
package=$1
|
package=$1
|
||||||
archive="$(eval echo \$$package"_ARCHIVE")"
|
archive="$(eval echo \$$package"_ARCHIVE")"
|
||||||
@@ -181,21 +193,13 @@ download() {
|
|||||||
FILE=$(basename $archive)
|
FILE=$(basename $archive)
|
||||||
printf " * $FILE "
|
printf " * $FILE "
|
||||||
|
|
||||||
test -f tarballs/$FILE && \
|
test -f tarballs/$FILE && check_sum $FILE && printf "(cached)" || (
|
||||||
( 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 from $archive)"
|
printf "(downloading from $archive)"
|
||||||
rm -f tarballs/$FILE
|
rm -f tarballs/$FILE
|
||||||
cd tarballs
|
cd tarballs
|
||||||
wget --no-check-certificate -q $archive
|
wget --no-check-certificate -q $archive
|
||||||
cd ..
|
cd ..
|
||||||
test ! -f sum/$FILE.cksum && test -f tarballs/$FILE && \
|
compute_sum $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})"
|
|
||||||
)
|
)
|
||||||
if [ ! -f tarballs/$FILE ]; then
|
if [ ! -f tarballs/$FILE ]; then
|
||||||
printf "\n${RED}Failed to download $FILE.${NC}\n"
|
printf "\n${RED}Failed to download $FILE.${NC}\n"
|
||||||
|
Reference in New Issue
Block a user