buildgcc: move from if test to if [ .. ]

Change-Id: I29fe23e377045f08b8212742d84c2ee2b4a61b15
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: http://review.coreboot.org/10485
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: build bot (Jenkins)
Reviewed-by: Alexander Couzens <lynxis@fe80.eu>
This commit is contained in:
Stefan Reinauer 2015-06-09 11:50:05 -07:00
parent d764912e0e
commit dbc0087f9e
1 changed files with 15 additions and 11 deletions

View File

@ -121,9 +121,9 @@ searchtool()
search="$2"
fi
for i in "$1" "g$1" "gnu$1"; do
if test -x "$(which $i 2>/dev/null)"; then
if test $(cat /dev/null | $i --version 2>&1 |grep -c "$search") \
-gt 0; then
if [ -x "$(which $i 2>/dev/null)" ]; then
if [ "$(cat /dev/null | $i --version 2>&1 | grep -c "$search")" \
-gt 0 ]; then
echo $i
return
fi
@ -133,7 +133,7 @@ searchtool()
# patch and tar also work.
if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" -o $UNAME = "OpenBSD" ]; then
if [ "$1" = "patch" -o "$1" = "tar" ]; then
if test -x "$(which $1 2>/dev/null)"; then
if [ -x "$(which $1 2>/dev/null)" ]; then
echo $1
return
fi
@ -141,19 +141,19 @@ searchtool()
fi
if [ "$(echo $1 | cut -b -3)" = "sha" ]; then
if [ $UNAME = "FreeBSD" ]; then
if test -x "$(which sha1 2>/dev/null)"; then
if [ -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
if [ -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
if [ -x "$(which openssl 2>/dev/null)" ]; then
echo openssl $(echo $1 | sed -e 's,sum,,')
return
fi
@ -188,8 +188,11 @@ download() {
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,')" ) && \
( 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
@ -200,9 +203,10 @@ download() {
(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 || \
if [ ! -f tarballs/$FILE ]; then
printf "\n${RED}Failed to download $FILE.${NC}\n"
test -f tarballs/$FILE || exit 1
exit 1
fi
printf "\n"
}