blob: b8917a093b87b51a2b2b66a5915ef5ec9c4a7306 [file] [log] [blame]
#!/bin/bash
# This build script is for running the Jenkins builds using docker.
# Trace bash processing
set -x
# Default variables
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
BOARD_DEFCONFIG=${BOARD_DEFCONFIG:-ast_g5_defconfig}
http_proxy=${http_proxy:-}
# Timestamp for job
echo "Build started, $(date)"
# Configure docker build
if [[ -n "${http_proxy}" ]]; then
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
Dockerfile=$(cat << EOF
FROM ubuntu:16.04
${PROXY}
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy \
make bc gcc gcc-arm-linux-gnueabi
RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
# Build the docker container
if ! docker build -t u-boot-build/ubuntu - <<< "${Dockerfile}" ; then
echo "Failed to build docker container."
exit 1
fi
# Create the docker run script
export PROXY_HOST=${http_proxy/#http*:\/\/}
export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
export PROXY_PORT=${http_proxy/#http*:\/\/*:}
mkdir -p "${WORKSPACE}"
cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
#!/bin/bash
set -x
cd "${WORKSPACE}"
gcc --version
arm-linux-gnueabi-gcc --version
# Go into the source directory (the script will put us in a build subdir)
cd u-boot
CROSS_COMPILE=arm-linux-gnueabi- make ${BOARD_DEFCONFIG}
CROSS_COMPILE=arm-linux-gnueabi- make
EOF_SCRIPT
chmod a+x "${WORKSPACE}"/build.sh
# Run the docker container, execute the build script we just built
docker run --rm=true -e WORKSPACE="${WORKSPACE}" --user="${USER}" \
-w "${HOME}" -v "${HOME}":"${HOME}" -t u-boot-build/ubuntu \
"${WORKSPACE}"/build.sh