gitlab-ci: Add Debian testing repository for x86_build image
[mesa.git] / .gitlab-ci / container / x86_build.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 export DEBIAN_FRONTEND=noninteractive
7
8 CROSS_ARCHITECTURES="i386 ppc64el s390x"
9 for arch in $CROSS_ARCHITECTURES; do
10 dpkg --add-architecture $arch
11 done
12
13 apt-get install -y \
14 ca-certificates \
15 gnupg \
16 unzip \
17 wget
18
19 # Upstream LLVM package repository
20 apt-key add .gitlab-ci/container/llvm-snapshot.gpg.key
21 echo "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-9 main" >/etc/apt/sources.list.d/llvm9.list
22
23 # Upstream Wine (WineHQ) package repository. We use the OBS service
24 # instead of the repository at the winehq.org domain because:
25 #
26 # " The WineHQ packages for Debian 10 and later require libfaudio0
27 # as a dependency. Since the distro does not provide it for Debian
28 # 10, users of that version can download libfaudio0 packages from
29 # the OBS. See https://forum.winehq.org/viewtopic.php?f=8&t=32192
30 # for details."
31 #
32 # As explained at https://wiki.winehq.org/Debian
33 apt-key add .gitlab-ci/container/obs-emulators-wine-debian.gpg.key
34 echo 'deb https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/Debian_10/ ./' >/etc/apt/sources.list.d/obs-emulators-wine-debian.list
35
36 sed -i -e 's/http:\/\/deb/https:\/\/deb/g' /etc/apt/sources.list
37 echo 'deb https://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list
38 echo 'deb https://deb.debian.org/debian testing main' >/etc/apt/sources.list.d/testing.list
39
40 apt-get update
41
42 # Don't use newer packages from testing by default
43 cat >/etc/apt/preferences <<EOF
44 Package: *
45 Pin: release a=testing
46 Pin-Priority: 100
47 EOF
48
49 apt-get dist-upgrade -y
50
51 apt-get install -y --no-remove \
52 autoconf \
53 automake \
54 autotools-dev \
55 bison \
56 ccache \
57 clang-9 \
58 cmake \
59 flex \
60 g++ \
61 gcc \
62 gettext \
63 git \
64 libclang-6.0-dev \
65 libclang-7-dev \
66 libclang-9-dev \
67 libclc-dev \
68 libelf-dev \
69 libepoxy-dev \
70 libexpat1-dev \
71 libgbm-dev \
72 libgtk-3-dev \
73 libomxil-bellagio-dev \
74 libpciaccess-dev \
75 libtool \
76 libunwind-dev \
77 libva-dev \
78 libvdpau-dev \
79 libvulkan-dev \
80 libvulkan-dev:ppc64el \
81 libx11-dev \
82 libx11-xcb-dev \
83 libxdamage-dev \
84 libxext-dev \
85 libxml2-utils \
86 libxrandr-dev \
87 libxrender-dev \
88 libxshmfence-dev \
89 libxvmc-dev \
90 libxxf86vm-dev \
91 llvm-6.0-dev \
92 llvm-7-dev \
93 llvm-9-dev \
94 meson \
95 pkg-config \
96 python-mako \
97 python3-mako \
98 python3-pil \
99 python3-requests \
100 qemu-user \
101 scons \
102 x11proto-dri2-dev \
103 x11proto-gl-dev \
104 x11proto-randr-dev \
105 xz-utils \
106 zlib1g-dev
107
108 apt-get install -y --no-remove -t buster-backports \
109 libclang-8-dev
110
111 # Cross-build Mesa deps
112 for arch in $CROSS_ARCHITECTURES; do
113 apt-get install -y --no-remove \
114 crossbuild-essential-${arch} \
115 libdrm-dev:${arch} \
116 libelf-dev:${arch} \
117 libexpat1-dev:${arch} \
118 libffi-dev:${arch} \
119 libstdc++6:${arch} \
120 libtinfo-dev:${arch}
121
122 apt-get install -y --no-remove -t buster-backports \
123 libllvm8:${arch}
124
125 if [ "$arch" == "i386" ]; then
126 # libpciaccess-dev is only needed for Intel.
127 apt-get install -y --no-remove \
128 libpciaccess-dev:${arch}
129 fi
130
131 mkdir /var/cache/apt/archives/${arch}
132 # Download llvm-* packages, but don't install them yet, since they can
133 # only be installed for one architecture at a time
134 apt-get install -o Dir::Cache::archives=/var/cache/apt/archives/$arch --download-only \
135 -y --no-remove -t buster-backports \
136 llvm-8-dev:${arch}
137 done
138
139 apt-get install -y --no-remove -t buster-backports \
140 llvm-8-dev \
141
142 # for 64bit windows cross-builds
143 apt-get install -y --no-remove \
144 libz-mingw-w64-dev \
145 mingw-w64 \
146 winehq-stable
147
148
149 . .gitlab-ci/container/container_pre_build.sh
150
151
152 # Debian's pkg-config wrapers for mingw are broken, and there's no sign that
153 # they're going to be fixed, so we'll just have to fix it ourselves
154 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
155 cat >/usr/local/bin/x86_64-w64-mingw32-pkg-config <<EOF
156 #!/bin/sh
157
158 PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig pkg-config \$@
159 EOF
160 chmod +x /usr/local/bin/x86_64-w64-mingw32-pkg-config
161
162
163 # Generate cross build files for Meson
164 for arch in $CROSS_ARCHITECTURES; do
165 cross_file="/cross_file-$arch.txt"
166 /usr/share/meson/debcrossgen --arch "$arch" -o "$cross_file"
167 # Explicitly set ccache path for cross compilers
168 sed -i "s|/usr/bin/\([^-]*\)-linux-gnu\([^-]*\)-g|/usr/lib/ccache/\\1-linux-gnu\\2-g|g" "$cross_file"
169 if [ "$arch" = "i386" ]; then
170 # Work around a bug in debcrossgen that should be fixed in the next release
171 sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" "$cross_file"
172 fi
173
174 # Rely on qemu-user being configured in binfmt_misc on the host
175 sed -i -e '/\[properties\]/a\' -e "needs_exe_wrapper = False" "$cross_file"
176 done
177
178
179 # for the vulkan overlay layer
180 wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
181 unzip glslang-master-linux-Release.zip bin/glslangValidator
182 install -m755 bin/glslangValidator /usr/local/bin/
183 rm bin/glslangValidator glslang-master-linux-Release.zip
184
185
186 # dependencies where we want a specific version
187 export XORG_RELEASES=https://xorg.freedesktop.org/releases/individual
188 export XCB_RELEASES=https://xcb.freedesktop.org/dist
189 export WAYLAND_RELEASES=https://wayland.freedesktop.org/releases
190
191 export XORGMACROS_VERSION=util-macros-1.19.0
192 export LIBDRM_VERSION=libdrm-2.4.100
193 export XCBPROTO_VERSION=xcb-proto-1.13
194 export LIBXCB_VERSION=libxcb-1.13
195 export LIBWAYLAND_VERSION=wayland-1.15.0
196 export WAYLAND_PROTOCOLS_VERSION=wayland-protocols-1.12
197
198 wget $XORG_RELEASES/util/$XORGMACROS_VERSION.tar.bz2
199 tar -xvf $XORGMACROS_VERSION.tar.bz2 && rm $XORGMACROS_VERSION.tar.bz2
200 cd $XORGMACROS_VERSION; ./configure; make install; cd ..
201 rm -rf $XORGMACROS_VERSION
202
203 wget $XCB_RELEASES/$XCBPROTO_VERSION.tar.bz2
204 tar -xvf $XCBPROTO_VERSION.tar.bz2 && rm $XCBPROTO_VERSION.tar.bz2
205 cd $XCBPROTO_VERSION; ./configure; make install; cd ..
206 rm -rf $XCBPROTO_VERSION
207
208 wget $XCB_RELEASES/$LIBXCB_VERSION.tar.bz2
209 tar -xvf $LIBXCB_VERSION.tar.bz2 && rm $LIBXCB_VERSION.tar.bz2
210 cd $LIBXCB_VERSION; ./configure; make install; cd ..
211 rm -rf $LIBXCB_VERSION
212
213 wget https://dri.freedesktop.org/libdrm/$LIBDRM_VERSION.tar.bz2
214 tar -xvf $LIBDRM_VERSION.tar.bz2 && rm $LIBDRM_VERSION.tar.bz2
215 cd $LIBDRM_VERSION
216 meson build -D vc4=true -D freedreno=true -D etnaviv=true -D libdir=lib/x86_64-linux-gnu; ninja -C build install
217 rm -rf build; meson --cross-file=/cross_file-ppc64el.txt build -D libdir=lib/powerpc64le-linux-gnu; ninja -C build install
218 rm -rf build; meson --cross-file=/cross_file-i386.txt build -D libdir=lib/i386-linux-gnu; ninja -C build install
219 cd ..
220 rm -rf $LIBDRM_VERSION
221
222 wget $WAYLAND_RELEASES/$LIBWAYLAND_VERSION.tar.xz
223 tar -xvf $LIBWAYLAND_VERSION.tar.xz && rm $LIBWAYLAND_VERSION.tar.xz
224 cd $LIBWAYLAND_VERSION; ./configure --enable-libraries --without-host-scanner --disable-documentation --disable-dtd-validation; make install; cd ..
225 rm -rf $LIBWAYLAND_VERSION
226
227 wget $WAYLAND_RELEASES/$WAYLAND_PROTOCOLS_VERSION.tar.xz
228 tar -xvf $WAYLAND_PROTOCOLS_VERSION.tar.xz && rm $WAYLAND_PROTOCOLS_VERSION.tar.xz
229 cd $WAYLAND_PROTOCOLS_VERSION; ./configure; make install; cd ..
230 rm -rf $WAYLAND_PROTOCOLS_VERSION
231
232
233 # The version of libglvnd-dev in debian is too old
234 # Check this page to see when this local compilation can be dropped in favour of the package:
235 # https://packages.debian.org/libglvnd-dev
236 GLVND_VERSION=1.2.0
237 wget https://gitlab.freedesktop.org/glvnd/libglvnd/-/archive/v$GLVND_VERSION/libglvnd-v$GLVND_VERSION.tar.gz
238 tar -xvf libglvnd-v$GLVND_VERSION.tar.gz && rm libglvnd-v$GLVND_VERSION.tar.gz
239 pushd libglvnd-v$GLVND_VERSION; ./autogen.sh; ./configure; make install; popd
240 rm -rf libglvnd-v$GLVND_VERSION
241
242
243 pushd /usr/local
244 git clone https://gitlab.freedesktop.org/mesa/shader-db.git --depth 1
245 rm -rf shader-db/.git
246 cd shader-db
247 make
248 popd
249
250
251 ############### Uninstall the build software
252
253 apt-get purge -y \
254 autoconf \
255 automake \
256 autotools-dev \
257 cmake \
258 git \
259 gnupg \
260 libgbm-dev \
261 libtool \
262 unzip \
263 wget
264
265 . .gitlab-ci/container/container_post_build.sh