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