xref: /linux/drivers/gpu/drm/ci/build.sh (revision 910d2d85febf93a115cdec961c75e6b208532eac)
10119c894STomeu Vizoso#!/bin/bash
20119c894STomeu Vizoso# SPDX-License-Identifier: MIT
30119c894STomeu Vizoso
40119c894STomeu Vizososet -ex
50119c894STomeu Vizoso
60119c894STomeu Vizoso# Clean up stale rebases that GitLab might not have removed when reusing a checkout dir
70119c894STomeu Vizosorm -rf .git/rebase-apply
80119c894STomeu Vizoso
90119c894STomeu Vizoso. .gitlab-ci/container/container_pre_build.sh
100119c894STomeu Vizoso
110119c894STomeu Vizoso# libssl-dev was uninstalled because it was considered an ephemeral package
120119c894STomeu Vizosoapt-get update
130119c894STomeu Vizosoapt-get install -y libssl-dev
140119c894STomeu Vizoso
150119c894STomeu Vizosoif [[ "$KERNEL_ARCH" = "arm64" ]]; then
160119c894STomeu Vizoso    GCC_ARCH="aarch64-linux-gnu"
170119c894STomeu Vizoso    DEBIAN_ARCH="arm64"
180119c894STomeu Vizoso    DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb"
190119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dtb"
200119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb"
210119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb"
22*910d2d85SVignesh Raman    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8016-sbc-usb-host.dtb"
230119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/apq8096-db820c.dtb"
240119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/amlogic/meson-g12b-a311d-khadas-vim3.dtb"
250119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtb"
260119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dtb"
270119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dtb"
280119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-limozeen-nots-r5.dtb"
290119c894STomeu Vizosoelif [[ "$KERNEL_ARCH" = "arm" ]]; then
300119c894STomeu Vizoso    GCC_ARCH="arm-linux-gnueabihf"
310119c894STomeu Vizoso    DEBIAN_ARCH="armhf"
320119c894STomeu Vizoso    DEVICE_TREES="arch/arm/boot/dts/rockchip/rk3288-veyron-jaq.dtb"
330119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm/boot/dts/allwinner/sun8i-h3-libretech-all-h3-cc.dtb"
340119c894STomeu Vizoso    DEVICE_TREES+=" arch/arm/boot/dts/nxp/imx/imx6q-cubox-i.dtb"
350119c894STomeu Vizoso    apt-get install -y libssl-dev:armhf
360119c894STomeu Vizosoelse
370119c894STomeu Vizoso    GCC_ARCH="x86_64-linux-gnu"
382b126e06SHelen Koike    DEBIAN_ARCH="amd64"
390119c894STomeu Vizoso    DEVICE_TREES=""
400119c894STomeu Vizosofi
410119c894STomeu Vizoso
420119c894STomeu Vizosoexport ARCH=${KERNEL_ARCH}
430119c894STomeu Vizosoexport CROSS_COMPILE="${GCC_ARCH}-"
440119c894STomeu Vizoso
450119c894STomeu Vizoso# The kernel doesn't like the gold linker (or the old lld in our debians).
460119c894STomeu Vizoso# Sneak in some override symlinks during kernel build until we can update
470119c894STomeu Vizoso# debian.
480119c894STomeu Vizosomkdir -p ld-links
490119c894STomeu Vizosofor i in /usr/bin/*-ld /usr/bin/ld; do
500119c894STomeu Vizoso    i=$(basename $i)
510119c894STomeu Vizoso    ln -sf /usr/bin/$i.bfd ld-links/$i
520119c894STomeu Vizosodone
530119c894STomeu Vizoso
540119c894STomeu VizosoNEWPATH=$(pwd)/ld-links
550119c894STomeu Vizosoexport PATH=$NEWPATH:$PATH
560119c894STomeu Vizoso
570119c894STomeu Vizosogit config --global user.email "fdo@example.com"
580119c894STomeu Vizosogit config --global user.name "freedesktop.org CI"
590119c894STomeu Vizosogit config --global pull.rebase true
600119c894STomeu Vizoso
610119c894STomeu Vizoso# Try to merge fixes from target repo
620119c894STomeu Vizosoif [ "$(git ls-remote --exit-code --heads ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes)" ]; then
630119c894STomeu Vizoso    git pull ${UPSTREAM_REPO} ${TARGET_BRANCH}-external-fixes
640119c894STomeu Vizosofi
650119c894STomeu Vizoso
660119c894STomeu Vizoso# Try to merge fixes from local repo if this isn't a merge request
67f9b4fbcbSDmitry Baryshkov# otherwise try merging the fixes from the merge target
680119c894STomeu Vizosoif [ -z "$CI_MERGE_REQUEST_PROJECT_PATH" ]; then
690119c894STomeu Vizoso    if [ "$(git ls-remote --exit-code --heads origin ${TARGET_BRANCH}-external-fixes)" ]; then
700119c894STomeu Vizoso        git pull origin ${TARGET_BRANCH}-external-fixes
710119c894STomeu Vizoso    fi
72f9b4fbcbSDmitry Baryshkovelse
73f9b4fbcbSDmitry Baryshkov    if [ "$(git ls-remote --exit-code --heads ${CI_MERGE_REQUEST_PROJECT_URL} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}-external-fixes)" ]; then
74f9b4fbcbSDmitry Baryshkov        git pull ${CI_MERGE_REQUEST_PROJECT_URL} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}-external-fixes
75f9b4fbcbSDmitry Baryshkov    fi
760119c894STomeu Vizosofi
770119c894STomeu Vizoso
780119c894STomeu Vizosofor opt in $ENABLE_KCONFIGS; do
790119c894STomeu Vizoso  echo CONFIG_$opt=y >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
800119c894STomeu Vizosodone
810119c894STomeu Vizosofor opt in $DISABLE_KCONFIGS; do
820119c894STomeu Vizoso  echo CONFIG_$opt=n >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
830119c894STomeu Vizosodone
840119c894STomeu Vizoso
850119c894STomeu Vizosoif [[ -n "${MERGE_FRAGMENT}" ]]; then
860119c894STomeu Vizoso    ./scripts/kconfig/merge_config.sh ${DEFCONFIG} drivers/gpu/drm/ci/${MERGE_FRAGMENT}
870119c894STomeu Vizosoelse
880119c894STomeu Vizoso    make `basename ${DEFCONFIG}`
890119c894STomeu Vizosofi
900119c894STomeu Vizoso
910119c894STomeu Vizosomake ${KERNEL_IMAGE_NAME}
920119c894STomeu Vizoso
930119c894STomeu Vizosomkdir -p /lava-files/
940119c894STomeu Vizosofor image in ${KERNEL_IMAGE_NAME}; do
950119c894STomeu Vizoso    cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
960119c894STomeu Vizosodone
970119c894STomeu Vizoso
980119c894STomeu Vizosoif [[ -n ${DEVICE_TREES} ]]; then
990119c894STomeu Vizoso    make dtbs
1000119c894STomeu Vizoso    cp ${DEVICE_TREES} /lava-files/.
1010119c894STomeu Vizosofi
1020119c894STomeu Vizoso
1030119c894STomeu Vizosomake modules
1040119c894STomeu Vizosomkdir -p install/modules/
1050119c894STomeu VizosoINSTALL_MOD_PATH=install/modules/ make modules_install
1060119c894STomeu Vizoso
1070119c894STomeu Vizosoif [[ ${DEBIAN_ARCH} = "arm64" ]]; then
1080119c894STomeu Vizoso    make Image.lzma
1090119c894STomeu Vizoso    mkimage \
1100119c894STomeu Vizoso        -f auto \
1110119c894STomeu Vizoso        -A arm \
1120119c894STomeu Vizoso        -O linux \
1130119c894STomeu Vizoso        -d arch/arm64/boot/Image.lzma \
1140119c894STomeu Vizoso        -C lzma\
1150119c894STomeu Vizoso        -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
1160119c894STomeu Vizoso        /lava-files/cheza-kernel
1170119c894STomeu Vizoso    KERNEL_IMAGE_NAME+=" cheza-kernel"
1180119c894STomeu Vizoso
1190119c894STomeu Vizoso    # Make a gzipped copy of the Image for db410c.
1200119c894STomeu Vizoso    gzip -k /lava-files/Image
1210119c894STomeu Vizoso    KERNEL_IMAGE_NAME+=" Image.gz"
1220119c894STomeu Vizosofi
1230119c894STomeu Vizoso
1240119c894STomeu Vizoso# Pass needed files to the test stage
1250119c894STomeu Vizosomkdir -p install
1260119c894STomeu Vizosocp -rfv .gitlab-ci/* install/.
1270119c894STomeu Vizosocp -rfv install/common install/ci-common
1280119c894STomeu Vizosocp -rfv drivers/gpu/drm/ci/* install/.
1290119c894STomeu Vizoso
1300119c894STomeu Vizoso. .gitlab-ci/container/container_post_build.sh
1310119c894STomeu Vizoso
1320119c894STomeu Vizosoif [[ "$UPLOAD_TO_MINIO" = "1" ]]; then
1330119c894STomeu Vizoso    xz -7 -c -T${FDO_CI_CONCURRENT:-4} vmlinux > /lava-files/vmlinux.xz
1340119c894STomeu Vizoso    FILES_TO_UPLOAD="$KERNEL_IMAGE_NAME vmlinux.xz"
1350119c894STomeu Vizoso
1360119c894STomeu Vizoso    if [[ -n $DEVICE_TREES ]]; then
1370119c894STomeu Vizoso        FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)"
1380119c894STomeu Vizoso    fi
1390119c894STomeu Vizoso
1400119c894STomeu Vizoso    for f in $FILES_TO_UPLOAD; do
1410119c894STomeu Vizoso        ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \
1420119c894STomeu Vizoso                https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/$f
1430119c894STomeu Vizoso    done
1440119c894STomeu Vizoso
1450119c894STomeu Vizoso    S3_ARTIFACT_NAME="kernel-files.tar.zst"
1460119c894STomeu Vizoso    tar --zstd -cf $S3_ARTIFACT_NAME install
1470119c894STomeu Vizoso    ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME}
1480119c894STomeu Vizoso
1490119c894STomeu Vizoso    echo "Download vmlinux.xz from https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/vmlinux.xz"
1500119c894STomeu Vizosofi
1510119c894STomeu Vizoso
1520119c894STomeu Vizosomkdir -p artifacts/install/lib
1530119c894STomeu Vizosomv install/* artifacts/install/.
1540119c894STomeu Vizosorm -rf artifacts/install/modules
1550119c894STomeu Vizosoln -s common artifacts/install/ci-common
15680b6434bSHelen Koikecp .config artifacts/${CI_JOB_NAME}_config
1570119c894STomeu Vizoso
1580119c894STomeu Vizosofor image in ${KERNEL_IMAGE_NAME}; do
1590119c894STomeu Vizoso    cp /lava-files/$image artifacts/install/.
1600119c894STomeu Vizosodone
1610119c894STomeu Vizoso
1620119c894STomeu Vizosotar -C artifacts -cf artifacts/install.tar install
1630119c894STomeu Vizosorm -rf artifacts/install
164