Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 1 | #!/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 |
| 10 | WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} |
| 11 | http_proxy=${http_proxy:-} |
| 12 | |
| 13 | # Timestamp for job |
| 14 | echo "Build started, $(date)" |
| 15 | |
| 16 | # Configure docker build |
| 17 | if [[ -n "${http_proxy}" ]]; then |
| 18 | PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" |
| 19 | fi |
| 20 | |
| 21 | Dockerfile=$(cat << EOF |
Joel Stanley | 5f4de95 | 2017-12-06 18:53:16 +1030 | [diff] [blame] | 22 | FROM ubuntu:latest |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 23 | |
| 24 | ${PROXY} |
| 25 | |
Chris Smart | 4593d4f | 2016-03-09 15:50:59 +1100 | [diff] [blame] | 26 | ENV DEBIAN_FRONTEND noninteractive |
Chris Smart | fc730ff | 2016-03-09 20:17:19 +1100 | [diff] [blame] | 27 | RUN apt-get update && apt-get install -yy \ |
Chris Smart | 4593d4f | 2016-03-09 15:50:59 +1100 | [diff] [blame] | 28 | bc \ |
| 29 | build-essential \ |
| 30 | git \ |
| 31 | gcc-powerpc64le-linux-gnu \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 32 | software-properties-common \ |
Joel Stanley | 15a77ae | 2017-12-12 00:17:14 +1030 | [diff] [blame^] | 33 | libssl-dev \ |
Saqib Khan | 5158a32 | 2017-10-23 11:31:24 -0500 | [diff] [blame] | 34 | iputils-ping |
Chris Smart | 4593d4f | 2016-03-09 15:50:59 +1100 | [diff] [blame] | 35 | |
| 36 | RUN apt-add-repository -y multiverse && apt-get update && apt-get install -yy \ |
| 37 | dwarves \ |
| 38 | sparse |
| 39 | |
| 40 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 41 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 42 | |
| 43 | USER ${USER} |
| 44 | ENV HOME ${HOME} |
| 45 | RUN /bin/bash |
| 46 | EOF |
| 47 | ) |
| 48 | |
| 49 | # Build the docker container |
| 50 | docker build -t linux-build/ubuntu - <<< "${Dockerfile}" |
| 51 | if [[ "$?" -ne 0 ]]; then |
| 52 | echo "Failed to build docker container." |
| 53 | exit 1 |
| 54 | fi |
| 55 | |
| 56 | # Create the docker run script |
| 57 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 58 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 59 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 60 | |
| 61 | mkdir -p ${WORKSPACE} |
| 62 | |
| 63 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
| 64 | #!/bin/bash |
| 65 | |
| 66 | set -x |
| 67 | |
| 68 | cd ${WORKSPACE} |
| 69 | |
| 70 | # Go into the linux directory (the script will put us in a build subdir) |
| 71 | cd linux |
| 72 | |
| 73 | # Record the version in the logs |
| 74 | powerpc64le-linux-gnu-gcc --version || exit 1 |
| 75 | |
Chris Smart | 7864662 | 2016-03-03 16:49:59 +1100 | [diff] [blame] | 76 | # Build kernel prep |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 77 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make clean || exit 1 |
| 78 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper || exit 1 |
Chris Smart | 7864662 | 2016-03-03 16:49:59 +1100 | [diff] [blame] | 79 | |
| 80 | # Build kernel with debug |
| 81 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 |
| 82 | echo "CONFIG_DEBUG_INFO=y" >> .config |
| 83 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make olddefconfig || exit 1 |
| 84 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) -s C=2 CF=-D__CHECK_ENDIAN__ 2>&1 | gzip > sparse.log.gz |
| 85 | pahole vmlinux 2>&1 | gzip > structs.dump.gz |
| 86 | |
| 87 | # Build kernel |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 88 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 |
| 89 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) || exit 1 |
| 90 | |
| 91 | EOF_SCRIPT |
| 92 | |
| 93 | chmod a+x ${WORKSPACE}/build.sh |
| 94 | |
| 95 | # Run the docker container, execute the build script we just built |
| 96 | docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \ |
| 97 | -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu ${WORKSPACE}/build.sh |
| 98 | |
| 99 | # Timestamp for build |
| 100 | echo "Build completed, $(date)" |
| 101 | |