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