[coreboot-gerrit] New patch to review for coreboot: 416645e buildgcc: factor out downloading, unpacking and patching

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Fri Jun 5 18:58:43 CEST 2015


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10433

-gerrit

commit 416645eee562c0757f25feb46fea9c9585f92a78
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Fri Jun 5 09:51:10 2015 -0700

    buildgcc: factor out downloading, unpacking and patching
    
    This will be useful for adding clang support (and hopefully
    makes the code a bit more readable)
    
    Change-Id: Ie866fb2bd71e2a64f26f2755961bd126e101cbe5
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 util/crossgcc/buildgcc | 98 ++++++++++++++++++++++++++------------------------
 1 file changed, 51 insertions(+), 47 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index a1b596e..22524d6 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -162,6 +162,55 @@ searchtool clang "clang version" > /dev/null
 searchtool wget > /dev/null
 searchtool bzip2 "bzip2," > /dev/null
 
+download() {
+	ARCHIVE=$1
+	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)" || (
+		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"
+	test -f tarballs/$FILE || exit 1
+	printf "\n"
+}
+
+unpack_and_patch() {
+	PACKAGE=$1
+	archive=$PACKAGE"_ARCHIVE"
+	archive="`eval echo '$'$archive`"
+	dir=$PACKAGE"_DIR"
+	dir="`eval echo '$'${dir}`"
+	test -d ${dir} && test -f ${dir}/.unpack_success || (
+		printf " * `basename $archive`\n"
+		FLAGS=zxf
+		suffix=`echo $archive | sed 's,.*\.,,'`
+		test "$suffix" = "gz" && FLAGS=zxf
+		test "$suffix" = "bz2" && FLAGS=jxf
+		test "$suffix" = "xz" && FLAGS="--xz -xf"
+		test "$suffix" = "lzma" && FLAGS="--lzma -xf"
+		$TAR $FLAGS tarballs/`basename $archive`
+		for patch in patches/${dir}_*.patch; do
+			test -r $patch || continue
+			printf "   o `basename $patch`\n"
+			$PATCH -s -N -p0 < `echo $patch` || \
+				printf "\n${RED}Failed $patch.${NC}\n"
+		done
+		touch ${dir}/.unpack_success
+	)
+}
+
 wait_for_build() {
 	# $1: directory in which log file and failure marker are stored
 	cat > "$1/crossgcc-build.log"
@@ -317,32 +366,7 @@ mkdir -p tarballs
 for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE  \
 	    $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
 	    $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
-	FILE=`basename $ARCHIVE`
-	printf " * $FILE "
-
-	##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"
-	test -f tarballs/$FILE || exit 1
-	printf "\n"
+	download $ARCHIVE
 done
 printf "Downloaded tar balls ... "
 printf "${green}ok${NC}\n"
@@ -350,27 +374,7 @@ printf "${green}ok${NC}\n"
 printf "Unpacking and patching ... \n"
 for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
 	    $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
-	archive=$PACKAGE"_ARCHIVE"
-	archive="`eval echo '$'$archive`"
-	dir=$PACKAGE"_DIR"
-	dir="`eval echo '$'${dir}`"
-	test -d ${dir} && test -f ${dir}/.unpack_success || (
-		printf " * `basename $archive`\n"
-		FLAGS=zxf
-		suffix=`echo $archive | sed 's,.*\.,,'`
-		test "$suffix" = "gz" && FLAGS=zxf
-		test "$suffix" = "bz2" && FLAGS=jxf
-		test "$suffix" = "xz" && FLAGS="--xz -xf"
-		test "$suffix" = "lzma" && FLAGS="--lzma -xf"
-		$TAR $FLAGS tarballs/`basename $archive`
-		for patch in patches/${dir}_*.patch; do
-			test -r $patch || continue
-			printf "   o `basename $patch`\n"
-			$PATCH -s -N -p0 < `echo $patch` || \
-				printf "\n${RED}Failed $patch.${NC}\n"
-		done
-		touch ${dir}/.unpack_success
-	)
+	unpack_and_patch $PACKAGE
 done
 printf "Unpacked and patched ... "
 printf "${green}ok${NC}\n"



More information about the coreboot-gerrit mailing list