blob: 6fc61b762d8688a4f333319a057b80f40ea35b98 [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
74./configure --target-list=arm-softmmu \
75 --disable-spice --disable-docs --disable-gtk --disable-smartcard \
76 --disable-usb-redir --disable-libusb --disable-sdl --disable-gnutls \
77 --disable-vte --disable-vnc --disable-vnc-png
78make -j4
79
80EOF_SCRIPT
81
82chmod a+x ${WORKSPACE}/build.sh
83
84# Run the docker container, execute the build script we just built
85docker run --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
86 -w "${HOME}" -v "${HOME}":"${HOME}" -t qemu-build/ubuntu ${WORKSPACE}/build.sh