1#!/usr/bin/env bash 2# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime. 3# shellcheck disable=SC2034 # Variables are used in scripts called from here 4# shellcheck disable=SC2086 # we want word splitting 5# When changing this file, you need to bump the following 6# .gitlab-ci/image-tags.yml tags: 7# KERNEL_ROOTFS_TAG 8 9set -e 10set -o xtrace 11 12export DEBIAN_FRONTEND=noninteractive 13export LLVM_VERSION="${LLVM_VERSION:=15}" 14 15check_minio() 16{ 17 S3_PATH="${S3_HOST}/mesa-lava/$1/${DISTRIBUTION_TAG}/${DEBIAN_ARCH}" 18 if curl -L --retry 4 -f --retry-delay 60 -s -X HEAD \ 19 "https://${S3_PATH}/done"; then 20 echo "Remote files are up-to-date, skip rebuilding them." 21 exit 22 fi 23} 24 25check_minio "${FDO_UPSTREAM_REPO}" 26check_minio "${CI_PROJECT_PATH}" 27 28. .gitlab-ci/container/container_pre_build.sh 29 30# Install rust, which we'll be using for deqp-runner. It will be cleaned up at the end. 31. .gitlab-ci/container/build-rust.sh 32 33if [[ "$DEBIAN_ARCH" = "arm64" ]]; then 34 GCC_ARCH="aarch64-linux-gnu" 35 KERNEL_ARCH="arm64" 36 SKQP_ARCH="arm64" 37 DEFCONFIG="arch/arm64/configs/defconfig" 38 DEVICE_TREES="rk3399-gru-kevin.dtb" 39 DEVICE_TREES+=" meson-g12b-a311d-khadas-vim3.dtb" 40 DEVICE_TREES+=" meson-gxl-s805x-libretech-ac.dtb" 41 DEVICE_TREES+=" meson-gxm-khadas-vim2.dtb" 42 DEVICE_TREES+=" sun50i-h6-pine-h64.dtb" 43 DEVICE_TREES+=" imx8mq-nitrogen.dtb" 44 DEVICE_TREES+=" mt8192-asurada-spherion-r0.dtb" 45 DEVICE_TREES+=" mt8183-kukui-jacuzzi-juniper-sku16.dtb" 46 DEVICE_TREES+=" tegra210-p3450-0000.dtb" 47 DEVICE_TREES+=" apq8016-sbc.dtb" 48 DEVICE_TREES+=" apq8096-db820c.dtb" 49 DEVICE_TREES+=" sc7180-trogdor-lazor-limozeen-nots-r5.dtb" 50 DEVICE_TREES+=" sc7180-trogdor-kingoftown.dtb" 51 DEVICE_TREES+=" sm8350-hdk.dtb" 52 KERNEL_IMAGE_NAME="Image" 53 54elif [[ "$DEBIAN_ARCH" = "armhf" ]]; then 55 GCC_ARCH="arm-linux-gnueabihf" 56 KERNEL_ARCH="arm" 57 SKQP_ARCH="arm" 58 DEFCONFIG="arch/arm/configs/multi_v7_defconfig" 59 DEVICE_TREES="rk3288-veyron-jaq.dtb" 60 DEVICE_TREES+=" sun8i-h3-libretech-all-h3-cc.dtb" 61 DEVICE_TREES+=" imx6q-cubox-i.dtb" 62 DEVICE_TREES+=" tegra124-jetson-tk1.dtb" 63 KERNEL_IMAGE_NAME="zImage" 64 . .gitlab-ci/container/create-cross-file.sh armhf 65 CONTAINER_ARCH_PACKAGES=( 66 libegl1-mesa-dev:armhf 67 libelf-dev:armhf 68 libgbm-dev:armhf 69 libgles2-mesa-dev:armhf 70 libpng-dev:armhf 71 libudev-dev:armhf 72 libvulkan-dev:armhf 73 libwaffle-dev:armhf 74 libwayland-dev:armhf 75 libx11-xcb-dev:armhf 76 libxkbcommon-dev:armhf 77 ) 78else 79 GCC_ARCH="x86_64-linux-gnu" 80 KERNEL_ARCH="x86_64" 81 SKQP_ARCH="x64" 82 DEFCONFIG="arch/x86/configs/x86_64_defconfig" 83 DEVICE_TREES="" 84 KERNEL_IMAGE_NAME="bzImage" 85 CONTAINER_ARCH_PACKAGES=( 86 libasound2-dev libcap-dev libfdt-dev libva-dev wayland-protocols p7zip wine 87 ) 88fi 89 90# Determine if we're in a cross build. 91if [[ -e /cross_file-$DEBIAN_ARCH.txt ]]; then 92 EXTRA_MESON_ARGS="--cross-file /cross_file-$DEBIAN_ARCH.txt" 93 EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=/toolchain-$DEBIAN_ARCH.cmake" 94 95 if [ $DEBIAN_ARCH = arm64 ]; then 96 RUST_TARGET="aarch64-unknown-linux-gnu" 97 elif [ $DEBIAN_ARCH = armhf ]; then 98 RUST_TARGET="armv7-unknown-linux-gnueabihf" 99 fi 100 rustup target add $RUST_TARGET 101 export EXTRA_CARGO_ARGS="--target $RUST_TARGET" 102 103 export ARCH=${KERNEL_ARCH} 104 export CROSS_COMPILE="${GCC_ARCH}-" 105fi 106 107# no need to remove these at end, image isn't saved at the end 108CONTAINER_EPHEMERAL=( 109 automake 110 bc 111 "clang-${LLVM_VERSION}" 112 cmake 113 curl 114 mmdebstrap 115 git 116 glslang-tools 117 libdrm-dev 118 libegl1-mesa-dev 119 libxext-dev 120 libfontconfig-dev 121 libgbm-dev 122 libgl-dev 123 libgles2-mesa-dev 124 libglu1-mesa-dev 125 libglx-dev 126 libpng-dev 127 libssl-dev 128 libudev-dev 129 libvulkan-dev 130 libwaffle-dev 131 libwayland-dev 132 libx11-xcb-dev 133 libxcb-dri2-0-dev 134 libxkbcommon-dev 135 libwayland-dev 136 ninja-build 137 openssh-server 138 patch 139 protobuf-compiler 140 python-is-python3 141 python3-distutils 142 python3-mako 143 python3-numpy 144 python3-serial 145 python3-venv 146 unzip 147 zstd 148) 149 150echo "deb [trusted=yes] https://gitlab.freedesktop.org/gfx-ci/ci-deb-repo/-/raw/${PKG_REPO_REV}/ ${FDO_DISTRIBUTION_VERSION%-*} main" | tee /etc/apt/sources.list.d/gfx-ci_.list 151 152apt-get update 153apt-get install -y --no-remove \ 154 -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' \ 155 "${CONTAINER_EPHEMERAL[@]}" \ 156 "${CONTAINER_ARCH_PACKAGES[@]}" \ 157 ${EXTRA_LOCAL_PACKAGES} 158 159ROOTFS=/lava-files/rootfs-${DEBIAN_ARCH} 160mkdir -p "$ROOTFS" 161 162# rootfs packages 163PKG_BASE=( 164 tzdata mount 165) 166PKG_CI=( 167 firmware-realtek 168 bash ca-certificates curl 169 initramfs-tools jq netcat-openbsd dropbear openssh-server 170 libasan8 171 git 172 python3-dev python3-pip python3-setuptools python3-wheel 173 weston # Wayland 174 xinit xserver-xorg-core xwayland # X11 175) 176PKG_MESA_DEP=( 177 libdrm2 libsensors5 libexpat1 # common 178 libvulkan1 # vulkan 179 libx11-6 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrender1 libxshmfence1 libxxf86vm1 # X11 180) 181PKG_DEP=( 182 libpng16-16 183 libwaffle-1-0 184 libpython3.11 python3 python3-lxml python3-mako python3-numpy python3-packaging python3-pil python3-renderdoc python3-requests python3-simplejson python3-yaml # Python 185 sntp 186 strace 187 waffle-utils 188 zstd 189) 190# arch dependent rootfs packages 191[ "$DEBIAN_ARCH" = "arm64" ] && PKG_ARCH=( 192 libgl1 libglu1-mesa 193 libvulkan-dev 194 firmware-linux-nonfree firmware-qcom-media 195 libfontconfig1 196) 197[ "$DEBIAN_ARCH" = "amd64" ] && PKG_ARCH=( 198 firmware-amd-graphics 199 firmware-misc-nonfree 200 libgl1 libglu1-mesa 201 inetutils-syslogd iptables libcap2 202 libfontconfig1 203 spirv-tools 204 libelf1 libfdt1 "libllvm${LLVM_VERSION}" 205 libva2 libva-drm2 206 libvulkan-dev 207 socat 208 sysvinit-core 209 wine 210) 211[ "$DEBIAN_ARCH" = "armhf" ] && PKG_ARCH=( 212 firmware-misc-nonfree 213) 214 215mmdebstrap \ 216 --variant=apt \ 217 --arch="${DEBIAN_ARCH}" \ 218 --components main,contrib,non-free-firmware \ 219 --include "${PKG_BASE[*]} ${PKG_CI[*]} ${PKG_DEP[*]} ${PKG_MESA_DEP[*]} ${PKG_ARCH[*]}" \ 220 bookworm \ 221 "$ROOTFS/" \ 222 "http://deb.debian.org/debian" \ 223 "deb [trusted=yes] https://gitlab.freedesktop.org/gfx-ci/ci-deb-repo/-/raw/${PKG_REPO_REV}/ ${FDO_DISTRIBUTION_VERSION%-*} main" 224 225############### Install mold 226. .gitlab-ci/container/build-mold.sh 227 228############### Setuping 229if [ "$DEBIAN_ARCH" = "amd64" ]; then 230 . .gitlab-ci/container/setup-wine.sh "/dxvk-wine64" 231 . .gitlab-ci/container/install-wine-dxvk.sh 232 mv /dxvk-wine64 $ROOTFS 233fi 234 235############### Installing 236if [ "$DEBIAN_ARCH" = "amd64" ]; then 237 . .gitlab-ci/container/install-wine-apitrace.sh 238 mkdir -p "$ROOTFS/apitrace-msvc-win64" 239 mv /apitrace-msvc-win64/bin "$ROOTFS/apitrace-msvc-win64" 240 rm -rf /apitrace-msvc-win64 241fi 242 243############### Building 244STRIP_CMD="${GCC_ARCH}-strip" 245mkdir -p $ROOTFS/usr/lib/$GCC_ARCH 246 247############### Build Vulkan validation layer (for zink) 248if [ "$DEBIAN_ARCH" = "amd64" ]; then 249 . .gitlab-ci/container/build-vulkan-validation.sh 250 mv /usr/lib/x86_64-linux-gnu/libVkLayer_khronos_validation.so $ROOTFS/usr/lib/x86_64-linux-gnu/ 251 mkdir -p $ROOTFS/usr/share/vulkan/explicit_layer.d 252 mv /usr/share/vulkan/explicit_layer.d/* $ROOTFS/usr/share/vulkan/explicit_layer.d/ 253fi 254 255############### Build apitrace 256. .gitlab-ci/container/build-apitrace.sh 257mkdir -p $ROOTFS/apitrace 258mv /apitrace/build $ROOTFS/apitrace 259rm -rf /apitrace 260 261############### Build ANGLE 262if [[ "$DEBIAN_ARCH" = "amd64" ]]; then 263 . .gitlab-ci/container/build-angle.sh 264 mv /angle /lava-files/rootfs-${DEBIAN_ARCH}/. 265 rm -rf /angle 266fi 267 268############### Build dEQP runner 269. .gitlab-ci/container/build-deqp-runner.sh 270mkdir -p $ROOTFS/usr/bin 271mv /usr/local/bin/*-runner $ROOTFS/usr/bin/. 272 273 274############### Build dEQP 275DEQP_API=GL \ 276DEQP_TARGET=surfaceless \ 277. .gitlab-ci/container/build-deqp.sh 278 279DEQP_API=VK \ 280DEQP_TARGET=default \ 281. .gitlab-ci/container/build-deqp.sh 282 283mv /deqp $ROOTFS/. 284 285 286############### Build SKQP 287if [[ "$DEBIAN_ARCH" = "arm64" ]] \ 288 || [[ "$DEBIAN_ARCH" = "amd64" ]]; then 289 . .gitlab-ci/container/build-skqp.sh 290 mv /skqp $ROOTFS/. 291fi 292 293############### Build piglit 294PIGLIT_OPTS="-DPIGLIT_BUILD_DMA_BUF_TESTS=ON -DPIGLIT_BUILD_GLX_TESTS=ON" . .gitlab-ci/container/build-piglit.sh 295mv /piglit $ROOTFS/. 296 297############### Build libva tests 298if [[ "$DEBIAN_ARCH" = "amd64" ]]; then 299 . .gitlab-ci/container/build-va-tools.sh 300 mv /va/bin/* $ROOTFS/usr/bin/ 301fi 302 303############### Build Crosvm 304if [[ ${DEBIAN_ARCH} = "amd64" ]]; then 305 . .gitlab-ci/container/build-crosvm.sh 306 mv /usr/local/bin/crosvm $ROOTFS/usr/bin/ 307 mv /usr/local/lib/libvirglrenderer.* $ROOTFS/usr/lib/$GCC_ARCH/ 308 mkdir -p $ROOTFS/usr/local/libexec/ 309 mv /usr/local/libexec/virgl* $ROOTFS/usr/local/libexec/ 310fi 311 312############### Build ci-kdl 313section_start kdl "Prepare a venv for kdl" 314. .gitlab-ci/container/build-kdl.sh 315mv ci-kdl.venv $ROOTFS 316section_end kdl 317 318############### Build local stuff for use by igt and kernel testing, which 319############### will reuse most of our container build process from a specific 320############### hash of the Mesa tree. 321if [[ -e ".gitlab-ci/local/build-rootfs.sh" ]]; then 322 . .gitlab-ci/local/build-rootfs.sh 323fi 324 325 326############### Build kernel 327. .gitlab-ci/container/build-kernel.sh 328 329############### Delete rust, since the tests won't be compiling anything. 330rm -rf /root/.cargo 331rm -rf /root/.rustup 332 333############### Delete firmware files we don't need 334if [ "$DEBIAN_ARCH" = "amd64" ]; then 335 dpkg -L firmware-misc-nonfree | grep -v "i915" | xargs rm || true 336fi 337 338############### Fill rootfs 339cp .gitlab-ci/container/setup-rootfs.sh $ROOTFS/. 340cp .gitlab-ci/container/strip-rootfs.sh $ROOTFS/. 341cp .gitlab-ci/container/debian/llvm-snapshot.gpg.key $ROOTFS/. 342cp .gitlab-ci/container/debian/winehq.gpg.key $ROOTFS/. 343chroot $ROOTFS bash /setup-rootfs.sh 344rm $ROOTFS/{llvm-snapshot,winehq}.gpg.key 345rm "$ROOTFS/setup-rootfs.sh" 346rm "$ROOTFS/strip-rootfs.sh" 347cp /etc/wgetrc $ROOTFS/etc/. 348 349if [ "${DEBIAN_ARCH}" = "arm64" ]; then 350 mkdir -p /lava-files/rootfs-arm64/lib/firmware/qcom/sm8350/ # for firmware imported later 351 # Make a gzipped copy of the Image for db410c. 352 gzip -k /lava-files/Image 353 KERNEL_IMAGE_NAME+=" Image.gz" 354fi 355 356ROOTFSTAR="lava-rootfs.tar.zst" 357du -ah "$ROOTFS" | sort -h | tail -100 358pushd $ROOTFS 359 tar --zstd -cf /lava-files/${ROOTFSTAR} . 360popd 361 362. .gitlab-ci/container/container_post_build.sh 363 364ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/"${ROOTFSTAR}" \ 365 https://${S3_PATH}/"${ROOTFSTAR}" 366 367touch /lava-files/done 368ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/done https://${S3_PATH}/done 369