# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-kernel/gentoo-sources/gentoo-sources-2.6.27-r2.ebuild,v 1.1 2008/10/30 21:44:25 dsd Exp $

ETYPE="sources"
K_WANT_GENPATCHES="base extras"
K_GENPATCHES_VER="9"
AA_VER="2.3"
AA_KV="2.6.27"
EXT4_KV="2.6.27"
REISER4_KV="2.6.27"
TUXONICE_VER="3.0-rc7a"
TUXONICE_KV="2.6.27-rc3"
DSDT_VER="0.9c"
DSDT_KV="2.6.26"
UNION_VER="2.5"
UNION_KV="2.6.27-rc6"

inherit kernel-2
detect_version
detect_arch

KEYWORDS="~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
IUSE=""
HOMEPAGE="http://dev.gentoo.org/~dsd/genpatches http://forge.novell.com/modules/xfmod/project/?apparmor"

DESCRIPTION="Full sources including the Gentoo & AppArmor patchset for the ${KV_MAJOR}.${KV_MINOR} kernel tree"
AA_SRC="ftp://forgeftp.novell.com/apparmor/AppArmor%202.3-Beta1/${AA_KV}-AA${AA_VER}.tgz
	http://ftp.mars.arge.at/apparmor/${AA_KV}-AA${AA_VER}.tgz"
EXT4_SRC="http://ftp.mars.arge.at/pub/linux-sabayon-${EXT4_KV}-from-ext4dev-to-ext4.patch"
REISER4_SRC="http://www.kernel.org/pub/linux/kernel/people/edward/reiser4/reiser4-for-2.6/reiser4-for-${REISER4_KV}.patch.bz2"
TUXONICE_SRC="http://www.tuxonice.net/downloads/all/tuxonice-${TUXONICE_VER}-for-${TUXONICE_KV}.patch.bz2
	http://user.it.uu.se/~mikpe/linux/patches/tuxonice/tuxonice-${TUXONICE_VER}-for-${TUXONICE_KV}.patch.bz2"
DSDT_SRC="http://gaugusch.at/acpi-dsdt-initrd-patches/acpi-dsdt-initrd-v${DSDT_VER}-${DSDT_KV}.patch"
UNION_SRC="http://download.filesystems.org/unionfs/unionfs-2.x/unionfs-${UNION_VER}_for_${UNION_KV}.diff.gz
	http://ftp.mars.arge.at/apparmor/UnionFS_${UNION_VER}-AppArmor_${AA_VER}.patch"

SRC_URI="${KERNEL_URI} ${GENPATCHES_URI} ${ARCH_URI} ${AA_SRC} ${EXT4_SRC} ${REISER4_SRC} ${TUXONICE_SRC} ${DSDT_SRC} ${UNION_SRC}"

src_unpack() {
	mkdir apparmor
	cd apparmor
	unpack "${AA_KV}-AA${AA_VER}.tgz"
	sed -e '/^#/d' -i ${AA_KV}/series
	cd ..

	kernel-2_src_unpack

	for f in $(<../apparmor/${AA_KV}/series) ; do
		EPATCH_OPTS="-p1" \
		EPATCH_SINGLE_MSG="Applying AppArmor's ${f}" \
		epatch ../apparmor/${AA_KV}/${f}
	done

	epatch ${DISTDIR}/reiser4-for-${REISER4_KV}.patch.bz2
	epatch ${DISTDIR}/tuxonice-${TUXONICE_VER}-for-${TUXONICE_KV}.patch.bz2
	epatch ${DISTDIR}/acpi-dsdt-initrd-v${DSDT_VER}-${DSDT_KV}.patch
	epatch ${DISTDIR}/unionfs-${UNION_VER}_for_${UNION_KV}.diff.gz
	epatch ${DISTDIR}/UnionFS_${UNION_VER}-AppArmor_${AA_VER}.patch
	epatch ${DISTDIR}/linux-sabayon-${EXT4_KV}-from-ext4dev-to-ext4.patch

	find ${WORKDIR} -iname "*.orig" -exec rm {} \; 2> /dev/null

}


pkg_postinst() {
	kernel-2_pkg_postinst
	einfo "For more info on this patchset, and how to report problems, see:"
	einfo "${HOMEPAGE}"
	einfo
	einfo "Make sure that your kernel configuration file is set with:"
	einfo " CONFIG_SECURITY=y"
	einfo "         CONFIG_SECURITY_APPARMOR=y"
	einfo "Without these, apparmor will not function."
}