# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI="6"
ETYPE="sources"

K_SECURITY_UNSUPPORTED=true

inherit kernel-2
detect_version
detect_arch

GENTHREE_URI="https://gitlab.com/genthree/linux/repository/archive.tar.bz2?ref=v${PV}"
GENTHREE_LINUX_TAR="genthree-linux-${PV}.tar.bz2"
GENTHREE_LINUX_DESTDIR="${WORKDIR}/${GENTHREE_LINUX_TAR%.tar*}"

DESCRIPTION="Full sources for the Linux kernel with genthree kernel config"
HOMEPAGE="https://gitlab.com/genthree/linux"
SRC_URI="${KERNEL_URI} ${ARCH_URI} ${GENTHREE_URI} -> ${GENTHREE_LINUX_TAR}"

KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
RDEPEND="app-arch/lz4"

src_unpack() {
	# unpack genthree-linux
	einfo "Unpacking ${GENTHREE_LINUX_TAR} to ${GENTHREE_LINUX_DESTDIR}"
	mkdir "${GENTHREE_LINUX_DESTDIR}" || die
	tar -C "${GENTHREE_LINUX_DESTDIR}" -x --strip-components 1 -f "${DISTDIR}/${GENTHREE_LINUX_TAR}" || die

	# unpack kernel-2
	kernel-2_src_unpack
}

src_prepare() {
	kernel-2_src_prepare

	# use .config from genthree-linux
	mv "${GENTHREE_LINUX_DESTDIR}/.config" .
}