--- klibc-1.5.15.ebuild_orig1 2009-09-15 21:21:00.495106639 -0400 +++ klibc-1.5.15.ebuild 2009-09-15 21:25:53.668025681 -0400 @@ -16,7 +16,7 @@ # This will be able to go away once the klibc author updates his code # to build again the headers provided by the kernel's 'headers_install' target. -inherit eutils multilib toolchain-funcs +inherit eutils multilib toolchain-funcs savedconfig DESCRIPTION="A minimal libc subset for use with initramfs." HOMEPAGE="http://www.zytor.com/mailman/listinfo/klibc" @@ -39,7 +39,7 @@ LICENSE="|| ( GPL-2 LGPL-2 )" KEYWORDS="~amd64 -mips ~ppc ~sparc ~x86 ~arm" SLOT="0" -IUSE="debug n32" +IUSE="debug n32 savedconfig" DEPEND="dev-lang/perl" RDEPEND="${DEPEND}" @@ -51,6 +51,8 @@ # Do not strip RESTRICT="strip" +SAVED_DEFCONFIG_SRC="${PORTAGE_CONFIGROOT}etc/portage/savedconfig/${CATEGORY}/${PF}" + kernel_asm_arch() { a="${1:${ARCH}}" case ${a} in @@ -63,10 +65,28 @@ esac } +savedconfig_dst() { + local a="$(kernel_asm_arch ${ARCH})" + echo "${KS}/arch/${a}/configs/savedconfig_defconfig" +} + +# for non-standardized defconfigs (e.g. arm*) +require_savedconfig() { + case ${ARCH} in + arm*) return 0 ;; + *) return 1 ;; + esac +} + # For a given Gentoo ARCH, # specify the kernel defconfig most relevant kernel_defconfig() { a="${1:${ARCH}}" + # for arches that do not have a standard defconfig (e.g. arm) + if require_savedconfig ; then + echo savedconfig_defconfig + return + fi # most, but not all arches have a sanely named defconfig case ${a} in ppc64) echo ppc64_defconfig ;; @@ -77,6 +97,32 @@ } src_unpack() { + + # do first to avoid wasting time or resources + if require_savedconfig ; then + if ! use savedconfig ; then + eerror "Your ARCH requires a saved defconfig located at" + eerror "${SAVED_DEFCONFIG_SRC}" + eerror "Please create the file using linux-${OKV}, and then add" + eerror "\"dev-libs/klibc savedconfig\" to " + eerror "${PORTAGE_CONFIGROOT}etc/portage/package.use" + die "USE=\"savedconfig\" is required for ARCH=${ARCH}" + else + if [ ! -f "${SAVED_DEFCONFIG_SRC}" ]; then + eerror "Your savedconfig file does not exist at" + eerror "${SAVED_DEFCONFIG_SRC}" + eerror "Please create the file using linux-${OKV}." + die "${SAVED_DEFCONFIG_SRC}: No such file or directory." + fi + fi + else + if use savedconfig ; then + ewarn "Using a saved defconfig with ARCH=${ARCH} is discouraged and also completely" + ewarn "unsupported. You have been warned." + epause + fi + fi + unpack linux-${OKV}.tar.bz2 ${P}.tar.bz2 [ -n "${PKV}" ] && EPATCH_OPTS="-d ${KS} -p1" epatch "${DISTDIR}"/patch-${PKV}.bz2 cd "${S}" @@ -102,6 +148,10 @@ # bug 229525, usr/include/arch/x86_64/sys/io.h has undefined variables epatch "${FILESDIR}"/${PN}-1.5.11-x86_64-io.h-return.diff + + if use savedconfig ; then + restore_config "$(savedconfig_dst)" || die + fi } # klibc has it's own ideas of arches