xref: /openbmc/linux/drivers/gpu/drm/ci/build.sh (revision 39f555fb)
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="x86_64"
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
67if [ -z "$CI_MERGE_REQUEST_PROJECT_PATH" ]; then
68    if [ "$(git ls-remote --exit-code --heads origin ${TARGET_BRANCH}-external-fixes)" ]; then
69        git pull origin ${TARGET_BRANCH}-external-fixes
70    fi
71fi
72
73for opt in $ENABLE_KCONFIGS; do
74  echo CONFIG_$opt=y >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
75done
76for opt in $DISABLE_KCONFIGS; do
77  echo CONFIG_$opt=n >> drivers/gpu/drm/ci/${KERNEL_ARCH}.config
78done
79
80if [[ -n "${MERGE_FRAGMENT}" ]]; then
81    ./scripts/kconfig/merge_config.sh ${DEFCONFIG} drivers/gpu/drm/ci/${MERGE_FRAGMENT}
82else
83    make `basename ${DEFCONFIG}`
84fi
85
86make ${KERNEL_IMAGE_NAME}
87
88mkdir -p /lava-files/
89for image in ${KERNEL_IMAGE_NAME}; do
90    cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
91done
92
93if [[ -n ${DEVICE_TREES} ]]; then
94    make dtbs
95    cp ${DEVICE_TREES} /lava-files/.
96fi
97
98make modules
99mkdir -p install/modules/
100INSTALL_MOD_PATH=install/modules/ make modules_install
101
102if [[ ${DEBIAN_ARCH} = "arm64" ]]; then
103    make Image.lzma
104    mkimage \
105        -f auto \
106        -A arm \
107        -O linux \
108        -d arch/arm64/boot/Image.lzma \
109        -C lzma\
110        -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
111        /lava-files/cheza-kernel
112    KERNEL_IMAGE_NAME+=" cheza-kernel"
113
114    # Make a gzipped copy of the Image for db410c.
115    gzip -k /lava-files/Image
116    KERNEL_IMAGE_NAME+=" Image.gz"
117fi
118
119# Pass needed files to the test stage
120mkdir -p install
121cp -rfv .gitlab-ci/* install/.
122cp -rfv install/common install/ci-common
123cp -rfv drivers/gpu/drm/ci/* install/.
124
125. .gitlab-ci/container/container_post_build.sh
126
127if [[ "$UPLOAD_TO_MINIO" = "1" ]]; then
128    xz -7 -c -T${FDO_CI_CONCURRENT:-4} vmlinux > /lava-files/vmlinux.xz
129    FILES_TO_UPLOAD="$KERNEL_IMAGE_NAME vmlinux.xz"
130
131    if [[ -n $DEVICE_TREES ]]; then
132        FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)"
133    fi
134
135    for f in $FILES_TO_UPLOAD; do
136        ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \
137                https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/$f
138    done
139
140    S3_ARTIFACT_NAME="kernel-files.tar.zst"
141    tar --zstd -cf $S3_ARTIFACT_NAME install
142    ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME}
143
144    echo "Download vmlinux.xz from https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/vmlinux.xz"
145fi
146
147mkdir -p artifacts/install/lib
148mv install/* artifacts/install/.
149rm -rf artifacts/install/modules
150ln -s common artifacts/install/ci-common
151
152for image in ${KERNEL_IMAGE_NAME}; do
153    cp /lava-files/$image artifacts/install/.
154done
155
156tar -C artifacts -cf artifacts/install.tar install
157rm -rf artifacts/install
158