Prepare code for the introduction of an on host compiler option. Introduce the download_and_set_compiler() method which will be used only when COMPILER_URL is set. No functionality change.
Signed-off-by: Tudor Ambarus tudor.ambarus@linaro.org --- syzkaller-start | 53 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/syzkaller-start b/syzkaller-start index 37c6200..5e44a69 100755 --- a/syzkaller-start +++ b/syzkaller-start @@ -230,34 +230,41 @@ while [ "${COMPILER_VERSION}" == "" ]; do esac done
-COMPILERDIR=${SYZKALLERDIR}/compilers/${COMPILER_VERSION} -mkdir -p ${COMPILERDIR} - -pushd ${COMPILERDIR} > /dev/null -if echo ${COMPILER_VERSION} | grep -q clang; then - # Parent directory in the Clang packages is already named correctly - cd .. - rmdir --ignore-fail-on-non-empty ${COMPILER_VERSION} - - COMPILER=${COMPILERDIR}/bin/clang -else - COMPILER=${COMPILERDIR}/${COMPILER_BIN_PATH}/bin/gcc -fi +download_and_set_compiler() +{ + COMPILERDIR=${SYZKALLERDIR}/compilers/${COMPILER_VERSION} + mkdir -p ${COMPILERDIR}
-if [ ! -f $(basename ${COMPILER_URL}) ]; then - print_blue "\nDownloading ${COMPILER_VERSION}:\n\n\t${COMPILER_URL}" - curl -C - -sLO --show-error ${COMPILER_URL} + pushd ${COMPILERDIR} > /dev/null + if echo ${COMPILER_VERSION} | grep -q clang; then + # Parent directory in the Clang packages is already named correctly + cd .. + rmdir --ignore-fail-on-non-empty ${COMPILER_VERSION}
- if echo ${COMPILER_URL} | grep -q "gz$"; then - tar -xzf ${COMPILER_VERSION}.tar.gz + COMPILER=${COMPILERDIR}/bin/clang else - tar -xJf ${COMPILER_VERSION}.tar.xz + COMPILER=${COMPILERDIR}/${COMPILER_BIN_PATH}/bin/gcc + fi + + if [ ! -f $(basename ${COMPILER_URL}) ]; then + print_blue "\nDownloading ${COMPILER_VERSION}:\n\n\t${COMPILER_URL}" + curl -C - -sLO --show-error ${COMPILER_URL} + + if echo ${COMPILER_URL} | grep -q "gz$"; then + tar -xzf ${COMPILER_VERSION}.tar.gz + else + tar -xJf ${COMPILER_VERSION}.tar.xz + fi + else + print_blue "\nUsing ${COMPILER_VERSION}" fi -else - print_blue "\nUsing ${COMPILER_VERSION}" -fi
-popd > /dev/null # ${COMPILERDIR} + popd > /dev/null # ${COMPILERDIR} +} + +if [ -n "${COMPILER_URL}" ]; then + download_and_set_compiler +fi
IMAGEDIR=${SYZKALLERDIR}/images mkdir -p ${IMAGEDIR}