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 DEFCONFIG="arch/arm64/configs/defconfig" 29 DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb" 30 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dtb" 31 DEVICE_TREES+=" arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb" 32 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb" 33 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8016-sbc.dtb" 34 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8096-db820c.dtb" 35 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dtb" 36 DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dtb" 37 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-limozeen-nots.dtb" 38 KERNEL_IMAGE_NAME="Image" 39elif [[ "$DEBIAN_ARCH" = "armhf" ]]; then 40 GCC_ARCH="arm-linux-gnueabihf" 41 KERNEL_ARCH="arm" 42 DEFCONFIG="arch/arm/configs/multi_v7_defconfig" 43 DEVICE_TREES="arch/arm/boot/dts/rk3288-veyron-jaq.dtb" 44 DEVICE_TREES+=" arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dtb" 45 DEVICE_TREES+=" arch/arm/boot/dts/imx6q-cubox-i.dtb" 46 KERNEL_IMAGE_NAME="zImage" 47 . .gitlab-ci/container/create-cross-file.sh armhf 48else 49 GCC_ARCH="x86_64-linux-gnu" 50 KERNEL_ARCH="x86_64" 51 DEFCONFIG="arch/x86/configs/x86_64_defconfig" 52 DEVICE_TREES="" 53 KERNEL_IMAGE_NAME="bzImage" 54 ARCH_PACKAGES="libva-dev" 55fi 56 57# Determine if we're in a cross build. 58if [[ -e /cross_file-$DEBIAN_ARCH.txt ]]; then 59 EXTRA_MESON_ARGS="--cross-file /cross_file-$DEBIAN_ARCH.txt" 60 EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=/toolchain-$DEBIAN_ARCH.cmake" 61 62 if [ $DEBIAN_ARCH = arm64 ]; then 63 RUST_TARGET="aarch64-unknown-linux-gnu" 64 elif [ $DEBIAN_ARCH = armhf ]; then 65 RUST_TARGET="armv7-unknown-linux-gnueabihf" 66 fi 67 rustup target add $RUST_TARGET 68 export EXTRA_CARGO_ARGS="--target $RUST_TARGET" 69 70 export ARCH=${KERNEL_ARCH} 71 export CROSS_COMPILE="${GCC_ARCH}-" 72fi 73 74apt-get update 75apt-get install -y --no-remove \ 76 ${ARCH_PACKAGES} \ 77 automake \ 78 bc \ 79 cmake \ 80 debootstrap \ 81 git \ 82 glslang-tools \ 83 libdrm-dev \ 84 libegl1-mesa-dev \ 85 libgbm-dev \ 86 libgles2-mesa-dev \ 87 libpng-dev \ 88 libssl-dev \ 89 libudev-dev \ 90 libvulkan-dev \ 91 libwaffle-dev \ 92 libwayland-dev \ 93 libx11-xcb-dev \ 94 libxcb-dri2-0-dev \ 95 libxkbcommon-dev \ 96 patch \ 97 python3-distutils \ 98 python3-mako \ 99 python3-numpy \ 100 python3-serial \ 101 wget 102 103 104if [[ "$DEBIAN_ARCH" = "armhf" ]]; then 105 apt-get install -y --no-remove \ 106 libegl1-mesa-dev:armhf \ 107 libelf-dev:armhf \ 108 libgbm-dev:armhf \ 109 libgles2-mesa-dev:armhf \ 110 libpng-dev:armhf \ 111 libudev-dev:armhf \ 112 libvulkan-dev:armhf \ 113 libwaffle-dev:armhf \ 114 libwayland-dev:armhf \ 115 libx11-xcb-dev:armhf \ 116 libxkbcommon-dev:armhf 117fi 118 119 120############### Building 121STRIP_CMD="${GCC_ARCH}-strip" 122mkdir -p /lava-files/rootfs-${DEBIAN_ARCH} 123 124 125############### Build apitrace 126. .gitlab-ci/container/build-apitrace.sh 127mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/apitrace 128mv /apitrace/build /lava-files/rootfs-${DEBIAN_ARCH}/apitrace 129rm -rf /apitrace 130 131 132############### Build dEQP runner 133. .gitlab-ci/container/build-deqp-runner.sh 134mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin 135mv /usr/local/bin/*-runner /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/. 136 137 138############### Build dEQP 139DEQP_TARGET=surfaceless . .gitlab-ci/container/build-deqp.sh 140 141mv /deqp /lava-files/rootfs-${DEBIAN_ARCH}/. 142 143 144############### Build piglit 145PIGLIT_OPTS="-DPIGLIT_BUILD_DMA_BUF_TESTS=ON" . .gitlab-ci/container/build-piglit.sh 146mv /piglit /lava-files/rootfs-${DEBIAN_ARCH}/. 147 148############### Build libva tests 149if [[ "$DEBIAN_ARCH" = "amd64" ]]; then 150 . .gitlab-ci/container/build-va-tools.sh 151 mv /va/bin/* /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/ 152fi 153 154############### Build libdrm 155EXTRA_MESON_ARGS+=" -D prefix=/libdrm" 156. .gitlab-ci/container/build-libdrm.sh 157 158############### Build kernel 159. .gitlab-ci/container/build-kernel.sh 160 161############### Delete rust, since the tests won't be compiling anything. 162rm -rf /root/.cargo 163 164############### Create rootfs 165set +e 166if ! debootstrap \ 167 --variant=minbase \ 168 --arch=${DEBIAN_ARCH} \ 169 --components main,contrib,non-free \ 170 bullseye \ 171 /lava-files/rootfs-${DEBIAN_ARCH}/ \ 172 http://deb.debian.org/debian; then 173 cat /lava-files/rootfs-${DEBIAN_ARCH}/debootstrap/debootstrap.log 174 exit 1 175fi 176set -e 177 178cp .gitlab-ci/container/create-rootfs.sh /lava-files/rootfs-${DEBIAN_ARCH}/. 179chroot /lava-files/rootfs-${DEBIAN_ARCH} sh /create-rootfs.sh 180rm /lava-files/rootfs-${DEBIAN_ARCH}/create-rootfs.sh 181 182 183############### Install the built libdrm 184# Dependencies pulled during the creation of the rootfs may overwrite 185# the built libdrm. Hence, we add it after the rootfs has been already 186# created. 187mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH 188find /libdrm/ -name lib\*\.so\* | xargs cp -t /lava-files/rootfs-${DEBIAN_ARCH}/usr/lib/$GCC_ARCH/. 189mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/libdrm/ 190cp -Rp /libdrm/share /lava-files/rootfs-${DEBIAN_ARCH}/libdrm/share 191rm -rf /libdrm 192 193 194if [ ${DEBIAN_ARCH} = arm64 ]; then 195 # Make a gzipped copy of the Image for db410c. 196 gzip -k /lava-files/Image 197 KERNEL_IMAGE_NAME+=" Image.gz" 198fi 199 200du -ah /lava-files/rootfs-${DEBIAN_ARCH} | sort -h | tail -100 201pushd /lava-files/rootfs-${DEBIAN_ARCH} 202 tar czf /lava-files/lava-rootfs.tgz . 203popd 204 205. .gitlab-ci/container/container_post_build.sh 206 207############### Upload the files! 208ci-fairy minio login $CI_JOB_JWT 209FILES_TO_UPLOAD="lava-rootfs.tgz \ 210 $KERNEL_IMAGE_NAME" 211 212if [[ -n $DEVICE_TREES ]]; then 213 FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)" 214fi 215 216for f in $FILES_TO_UPLOAD; do 217 ci-fairy minio cp /lava-files/$f \ 218 minio://${MINIO_PATH}/$f 219done 220 221touch /lava-files/done 222ci-fairy minio cp /lava-files/done minio://${MINIO_PATH}/done 223