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