blob: a80d4e7ce0912ec1c0b1632f01a16612d080e887 [file] [log] [blame]
Joel Stanley0b851182016-06-21 23:51:19 +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}}
10http_proxy=${http_proxy:-}
11
12# Timestamp for job
13echo "Build started, $(date)"
14
15# Configure docker build
16if [[ -n "${http_proxy}" ]]; then
17PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
18fi
19
20Dockerfile=$(cat << EOF
21FROM ubuntu:16.04
22
23${PROXY}
24
Joel Stanley0b851182016-06-21 23:51:19 +093025ENV DEBIAN_FRONTEND noninteractive
26RUN apt-get update && apt-get install -yy --no-install-recommends \
27 flex bison \
28 libpixman-1-dev \
29 libglib2.0-dev \
30 libfdt-dev \
31 make python-yaml gcc libc6-dev
32
Joel Stanley0b851182016-06-21 23:51:19 +093033RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
34RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
35
36USER ${USER}
37ENV HOME ${HOME}
38RUN /bin/bash
39EOF
40)
41
42# Build the docker container
43docker build -t qemu-build/ubuntu - <<< "${Dockerfile}"
44if [[ "$?" -ne 0 ]]; then
45 echo "Failed to build docker container."
46 exit 1
47fi
48
49# Create the docker run script
50export PROXY_HOST=${http_proxy/#http*:\/\/}
51export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
52export PROXY_PORT=${http_proxy/#http*:\/\/*:}
53
54mkdir -p ${WORKSPACE}
55
56cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
57#!/bin/bash
58
59set -x
60
61cd ${WORKSPACE}
62
63gcc --version
64
65# Go into the source directory (the script will put us in a build subdir)
66cd qemu
67# disable anything that requires us to pull in X
68./configure --target-list=arm-softmmu \
69 --disable-spice --disable-docs --disable-gtk --disable-smartcard \
70 --disable-usb-redir --disable-libusb --disable-sdl --disable-gnutls \
71 --disable-vte --disable-vnc --disable-vnc-png
72make -j4
73
74EOF_SCRIPT
75
76chmod a+x ${WORKSPACE}/build.sh
77
78# Run the docker container, execute the build script we just built
79docker run --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
80 -w "${HOME}" -v "${HOME}":"${HOME}" -t qemu-build/ubuntu ${WORKSPACE}/build.sh