#!/bin/bash usage() { echo "MakeRelease: [options]" echo " --workspace - Specify an alternate workspace" echo " --tarbin - Build a binary tarball" echo " --target XXX - Specify the target triplet to build" echo " --date XXX - Specify a date, which becmes part pf the release name" echo " --ref XXX - Specify a Git reference directory" echo " --toolchainconfig XXX - [Optional] Explicitly define which toolchain" echo " to build, e.g., 'default', 'gcc5', 'gcc6'. " echo " If not specified, 'default' is the default" echo " --fileserver XXX - Specify the fileserver for tarballs" echo " --manifest XXX - Optionally use a manifest as input" echo " --glibc XXX - Specify Glibc version to build" echo " --gcc XXX - Specify GCC version to build" echo " --binutils XXX - Specify Binutils version to build" echo " --help" exit } # Jenkins may run only using environment variables, a user needs to always # supply some command line arguments. if test $# -eq 0 -a x"${JENKINS_SERVER_COOKIE}" = x; then usage fi # Set defaults if test x"${debug}" = x"true"; then export CONFIG_SHELL="/bin/bash -x" else export CONFIG_SHELL="/bin/bash" fi target="" tarbin="" check="" ref="snapshots-ref" fileserver="148.251.136.42" extra= toolchain_config="" user_workspace="${WORKSPACE:-/home/${USER:-buildslave}/workspace}" OPTS="`getopt -o r:t:f:d:bw:m:l:g:u:h -l target:,ref:,date:,fileserver:,tarbin:,workspace:,toolchainconfig:,manifest:,glibc:,gcc:,binutils:,help`" while test $# -gt 0; do case $1 in -w|--workspace) user_workspace=$2 ;; -b|--tarbin) tarbin=yes ;; -t|--target) target=$2 ;; -d|--date) date=$2 ;; -r|--ref) ref=$2 ;; --toolchainconfig) toolchain_config=$2 ;; -f|--fileserver) fileserver=$2 ;; -m|--manifest) manifest_src=$2 ;; -l|--glibc) glibc_src=$2 ;; -g|--gcc) gcc_src=$2 ;; -u|--binutils) binutils_src=$2 ;; -h|--help) usage ;; --) break ;; esac shift done if test x"${target}" != x"native" -a x"${target}" != x; then platform="--target ${target}" fi shared="/home/buildslave/workspace/shared/" abe_dir="$(dirname $0)/.." user_snapshots="${user_workspace}/snapshots" if test -e ${user_workspace}; then cat << EOF > ${user_workspace}/BUILD-INFO.txt Format-Version: 0.5 Files-Pattern: * License-Type: open EOF fi # Create a build directory if test ! -d ${user_workspace}/_build; then mkdir -p ${user_workspace}/_build else rm -fr ${user_workspace}/_build/* ${user_workspace}/_build/sysroots/* fi # By default, always update all sources update="" if test x"${toolchain_config}" != x"" \ -a x"${toolchain_config}" != x"default"; then # Note, we need to specify ../config/FOO because the build is done # inside _build directory 1 level up from ABE's top. extra="${extra} --extraconfigdir ../config/${toolchain_config}" fi if test x"${runtests}" = xtrue; then chroot="--enable-schroot-test" fi guess="`${abe_dir}/config.guess`" machine="`gcc -dumpmachine`" if test x"${guess}" != x"${machine}"; then arch="`echo ${machine} | cut -d '-' -f 1`" CONFIG_SHELL="setarch ${arch} ${CONFIG_SHELL}" fi # Use the newly created build directory cd ${user_workspace}/_build if ! test -e host.conf; then $CONFIG_SHELL ${abe_dir}/configure ${chroot} --with-local-snapshots=${user_snapshots} \ --with-git-reference-dir=${shared}/snapshots --with-fileserver=${fileserver} --with-remote-snapshots=${ref} fi if test x"${runtests}" = xtrue; then chroot="--enable-schroot-test" check="--check all" else check="" fi if test x"${date}" != x; then release="${date}" fi if test "`echo ${target} | grep -c linux`" -gt 0; then if test "`echo ${gcc_src} | grep -c -- '-[56][[:digit:]\.]*'`" -gt 0; then libc="--set libc=glibc" else libc="--set libc=eglibc" fi else # ELF and EABI based targets are bare metal only libc="--set libc=newlib" fi manifest=${manifest:+--manifest ${manifest_src}} glibc=${glibc_src:+glibc=${glibc_src}} binutils=${binutils_src:+binutils=${binutils_src}} gcc=${gcc_src:+gcc=${gcc_src}} srcs="${gcc} ${binutils} ${glibc} ${manifest}" # Build a binary release tarball, then run the tests on the installed binaries if test x"${tarbin}" = x"yes"; then # Canadian cross builds require a Linux hosted cross compiler first if test x"${canadian}" = x"true"; then $CONFIG_SHELL ${abe_dir}/abe.sh ${update} --release ${release} ${check} ${srcs} ${platform} --build all ${libc} ${extra} host="--host i686-w64-mingw32" rm -fr ${local_builds}/${host}/${target}/ # update="--disable update" else host="" fi $CONFIG_SHELL ${abe_dir}/abe.sh ${update} --release ${release} --tarbin ${check} ${srcs} ${platform} ${host} --build all ${libc} ${extra} fi # force a failure if abe has build problems. if test $? -gt 0; then exit 1 fi # Copy the source build test results and tarballs to the fileserver bases="/work/abe/baselines/${release}/${target}" snaps="/home/abe/var/snapshots/" # Copy the binary test results to the fileserver binaries="/work/space/binaries/${release}/${target}" if test x"${tarbin}" = xyes; then manifest="`find ${user_workspace} -name \*manifest.txt`" ssh ${fileserver} "if test ! -d ${binaries}; then mkdir -p ${binaries}; fi" scp ${manifest} ${fileserver}:${binaries}/ tarballs="`find ${user_snapshots} -name \*${release}\*.xz -o -name \*${release}\*.asc`" scp ${tarballs} ${fileserver}:${binaries}/ if test x"${check}" != x; then sums="`find ${user_workspace} -name \*.sum`" logs="`find ${user_workspace} -name \*.log`" if test x"${sums}" != x; then xz ${sums} ${logs} sums="`echo ${sums} | sed -e 's/\.sum/\.sum.xz/g'`" logs="`echo ${logs} | sed -e 's/\.log/\.log.xz/g'`" ssh ${fileserver} "mkdir -p ${binaries}/" scp ${sums} ${logs} ${fileserver}:${binaries}/ else echo "ERROR: No test results were found!" fi # Diff the two directories scp ${abe_dir}/tcwgweb.sh ${fileserver}:/tmp/tcwgweb$$.sh out="`ssh ${fileserver} "if test -e ${bases}; then echo YES; else echo NO; fi"`" if test x"${out}" = x"YES"; then out="`ssh ${fileserver} /tmp/tcwgweb$$.sh --email --tdir ${bases} ${binaries}`" if test "`echo ${out} | grep -c REGRESSIONS`"; then exit 1 fi fi fi fi exit 0