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