1f9ad3f9eSChris Smart#!/bin/bash 2f9ad3f9eSChris Smart 3f9ad3f9eSChris Smart# This build script is for running the Jenkins builds using docker. 4f9ad3f9eSChris Smart# 5f9ad3f9eSChris Smart 6f9ad3f9eSChris Smart# Trace bash processing 7f9ad3f9eSChris Smart#set -x 8f9ad3f9eSChris Smart 9f9ad3f9eSChris Smart# Default variables 10f9ad3f9eSChris SmartWORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} 11f9ad3f9eSChris Smarthttp_proxy=${http_proxy:-} 12f9ad3f9eSChris Smart 13f9ad3f9eSChris Smart# Timestamp for job 14f9ad3f9eSChris Smartecho "Build started, $(date)" 15f9ad3f9eSChris Smart 16f9ad3f9eSChris Smart# Configure docker build 17f9ad3f9eSChris Smartif [[ -n "${http_proxy}" ]]; then 18f9ad3f9eSChris SmartPROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" 19f9ad3f9eSChris Smartfi 20f9ad3f9eSChris Smart 21f9ad3f9eSChris SmartDockerfile=$(cat << EOF 22f9ad3f9eSChris SmartFROM ubuntu:15.10 23f9ad3f9eSChris Smart 24f9ad3f9eSChris Smart${PROXY} 25f9ad3f9eSChris Smart 26*78646628SChris Smart# If we need to fetch new apt repo data, update the timestamp 27*78646628SChris SmartRUN echo 201603031716 && apt-get update 28f9ad3f9eSChris SmartRUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -yy 29f9ad3f9eSChris SmartRUN DEBIAN_FRONTEND=noninteractive apt-get install -yy bc build-essential git gcc-powerpc64le-linux-gnu 30*78646628SChris SmartRUN DEBIAN_FRONTEND=noninteractive apt-get install -yy software-properties-common 31*78646628SChris SmartRUN apt-add-repository -y multiverse 32*78646628SChris Smart# If we need to fetch new apt repo data, update the timestamp 33*78646628SChris SmartRUN echo 201603031716 && apt-get update 34*78646628SChris SmartRUN apt-get update 35*78646628SChris SmartRUN DEBIAN_FRONTEND=noninteractive apt-get install -yy dwarves sparse 36f9ad3f9eSChris SmartRUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} 37f9ad3f9eSChris Smart 38f9ad3f9eSChris SmartUSER ${USER} 39f9ad3f9eSChris SmartENV HOME ${HOME} 40f9ad3f9eSChris SmartRUN /bin/bash 41f9ad3f9eSChris SmartEOF 42f9ad3f9eSChris Smart) 43f9ad3f9eSChris Smart 44f9ad3f9eSChris Smart# Build the docker container 45f9ad3f9eSChris Smartdocker build -t linux-build/ubuntu - <<< "${Dockerfile}" 46f9ad3f9eSChris Smartif [[ "$?" -ne 0 ]]; then 47f9ad3f9eSChris Smart echo "Failed to build docker container." 48f9ad3f9eSChris Smart exit 1 49f9ad3f9eSChris Smartfi 50f9ad3f9eSChris Smart 51f9ad3f9eSChris Smart# Create the docker run script 52f9ad3f9eSChris Smartexport PROXY_HOST=${http_proxy/#http*:\/\/} 53f9ad3f9eSChris Smartexport PROXY_HOST=${PROXY_HOST/%:[0-9]*} 54f9ad3f9eSChris Smartexport PROXY_PORT=${http_proxy/#http*:\/\/*:} 55f9ad3f9eSChris Smart 56f9ad3f9eSChris Smartmkdir -p ${WORKSPACE} 57f9ad3f9eSChris Smart 58f9ad3f9eSChris Smartcat > "${WORKSPACE}"/build.sh << EOF_SCRIPT 59f9ad3f9eSChris Smart#!/bin/bash 60f9ad3f9eSChris Smart 61f9ad3f9eSChris Smartset -x 62f9ad3f9eSChris Smart 63f9ad3f9eSChris Smartcd ${WORKSPACE} 64f9ad3f9eSChris Smart 65f9ad3f9eSChris Smart# Go into the linux directory (the script will put us in a build subdir) 66f9ad3f9eSChris Smartcd linux 67f9ad3f9eSChris Smart 68f9ad3f9eSChris Smart# Record the version in the logs 69f9ad3f9eSChris Smartpowerpc64le-linux-gnu-gcc --version || exit 1 70f9ad3f9eSChris Smart 71*78646628SChris Smart# Build kernel prep 72f9ad3f9eSChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make clean || exit 1 73f9ad3f9eSChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper || exit 1 74*78646628SChris Smart 75*78646628SChris Smart# Build kernel with debug 76*78646628SChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 77*78646628SChris Smartecho "CONFIG_DEBUG_INFO=y" >> .config 78*78646628SChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make olddefconfig || exit 1 79*78646628SChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) -s C=2 CF=-D__CHECK_ENDIAN__ 2>&1 | gzip > sparse.log.gz 80*78646628SChris Smartpahole vmlinux 2>&1 | gzip > structs.dump.gz 81*78646628SChris Smart 82*78646628SChris Smart# Build kernel 83f9ad3f9eSChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make pseries_le_defconfig || exit 1 84f9ad3f9eSChris SmartARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) || exit 1 85f9ad3f9eSChris Smart 86f9ad3f9eSChris SmartEOF_SCRIPT 87f9ad3f9eSChris Smart 88f9ad3f9eSChris Smartchmod a+x ${WORKSPACE}/build.sh 89f9ad3f9eSChris Smart 90f9ad3f9eSChris Smart# Run the docker container, execute the build script we just built 91f9ad3f9eSChris Smartdocker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \ 92f9ad3f9eSChris Smart -w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu ${WORKSPACE}/build.sh 93f9ad3f9eSChris Smart 94f9ad3f9eSChris Smart# Timestamp for build 95f9ad3f9eSChris Smartecho "Build completed, $(date)" 96f9ad3f9eSChris Smart 97