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