Cyril Bur | bbf7e09 | 2018-02-06 16:50:30 +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:latest |
| 23 | |
| 24 | ${PROXY} |
| 25 | |
| 26 | ENV DEBIAN_FRONTEND noninteractive |
| 27 | RUN apt-get update && apt-get install -yy \ |
| 28 | bc \ |
| 29 | build-essential \ |
| 30 | git \ |
| 31 | gcc-powerpc64le-linux-gnu \ |
| 32 | software-properties-common \ |
| 33 | libssl-dev \ |
| 34 | iputils-ping \ |
| 35 | bison \ |
| 36 | flex |
| 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} |
| 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 trace-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 |
| 69 | set -e -o pipefail |
| 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 |
| 77 | powerpc64le-linux-gnu-gcc --version |
| 78 | |
| 79 | # Build kernel prep |
| 80 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper |
| 81 | |
| 82 | # Generate the config |
| 83 | echo "CONFIG_PPC_PSERIES=y" >> fragment.config |
| 84 | echo "CONFIG_PPC_POWERNV=y" >> fragment.config |
| 85 | echo "CONFIG_MTD=y" >> fragment.config |
| 86 | echo "CONFIG_MTD_BLOCK=y" >> fragment.config |
| 87 | echo "CONFIG_MTD_POWERNV_FLASH=y" >> fragment.config |
| 88 | ARCH=powerpc scripts/kconfig/merge_config.sh \ |
| 89 | arch/powerpc/configs/ppc64_defconfig \ |
| 90 | arch/powerpc/configs/le.config \ |
| 91 | fragment.config |
| 92 | |
Joel Stanley | 4ec31c6 | 2018-08-02 13:30:19 +0930 | [diff] [blame] | 93 | # Ensure config is up to date and no questions will be asked |
| 94 | yes "" | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make oldconfig |
| 95 | |
Cyril Bur | bbf7e09 | 2018-02-06 16:50:30 +1100 | [diff] [blame] | 96 | # Build kernel |
Joel Stanley | 4ec31c6 | 2018-08-02 13:30:19 +0930 | [diff] [blame] | 97 | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) vmlinux |
Cyril Bur | bbf7e09 | 2018-02-06 16:50:30 +1100 | [diff] [blame] | 98 | |
| 99 | EOF_SCRIPT |
| 100 | |
| 101 | chmod a+x ${WORKSPACE}/build.sh |
| 102 | |
| 103 | # Run the docker container, execute the build script we just built |
| 104 | docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \ |
| 105 | -w "${WORKSPACE}" -v "${WORKSPACE}":"${WORKSPACE}" -t trace-linux-build/ubuntu ${WORKSPACE}/build.sh |
| 106 | |
| 107 | result=${?} |
| 108 | |
| 109 | # Timestamp for build |
| 110 | echo "Build completed, $(date)" |
| 111 | |
| 112 | exit ${result} |