blob: 79f72389f420979b65617b95b91a1d3fd14b877b [file] [log] [blame]
Joel Stanleybe53a682016-06-21 23:38:56 +09301#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4
5# Trace bash processing
6set -x
7
8# Default variables
9WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
10BOARD_DEFCONFIG=${BOARD_DEFCONFIG:-ast_g5_defconfig}
11http_proxy=${http_proxy:-}
12
13# Timestamp for job
14echo "Build started, $(date)"
15
16# Configure docker build
17if [[ -n "${http_proxy}" ]]; then
18PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
19fi
20
21Dockerfile=$(cat << EOF
22FROM ubuntu:16.04
23
24${PROXY}
25
26ENV DEBIAN_FRONTEND noninteractive
27RUN apt-get update && apt-get install -yy \
28 make bc gcc gcc-arm-linux-gnueabi
29
30RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
31RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
32
33USER ${USER}
34ENV HOME ${HOME}
35RUN /bin/bash
36EOF
37)
38
39# Build the docker container
40docker build -t u-boot-build/ubuntu - <<< "${Dockerfile}"
41if [[ "$?" -ne 0 ]]; then
42 echo "Failed to build docker container."
43 exit 1
44fi
45
46# Create the docker run script
47export PROXY_HOST=${http_proxy/#http*:\/\/}
48export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
49export PROXY_PORT=${http_proxy/#http*:\/\/*:}
50
51mkdir -p ${WORKSPACE}
52
53cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
54#!/bin/bash
55
56set -x
57
58cd ${WORKSPACE}
59
60gcc --version
61arm-linux-gnueabi-gcc --version
62
63# Go into the source directory (the script will put us in a build subdir)
64cd u-boot
65CROSS_COMPILE=arm-linux-gnueabi- make ${BOARD_DEFCONFIG}
66CROSS_COMPILE=arm-linux-gnueabi- make
67
68EOF_SCRIPT
69
70chmod a+x ${WORKSPACE}/build.sh
71
72# Run the docker container, execute the build script we just built
73docker run --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
74 -w "${HOME}" -v "${HOME}":"${HOME}" -t u-boot-build/ubuntu ${WORKSPACE}/build.sh