blob: 9c9dee62cfea7305f1ffd2e81e763e38ccd119a0 [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 \
Alanny Lopez13596132017-06-15 11:26:18 -050027 bison \
28 flex \
29 gcc \
30 git \
31 libc6-dev \
32 libfdt-dev \
33 libglib2.0-dev \
34 libpixman-1-dev \
35 make \
36 python-yaml \
37 python3-yaml
Joel Stanley0b851182016-06-21 23:51:19 +093038
Joel Stanley0b851182016-06-21 23:51:19 +093039RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
40RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
41
42USER ${USER}
43ENV HOME ${HOME}
44RUN /bin/bash
45EOF
46)
47
48# Build the docker container
49docker build -t qemu-build/ubuntu - <<< "${Dockerfile}"
50if [[ "$?" -ne 0 ]]; then
51 echo "Failed to build docker container."
52 exit 1
53fi
54
55# Create the docker run script
56export PROXY_HOST=${http_proxy/#http*:\/\/}
57export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
58export PROXY_PORT=${http_proxy/#http*:\/\/*:}
59
60mkdir -p ${WORKSPACE}
61
62cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
63#!/bin/bash
64
65set -x
66
67cd ${WORKSPACE}
68
69gcc --version
70
71# Go into the source directory (the script will put us in a build subdir)
72cd qemu
73# disable anything that requires us to pull in X
Alanny Lopeze30237c2017-06-15 13:27:47 -050074./configure \
75 --target-list=arm-softmmu \
76 --disable-spice \
77 --disable-docs \
78 --disable-gtk \
79 --disable-smartcard \
80 --disable-usb-redir \
81 --disable-libusb \
82 --disable-sdl \
83 --disable-gnutls \
84 --disable-vte \
85 --disable-vnc \
86 --disable-vnc-png
Joel Stanley0b851182016-06-21 23:51:19 +093087make -j4
88
89EOF_SCRIPT
90
91chmod a+x ${WORKSPACE}/build.sh
92
93# Run the docker container, execute the build script we just built
Alanny Lopeze30237c2017-06-15 13:27:47 -050094docker run \
95 --rm=true \
96 -e WORKSPACE=${WORKSPACE} \
97 -w "${HOME}" \
98 -v "${HOME}":"${HOME}" \
99 -t qemu-build/ubuntu \
100 ${WORKSPACE}/build.sh