# Template file for 'linux-longterm'
#
# One template, four outputs (driver subpackages):
#   linux-longterm            meta, depends linux=<version>
#   linux-longterm-headers    meta, depends linux-headers=<version>
#   linux              image + modules + maps (post-install: depmod)
#   linux-headers      sanitized headers_install (user API only -
#                             NOT a module-build tree; openbcm needs a
#                             follow-up, see mk/kernel.inc)
pkgname=linux-longterm
version=6.18.51
revision=0
short_desc="UNOS kernel meta - longterm line"
maintainer="finwo <finwo@pm.me>"
license="GPL-2.0-only"
homepage="https://www.kernel.org"
distfiles="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.18.51.tar.xz"
checksum=ba2f60f858bf4d1f929101faa356c93dc8b925b17aaa9f95eabd4627758df613
# the meta points at this line's kernel build (exact pin incl. revision -
# apk's `=` only matches the full pkgver, so a bare version never matches)
depends="linux=${version}-r${revision}"
hostmakedepends="bc flex bison"
subpackages="linux-longterm-headers linux linux-headers"

short_desc_linux_longterm_headers="UNOS kernel headers meta - longterm line"
depends_linux_longterm_headers="linux-headers=${version}-r${revision}"
short_desc_linux="Linux kernel image and modules"
depends_linux="busybox"
short_desc_linux_headers="Linux kernel sanitized headers"
depends_linux_headers=

# Notes:
# - defconfig + deltas (see mk/kernel.inc for the shared mechanics).
#   Verified against 6.18 defconfig: everything load-bearing except VRF
#   (absent) and IKCONFIG (off) already defaults right; NEXTHOP is not a
#   symbol at all (nexthop objects are unconditional core). MODULE_SIG
#   already defaults off (no ephemeral signing keys). VRF's full dep
#   chain (IP_MULTIPLE_TABLES + NET_L3_MASTER_DEV + IPV6_MULTIPLE_TABLES)
#   is enabled explicitly - olddefconfig silently drops symbols whose
#   deps are unmet, which is exactly what the asserts guard against.
# - linux needs busybox first: its post-install runs under /bin/sh
#   (same ordering rule as the library packages).

# shellcheck disable=SC1091
. "${UNOS_MKDIR}/kernel.inc"

KDELTA_ENABLE="IKCONFIG IKCONFIG_PROC NET_L3_MASTER_DEV IPV6_MULTIPLE_TABLES BLK_DEV_NVME MMC MMC_BLOCK BRIDGE VLAN_8021Q"
KDELTA_MODULE="NET_VRF"
KDELTA_DISABLE=""
KASSERT_Y="IPV6 IP_MULTIPLE_TABLES IPV6_MULTIPLE_TABLES NET_L3_MASTER_DEV DEVTMPFS_MOUNT BLK_DEV_INITRD SERIAL_8250_CONSOLE MODULES IKCONFIG IKCONFIG_PROC EFI_STUB BLK_DEV_NVME MMC MMC_BLOCK NVME_CORE BRIDGE VLAN_8021Q"
KASSERT_M="NET_VRF"
KASSERT_N="MODULE_SIG"

do_configure() { kernel_configure; }
do_build() { kernel_build; }
do_install() { kernel_install; }

sub_linux_longterm_headers() { :; }
sub_linux() {
  spick boot
  spick lib/modules
}
sub_linux_headers() {
  spick usr/include
}
