# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="8"

ETYPE="sources"
K_WANT_GENPATCHES="base extras"
K_GENPATCHES_VER="5"

XANMOD_VERSION="1"

K_SECURITY_UNSUPPORTED="1"
K_NOSETEXTRAVERSION="1"

inherit kernel-2
detect_version
detect_arch

DESCRIPTION="Full XanMod sources including the Gentoo patchset "
HOMEPAGE="https://xanmod.org"
SRC_URI="
	${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz
	https://downloads.sourceforge.net/xanmod/patch-${OKV}-xanmod${XANMOD_VERSION}.xz
	${GENPATCHES_URI}
"
KEYWORDS="~amd64"

src_unpack() {
	# workaround check
	# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82961749e651a57b04bab9a930a7e44d66fa9b7b
	KPATCH_DIR="${WORKDIR}/patches"
	mkdir -p "${KPATCH_DIR}" || die
	touch "${KPATCH_DIR}/1000-${OKV}.patch" || die

	UNIPATCH_STRICTORDER=1
	UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}-xanmod${XANMOD_VERSION}.xz"
	UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} 1*_linux-${KV_MAJOR}.${KV_MINOR}.*.patch"

	kernel-2_src_unpack
}

pkg_postinst() {
	kernel-2_pkg_postinst
}

pkg_postrm() {
	kernel-2_pkg_postrm
}