xref: /kernel/linux/linux-6.6/drivers/gpu/drm/ci/build.sh (revision 62306a36)
162306a36Sopenharmony_ci#!/bin/bash
262306a36Sopenharmony_ci# SPDX-License-Identifier: MIT
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciset -ex
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci# Clean up stale rebases that GitLab might not have removed when reusing a checkout dir
762306a36Sopenharmony_cirm -rf .git/rebase-apply
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci. .gitlab-ci/container/container_pre_build.sh
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci# libssl-dev was uninstalled because it was considered an ephemeral package
1262306a36Sopenharmony_ciapt-get update
1362306a36Sopenharmony_ciapt-get install -y libssl-dev
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciif [[ "$KERNEL_ARCH" = "arm64" ]]; then
1662306a36Sopenharmony_ci    GCC_ARCH="aarch64-linux-gnu"
1762306a36Sopenharmony_ci    DEBIAN_ARCH="arm64"
1862306a36Sopenharmony_ci    DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb"
1962306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dtb"
2062306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb"
2162306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb"
2262306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8016-sbc.dtb"
2362306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8096-db820c.dtb"
2462306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dtb"
2562306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtb"
2662306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dtb"
2762306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dtb"
2862306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-limozeen-nots-r5.dtb"
2962306a36Sopenharmony_cielif [[ "$KERNEL_ARCH" = "arm" ]]; then
3062306a36Sopenharmony_ci    GCC_ARCH="arm-linux-gnueabihf"
3162306a36Sopenharmony_ci    DEBIAN_ARCH="armhf"
3262306a36Sopenharmony_ci    DEVICE_TREES="arch/arm/boot/dts/rockchip/rk3288-veyron-jaq.dtb"
3362306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm/boot/dts/allwinner/sun8i-h3-libretech-all-h3-cc.dtb"
3462306a36Sopenharmony_ci    DEVICE_TREES+=" arch/arm/boot/dts/nxp/imx/imx6q-cubox-i.dtb"
3562306a36Sopenharmony_ci    apt-get install -y libssl-dev:armhf
3662306a36Sopenharmony_cielse
3762306a36Sopenharmony_ci    GCC_ARCH="x86_64-linux-gnu"
3862306a36Sopenharmony_ci    DEBIAN_ARCH="x86_64"
3962306a36Sopenharmony_ci    DEVICE_TREES=""
4062306a36Sopenharmony_cifi
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciexport ARCH=${KERNEL_ARCH}
4362306a36Sopenharmony_ciexport CROSS_COMPILE="${GCC_ARCH}-"
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci# The kernel doesn't like the gold linker (or the old lld in our debians).
4662306a36Sopenharmony_ci# Sneak in some override symlinks during kernel build until we can update
4762306a36Sopenharmony_ci# debian.
4862306a36Sopenharmony_cimkdir -p ld-links
4962306a36Sopenharmony_cifor i in /usr/bin/*-ld /usr/bin/ld; do
5062306a36Sopenharmony_ci    i=$(basename $i)
5162306a36Sopenharmony_ci    ln -sf /usr/bin/$i.bfd ld-links/$i
5262306a36Sopenharmony_cidone
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciNEWPATH=$(pwd)/ld-links
5562306a36Sopenharmony_ciexport PATH=$NEWPATH:$PATH
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cigit config --global user.email "fdo@example.com"
5862306a36Sopenharmony_cigit config --global user.name "freedesktop.org CI"
5962306a36Sopenharmony_cigit config --global pull.rebase true
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci# Try to merge fixes from target repo
6262306a36Sopenharmony_ciif [ "$(git ls-remote --exit-code --heads ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes)" ]; then
6362306a36Sopenharmony_ci    git pull ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes
6462306a36Sopenharmony_cifi
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci# Try to merge fixes from local repo if this isn't a merge request
6762306a36Sopenharmony_ciif [ -z "$CI_MERGE_REQUEST_PROJECT_PATH" ]; then
6862306a36Sopenharmony_ci    if [ "$(git ls-remote --exit-code --heads origin ${TARGET_BRANCH}-external-fixes)" ]; then
6962306a36Sopenharmony_ci        git pull origin ${TARGET_BRANCH}-external-fixes
7062306a36Sopenharmony_ci    fi
7162306a36Sopenharmony_cifi
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_cifor opt in $ENABLE_KCONFIGS; do
7462306a36Sopenharmony_ci  echo CONFIG_$opt=y >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
7562306a36Sopenharmony_cidone
7662306a36Sopenharmony_cifor opt in $DISABLE_KCONFIGS; do
7762306a36Sopenharmony_ci  echo CONFIG_$opt=n >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
7862306a36Sopenharmony_cidone
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciif [[ -n "${MERGE_FRAGMENT}" ]]; then
8162306a36Sopenharmony_ci    ./scripts/kconfig/merge_config.sh ${DEFCONFIG} drivers/gpu/drm/ci/${MERGE_FRAGMENT}
8262306a36Sopenharmony_cielse
8362306a36Sopenharmony_ci    make `basename ${DEFCONFIG}`
8462306a36Sopenharmony_cifi
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_cimake ${KERNEL_IMAGE_NAME}
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cimkdir -p /lava-files/
8962306a36Sopenharmony_cifor image in ${KERNEL_IMAGE_NAME}; do
9062306a36Sopenharmony_ci    cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
9162306a36Sopenharmony_cidone
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciif [[ -n ${DEVICE_TREES} ]]; then
9462306a36Sopenharmony_ci    make dtbs
9562306a36Sopenharmony_ci    cp ${DEVICE_TREES} /lava-files/.
9662306a36Sopenharmony_cifi
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cimake modules
9962306a36Sopenharmony_cimkdir -p install/modules/
10062306a36Sopenharmony_ciINSTALL_MOD_PATH=install/modules/ make modules_install
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ciif [[ ${DEBIAN_ARCH} = "arm64" ]]; then
10362306a36Sopenharmony_ci    make Image.lzma
10462306a36Sopenharmony_ci    mkimage \
10562306a36Sopenharmony_ci        -f auto \
10662306a36Sopenharmony_ci        -A arm \
10762306a36Sopenharmony_ci        -O linux \
10862306a36Sopenharmony_ci        -d arch/arm64/boot/Image.lzma \
10962306a36Sopenharmony_ci        -C lzma\
11062306a36Sopenharmony_ci        -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
11162306a36Sopenharmony_ci        /lava-files/cheza-kernel
11262306a36Sopenharmony_ci    KERNEL_IMAGE_NAME+=" cheza-kernel"
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci    # Make a gzipped copy of the Image for db410c.
11562306a36Sopenharmony_ci    gzip -k /lava-files/Image
11662306a36Sopenharmony_ci    KERNEL_IMAGE_NAME+=" Image.gz"
11762306a36Sopenharmony_cifi
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci# Pass needed files to the test stage
12062306a36Sopenharmony_cimkdir -p install
12162306a36Sopenharmony_cicp -rfv .gitlab-ci/* install/.
12262306a36Sopenharmony_cicp -rfv install/common install/ci-common
12362306a36Sopenharmony_cicp -rfv drivers/gpu/drm/ci/* install/.
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci. .gitlab-ci/container/container_post_build.sh
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciif [[ "$UPLOAD_TO_MINIO" = "1" ]]; then
12862306a36Sopenharmony_ci    xz -7 -c -T${FDO_CI_CONCURRENT:-4} vmlinux > /lava-files/vmlinux.xz
12962306a36Sopenharmony_ci    FILES_TO_UPLOAD="$KERNEL_IMAGE_NAME vmlinux.xz"
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci    if [[ -n $DEVICE_TREES ]]; then
13262306a36Sopenharmony_ci        FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)"
13362306a36Sopenharmony_ci    fi
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci    for f in $FILES_TO_UPLOAD; do
13662306a36Sopenharmony_ci        ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \
13762306a36Sopenharmony_ci                https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/$f
13862306a36Sopenharmony_ci    done
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci    S3_ARTIFACT_NAME="kernel-files.tar.zst"
14162306a36Sopenharmony_ci    tar --zstd -cf $S3_ARTIFACT_NAME install
14262306a36Sopenharmony_ci    ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME}
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci    echo "Download vmlinux.xz from https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/vmlinux.xz"
14562306a36Sopenharmony_cifi
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_cimkdir -p artifacts/install/lib
14862306a36Sopenharmony_cimv install/* artifacts/install/.
14962306a36Sopenharmony_cirm -rf artifacts/install/modules
15062306a36Sopenharmony_ciln -s common artifacts/install/ci-common
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_cifor image in ${KERNEL_IMAGE_NAME}; do
15362306a36Sopenharmony_ci    cp /lava-files/$image artifacts/install/.
15462306a36Sopenharmony_cidone
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_citar -C artifacts -cf artifacts/install.tar install
15762306a36Sopenharmony_cirm -rf artifacts/install
158