1#!/bin/bash 2# SPDX-License-Identifier: MIT 3 4set -ex 5 6# Clean up stale rebases that GitLab might not have removed when reusing a checkout dir 7rm -rf .git/rebase-apply 8 9. .gitlab-ci/container/container_pre_build.sh 10 11# libssl-dev was uninstalled because it was considered an ephemeral package 12apt-get update 13apt-get install -y libssl-dev 14 15if [[ "$KERNEL_ARCH" = "arm64" ]]; then 16 GCC_ARCH="aarch64-linux-gnu" 17 DEBIAN_ARCH="arm64" 18 DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb" 19 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dtb" 20 DEVICE_TREES+=" arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb" 21 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb" 22 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8016-sbc.dtb" 23 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8096-db820c.dtb" 24 DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dtb" 25 DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtb" 26 DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dtb" 27 DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dtb" 28 DEVICE_TREES+=" arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-limozeen-nots-r5.dtb" 29elif [[ "$KERNEL_ARCH" = "arm" ]]; then 30 GCC_ARCH="arm-linux-gnueabihf" 31 DEBIAN_ARCH="armhf" 32 DEVICE_TREES="arch/arm/boot/dts/rockchip/rk3288-veyron-jaq.dtb" 33 DEVICE_TREES+=" arch/arm/boot/dts/allwinner/sun8i-h3-libretech-all-h3-cc.dtb" 34 DEVICE_TREES+=" arch/arm/boot/dts/nxp/imx/imx6q-cubox-i.dtb" 35 apt-get install -y libssl-dev:armhf 36else 37 GCC_ARCH="x86_64-linux-gnu" 38 DEBIAN_ARCH="amd64" 39 DEVICE_TREES="" 40fi 41 42export ARCH=${KERNEL_ARCH} 43export CROSS_COMPILE="${GCC_ARCH}-" 44 45# The kernel doesn't like the gold linker (or the old lld in our debians). 46# Sneak in some override symlinks during kernel build until we can update 47# debian. 48mkdir -p ld-links 49for i in /usr/bin/*-ld /usr/bin/ld; do 50 i=$(basename $i) 51 ln -sf /usr/bin/$i.bfd ld-links/$i 52done 53 54NEWPATH=$(pwd)/ld-links 55export PATH=$NEWPATH:$PATH 56 57git config --global user.email "fdo@example.com" 58git config --global user.name "freedesktop.org CI" 59git config --global pull.rebase true 60 61# Try to merge fixes from target repo 62if [ "$(git ls-remote --exit-code --heads ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes)" ]; then 63 git pull ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes 64fi 65 66# Try to merge fixes from local repo if this isn't a merge request 67# otherwise try merging the fixes from the merge target 68if [ -z "$CI_MERGE_REQUEST_PROJECT_PATH" ]; then 69 if [ "$(git ls-remote --exit-code --heads origin ${TARGET_BRANCH}-external-fixes)" ]; then 70 git pull origin ${TARGET_BRANCH}-external-fixes 71 fi 72else 73 if [ "$(git ls-remote --exit-code --heads ${CI_MERGE_REQUEST_PROJECT_URL} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}-external-fixes)" ]; then 74 git pull ${CI_MERGE_REQUEST_PROJECT_URL} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}-external-fixes 75 fi 76fi 77 78for opt in $ENABLE_KCONFIGS; do 79 echo CONFIG_$opt=y >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config 80done 81for opt in $DISABLE_KCONFIGS; do 82 echo CONFIG_$opt=n >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config 83done 84 85if [[ -n "${MERGE_FRAGMENT}" ]]; then 86 ./scripts/kconfig/merge_config.sh ${DEFCONFIG} drivers/gpu/drm/ci/${MERGE_FRAGMENT} 87else 88 make `basename ${DEFCONFIG}` 89fi 90 91make ${KERNEL_IMAGE_NAME} 92 93mkdir -p /lava-files/ 94for image in ${KERNEL_IMAGE_NAME}; do 95 cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/. 96done 97 98if [[ -n ${DEVICE_TREES} ]]; then 99 make dtbs 100 cp ${DEVICE_TREES} /lava-files/. 101fi 102 103make modules 104mkdir -p install/modules/ 105INSTALL_MOD_PATH=install/modules/ make modules_install 106 107if [[ ${DEBIAN_ARCH} = "arm64" ]]; then 108 make Image.lzma 109 mkimage \ 110 -f auto \ 111 -A arm \ 112 -O linux \ 113 -d arch/arm64/boot/Image.lzma \ 114 -C lzma\ 115 -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \ 116 /lava-files/cheza-kernel 117 KERNEL_IMAGE_NAME+=" cheza-kernel" 118 119 # Make a gzipped copy of the Image for db410c. 120 gzip -k /lava-files/Image 121 KERNEL_IMAGE_NAME+=" Image.gz" 122fi 123 124# Pass needed files to the test stage 125mkdir -p install 126cp -rfv .gitlab-ci/* install/. 127cp -rfv install/common install/ci-common 128cp -rfv drivers/gpu/drm/ci/* install/. 129 130. .gitlab-ci/container/container_post_build.sh 131 132if [[ "$UPLOAD_TO_MINIO" = "1" ]]; then 133 xz -7 -c -T${FDO_CI_CONCURRENT:-4} vmlinux > /lava-files/vmlinux.xz 134 FILES_TO_UPLOAD="$KERNEL_IMAGE_NAME vmlinux.xz" 135 136 if [[ -n $DEVICE_TREES ]]; then 137 FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)" 138 fi 139 140 for f in $FILES_TO_UPLOAD; do 141 ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \ 142 https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/$f 143 done 144 145 S3_ARTIFACT_NAME="kernel-files.tar.zst" 146 tar --zstd -cf $S3_ARTIFACT_NAME install 147 ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME} 148 149 echo "Download vmlinux.xz from https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/vmlinux.xz" 150fi 151 152mkdir -p artifacts/install/lib 153mv install/* artifacts/install/. 154rm -rf artifacts/install/modules 155ln -s common artifacts/install/ci-common 156cp .config artifacts/${CI_JOB_NAME}_config 157 158for image in ${KERNEL_IMAGE_NAME}; do 159 cp /lava-files/$image artifacts/install/. 160done 161 162tar -C artifacts -cf artifacts/install.tar install 163rm -rf artifacts/install 164