blob: d95480afcde2eb908e7684dc9718f9df938eb1ff [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
25RUN echo "deb http://au.archive.ubuntu.com/ubuntu/ xenial main" > \
26 /etc/apt/sources.list
27
28
29ENV DEBIAN_FRONTEND noninteractive
30RUN apt-get update && apt-get install -yy --no-install-recommends \
31 flex bison \
32 libpixman-1-dev \
33 libglib2.0-dev \
34 libfdt-dev \
35 make python-yaml gcc libc6-dev
36
37
38RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
39RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
40
41USER ${USER}
42ENV HOME ${HOME}
43RUN /bin/bash
44EOF
45)
46
47# Build the docker container
48docker build -t qemu-build/ubuntu - <<< "${Dockerfile}"
49if [[ "$?" -ne 0 ]]; then
50 echo "Failed to build docker container."
51 exit 1
52fi
53
54# Create the docker run script
55export PROXY_HOST=${http_proxy/#http*:\/\/}
56export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
57export PROXY_PORT=${http_proxy/#http*:\/\/*:}
58
59mkdir -p ${WORKSPACE}
60
61cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
62#!/bin/bash
63
64set -x
65
66cd ${WORKSPACE}
67
68gcc --version
69
70# Go into the source directory (the script will put us in a build subdir)
71cd qemu
72# disable anything that requires us to pull in X
73./configure --target-list=arm-softmmu \
74 --disable-spice --disable-docs --disable-gtk --disable-smartcard \
75 --disable-usb-redir --disable-libusb --disable-sdl --disable-gnutls \
76 --disable-vte --disable-vnc --disable-vnc-png
77make -j4
78
79EOF_SCRIPT
80
81chmod a+x ${WORKSPACE}/build.sh
82
83# Run the docker container, execute the build script we just built
84docker run --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
85 -w "${HOME}" -v "${HOME}":"${HOME}" -t qemu-build/ubuntu ${WORKSPACE}/build.sh