blob: af2bec0d8e23fede67b61c65a5c1acd8e002cfa7 [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
Chris Smart78646622016-03-03 16:49:59 +110026# If we need to fetch new apt repo data, update the timestamp
27RUN echo 201603031716 && apt-get update
Chris Smartf9ad3f92016-01-11 14:59:28 +110028RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy
29RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy bc build-essential git gcc-powerpc64le-linux-gnu
Chris Smart78646622016-03-03 16:49:59 +110030RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy software-properties-common
31RUN apt-add-repository -y multiverse
32# If we need to fetch new apt repo data, update the timestamp
33RUN echo 201603031716 && apt-get update
34RUN apt-get update
35RUN DEBIAN_FRONTEND=noninteractive apt-get install -yy dwarves sparse
Chris Smartf9ad3f92016-01-11 14:59:28 +110036RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
37
38USER ${USER}
39ENV HOME ${HOME}
40RUN /bin/bash
41EOF
42)
43
44# Build the docker container
45docker build -t linux-build/ubuntu - <<< "${Dockerfile}"
46if [[ "$?" -ne 0 ]]; then
47 echo "Failed to build docker container."
48 exit 1
49fi
50
51# Create the docker run script
52export PROXY_HOST=${http_proxy/#http*:\/\/}
53export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
54export PROXY_PORT=${http_proxy/#http*:\/\/*:}
55
56mkdir -p ${WORKSPACE}
57
58cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
59#!/bin/bash
60
61set -x
62
63cd ${WORKSPACE}
64
65# Go into the linux directory (the script will put us in a build subdir)
66cd linux
67
68# Record the version in the logs
69powerpc64le-linux-gnu-gcc --version || exit 1
70
Chris Smart78646622016-03-03 16:49:59 +110071# Build kernel prep
Chris Smartf9ad3f92016-01-11 14:59:28 +110072ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make clean || exit 1
73ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper || exit 1
Chris Smart78646622016-03-03 16:49:59 +110074
75# Build kernel with debug
76ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1
77echo "CONFIG_DEBUG_INFO=y" >> .config
78ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make olddefconfig || exit 1
79ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) -s C=2 CF=-D__CHECK_ENDIAN__ 2>&1 | gzip > sparse.log.gz
80pahole vmlinux 2>&1 | gzip > structs.dump.gz
81
82# Build kernel
Chris Smartf9ad3f92016-01-11 14:59:28 +110083ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1
84ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) || exit 1
85
86EOF_SCRIPT
87
88chmod a+x ${WORKSPACE}/build.sh
89
90# Run the docker container, execute the build script we just built
91docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
92 -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu ${WORKSPACE}/build.sh
93
94# Timestamp for build
95echo "Build completed, $(date)"
96