Joel Stanley | 0b85118 | 2016-06-21 23:51:19 +0930 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # This build script is for running the Jenkins builds using docker. |
| 4 | |
| 5 | # Trace bash processing |
| 6 | set -x |
| 7 | |
| 8 | # Default variables |
| 9 | WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}} |
| 10 | http_proxy=${http_proxy:-} |
| 11 | |
| 12 | # Timestamp for job |
| 13 | echo "Build started, $(date)" |
| 14 | |
| 15 | # Configure docker build |
| 16 | if [[ -n "${http_proxy}" ]]; then |
| 17 | PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy" |
| 18 | fi |
| 19 | |
| 20 | Dockerfile=$(cat << EOF |
| 21 | FROM ubuntu:16.04 |
| 22 | |
| 23 | ${PROXY} |
| 24 | |
Joel Stanley | 0b85118 | 2016-06-21 23:51:19 +0930 | [diff] [blame] | 25 | ENV DEBIAN_FRONTEND noninteractive |
| 26 | RUN apt-get update && apt-get install -yy --no-install-recommends \ |
Alanny Lopez | 1359613 | 2017-06-15 11:26:18 -0500 | [diff] [blame] | 27 | 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 Stanley | 0b85118 | 2016-06-21 23:51:19 +0930 | [diff] [blame] | 38 | |
Joel Stanley | 0b85118 | 2016-06-21 23:51:19 +0930 | [diff] [blame] | 39 | RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER} |
| 40 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER} |
| 41 | |
| 42 | USER ${USER} |
| 43 | ENV HOME ${HOME} |
| 44 | RUN /bin/bash |
| 45 | EOF |
| 46 | ) |
| 47 | |
| 48 | # Build the docker container |
| 49 | docker build -t qemu-build/ubuntu - <<< "${Dockerfile}" |
| 50 | if [[ "$?" -ne 0 ]]; then |
| 51 | echo "Failed to build docker container." |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | # Create the docker run script |
| 56 | export PROXY_HOST=${http_proxy/#http*:\/\/} |
| 57 | export PROXY_HOST=${PROXY_HOST/%:[0-9]*} |
| 58 | export PROXY_PORT=${http_proxy/#http*:\/\/*:} |
| 59 | |
| 60 | mkdir -p ${WORKSPACE} |
| 61 | |
| 62 | cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT |
| 63 | #!/bin/bash |
| 64 | |
| 65 | set -x |
| 66 | |
| 67 | cd ${WORKSPACE} |
| 68 | |
| 69 | gcc --version |
| 70 | |
| 71 | # Go into the source directory (the script will put us in a build subdir) |
| 72 | cd qemu |
| 73 | # disable anything that requires us to pull in X |
Alanny Lopez | e30237c | 2017-06-15 13:27:47 -0500 | [diff] [blame^] | 74 | ./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 Stanley | 0b85118 | 2016-06-21 23:51:19 +0930 | [diff] [blame] | 87 | make -j4 |
| 88 | |
| 89 | EOF_SCRIPT |
| 90 | |
| 91 | chmod a+x ${WORKSPACE}/build.sh |
| 92 | |
| 93 | # Run the docker container, execute the build script we just built |
Alanny Lopez | e30237c | 2017-06-15 13:27:47 -0500 | [diff] [blame^] | 94 | docker run \ |
| 95 | --rm=true \ |
| 96 | -e WORKSPACE=${WORKSPACE} \ |
| 97 | -w "${HOME}" \ |
| 98 | -v "${HOME}":"${HOME}" \ |
| 99 | -t qemu-build/ubuntu \ |
| 100 | ${WORKSPACE}/build.sh |