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@coreboot.org>
Reviewed-on: http://review.coreboot.org/10433
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Stefan Reinauer 2015-06-05 09:51:10 -07:00
parent 83fc32f7a7
commit 88935481c9
1 changed files with 51 additions and 47 deletions

View File

@ -162,6 +162,55 @@ searchtool clang "clang version" > /dev/null
searchtool wget > /dev/null searchtool wget > /dev/null
searchtool bzip2 "bzip2," > /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() { wait_for_build() {
# $1: directory in which log file and failure marker are stored # $1: directory in which log file and failure marker are stored
cat > "$1/crossgcc-build.log" cat > "$1/crossgcc-build.log"
@ -317,32 +366,7 @@ mkdir -p tarballs
for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \ for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
$GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \ $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
$IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
FILE=`basename $ARCHIVE` download $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"
done done
printf "Downloaded tar balls ... " printf "Downloaded tar balls ... "
printf "${green}ok${NC}\n" printf "${green}ok${NC}\n"
@ -350,27 +374,7 @@ printf "${green}ok${NC}\n"
printf "Unpacking and patching ... \n" printf "Unpacking and patching ... \n"
for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \ for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
$EXPAT_PACKAGE $GDB_PACKAGE IASL; do $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
archive=$PACKAGE"_ARCHIVE" unpack_and_patch $PACKAGE
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
)
done done
printf "Unpacked and patched ... " printf "Unpacked and patched ... "
printf "${green}ok${NC}\n" printf "${green}ok${NC}\n"