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