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