1#!/bin/bash 2 3set -e 4set -o xtrace 5 6export DEBIAN_FRONTEND=noninteractive 7 8check_minio() 9{ 10 MINIO_PATH="${MINIO_HOST}/mesa-lava/$1/${DISTRIBUTION_TAG}/${DEBIAN_ARCH}" 11 if wget -q --method=HEAD "https://${MINIO_PATH}/done"; then 12 exit 13 fi 14} 15 16# If remote files are up-to-date, skip rebuilding them 17check_minio "${FDO_UPSTREAM_REPO}" 18check_minio "${CI_PROJECT_PATH}" 19 20. .gitlab-ci/container/container_pre_build.sh 21 22# Install rust, which we'll be using for deqp-runner. It will be cleaned up at the end. 23. .gitlab-ci/container/build-rust.sh 24 25if [[ "$DEBIAN_ARCH" = "arm64" ]]; then 26 GCC_ARCH="aarch64-linux-gnu" 27 KERNEL_ARCH="arm64" 28 SKQP_ARCH="arm64" 29 DEFCONFIG="arch/arm64/configs/defconfig" 30 DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb" 31 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dtb" 32 DEVICE_TREES+=" arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb" 33 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb" 34 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8016-sbc.dtb" 35 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8096-db820c.dtb" 36 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dtb" 37 DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dtb" 38 DEVICE_TREES+=" arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dtb" 39 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-limozeen-nots-r5.dtb" 40 KERNEL_IMAGE_NAME="Image" 41 42elif [[ "$DEBIAN_ARCH" = "armhf" ]]; then 43 GCC_ARCH="arm-linux-gnueabihf" 44 KERNEL_ARCH="arm" 45 SKQP_ARCH="arm" 46 DEFCONFIG="arch/arm/configs/multi_v7_defconfig" 47 DEVICE_TREES="arch/arm/boot/dts/rk3288-veyron-jaq.dtb" 48 DEVICE_TREES+=" arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dtb" 49 DEVICE_TREES+=" arch/arm/boot/dts/imx6q-cubox-i.dtb" 50 KERNEL_IMAGE_NAME="zImage" 51 . .gitlab-ci/container/create-cross-file.sh armhf 52else 53 GCC_ARCH="x86_64-linux-gnu" 54 KERNEL_ARCH="x86_64" 55 SKQP_ARCH="x64" 56 DEFCONFIG="arch/x86/configs/x86_64_defconfig" 57 DEVICE_TREES="" 58 KERNEL_IMAGE_NAME="bzImage" 59 ARCH_PACKAGES="libasound2-dev libcap-dev libfdt-dev libva-dev wayland-protocols" 60fi 61 62# Determine if we're in a cross build. 63if [[ -e /cross_file-$DEBIAN_ARCH.txt ]]; then 64 EXTRA_MESON_ARGS="--cross-file /cross_file-$DEBIAN_ARCH.txt" 65 EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=/toolchain-$DEBIAN_ARCH.cmake" 66 67 if [ $DEBIAN_ARCH = arm64 ]; then 68 RUST_TARGET="aarch64-unknown-linux-gnu" 69 elif [ $DEBIAN_ARCH = armhf ]; then 70 RUST_TARGET="armv7-unknown-linux-gnueabihf" 71 fi 72 rustup target add $RUST_TARGET 73 export EXTRA_CARGO_ARGS="--target $RUST_TARGET" 74 75 export ARCH=${KERNEL_ARCH} 76 export CROSS_COMPILE="${GCC_ARCH}-" 77fi 78 79apt-get update 80apt-get install -y --no-remove \ 81 ${ARCH_PACKAGES} \ 82 automake \ 83 bc \ 84 clang \ 85 cmake \ 86 debootstrap \ 87 git \ 88 glslang-tools \ 89 libdrm-dev \ 90 libegl1-mesa-dev \ 91 libxext-dev \ 92 libfontconfig-dev \ 93 libgbm-dev \ 94 libgl-dev \ 95 libgles2-mesa-dev \ 96 libglu1-mesa-dev \ 97 libglx-dev \ 98 libpng-dev \ 99 libssl-dev \ 100 libudev-dev \ 101 libvulkan-dev \ 102 libwaffle-dev \ 103 libwayland-dev \ 104 libx11-xcb-dev \ 105 libxcb-dri2-0-dev \ 106 libxkbcommon-dev \ 107 ninja-build \ 108 patch \ 109 python-is-python3 \ 110 python3-distutils \ 111 python3-mako \ 112 python3-numpy \ 113 python3-serial \ 114 unzip \ 115 wget 116 117 118if [[ "$DEBIAN_ARCH" = "armhf" ]]; then 119 apt-get install -y --no-remove \ 120 libegl1-mesa-dev:armhf \ 121 libelf-dev:armhf \ 122 libgbm-dev:armhf \ 123 libgles2-mesa-dev:armhf \ 124 libpng-dev:armhf \ 125 libudev-dev:armhf \ 126 libvulkan-dev:armhf \ 127 libwaffle-dev:armhf \ 128 libwayland-dev:armhf \ 129 libx11-xcb-dev:armhf \ 130 libxkbcommon-dev:armhf 131fi 132 133 134############### Building 135STRIP_CMD="${GCC_ARCH}-strip" 136mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH 137 138 139############### Build apitrace 140. .gitlab-ci/container/build-apitrace.sh 141mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/apitrace 142mv /apitrace/build /lava-files/rootfs-${DEBIAN_ARCH}/apitrace 143rm -rf /apitrace 144 145 146############### Build dEQP runner 147. .gitlab-ci/container/build-deqp-runner.sh 148mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin 149mv /usr/local/bin/*-runner /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/. 150 151 152############### Build dEQP 153DEQP_TARGET=surfaceless . .gitlab-ci/container/build-deqp.sh 154 155mv /deqp /lava-files/rootfs-${DEBIAN_ARCH}/. 156 157 158############### Build SKQP 159if [[ "$DEBIAN_ARCH" = "arm64" ]] \ 160 || [[ "$DEBIAN_ARCH" = "amd64" ]]; then 161 . .gitlab-ci/container/build-skqp.sh 162 mv /skqp /lava-files/rootfs-${DEBIAN_ARCH}/. 163fi 164 165############### Build piglit 166PIGLIT_OPTS="-DPIGLIT_BUILD_DMA_BUF_TESTS=ON" . .gitlab-ci/container/build-piglit.sh 167mv /piglit /lava-files/rootfs-${DEBIAN_ARCH}/. 168 169############### Build libva tests 170if [[ "$DEBIAN_ARCH" = "amd64" ]]; then 171 . .gitlab-ci/container/build-va-tools.sh 172 mv /va/bin/* /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/ 173fi 174 175############### Build Crosvm 176if [[ ${DEBIAN_ARCH} = "amd64" ]]; then 177 . .gitlab-ci/container/build-crosvm.sh 178 mv /usr/local/bin/crosvm /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/ 179 mv /usr/local/lib/$GCC_ARCH/libvirglrenderer.* /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH/ 180fi 181 182############### Build libdrm 183EXTRA_MESON_ARGS+=" -D prefix=/libdrm" 184. .gitlab-ci/container/build-libdrm.sh 185 186 187############### Build local stuff for use by igt and kernel testing, which 188############### will reuse most of our container build process from a specific 189############### hash of the Mesa tree. 190if [[ -e ".gitlab-ci/local/build-rootfs.sh" ]]; then 191 . .gitlab-ci/local/build-rootfs.sh 192fi 193 194 195############### Build kernel 196. .gitlab-ci/container/build-kernel.sh 197 198############### Delete rust, since the tests won't be compiling anything. 199rm -rf /root/.cargo 200rm -rf /root/.rustup 201 202############### Create rootfs 203set +e 204if ! debootstrap \ 205 --variant=minbase \ 206 --arch=${DEBIAN_ARCH} \ 207 --components main,contrib,non-free \ 208 bullseye \ 209 /lava-files/rootfs-${DEBIAN_ARCH}/ \ 210 http://deb.debian.org/debian; then 211 cat /lava-files/rootfs-${DEBIAN_ARCH}/debootstrap/debootstrap.log 212 exit 1 213fi 214set -e 215 216cp .gitlab-ci/container/create-rootfs.sh /lava-files/rootfs-${DEBIAN_ARCH}/. 217cp .gitlab-ci/container/debian/llvm-snapshot.gpg.key /lava-files/rootfs-${DEBIAN_ARCH}/. 218chroot /lava-files/rootfs-${DEBIAN_ARCH} sh /create-rootfs.sh 219rm /lava-files/rootfs-${DEBIAN_ARCH}/llvm-snapshot.gpg.key 220rm /lava-files/rootfs-${DEBIAN_ARCH}/create-rootfs.sh 221 222 223############### Install the built libdrm 224# Dependencies pulled during the creation of the rootfs may overwrite 225# the built libdrm. Hence, we add it after the rootfs has been already 226# created. 227find /libdrm/ -name lib\*\.so\* | xargs cp -t /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH/. 228mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/libdrm/ 229cp -Rp /libdrm/share /lava-files/rootfs-${DEBIAN_ARCH}/libdrm/share 230rm -rf /libdrm 231 232 233if [ ${DEBIAN_ARCH} = arm64 ]; then 234 # Make a gzipped copy of the Image for db410c. 235 gzip -k /lava-files/Image 236 KERNEL_IMAGE_NAME+=" Image.gz" 237fi 238 239du -ah /lava-files/rootfs-${DEBIAN_ARCH} | sort -h | tail -100 240pushd /lava-files/rootfs-${DEBIAN_ARCH} 241 tar czf /lava-files/lava-rootfs.tgz . 242popd 243 244. .gitlab-ci/container/container_post_build.sh 245 246############### Upload the files! 247FILES_TO_UPLOAD="lava-rootfs.tgz \ 248 $KERNEL_IMAGE_NAME" 249 250if [[ -n $DEVICE_TREES ]]; then 251 FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)" 252fi 253 254for f in $FILES_TO_UPLOAD; do 255 ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \ 256 https://${MINIO_PATH}/$f 257done 258 259touch /lava-files/done 260ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/done https://${MINIO_PATH}/done 261