[coreboot-gerrit] New patch to review for coreboot: buildgcc: Search the cksum command without checking OS type

Zheng Bao (zheng.bao@amd.com) gerrit at coreboot.org
Wed Sep 2 06:47:25 CET 2015


Zheng Bao (zheng.bao at amd.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11483

-gerrit

commit 86fa6bafe6691f080f67655f82a2dc0941a1b31d
Author: zbao <fishbaozi at gmail.com>
Date:   Tue Sep 1 22:28:57 2015 -0400

    buildgcc: Search the cksum command without checking OS type
    
    Change-Id: Ia3f4f5f0f98ff47d322a4f70689cca0bd4fa79fa
    Signed-off-by: Zheng Bao <zheng.bao at amd.com>
    Signed-off-by: Zheng Bao <fishbaozi at gmail.com>
---
 util/crossgcc/buildgcc | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 49e41e5..bbf01b9 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -149,24 +149,26 @@ searchtool()
 			fi
 		fi
 	fi
-	if [ "$(echo $1 | cut -b -3)" = "sha" ]; then
-		if [ $UNAME = "FreeBSD" ]; then
-			if [ -x "$(which sha1 2>/dev/null)" ]; then
-				echo sha1
-				return
-			fi
-		fi
-		if [ $UNAME = "NetBSD" ]; 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 [ -x "$(which openssl 2>/dev/null)" ]; then
-				echo openssl $(echo $1 | sed -e 's,sum,,')
-				return
-			fi
+	if echo $1 | grep -q "sum" ; then
+		algor=$(echo $1 | sed -e 's,sum,,')
+		if [ -x "$(which $1 2>/dev/null)" ]; then
+			#xxxsum [file]
+			echo $1
+			return
+		elif [ -x "$(which $algor 2>/dev/null)" ]; then
+			#xxx [file]
+			echo $algor
+			return
+		elif [ -x "$(which openssl 2>/dev/null)" ]; then
+			#openssl xxx [file]
+			echo openssl $algor
+			return
+		elif [ -x "$(which cksum 2>/dev/null)" ]; then
+			#cksum -a xxx [file]
+			#cksum has special options in NetBSD. Actually, NetBSD will use the second case above.
+			echo "buildgcc" | cksum -a $algor > /dev/null 2>/dev/null && \
+			echo cksum -a $algor
+			return
 		fi
 	fi
 	please_install $1
@@ -590,6 +592,7 @@ PATCH=$(searchtool patch) || exit $?
 MAKE=$(searchtool make) || exit $?
 SHA1SUM=$(searchtool sha1sum)
 SHA512SUM=$(searchtool sha512sum)
+MD5SUM=$(searchtool md5sum)
 CHECKSUM=$SHA1SUM
 
 searchtool m4 > /dev/null



More information about the coreboot-gerrit mailing list