-
Notifications
You must be signed in to change notification settings - Fork 52
/
qemu-build.sh
executable file
·140 lines (119 loc) · 3.49 KB
/
qemu-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
###############################################################################
#
# This build script is for running the QEMU build in a container
#
# It expects to be run in with the qemu source present in the directory called
# '$WORKSPACE/qemu', where WORKSPACE is an environment variable.
#
# In Jenkins configure the git SCM 'Additional Behaviours', 'check-out to a sub
# directory' called 'qemu'.
#
# When building locally set WORKSPACE to be the directory above the qemu
# checkout:
# git clone https://github.com/qemu/qemu
# WORKSPACE=$PWD/qemu ~/openbmc-build-scripts/qemu-build.sh
#
###############################################################################
#
# Script Variables:
# http_proxy The HTTP address of the proxy server to connect to.
# Default: "", proxy is not setup if this is not set
# WORKSPACE Path of the workspace directory where the build will
# occur, and output artifacts will be produced.
# DOCKER_REG: <optional, the URL of a docker registry to utilize
# instead of our default (public.ecr.aws/ubuntu)
# (ex. docker.io)
#
###############################################################################
# Trace bash processing
#set -x
# Script Variables:
http_proxy=${http_proxy:-}
if [ -z ${WORKSPACE+x} ]; then
echo "Please set WORKSPACE variable"
exit 1
fi
docker_reg=${DOCKER_REG:-"public.ecr.aws/ubuntu"}
# Docker Image Build Variables:
img_name=qemu-build
# Timestamp for job
echo "Build started, $(date)"
# Setup Proxy
if [[ -n "${http_proxy}" ]]; then
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
# Create the docker run script
export PROXY_HOST=${http_proxy/#http*:\/\/}
export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
export PROXY_PORT=${http_proxy/#http*:\/\/*:}
cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
#!/bin/bash
set -x
# Go into the build directory
cd ${WORKSPACE}/qemu
gcc --version
git submodule update --init dtc
# disable anything that requires us to pull in X
./configure \
--target-list=arm-softmmu \
--disable-spice \
--disable-docs \
--disable-gtk \
--disable-smartcard \
--disable-usb-redir \
--disable-libusb \
--disable-sdl \
--disable-gnutls \
--disable-vte \
--disable-vnc \
--disable-werror
make clean
make -j4
EOF_SCRIPT
chmod a+x "${WORKSPACE}"/build.sh
# Configure docker build
# !!!
# Keep the base docker image in sync with the image under which we run the
# resulting qemu binary.
# !!!
Dockerfile=$(cat << EOF
FROM ${docker_reg}/ubuntu:jammy
${PROXY}
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy --no-install-recommends \
bison \
bzip2 \
ca-certificates \
flex \
gcc \
git \
libc6-dev \
libfdt-dev \
libglib2.0-dev \
libpixman-1-dev \
libslirp-dev \
make \
ninja-build \
python3-tomli \
python3-venv \
python3-yaml \
iputils-ping
RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
USER ${USER}
ENV HOME ${HOME}
EOF
)
if ! docker build -t ${img_name} - <<< "${Dockerfile}" ; then
echo "Failed to build docker container."
exit 1
fi
docker run \
--rm=true \
-e WORKSPACE="${WORKSPACE}" \
-w "${HOME}" \
--user="${USER}" \
-v "${HOME}":"${HOME}" \
-t ${img_name} \
"${WORKSPACE}"/build.sh