This repository has been archived on 2025-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
home-assistant-yellow/build-kernel.sh
Dustin C. Hatch 4900085a1c Support external build directory
When running inside a QEMU microvm with the source directory shared
via 9pfs, the kernel build process fails

> Error: Could not mmap file: vmlinux

Thus, we need to run the build in a path on a local filesystem.  To
support this, the Makefile now supports an `O` option, and all the build
scripts have been adjusted to make use of it as needed.

Since building in a local filesystem would ultimately discard the final
artifacts when the VM terminates, we need yet a different location for
the files we want to keep.  The `IMAGESDIR` option can be used to
specify this path.  This path can be on a shared filesystem, thus
saving the artifacts outside the microvm.
2023-03-03 12:36:15 -06:00

40 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
O="${1}"
. ./config
emerge -vnj ${kernel_pkg}
export ARCH=arm64 CROSS_COMPILE=${target}-
unset MAKEFLAGS MAKEOVERRIDES MAKELEVEL
mkdir -p "${O}"/linux
/usr/src/linux/scripts/kconfig/merge_config.sh -m \
-O "${O}"/linux \
/usr/src/linux/arch/*/configs/${kernel_defconfig}_defconfig \
linux.config
cd "${O}"/linux
make -C /usr/src/linux O=${PWD} olddefconfig
make -j$(nproc)
touch arch/arm64/boot/Image.gz
kver=$(make -s kernelversion)
make modules_install INSTALL_MOD_PATH=/mnt/gentoo/usr
cd -
printf 'Installing Kernel %s ...\n' "${kver}"
mkdir -p /mnt/gentoo/boot
cp -au "${O}"/linux/arch/arm64/boot/Image.gz /mnt/gentoo/boot/vmlinuz-${kver}
cp -au "${O}"/linux/.config /mnt/gentoo/boot/config-${kver}
cp -au "${O}"/linux/System.map /mnt/gentoo/boot/System.map-${kver}
printf 'Installing device tree binaries ...\n'
mkdir -p "${O}"/efi-part/overlays
cp -u "${O}"/linux/arch/arm64/boot/dts/${device_tree} "${O}"/efi-part/
cp -u \
"${O}"/linux/arch/arm64/boot/dts/overlays/*.dtb \
"${O}"/linux/arch/arm64/boot/dts/overlays/*.dtbo \
"${O}"/efi-part/overlays/