blob: 880265d354f9ecc846e3dd311abb2cb07aa4189c [file] [log] [blame]
Chris Smart78efac72016-03-11 16:05:25 +11001#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4#
5# It expects a few variables which are part of Jenkins build job matrix:
6# target = palmetto|qemu|habanero|firestone|garrison
7# distro = ubuntu
8# WORKSPACE =
9
10# Trace bash processing
11set -x
12
13# Default variables
14target=${target:-palmetto}
15distro=${distro:-ubuntu}
16WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
17http_proxy=${http_proxy:-}
18
19# Timestamp for job
20echo "Build started, $(date)"
21
22# Configure docker build
23
24Dockerfile=$(cat << EOF
25FROM fedora:23
26
27RUN dnf --refresh repolist && dnf install -y \
28 bison \
29 ccache \
30 file \
31 flex \
32 gcc \
33 gcc-c++ \
34 git \
35 gmp-devel \
36 libmpc-devel \
37 make \
38 mpfr-devel \
39 tar \
40 texinfo \
41 xz
42
43RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
44RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
45
46USER ${USER}
47ENV HOME ${HOME}
48RUN /bin/bash
49EOF
50)
51
52# Build the docker container
53docker build -t gcc/fedora - <<< "${Dockerfile}"
54if [[ "$?" -ne 0 ]]; then
55 echo "Failed to build docker container."
56 exit 1
57fi
58
59mkdir -p ${WORKSPACE}
60
61cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
62#!/bin/bash
63
64set -x
65
66export CC="ccache gcc"
67mkdir -p "${WORKSPACE}/gcc-build"
68mkdir -p "${WORKSPACE}/cross"
69
70cd "${WORKSPACE}/toolchain-build-script"
71./build-gcc.sh --debug -v HEAD -t ppc -b ${WORKSPACE}/gcc-build -i ${WORKSPACE}/cross --gcc ${WORKSPACE}/gcc --binutils ${WORKSPACE}/binutils-gdb --clean --local
72
73EOF_SCRIPT
74
75chmod a+x ${WORKSPACE}/build.sh
76
77# Run the docker container, execute the build script we just built
78docker run --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
79 -w "${HOME}" -v "${HOME}":"${HOME}":Z -t gcc/fedora ${WORKSPACE}/build.sh
80
81# Timestamp for build
82echo "Build completed, $(date)"