1bf215546Sopenharmony_ci#!/bin/bash
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ciset -ex
4bf215546Sopenharmony_ci
5bf215546Sopenharmony_cimkdir -p kernel
6bf215546Sopenharmony_ciwget -qO- ${KERNEL_URL} | tar -xj --strip-components=1 -C kernel
7bf215546Sopenharmony_cipushd kernel
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ci# The kernel doesn't like the gold linker (or the old lld in our debians).
10bf215546Sopenharmony_ci# Sneak in some override symlinks during kernel build until we can update
11bf215546Sopenharmony_ci# debian (they'll get blown away by the rm of the kernel dir at the end).
12bf215546Sopenharmony_cimkdir -p ld-links
13bf215546Sopenharmony_cifor i in /usr/bin/*-ld /usr/bin/ld; do
14bf215546Sopenharmony_ci    i=`basename $i`
15bf215546Sopenharmony_ci    ln -sf /usr/bin/$i.bfd ld-links/$i
16bf215546Sopenharmony_cidone
17bf215546Sopenharmony_ciexport PATH=`pwd`/ld-links:$PATH
18bf215546Sopenharmony_ci
19bf215546Sopenharmony_ciexport LOCALVERSION="`basename $KERNEL_URL`"
20bf215546Sopenharmony_ci./scripts/kconfig/merge_config.sh ${DEFCONFIG} ../.gitlab-ci/container/${KERNEL_ARCH}.config
21bf215546Sopenharmony_cimake ${KERNEL_IMAGE_NAME}
22bf215546Sopenharmony_cifor image in ${KERNEL_IMAGE_NAME}; do
23bf215546Sopenharmony_ci    cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
24bf215546Sopenharmony_cidone
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ciif [[ -n ${DEVICE_TREES} ]]; then
27bf215546Sopenharmony_ci    make dtbs
28bf215546Sopenharmony_ci    cp ${DEVICE_TREES} /lava-files/.
29bf215546Sopenharmony_cifi
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ciif [[ ${DEBIAN_ARCH} = "amd64" || ${DEBIAN_ARCH} = "arm64" ]]; then
32bf215546Sopenharmony_ci    make modules
33bf215546Sopenharmony_ci    INSTALL_MOD_PATH=/lava-files/rootfs-${DEBIAN_ARCH}/ make modules_install
34bf215546Sopenharmony_cifi
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ciif [[ ${DEBIAN_ARCH} = "arm64" ]]; then
37bf215546Sopenharmony_ci    make Image.lzma
38bf215546Sopenharmony_ci    mkimage \
39bf215546Sopenharmony_ci        -f auto \
40bf215546Sopenharmony_ci        -A arm \
41bf215546Sopenharmony_ci        -O linux \
42bf215546Sopenharmony_ci        -d arch/arm64/boot/Image.lzma \
43bf215546Sopenharmony_ci        -C lzma\
44bf215546Sopenharmony_ci        -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
45bf215546Sopenharmony_ci        /lava-files/cheza-kernel
46bf215546Sopenharmony_ci    KERNEL_IMAGE_NAME+=" cheza-kernel"
47bf215546Sopenharmony_cifi
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_cipopd
50bf215546Sopenharmony_cirm -rf kernel
51bf215546Sopenharmony_ci
52