blob: f74747a5831e254c17e3977f9b98d728224f8320 [file] [log] [blame]
Chris Smartf9ad3f92016-01-11 14:59:28 +11001#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4#
5
6# Trace bash processing
7#set -x
8
9# Default variables
10WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
11http_proxy=${http_proxy:-}
12
13# Timestamp for job
14echo "Build started, $(date)"
15
16# Configure docker build
17if [[ -n "${http_proxy}" ]]; then
18PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
19fi
20
21Dockerfile=$(cat << EOF
22FROM ubuntu:15.10
23
24${PROXY}
25
26RUN echo $(date +%s) && apt-get update
27RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy
28RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy bc build-essential git gcc-powerpc64le-linux-gnu
29RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
30
31USER ${USER}
32ENV HOME ${HOME}
33RUN /bin/bash
34EOF
35)
36
37# Build the docker container
38docker build -t linux-build/ubuntu - <<< "${Dockerfile}"
39if [[ "$?" -ne 0 ]]; then
40 echo "Failed to build docker container."
41 exit 1
42fi
43
44# Create the docker run script
45export PROXY_HOST=${http_proxy/#http*:\/\/}
46export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
47export PROXY_PORT=${http_proxy/#http*:\/\/*:}
48
49mkdir -p ${WORKSPACE}
50
51cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
52#!/bin/bash
53
54set -x
55
56cd ${WORKSPACE}
57
58# Go into the linux directory (the script will put us in a build subdir)
59cd linux
60
61# Record the version in the logs
62powerpc64le-linux-gnu-gcc --version || exit 1
63
64# Build kernel
65ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make clean || exit 1
66ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper || exit 1
67ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1
68ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) || exit 1
69
70EOF_SCRIPT
71
72chmod a+x ${WORKSPACE}/build.sh
73
74# Run the docker container, execute the build script we just built
75docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
76 -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu ${WORKSPACE}/build.sh
77
78# Timestamp for build
79echo "Build completed, $(date)"
80