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 |
| 22 | FROM ubuntu:15.10 |
| 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 \ |
| 32 | software-properties-common |
| 33 | |
| 34 | RUN apt-add-repository -y multiverse && apt-get update && apt-get install -yy \ |
| 35 | dwarves \ |
| 36 | sparse |
| 37 | |
| 38 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 39 | 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] | 40 | |
| 41 | USER ${USER} |
| 42 | ENV HOME ${HOME} |
| 43 | RUN /bin/bash |
| 44 | EOF |
| 45 | ) |
| 46 | |
| 47 | # Build the docker container |
| 48 | docker build -t linux-build/ubuntu - <<< "${Dockerfile}" |
| 49 | if [[ "$?" -ne 0 ]]; then |
| 50 | echo "Failed to build docker container." |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | # Create the docker run script |
| 55 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 56 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 57 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 58 | |
| 59 | mkdir -p ${WORKSPACE} |
| 60 | |
| 61 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
| 62 | #!/bin/bash |
| 63 | |
| 64 | set -x |
| 65 | |
| 66 | cd ${WORKSPACE} |
| 67 | |
| 68 | # Go into the linux directory (the script will put us in a build subdir) |
| 69 | cd linux |
| 70 | |
| 71 | # Record the version in the logs |
| 72 | powerpc64le-linux-gnu-gcc --version || exit 1 |
| 73 | |
Chris Smart | 7864662 | 2016-03-03 16:49:59 +1100 | [diff] [blame] | 74 | # Build kernel prep |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 75 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make clean || exit 1 |
| 76 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper || exit 1 |
Chris Smart | 7864662 | 2016-03-03 16:49:59 +1100 | [diff] [blame] | 77 | |
| 78 | # Build kernel with debug |
| 79 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 |
| 80 | echo "CONFIG_DEBUG_INFO=y" >> .config |
| 81 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make olddefconfig || exit 1 |
| 82 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) -s C=2 CF=-D__CHECK_ENDIAN__ 2>&1 | gzip > sparse.log.gz |
| 83 | pahole vmlinux 2>&1 | gzip > structs.dump.gz |
| 84 | |
| 85 | # Build kernel |
Chris Smart | f9ad3f9 | 2016-01-11 14:59:28 +1100 | [diff] [blame] | 86 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 |
| 87 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) || exit 1 |
| 88 | |
| 89 | EOF_SCRIPT |
| 90 | |
| 91 | chmod a+x ${WORKSPACE}/build.sh |
| 92 | |
| 93 | # Run the docker container, execute the build script we just built |
| 94 | docker 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 |
| 98 | echo "Build completed, $(date)" |
| 99 | |