# Installed as /etc/portage/env/sys-kernel/gentoo-kernel
# /proc/version → "... (fiw@gentoo) ..."
export KBUILD_BUILD_USER=fiw
export KBUILD_BUILD_HOST=gentoo

# Version the CachyOS patch in /etc/portage/patches was generated for.
# fiw-cachy-patch rewrites this line (the postsync hook runs it when CachyOS
# has a release for a new gentoo-kernel). A newer point release in the same
# series (7.2.x) reuses the existing patch and config.d unchanged; if the patch
# no longer applies, the build stops and the installed kernels stay as they are.
FIW_CACHY_PV=7.2.9
pre_src_prepare() {
	[[ ${PV} == "${FIW_CACHY_PV}" ]] && return
	if [[ ${PV%.*} != "${FIW_CACHY_PV%.*}" ]]; then
		die "CachyOS patch is for ${FIW_CACHY_PV}; ${PV} is a new series. Run: fiw-cachy-patch ${PV}"
	fi
	ewarn "No CachyOS patch for ${PV} yet: reusing the ${FIW_CACHY_PV} patch and config."
	ewarn "Fallbacks if it misbehaves: gentoo-kernel-bin entry, or CachyOS."
}
