1bbf7e092SCyril Bur#!/bin/bash 2bbf7e092SCyril Bur 3bbf7e092SCyril Bur# This build script is for running the Jenkins builds using docker. 4bbf7e092SCyril Bur# 5bbf7e092SCyril Bur 6bbf7e092SCyril Bur# Trace bash processing 7bbf7e092SCyril Bur#set -x 8bbf7e092SCyril Bur 9bbf7e092SCyril Bur# Default variables 10bbf7e092SCyril BurWORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} 11bbf7e092SCyril Burhttp_proxy=${http_proxy:-} 12bbf7e092SCyril Bur 13bbf7e092SCyril Bur# Timestamp for job 14bbf7e092SCyril Burecho "Build started, $(date)" 15bbf7e092SCyril Bur 16bbf7e092SCyril Bur# Configure docker build 17bbf7e092SCyril Burif [[ -n "${http_proxy}" ]]; then 18bbf7e092SCyril Bur PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" 19bbf7e092SCyril Burfi 20bbf7e092SCyril Bur 21bbf7e092SCyril BurDockerfile=$(cat << EOF 22bbf7e092SCyril BurFROM ubuntu:latest 23bbf7e092SCyril Bur 24bbf7e092SCyril Bur${PROXY} 25bbf7e092SCyril Bur 26bbf7e092SCyril BurENV DEBIAN_FRONTEND noninteractive 27bbf7e092SCyril BurRUN apt-get update && apt-get install -yy \ 28bbf7e092SCyril Bur bc \ 29bbf7e092SCyril Bur build-essential \ 30bbf7e092SCyril Bur git \ 31bbf7e092SCyril Bur gcc-powerpc64le-linux-gnu \ 32bbf7e092SCyril Bur software-properties-common \ 33bbf7e092SCyril Bur libssl-dev \ 34bbf7e092SCyril Bur iputils-ping \ 35bbf7e092SCyril Bur bison \ 36bbf7e092SCyril Bur flex 37bbf7e092SCyril Bur 38bbf7e092SCyril BurRUN apt-add-repository -y multiverse && apt-get update && apt-get install -yy \ 39bbf7e092SCyril Bur dwarves \ 40bbf7e092SCyril Bur sparse 41bbf7e092SCyril Bur 42*384d741bSPatrick WilliamsRUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER} 43*384d741bSPatrick WilliamsRUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER} 44bbf7e092SCyril Bur 45bbf7e092SCyril BurUSER ${USER} 46bbf7e092SCyril BurENV HOME ${HOME} 47bbf7e092SCyril BurRUN /bin/bash 48bbf7e092SCyril BurEOF 49bbf7e092SCyril Bur) 50bbf7e092SCyril Bur 51bbf7e092SCyril Bur# Build the docker container 52*384d741bSPatrick Williamsif ! docker build -t trace-linux-build/ubuntu - <<< "${Dockerfile}" ; then 53bbf7e092SCyril Bur echo "Failed to build docker container." 54bbf7e092SCyril Bur exit 1 55bbf7e092SCyril Burfi 56bbf7e092SCyril Bur 57bbf7e092SCyril Bur# Create the docker run script 58bbf7e092SCyril Burexport PROXY_HOST=${http_proxy/#http*:\/\/} 59bbf7e092SCyril Burexport PROXY_HOST=${PROXY_HOST/%:[0-9]*} 60bbf7e092SCyril Burexport PROXY_PORT=${http_proxy/#http*:\/\/*:} 61bbf7e092SCyril Bur 62*384d741bSPatrick Williamsmkdir -p "${WORKSPACE}" 63bbf7e092SCyril Bur 64bbf7e092SCyril Burcat > "${WORKSPACE}"/build.sh << EOF_SCRIPT 65bbf7e092SCyril Bur#!/bin/bash 66bbf7e092SCyril Bur 67c5243f0cSJoel Stanleyset -xe 68bbf7e092SCyril Bur 69bbf7e092SCyril Burcd ${WORKSPACE} 70bbf7e092SCyril Bur 71bbf7e092SCyril Bur# Go into the linux directory (the script will put us in a build subdir) 72bbf7e092SCyril Burcd linux 73bbf7e092SCyril Bur 74bbf7e092SCyril Bur# Record the version in the logs 75bbf7e092SCyril Burpowerpc64le-linux-gnu-gcc --version 76bbf7e092SCyril Bur 77bbf7e092SCyril Bur# Build kernel prep 78bbf7e092SCyril BurARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper 79bbf7e092SCyril Bur 80bbf7e092SCyril Bur# Generate the config 81bbf7e092SCyril Burecho "CONFIG_PPC_PSERIES=y" >> fragment.config 82bbf7e092SCyril Burecho "CONFIG_PPC_POWERNV=y" >> fragment.config 83bbf7e092SCyril Burecho "CONFIG_MTD=y" >> fragment.config 84bbf7e092SCyril Burecho "CONFIG_MTD_BLOCK=y" >> fragment.config 85bbf7e092SCyril Burecho "CONFIG_MTD_POWERNV_FLASH=y" >> fragment.config 86bbf7e092SCyril BurARCH=powerpc scripts/kconfig/merge_config.sh \ 87bbf7e092SCyril Bur arch/powerpc/configs/ppc64_defconfig \ 88bbf7e092SCyril Bur arch/powerpc/configs/le.config \ 89bbf7e092SCyril Bur fragment.config 90bbf7e092SCyril Bur 914ec31c66SJoel Stanley# Ensure config is up to date and no questions will be asked 924ec31c66SJoel Stanleyyes "" | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make oldconfig 934ec31c66SJoel Stanley 94bbf7e092SCyril Bur# Build kernel 954ec31c66SJoel StanleyARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) vmlinux 96bbf7e092SCyril Bur 97bbf7e092SCyril BurEOF_SCRIPT 98bbf7e092SCyril Bur 99*384d741bSPatrick Williamschmod a+x "${WORKSPACE}"/build.sh 100bbf7e092SCyril Bur 101bbf7e092SCyril Bur# Run the docker container, execute the build script we just built 102*384d741bSPatrick Williamsdocker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE="${WORKSPACE}" --user="${USER}" \ 103*384d741bSPatrick Williams -w "${WORKSPACE}" -v "${WORKSPACE}":"${WORKSPACE}" \ 104*384d741bSPatrick Williams -t trace-linux-build/ubuntu "${WORKSPACE}"/build.sh 105bbf7e092SCyril Bur 106bbf7e092SCyril Burresult=${?} 107bbf7e092SCyril Bur 108bbf7e092SCyril Bur# Timestamp for build 109bbf7e092SCyril Burecho "Build completed, $(date)" 110bbf7e092SCyril Bur 111bbf7e092SCyril Burexit ${result} 112