public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] dev/heroxbd:master commit in: eclass/
  2016-05-26  4:05 [gentoo-commits] proj/android:master commit in: eclass/ Benda XU
@ 2016-05-26  4:04 ` Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e3dbf227fb7126e54e7b151aac2ec4feffff5e24
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 04:03:51 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu May 26 04:03:51 2016 +0000
URL:        https://gitweb.gentoo.org/dev/heroxbd.git/commit/?id=e3dbf227

db.eclass: import from prefix tree.

 eclass/db.eclass | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 210 insertions(+)

diff --git a/eclass/db.eclass b/eclass/db.eclass
new file mode 100644
index 0000000..f7070d4
--- /dev/null
+++ b/eclass/db.eclass
@@ -0,0 +1,210 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/db.eclass,v 1.49 2013/07/21 09:23:45 pacho Exp $
+# This is a common location for functions used in the sys-libs/db ebuilds
+#
+# Bugs: maintainer-needed@gentoo.org
+
+inherit eutils multilib
+
+IUSE="doc test examples"
+
+EXPORT_FUNCTIONS src_test
+
+DEPEND="test? ( >=dev-lang/tcl-8.4 )"
+
+RDEPEND=""
+
+db_fix_so() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
+	LIB="${EROOT}/usr/$(get_libdir)"
+
+	cd "${LIB}"
+
+	# first clean up old symlinks
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+
+	# now rebuild all the correct ones
+	for ext in so a dylib sl; do
+		for name in libdb libdb_{cxx,tcl,java,sql,stl}; do
+			target=`find . -maxdepth 1 -type f -name "${name}-*.${ext}" |sort -n |tail -n 1`
+			[ -n "${target}" ] || continue;
+			case ${CHOST} in 
+			*-aix*)
+				aixdll --merge-runtime \
+					--keepdir=false \
+					--target="${name}.${ext}" \
+					--current="${target}" \
+					`find . -maxdepth 1 -type f -name "${name}-*.${ext}"`
+				;;
+			*)
+				ln -sf ${target//.\//} ${name}.${ext}
+				;;
+			esac;
+		done;
+	done;
+
+	# db[23] gets some extra-special stuff
+	if [ -f libdb1$(get_libname 2) ]; then
+		ln -sf libdb1$(get_libname 2) libdb$(get_libname 2)
+		ln -sf libdb1$(get_libname 2) libdb1$(get_libname)
+		ln -sf libdb1$(get_libname 2) libdb-1$(get_libame)
+	fi
+	# what do we do if we ever get 3.3 ?
+	for i in libdb libdb_{cxx,tcl,java,sql,stl}; do
+		if [ -f $i-3$(get_libname 2) ]; then
+			ln -sf $i-3$(get_libname 2) $i-3$(get_libname)
+			ln -sf $i-3$(get_libname 2) $i$(get_libname 3)
+		fi
+	done
+
+	# do the same for headers now
+	# but since there are only two of them, just overwrite them
+	cd "${EROOT}"/usr/include
+	target=`find . -maxdepth 1 -type d -name 'db[0-9]*' | sort -n |cut -d/ -f2- | tail -n1`
+	if [ -n "${target}" ] && [ -e "${target}/db.h" ] && ( ! [[ -e db.h ]] || [[ -h db.h ]] ); then
+		einfo "Creating db.h symlinks to ${target}"
+		ln -sf "${target}"/db.h .
+		ln -sf "${target}"/db_185.h .
+	elif [ ! -e "${target}/db.h" ]; then
+		if [ -n "${target}" ]; then
+			ewarn "Could not find ${target}/db.h"
+		elif [ -h db.h ]; then
+			einfo "Apparently you just removed the last instance of $PN. Removing the symlinks"
+			rm -f db.h db_185.h
+		fi
+	fi
+}
+
+db_src_install_doc() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# not everybody wants this wad of documentation as it is primarily API docs
+	if use doc; then
+		dodir /usr/share/doc/${PF}/html
+		mv "${ED}"/usr/docs/* "${ED}"/usr/share/doc/${PF}/html/
+		rm -rf "${ED}"/usr/docs
+	else
+		rm -rf "${ED}"/usr/docs
+	fi
+
+	db_src_install_examples
+}
+
+db_src_install_examples() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	if use examples ; then
+		local langs="c cxx stl"
+		[[ "${IUSE/java}" != "${IUSE}" ]] \
+			&& use java \
+			&& langs="${langs} java"
+		for i in $langs ; do
+			destdir="/usr/share/doc/${PF}/"
+			src="${S}/../examples_${i}/"
+			if [ -f "${src}" ]; then
+				dodir "${destdir}"
+				cp -ra "${src}" "${ED}${destdir}/"
+			fi
+		done
+	fi
+}
+
+db_src_install_usrbinslot() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# slot all program names to avoid overwriting
+	for fname in "${ED}"/usr/bin/db*
+	do
+		dn="$(dirname "${fname}")"
+		bn="$(basename "${fname}")"
+		bn="${bn/db/db${SLOT}}"
+		mv "${fname}" "${dn}/${bn}" || \
+			die "Failed to rename ${fname} to ${dn}/${bn}"
+	done
+}
+
+db_src_install_headerslot() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# install all headers in a slotted location
+	dodir /usr/include/db${SLOT}
+	mv "${ED}"/usr/include/*.h "${ED}"/usr/include/db${SLOT}/
+}
+
+db_src_install_usrlibcleanup() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	LIB="${ED}/usr/$(get_libdir)"
+	# Clean out the symlinks so that they will not be recorded in the
+	# contents (bug #60732)
+
+	if [ "${ED}" = "" ]; then
+		die "Calling clean_links while \$ED not defined"
+	fi
+
+	if [ -e "${LIB}"/libdb.a ] && [ ! -e "${LIB}"/libdb-${SLOT}.a ]; then
+		einfo "Moving libdb.a to a versioned name"
+		mv "${LIB}/libdb.a" "${LIB}/libdb-${SLOT}.a"
+	fi
+
+	if [ -e "${LIB}"/libdb_cxx.a ] && [ ! -e "${LIB}"/libdb_cxx-${SLOT}.a ]; then
+		einfo "Moving libdb_cxx.a to a versioned name"
+		mv "${LIB}/libdb_cxx.a" "${LIB}/libdb_cxx-${SLOT}.a"
+	fi
+
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
+	einfo "removing unversioned static archives"
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+
+	rm -f \
+		"${ED}"/usr/include/{db,db_185}.h \
+		"${LIB}"/libdb{,_{cxx,sql,stl,java,tcl}}.a
+}
+
+db_src_test() {
+	if [[ $UID -eq 0 ]]; then
+		M="You must run the testsuite as non-root, skipping"
+		ewarn "${M}"
+		elog "${M}"
+		return 0
+	fi
+
+	if use tcl; then
+		einfo "Running sys-libs/db testsuite"
+		ewarn "This can take 6+ hours on modern machines"
+		# Fix stuff that fails with relative paths, and upstream moving files
+		# around...
+		local test_parallel=''
+		for t in \
+			"${S}"/test/parallel.tcl \
+			"${S}"/../test/parallel.tcl \
+			"${S}"/test/tcl/parallel.tcl \
+			"${S}"/../test/tcl/parallel.tcl \
+			; do
+			[[ -f "${t}" ]] && test_parallel="${t}" && break
+		done
+
+		sed -ri \
+			-e '/regsub .test_path ./s,(regsub),#\1,g' \
+			-e '/regsub .src_root ./s,(regsub),#\1,g' \
+			-e '/regsub .tcl_utils ./s,(regsub),#\1,g' \
+			"${test_parallel}"
+		cd "${S}"
+		for t in \
+			../test/test.tcl \
+			../test/tcl/test.tcl \
+			; do
+			[[ -f "${t}" ]] && testbase="${t}" && break
+		done
+		echo "source ${t}" > testrunner.tcl
+		echo "run_parallel $(makeopts_jobs) run_std" >> testrunner.tcl
+
+		tclsh testrunner.tcl
+		egrep -qs '^FAIL' ALL.OUT* && die "Some tests failed, please see ${S}/ALL.OUT*"
+	else
+		eerror "You must have USE=tcl to run the sys-libs/db testsuite."
+	fi
+}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-05-26  4:05 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     eae808b55c1155d75825122ed5d875f7bf277c86
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 04:03:01 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sun May 22 04:03:01 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=eae808b5

Revert "prefix.eclass: merged"

This reverts commit abe0e1cb5fc08292397e3c38895185ec9481c9dc.

 eclass/prefix.eclass | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/eclass/prefix.eclass b/eclass/prefix.eclass
new file mode 100644
index 0000000..1f3c4b0
--- /dev/null
+++ b/eclass/prefix.eclass
@@ -0,0 +1,52 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: prefix.eclass
+# @MAINTAINER:
+# Feel free to contact the Prefix team through <prefix@gentoo.org> if
+# you have problems, suggestions or questions.
+# @BLURB: Eclass to provide Prefix functionality
+# @DESCRIPTION:
+# Gentoo Prefix allows users to install into a self defined offset
+# located somewhere in the filesystem.  Prefix ebuilds require
+# additional functions and variables which are defined by this eclass.
+
+# @ECLASS-VARIABLE: EPREFIX
+# @DESCRIPTION:
+# The offset prefix of a Gentoo Prefix installation.  When Gentoo Prefix
+# is not used, ${EPREFIX} should be "".  Prefix Portage sets EPREFIX,
+# hence this eclass has nothing to do here in that case.
+# Note that setting EPREFIX in the environment with Prefix Portage sets
+# Portage into cross-prefix mode.
+if [[ ! ${EPREFIX+set} ]]; then
+	export EPREFIX=''
+fi
+
+
+# @FUNCTION: eprefixify
+# @USAGE: <list of to be eprefixified files>
+# @DESCRIPTION:
+# replaces @GENTOO_PORTAGE_EPREFIX@ with ${EPREFIX} for the given files,
+# dies if no arguments are given, a file does not exist, or changing a
+# file failed.
+eprefixify() {
+	[[ $# -lt 1 ]] && die "at least one argument required"
+
+	einfo "Adjusting to prefix ${EPREFIX:-/}"
+	local x
+	for x in "$@" ; do
+		if [[ -e ${x} ]] ; then
+			ebegin "  ${x##*/}"
+			sed -i -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" "${x}"
+			eend $? || die "failed to eprefixify ${x}"
+		else
+			die "${x} does not exist"
+		fi
+	done
+
+	return 0
+}
+
+
+# vim: tw=72:


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-05-26  4:05 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     da66246c68be060ea7484110fac298ac7fa4363d
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 04:03:48 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sun May 22 04:03:48 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=da66246c

prefix.eclass: add eprefixify_patch.

 eclass/prefix.eclass | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/eclass/prefix.eclass b/eclass/prefix.eclass
index 1f3c4b0..101cce2 100644
--- a/eclass/prefix.eclass
+++ b/eclass/prefix.eclass
@@ -12,6 +12,8 @@
 # located somewhere in the filesystem.  Prefix ebuilds require
 # additional functions and variables which are defined by this eclass.
 
+inherit eutils
+
 # @ECLASS-VARIABLE: EPREFIX
 # @DESCRIPTION:
 # The offset prefix of a Gentoo Prefix installation.  When Gentoo Prefix
@@ -48,5 +50,28 @@ eprefixify() {
 	return 0
 }
 
+# @FUNCTION: eprefixify_patch
+# @USAGE: <list of patch files to be eprefixified>
+# @DESCRIPTION:
+# copies the patch files to ${T} and eprefixify before applying.
+# dies if no arguments are given, a file does not exist, or changing a
+# file failed.
+eprefixity_patch() {
+	[[ $# -lt 1 ]] && die "at least one argument required"
+
+	local x f
+	for x in "$@" ; do
+		if [[ -e ${x} ]] ; then
+			f=${x##*/}
+			cp "${x}" "${T}" || die "failed to copy patch"
+			eprefixify "${T}"/${f}
+			epatch "${T}"/${f}
+		else
+			die "${x} does not exist"
+		fi
+	done
+
+	return 0
+}
 
 # vim: tw=72:


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
  2016-05-23 16:15 [gentoo-commits] dev/heroxbd:master " Benda XU
@ 2016-05-26  4:05 ` Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     81fc154277582961526722e099fb8d38751000fd
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 16:14:35 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Mon May 23 16:14:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=81fc1542

kernel-2.eclass: track.

Bug: 478436

 eclass/kernel-2.eclass | 1321 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 1321 insertions(+)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
new file mode 100644
index 0000000..e8cb8f2
--- /dev/null
+++ b/eclass/kernel-2.eclass
@@ -0,0 +1,1321 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.297 2014/11/28 17:40:20 mpagano Exp $
+
+# Description: kernel.eclass rewrite for a clean base regarding the 2.6
+#              series of kernel with back-compatibility for 2.4
+#
+# Original author: John Mylchreest <johnm@gentoo.org>
+# Maintainer: kernel-misc@gentoo.org
+#
+# Please direct your bugs to the current eclass maintainer :)
+
+# added functionality:
+# unipatch		- a flexible, singular method to extract, add and remove patches.
+
+# A Couple of env vars are available to effect usage of this eclass
+# These are as follows:
+#
+# K_USEPV				- When setting the EXTRAVERSION variable, it should
+#						  add PV to the end.
+#						  this is useful for thigns like wolk. IE:
+#						  EXTRAVERSION would be something like : -wolk-4.19-r1
+# K_NOSETEXTRAVERSION	- if this is set then EXTRAVERSION will not be
+#						  automatically set within the kernel Makefile
+# K_NOUSENAME			- if this is set then EXTRAVERSION will not include the
+#						  first part of ${PN} in EXTRAVERSION
+# K_NOUSEPR				- if this is set then EXTRAVERSION will not include the
+#						  anything based on ${PR}.
+# K_PREPATCHED			- if the patchset is prepatched (ie: mm-sources,
+#						  ck-sources, ac-sources) it will use PR (ie: -r5) as
+#						  the patchset version for
+#						  and not use it as a true package revision
+# K_EXTRAEINFO			- this is a new-line seperated list of einfo displays in
+#						  postinst and can be used to carry additional postinst
+#						  messages
+# K_EXTRAELOG			- same as K_EXTRAEINFO except using elog instead of einfo
+# K_EXTRAEWARN			- same as K_EXTRAEINFO except using ewarn instead of einfo
+# K_SYMLINK				- if this is set, then forcably create symlink anyway
+#
+# K_DEFCONFIG			- Allow specifying a different defconfig target.
+#						  If length zero, defaults to "defconfig".
+# K_WANT_GENPATCHES		- Apply genpatches to kernel source. Provide any
+# 						  combination of "base", "extras" or "experimental".
+# K_EXP_GENPATCHES_PULL	- If set, we pull "experimental" regardless of the USE FLAG
+#						  but expect the ebuild maintainer to use K_EXP_GENPATCHES_LIST.
+# K_EXP_GENPATCHES_NOUSE	- If set, no USE flag will be provided for "experimental";
+# 						  as a result the user cannot choose to apply those patches.
+# K_EXP_GENPATCHES_LIST	- A list of patches to pick from "experimental" to apply when
+# 						  the USE flag is unset and K_EXP_GENPATCHES_PULL is set.
+# K_GENPATCHES_VER		- The version of the genpatches tarball(s) to apply.
+#						  A value of "5" would apply genpatches-2.6.12-5 to
+#						  my-sources-2.6.12.ebuild
+# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
+# K_DEBLOB_AVAILABLE	- A value of "0" will disable all of the optional deblob
+#						  code. If empty, will be set to "1" if deblobbing is
+#						  possible. Test ONLY for "1".
+# K_PREDEBLOBBED		- This kernel was already deblobbed elsewhere.
+#						  If false, either optional deblobbing will be available
+#						  or the license will note the inclusion of freedist
+#						  code.
+# K_LONGTERM			- If set, the eclass will search for the kernel source
+#						  in the long term directories on the upstream servers
+#						  as the location has been changed by upstream
+# H_SUPPORTEDARCH		- this should be a space separated list of ARCH's which
+#						  can be supported by the headers ebuild
+
+# UNIPATCH_LIST			- space delimetered list of patches to be applied to the
+#						  kernel
+# UNIPATCH_EXCLUDE		- an addition var to support exlusion based completely
+#						  on "<passedstring>*" and not "<passedno#>_*"
+#						- this should _NOT_ be used from the ebuild as this is
+#						  reserved for end users passing excludes from the cli
+# UNIPATCH_DOCS			- space delimemeted list of docs to be installed to
+#						  the doc dir
+# UNIPATCH_STRICTORDER	- if this is set places patches into directories of
+#						  order, so they are applied in the order passed
+
+# Changing any other variable in this eclass is not supported; you can request
+# for additional variables to be added by contacting the current maintainer.
+# If you do change them, there is a chance that we will not fix resulting bugs;
+# that of course does not mean we're not willing to help.
+
+PYTHON_COMPAT=( python{2_6,2_7} )
+
+inherit eutils toolchain-funcs versionator multilib python-any-r1
+EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
+
+# Added by Daniel Ostrow <dostrow@gentoo.org>
+# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
+# I will remove it when I come up with something more reasonable.
+[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
+	export CTARGET=${CATEGORY/cross-}
+fi
+
+HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
+: ${LICENSE:="GPL-2"}
+
+# This is the latest KV_PATCH of the deblob tool available from the
+# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
+# for ALL kernel-2 consumer packages where deblob is available.
+: ${DEBLOB_MAX_VERSION:=38}
+
+# No need to run scanelf/strip on kernel sources/headers (bug #134453).
+RESTRICT="binchecks strip"
+
+# set LINUX_HOSTCFLAGS if not already set
+: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
+
+# debugging functions
+#==============================================================
+# this function exists only to help debug kernel-2.eclass
+# if you are adding new functionality in, put a call to it
+# at the start of src_unpack, or during SRC_URI/dep generation.
+debug-print-kernel2-variables() {
+	for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
+			RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
+			UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do
+		debug-print "${v}: ${!v}"
+	done
+}
+
+#Eclass functions only from here onwards ...
+#==============================================================
+handle_genpatches() {
+	local tarball
+	[[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
+
+	debug-print "Inside handle_genpatches"
+	local OKV_ARRAY
+	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+	# for > 3.0 kernels, handle genpatches tarball name
+	# genpatches for 3.0 and 3.0.1 might be named
+	# genpatches-3.0-1.base.tar.xz and genpatches-3.0-2.base.tar.xz
+	# respectively.  Handle this.
+
+	for i in ${K_WANT_GENPATCHES} ; do
+		if [[ ${KV_MAJOR} -ge 3 ]]; then
+			if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+				tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.xz"
+			else
+				tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.xz"
+			fi
+		else
+			tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.xz"
+		fi
+
+		local use_cond_start="" use_cond_end=""
+
+		if [[ "${i}" == "experimental" && -z ${K_EXP_GENPATCHES_PULL} && -z ${K_EXP_GENPATCHES_NOUSE} ]] ; then
+			use_cond_start="experimental? ( "
+			use_cond_end=" )"
+
+			if use experimental ; then
+				UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
+				debug-print "genpatches tarball: $tarball"
+			fi
+		else
+			UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
+			debug-print "genpatches tarball: $tarball"
+		fi
+
+		GENPATCHES_URI+=" ${use_cond_start}mirror://gentoo/${tarball}${use_cond_end}"
+	done
+}
+
+detect_version() {
+	# this function will detect and set
+	# - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
+	# - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
+	# - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
+
+	# We've already run, so nothing to do here.
+	[[ -n ${KV_FULL} ]] && return 0
+
+	# CKV is used as a comparison kernel version, which is used when
+	# PV doesnt reflect the genuine kernel version.
+	# this gets set to the portage style versioning. ie:
+	#   CKV=2.6.11_rc4
+	CKV=${CKV:-${PV}}
+	OKV=${OKV:-${CKV}}
+	OKV=${OKV/_beta/-test}
+	OKV=${OKV/_rc/-rc}
+	OKV=${OKV/-r*}
+	OKV=${OKV/_p*}
+
+	KV_MAJOR=$(get_version_component_range 1 ${OKV})
+	# handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
+	local OKV_ARRAY
+	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+	# if KV_MAJOR >= 3, then we have no more KV_MINOR
+	#if [[ ${KV_MAJOR} -lt 3 ]]; then
+	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+		KV_MINOR=$(get_version_component_range 2 ${OKV})
+		KV_PATCH=$(get_version_component_range 3 ${OKV})
+		if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
+	        KV_EXTRA=$(get_version_component_range 4- ${OKV})
+	        KV_EXTRA=${KV_EXTRA/[-_]*}
+		else
+			KV_PATCH=$(get_version_component_range 3- ${OKV})
+		fi
+	else
+		KV_PATCH=$(get_version_component_range 2 ${OKV})
+		KV_EXTRA=$(get_version_component_range 3- ${OKV})
+		KV_EXTRA=${KV_EXTRA/[-_]*}
+	fi
+
+	debug-print "KV_EXTRA is ${KV_EXTRA}"
+
+	KV_PATCH=${KV_PATCH/[-_]*}
+
+	local v n=0 missing
+	#if [[ ${KV_MAJOR} -lt 3 ]]; then
+	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+		for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
+			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
+		done
+	else
+		for v in CKV OKV KV_{MAJOR,PATCH} ; do
+			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
+		done
+	fi
+
+	[[ $n -eq 1 ]] && \
+		eerror "Missing variables: ${missing}" && \
+		die "Failed to extract kernel version (try explicit CKV in ebuild)!"
+	unset v n missing
+
+#	if [[ ${KV_MAJOR} -ge 3 ]]; then
+	if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then
+		KV_PATCH_ARR=(${KV_PATCH//\./ })
+
+		# at this point 031412, Linus is putting all 3.x kernels in a
+		# 3.x directory, may need to revisit when 4.x is released
+		KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
+
+		[[ -n "${K_LONGTERM}" ]] &&
+			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
+	else
+		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
+		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
+		if [[ ${KV_MAJOR} -ge 3 ]]; then
+			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
+		else
+			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
+		fi
+
+		[[ -n "${K_LONGTERM}" ]] &&
+			#KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
+			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+	fi
+
+	debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
+
+	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+		# handle non genpatch using sources correctly
+		if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then
+			KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.xz"
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
+		fi
+		KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz"
+	else
+		KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+	fi
+
+	RELEASE=${CKV/${OKV}}
+	RELEASE=${RELEASE/_beta}
+	RELEASE=${RELEASE/_rc/-rc}
+	RELEASE=${RELEASE/_pre/-pre}
+	# We cannot trivally call kernel_is here, because it calls us to detect the
+	# version
+	#kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
+	[ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
+	RELEASETYPE=${RELEASE//[0-9]}
+
+	# Now we know that RELEASE is the -rc/-git
+	# and RELEASETYPE is the same but with its numerics stripped
+	# we can work on better sorting EXTRAVERSION.
+	# first of all, we add the release
+	EXTRAVERSION="${RELEASE}"
+	debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
+	[[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
+
+	debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
+	if [[ -n "${K_NOUSEPR}" ]]; then
+		# Don't add anything based on PR to EXTRAVERSION
+		debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
+	elif [[ -n ${K_PREPATCHED} ]]; then
+		debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
+		EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
+	elif [[ "${ETYPE}" = "sources" ]]; then
+		debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
+		# For some sources we want to use the PV in the extra version
+		# This is because upstream releases with a completely different
+		# versioning scheme.
+		case ${PN/-*} in
+		     wolk) K_USEPV=1;;
+		  vserver) K_USEPV=1;;
+		esac
+
+		[[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
+		[[ -n "${K_USEPV}" ]]     && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
+		[[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
+	fi
+	debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
+
+	# The only messing around which should actually effect this is for KV_EXTRA
+	# since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
+	# KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
+
+	if [[ -n ${KV_EXTRA} ]]; then
+		if [[ -n ${KV_MINOR} ]]; then
+			OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+		else
+			OKV="${KV_MAJOR}.${KV_PATCH}"
+		fi
+		KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.xz
+					${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+		UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
+	fi
+
+	# We need to set this using OKV, but we need to set it before we do any
+	# messing around with OKV based on RELEASETYPE
+	KV_FULL=${OKV}${EXTRAVERSION}
+
+	# we will set this for backwards compatibility.
+	S=${WORKDIR}/linux-${KV_FULL}
+	KV=${KV_FULL}
+
+	# -rc-git pulls can be achieved by specifying CKV
+	# for example:
+	#   CKV="2.6.11_rc3_pre2"
+	# will pull:
+	#   linux-2.6.10.tar.xz & patch-2.6.11-rc3.xz & patch-2.6.11-rc3-git2.xz
+
+	if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then
+
+		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
+			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
+			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
+		fi
+
+		if [[ ${RELEASETYPE} == -git ]]; then
+			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
+		fi
+
+		if [[ ${RELEASETYPE} == -rc-git ]]; then
+			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
+			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz
+						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz"
+		fi
+	else
+		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
+			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
+				OKV="2.6.39"
+			else
+				KV_PATCH_ARR=(${KV_PATCH//\./ })
+				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
+			fi
+			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
+		fi
+
+		if [[ ${RELEASETYPE} == -git ]]; then
+			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
+		fi
+
+		if [[ ${RELEASETYPE} == -rc-git ]]; then
+			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
+				OKV="2.6.39"
+			else
+				KV_PATCH_ARR=(${KV_PATCH//\./ })
+				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
+			fi
+			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz
+						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz
+						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
+
+			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz"
+		fi
+
+
+	fi
+
+
+	debug-print-kernel2-variables
+
+	handle_genpatches
+}
+
+# Note: duplicated in linux-info.eclass
+kernel_is() {
+	# ALL of these should be set before we can safely continue this function.
+	# some of the sources have in the past had only one set.
+	local v n=0
+	for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
+	[[ $n -eq 1 ]] && detect_version
+	unset v n
+
+	# Now we can continue
+	local operator test value
+
+	case ${1#-} in
+	  lt) operator="-lt"; shift;;
+	  gt) operator="-gt"; shift;;
+	  le) operator="-le"; shift;;
+	  ge) operator="-ge"; shift;;
+	  eq) operator="-eq"; shift;;
+	   *) operator="-eq";;
+	esac
+	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
+
+	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
+	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
+	[ ${test} ${operator} ${value} ]
+}
+
+kernel_is_2_4() {
+	kernel_is 2 4
+}
+
+kernel_is_2_6() {
+	kernel_is 2 6 || kernel_is 2 5
+}
+
+# Capture the sources type and set DEPENDs
+if [[ ${ETYPE} == sources ]]; then
+	DEPEND="!build? (
+		sys-apps/sed
+		>=sys-devel/binutils-2.11.90.0.31
+	)"
+	RDEPEND="!build? (
+		>=sys-libs/ncurses-5.2
+		sys-devel/make
+		dev-lang/perl
+		sys-devel/bc
+	)"
+	PDEPEND="!build? ( virtual/dev-manager )"
+
+	SLOT="${PVR}"
+	DESCRIPTION="Sources based on the Linux Kernel."
+	IUSE="symlink build"
+
+	# Bug #266157, deblob for libre support
+	if [[ -z ${K_PREDEBLOBBED} ]] ; then
+		# Bug #359865, force a call to detect_version if needed
+		kernel_is ge 2 6 27 && \
+			[[ -z "${K_DEBLOB_AVAILABLE}" ]] && \
+				kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
+					K_DEBLOB_AVAILABLE=1
+		if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
+			IUSE="${IUSE} deblob"
+
+			# Reflect that kernels contain firmware blobs unless otherwise
+			# stripped
+			LICENSE="${LICENSE} !deblob? ( freedist )"
+
+			DEPEND+=" deblob? ( ${PYTHON_DEPS} )"
+
+			if [[ -n KV_MINOR ]]; then
+				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+			else
+				DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}"
+			fi
+
+			if [[ ${KV_MAJOR} -ge 3 ]]; then
+				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}"
+			fi
+
+			DEBLOB_A="deblob-${DEBLOB_PV}"
+			DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
+			DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
+			DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
+			if ! has "${EAPI:-0}" 0 1 ; then
+				DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
+			else
+				DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
+			fi
+			DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
+			HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
+
+			KERNEL_URI="${KERNEL_URI}
+				deblob? (
+					${DEBLOB_URI}
+					${DEBLOB_CHECK_URI}
+				)"
+		else
+			# We have no way to deblob older kernels, so just mark them as
+			# tainted with non-libre materials.
+			LICENSE="${LICENSE} freedist"
+		fi
+	fi
+
+elif [[ ${ETYPE} == headers ]]; then
+	DESCRIPTION="Linux system headers"
+
+	# Since we should NOT honour KBUILD_OUTPUT in headers
+	# lets unset it here.
+	unset KBUILD_OUTPUT
+
+	SLOT="0"
+else
+	eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
+	die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
+fi
+
+# Cross-compile support functions
+#==============================================================
+kernel_header_destdir() {
+	[[ ${CTARGET} == ${CHOST} ]] \
+		&& echo "${EPREFIX}"/usr/include \
+		|| echo "${EPREFIX}"/usr/${CTARGET}/usr/include
+}
+
+cross_pre_c_headers() {
+	use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
+}
+
+env_setup_xmakeopts() {
+	# Kernel ARCH != portage ARCH
+	export KARCH=$(tc-arch-kernel)
+
+	# When cross-compiling, we need to set the ARCH/CROSS_COMPILE
+	# variables properly or bad things happen !
+	xmakeopts="ARCH=${KARCH}"
+	if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
+		xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
+	elif type -p ${CHOST}-ar > /dev/null ; then
+		xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
+	fi
+	export xmakeopts
+}
+
+# Unpack functions
+#==============================================================
+unpack_2_4() {
+	# this file is required for other things to build properly,
+	# so we autogenerate it
+	make -s mrproper ${xmakeopts} || die "make mrproper failed"
+	make -s symlinks ${xmakeopts} || die "make symlinks failed"
+	make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
+	echo ">>> version.h compiled successfully."
+}
+
+unpack_2_6() {
+	# this file is required for other things to build properly, so we
+	# autogenerate it ... generate a .config to keep version.h build from
+	# spitting out an annoying warning
+	make -s mrproper ${xmakeopts} 2>/dev/null \
+		|| die "make mrproper failed"
+
+	# quick fix for bug #132152 which triggers when it cannot include linux
+	# headers (ie, we have not installed it yet)
+	if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
+		touch .config
+		eerror "make defconfig failed."
+		eerror "assuming you dont have any headers installed yet and continuing"
+		epause 5
+	fi
+
+	make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
+		|| die "make include/linux/version.h failed"
+	rm -f .config >/dev/null
+}
+
+universal_unpack() {
+	debug-print "Inside universal_unpack"
+
+	local OKV_ARRAY
+	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+	cd "${WORKDIR}"
+	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+		unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.xz
+	else
+		unpack linux-${OKV}.tar.xz
+	fi
+
+	if [[ -d "linux" ]]; then
+		debug-print "Moving linux to linux-${KV_FULL}"
+		mv linux linux-${KV_FULL} \
+			|| die "Unable to move source tree to ${KV_FULL}."
+	elif [[ "${OKV}" != "${KV_FULL}" ]]; then
+		if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] &&
+			[[ "${ETYPE}" = "sources" ]]; then
+			debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} "
+			mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
+				|| die "Unable to move source tree to ${KV_FULL}."
+		else
+			debug-print "moving linux-${OKV} to linux-${KV_FULL} "
+			mv linux-${OKV} linux-${KV_FULL} \
+				|| die "Unable to move source tree to ${KV_FULL}."
+		fi
+	elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+		mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
+			|| die "Unable to move source tree to ${KV_FULL}."
+	fi
+	cd "${S}"
+
+	# remove all backup files
+	find . -iname "*~" -exec rm {} \; 2> /dev/null
+
+}
+
+unpack_set_extraversion() {
+	cd "${S}"
+	sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
+	cd "${OLDPWD}"
+}
+
+# Should be done after patches have been applied
+# Otherwise patches that modify the same area of Makefile will fail
+unpack_fix_install_path() {
+	cd "${S}"
+	sed	-i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
+}
+
+# Compile Functions
+#==============================================================
+compile_headers() {
+	env_setup_xmakeopts
+
+	# if we couldnt obtain HOSTCFLAGS from the Makefile,
+	# then set it to something sane
+	local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
+	HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
+
+	if kernel_is 2 4; then
+		yes "" | make oldconfig ${xmakeopts}
+		echo ">>> make oldconfig complete"
+		make dep ${xmakeopts}
+	elif kernel_is 2 6; then
+		# 2.6.18 introduces headers_install which means we dont need any
+		# of this crap anymore :D
+		kernel_is ge 2 6 18 && return 0
+
+		# autoconf.h isnt generated unless it already exists. plus, we have
+		# no guarantee that any headers are installed on the system...
+		[[ -f ${EROOT}/usr/include/linux/autoconf.h ]] \
+			|| touch include/linux/autoconf.h
+
+		# if K_DEFCONFIG isn't set, force to "defconfig"
+		# needed by mips
+		if [[ -z ${K_DEFCONFIG} ]]; then
+			if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
+				case ${CTARGET} in
+					powerpc64*)	K_DEFCONFIG="ppc64_defconfig";;
+					powerpc*)	K_DEFCONFIG="pmac32_defconfig";;
+					*)			K_DEFCONFIG="defconfig";;
+				esac
+			else
+				K_DEFCONFIG="defconfig"
+			fi
+		fi
+
+		# if there arent any installed headers, then there also isnt an asm
+		# symlink in /usr/include/, and make defconfig will fail, so we have
+		# to force an include path with $S.
+		HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
+		ln -sf asm-${KARCH} "${S}"/include/asm
+		cross_pre_c_headers && return 0
+
+		make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
+		if compile_headers_tweak_config ; then
+			yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
+		fi
+		make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
+		make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
+	fi
+}
+
+compile_headers_tweak_config() {
+	# some targets can be very very picky, so let's finesse the
+	# .config based upon any info we may have
+	case ${CTARGET} in
+	sh*)
+		sed -i '/CONFIG_CPU_SH/d' .config
+		echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
+		return 0;;
+	esac
+
+	# no changes, so lets do nothing
+	return 1
+}
+
+# install functions
+#==============================================================
+install_universal() {
+	# Fix silly permissions in tarball
+	cd "${WORKDIR}"
+	chown -R 0:0 * >& /dev/null
+	chmod -R a+r-w+X,u+w *
+	cd ${OLDPWD}
+}
+
+install_headers() {
+	local ddir=$(kernel_header_destdir)
+
+	# 2.6.18 introduces headers_install which means we dont need any
+	# of this crap anymore :D
+	if kernel_is ge 2 6 18 ; then
+		env_setup_xmakeopts
+		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+
+		# let other packages install some of these headers
+		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		return 0
+	fi
+
+	# Do not use "linux/*" as that can cause problems with very long
+	# $S values where the cmdline to cp is too long
+	pushd "${S}" >/dev/null
+	dodir ${ddir#${EPREFIX}}/linux
+	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
+	rm -rf "${D}"/${ddir}/linux/modules
+
+	dodir ${ddir#${EPREFIX}}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm
+
+	if kernel_is 2 6 ; then
+		dodir ${ddir#${EPREFIX}}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+	fi
+
+	# clean up
+	find "${D}" -name '*.orig' -exec rm -f {} \;
+
+	popd >/dev/null
+}
+
+install_sources() {
+	local file
+
+	cd "${S}"
+	dodir /usr/src
+	echo ">>> Copying sources ..."
+
+	file="$(find ${WORKDIR} -iname "docs" -type d)"
+	if [[ -n ${file} ]]; then
+		for file in $(find ${file} -type f); do
+			echo "${file//*docs\/}" >> "${S}"/patches.txt
+			echo "===================================================" >> "${S}"/patches.txt
+			cat ${file} >> "${S}"/patches.txt
+			echo "===================================================" >> "${S}"/patches.txt
+			echo "" >> "${S}"/patches.txt
+		done
+	fi
+
+	if [[ ! -f ${S}/patches.txt ]]; then
+		# patches.txt is empty so lets use our ChangeLog
+		[[ -f ${FILESDIR}/../ChangeLog ]] && \
+			echo "Please check the ebuild ChangeLog for more details." \
+			> "${S}"/patches.txt
+	fi
+
+	mv ${WORKDIR}/linux* "${ED}"/usr/src
+
+	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
+		for i in ${UNIPATCH_DOCS}; do
+			dodoc "${T}"/${i}
+		done
+	fi
+}
+
+# pkg_preinst functions
+#==============================================================
+preinst_headers() {
+	local ddir=$(kernel_header_destdir)
+	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
+	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+}
+
+# pkg_postinst functions
+#==============================================================
+postinst_sources() {
+	local MAKELINK=0
+
+	# if we have USE=symlink, then force K_SYMLINK=1
+	use symlink && K_SYMLINK=1
+
+	# if we're using a deblobbed kernel, it's not supported
+	[[ $K_DEBLOB_AVAILABLE == 1 ]] && \
+		use deblob && \
+		K_SECURITY_UNSUPPORTED=deblob
+
+	# if we are to forcably symlink, delete it if it already exists first.
+	if [[ ${K_SYMLINK} > 0 ]]; then
+		[[ -h ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux
+		MAKELINK=1
+	fi
+
+	# if the link doesnt exist, lets create it
+	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
+
+	if [[ ${MAKELINK} == 1 ]]; then
+		cd "${EROOT}"usr/src
+		ln -sf linux-${KV_FULL} linux
+		cd ${OLDPWD}
+	fi
+
+	# Don't forget to make directory for sysfs
+	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}sys
+
+	echo
+	elog "If you are upgrading from a previous kernel, you may be interested"
+	elog "in the following document:"
+	elog "  - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
+	echo
+
+	# if K_EXTRAEINFO is set then lets display it now
+	if [[ -n ${K_EXTRAEINFO} ]]; then
+		echo ${K_EXTRAEINFO} | fmt |
+		while read -s ELINE; do	einfo "${ELINE}"; done
+	fi
+
+	# if K_EXTRAELOG is set then lets display it now
+	if [[ -n ${K_EXTRAELOG} ]]; then
+		echo ${K_EXTRAELOG} | fmt |
+		while read -s ELINE; do	elog "${ELINE}"; done
+	fi
+
+	# if K_EXTRAEWARN is set then lets display it now
+	if [[ -n ${K_EXTRAEWARN} ]]; then
+		echo ${K_EXTRAEWARN} | fmt |
+		while read -s ELINE; do ewarn "${ELINE}"; done
+	fi
+
+	# optionally display security unsupported message
+	#  Start with why
+	if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
+		ewarn "Deblobbed kernels may not be up-to-date security-wise"
+		ewarn "as they depend on external scripts."
+	elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
+		ewarn "${PN} is UNSUPPORTED by Gentoo Security."
+	fi
+	#  And now the general message.
+	if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
+		ewarn "This means that it is likely to be vulnerable to recent security issues."
+		ewarn "For specific information on why this kernel is unsupported, please read:"
+		ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
+	fi
+
+	# warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
+	KV_MAJOR=$(get_version_component_range 1 ${OKV})
+	KV_MINOR=$(get_version_component_range 2 ${OKV})
+	KV_PATCH=$(get_version_component_range 3 ${OKV})
+	if [[ "$(tc-arch)" = "sparc" ]]; then
+		if [[ $(gcc-major-version) -lt 4 && $(gcc-minor-version) -lt 4 ]]; then
+			if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] ; then
+				echo
+				elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
+				elog "you now need to do"
+				elog "  make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
+				elog "instead of just"
+				elog "  make"
+				elog "to compile the kernel. For more information please browse to"
+				elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
+				echo
+			fi
+		fi
+	fi
+}
+
+# pkg_setup functions
+#==============================================================
+setup_headers() {
+	[[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
+	for i in ${H_SUPPORTEDARCH}; do
+		[[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
+	done
+
+	if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
+		echo
+		eerror "This version of ${PN} does not support $(tc-arch)."
+		eerror "Please merge the appropriate sources, in most cases"
+		eerror "(but not all) this will be called $(tc-arch)-headers."
+		die "Package unsupported for $(tc-arch)"
+	fi
+}
+
+# unipatch
+#==============================================================
+unipatch() {
+	local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
+	local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
+
+	# set to a standard locale to ensure sorts are ordered properly.
+	myLC_ALL="${LC_ALL}"
+	myLANG="${LANG}"
+	LC_ALL="C"
+	LANG=""
+
+	[ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
+	[ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
+
+	# We're gonna need it when doing patches with a predefined patchlevel
+	eshopts_push -s extglob
+
+	# This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
+	# usage can be either via an env var or by params
+	# although due to the nature we pass this within this eclass
+	# it shall be by param only.
+	# -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
+	UNIPATCH_LIST="${@}"
+
+	#unpack any passed tarballs
+	for i in ${UNIPATCH_LIST}; do
+		if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
+			if [ -n "${UNIPATCH_STRICTORDER}" ]; then
+				unset z
+				STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
+				for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
+					do z="${z}0";
+				done
+				PATCH_ORDER="${z}${STRICT_COUNT}"
+
+				mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
+				pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
+				unpack ${i##*/}
+				popd >/dev/null
+			else
+				pushd "${KPATCH_DIR}" >/dev/null
+				unpack ${i##*/}
+				popd >/dev/null
+			fi
+
+			[[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
+		else
+			extention=${i/*./}
+			extention=${extention/:*/}
+			PIPE_CMD=""
+			case ${extention} in
+				     xz) PIPE_CMD="xz -dc";;
+				   lzma) PIPE_CMD="lzma -dc";;
+				    bz2) PIPE_CMD="bzip2 -dc";;
+				 patch*) PIPE_CMD="cat";;
+				   diff) PIPE_CMD="cat";;
+				 gz|Z|z) PIPE_CMD="gzip -dc";;
+				ZIP|zip) PIPE_CMD="unzip -p";;
+				      *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
+			esac
+
+			PATCH_LEVEL=${i/*([^:])?(:)}
+			i=${i/:*/}
+			x=${i/*\//}
+			x=${x/\.${extention}/}
+
+			if [ -n "${PIPE_CMD}" ]; then
+				if [ ! -r "${i}" ]; then
+					echo
+					eerror "FATAL: unable to locate:"
+					eerror "${i}"
+					eerror "for read-only. The file either has incorrect permissions"
+					eerror "or does not exist."
+					die Unable to locate ${i}
+				fi
+
+				if [ -n "${UNIPATCH_STRICTORDER}" ]; then
+					unset z
+					STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
+					for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
+						do z="${z}0";
+					done
+					PATCH_ORDER="${z}${STRICT_COUNT}"
+
+					mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
+					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
+				else
+					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
+				fi
+			fi
+		fi
+
+		# If experimental was not chosen by the user, drop experimental patches not in K_EXP_GENPATCHES_LIST.
+		if [[ "${i}" == *"genpatches-"*".experimental."* && -n ${K_EXP_GENPATCHES_PULL} ]] ; then
+			if [[ -z ${K_EXP_GENPATCHES_NOUSE} ]] && use experimental; then
+				continue
+			fi
+
+			local j
+			for j in ${KPATCH_DIR}/*/50*_*.patch*; do
+				for k in ${K_EXP_GENPATCHES_LIST} ; do
+					[[ "$(basename ${j})" == ${k}* ]] && continue 2
+				done
+				UNIPATCH_DROP+=" $(basename ${j})"
+			done
+		fi
+	done
+
+	#populate KPATCH_DIRS so we know where to look to remove the excludes
+	x=${KPATCH_DIR}
+	KPATCH_DIR=""
+	for i in $(find ${x} -type d | sort -n); do
+		KPATCH_DIR="${KPATCH_DIR} ${i}"
+	done
+
+	# do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
+	# bug #272676
+	if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
+		if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
+			UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
+			echo
+			ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
+			ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
+			ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
+			echo
+		fi
+	fi
+
+	#so now lets get rid of the patchno's we want to exclude
+	UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
+	for i in ${UNIPATCH_DROP}; do
+		ebegin "Excluding Patch #${i}"
+		for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
+		eend $?
+	done
+
+	# and now, finally, we patch it :)
+	for x in ${KPATCH_DIR}; do
+		for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
+			STDERR_T="${T}/${i/*\//}"
+			STDERR_T="${STDERR_T/.patch*/.err}"
+
+			[ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
+			#[ -z ${i/*.diff*/} ]  && PATCH_DEPTH=${i/*.diff/}
+
+			if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
+
+			####################################################################
+			# IMPORTANT: This is temporary code to support Linux git 3.15_rc1! #
+			#                                                                  #
+			# The patch contains a removal of a symlink, followed by addition  #
+			# of a file with the same name as the symlink in the same          #
+			# location; this causes the dry-run to fail, filed bug #507656.    #
+			#                                                                  #
+			# https://bugs.gentoo.org/show_bug.cgi?id=507656                   #
+			####################################################################
+			if [[ ${PN} == "git-sources" ]] ; then
+				if [[ ${KV_MAJOR}${KV_PATCH} -ge 315 && ${RELEASETYPE} == -rc ]] ; then
+					ebegin "Applying ${i/*\//} (-p1)"
+					if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
+						eend 0
+						rm ${STDERR_T}
+						break
+					else
+						eend 1
+						eerror "Failed to apply patch ${i/*\//}"
+						eerror "Please attach ${STDERR_T} to any bug you may post."
+						eshopts_pop
+						die "Failed to apply ${i/*\//} on patch depth 1."
+					fi
+				fi
+			fi
+			####################################################################
+
+			while [ ${PATCH_DEPTH} -lt 5 ]; do
+				echo "Attempting Dry-run:" >> ${STDERR_T}
+				echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
+				echo "=======================================================" >> ${STDERR_T}
+				if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
+					ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH})"
+					echo "Attempting patch:" > ${STDERR_T}
+					echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
+					echo "=======================================================" >> ${STDERR_T}
+					if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
+						eend 0
+						rm ${STDERR_T}
+						break
+					else
+						eend 1
+						eerror "Failed to apply patch ${i/*\//}"
+						eerror "Please attach ${STDERR_T} to any bug you may post."
+						eshopts_pop
+						die "Failed to apply ${i/*\//} on patch depth ${PATCH_DEPTH}."
+					fi
+				else
+					PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
+				fi
+			done
+			if [ ${PATCH_DEPTH} -eq 5 ]; then
+				eerror "Failed to dry-run patch ${i/*\//}"
+				eerror "Please attach ${STDERR_T} to any bug you may post."
+				eshopts_pop
+				die "Unable to dry-run patch on any patch depth lower than 5."
+			fi
+		done
+	done
+
+	# When genpatches is used, we want to install 0000_README which documents
+	# the patches that were used; such that the user can see them, bug #301478.
+	if [[ ! -z ${K_WANT_GENPATCHES} ]] ; then
+		UNIPATCH_DOCS="${UNIPATCH_DOCS} 0000_README"
+	fi
+
+	# When files listed in UNIPATCH_DOCS are found in KPATCH_DIR's, we copy it
+	# to the temporary directory and remember them in UNIPATCH_DOCS to install
+	# them during the install phase.
+	local tmp
+	for x in ${KPATCH_DIR}; do
+		for i in ${UNIPATCH_DOCS}; do
+			if [[ -f "${x}/${i}" ]] ; then
+				tmp="${tmp} ${i}"
+				cp -f "${x}/${i}" "${T}"/
+			fi
+		done
+	done
+	UNIPATCH_DOCS="${tmp}"
+
+	# clean up  KPATCH_DIR's - fixes bug #53610
+	for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
+
+	LC_ALL="${myLC_ALL}"
+	LANG="${myLANG}"
+	eshopts_pop
+}
+
+# getfilevar accepts 2 vars as follows:
+# getfilevar <VARIABLE> <CONFIGFILE>
+# pulled from linux-info
+
+getfilevar() {
+	local workingdir basefname basedname xarch=$(tc-arch-kernel)
+
+	if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
+		echo -e "\n"
+		eerror "getfilevar requires 2 variables, with the second a valid file."
+		eerror "   getfilevar <VARIABLE> <CONFIGFILE>"
+	else
+		workingdir=${PWD}
+		basefname=$(basename ${2})
+		basedname=$(dirname ${2})
+		unset ARCH
+
+		cd ${basedname}
+		echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
+			make ${BUILD_FIXES} -s -f - e 2>/dev/null
+		cd ${workingdir}
+
+		ARCH=${xarch}
+	fi
+}
+
+detect_arch() {
+	# This function sets ARCH_URI and ARCH_PATCH
+	# with the neccessary info for the arch sepecific compatibility
+	# patchsets.
+
+	local ALL_ARCH LOOP_ARCH COMPAT_URI i
+
+	# COMPAT_URI is the contents of ${ARCH}_URI
+	# ARCH_URI is the URI for all the ${ARCH}_URI patches
+	# ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
+
+	ARCH_URI=""
+	ARCH_PATCH=""
+	ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
+
+	for LOOP_ARCH in ${ALL_ARCH}; do
+		COMPAT_URI="${LOOP_ARCH}_URI"
+		COMPAT_URI="${!COMPAT_URI}"
+
+		[[ -n ${COMPAT_URI} ]] && \
+			ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
+
+		if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; 	then
+			for i in ${COMPAT_URI}; do
+				ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
+			done
+		fi
+	done
+}
+
+headers___fix() {
+	# Voodoo to partially fix broken upstream headers.
+	# note: do not put inline/asm/volatile together (breaks "inline asm volatile")
+	sed -i \
+		-e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
+		-e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
+		-e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
+		-e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
+		-e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
+		"$@"
+}
+
+# common functions
+#==============================================================
+kernel-2_src_unpack() {
+	universal_unpack
+	debug-print "Doing unipatch"
+
+	[[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
+		unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
+
+	debug-print "Doing premake"
+
+	# allow ebuilds to massage the source tree after patching but before
+	# we run misc `make` functions below
+	[[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
+
+	debug-print "Doing epatch_user"
+	epatch_user
+
+	debug-print "Doing unpack_set_extraversion"
+
+	[[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
+	unpack_fix_install_path
+
+	# Setup xmakeopts and cd into sourcetree.
+	env_setup_xmakeopts
+	cd "${S}"
+
+	# We dont need a version.h for anything other than headers
+	# at least, I should hope we dont. If this causes problems
+	# take out the if/fi block and inform me please.
+	# unpack_2_6 should now be 2.6.17 safe anyways
+	if [[ ${ETYPE} == headers ]]; then
+		kernel_is 2 4 && unpack_2_4
+		kernel_is 2 6 && unpack_2_6
+	fi
+
+	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
+		cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
+		cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
+		chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
+	fi
+
+	# fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
+	# only do this for kernel < 2.6.27 since this file does not exist in later
+	# kernels
+	if [[ -n ${KV_MINOR} &&  ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] ; then
+		sed -i \
+			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
+			"${S}"/arch/ppc/Makefile
+	else
+		sed -i \
+			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
+			"${S}"/arch/powerpc/Makefile
+	fi
+}
+
+kernel-2_src_compile() {
+	cd "${S}"
+	[[ ${ETYPE} == headers ]] && compile_headers
+
+	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
+		echo ">>> Running deblob script ..."
+		python_setup
+		sh "${T}/${DEBLOB_A}" --force || die "Deblob script failed to run!!!"
+	fi
+}
+
+# if you leave it to the default src_test, it will run make to
+# find whether test/check targets are present; since "make test"
+# actually produces a few support files, they are installed even
+# though the package is binchecks-restricted.
+#
+# Avoid this altogether by making the function moot.
+kernel-2_src_test() { :; }
+
+kernel-2_pkg_preinst() {
+	[[ ${ETYPE} == headers ]] && preinst_headers
+}
+
+kernel-2_src_install() {
+	install_universal
+	[[ ${ETYPE} == headers ]] && install_headers
+	[[ ${ETYPE} == sources ]] && install_sources
+}
+
+kernel-2_pkg_postinst() {
+	[[ ${ETYPE} == sources ]] && postinst_sources
+}
+
+kernel-2_pkg_setup() {
+	if kernel_is 2 4; then
+		if [[ $(gcc-major-version) -ge 4 ]] ; then
+			echo
+			ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
+			ewarn "Either switch to another gcc-version (via gcc-config) or use a"
+			ewarn "newer kernel that supports gcc-4."
+			echo
+			ewarn "Also be aware that bugreports about gcc-4 not working"
+			ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
+			echo
+			epause 10
+		fi
+	fi
+
+	ABI="${KERNEL_ABI}"
+	[[ ${ETYPE} == headers ]] && setup_headers
+	[[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
+}
+
+kernel-2_pkg_postrm() {
+	# This warning only makes sense for kernel sources.
+	[[ ${ETYPE} == headers ]] && return 0
+
+	# If there isn't anything left behind, then don't complain.
+	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	echo
+	ewarn "Note: Even though you have successfully unmerged "
+	ewarn "your kernel package, directories in kernel source location: "
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
+	ewarn "with modified files will remain behind. By design, package managers"
+	ewarn "will not remove these modified files and the directories they reside in."
+	echo
+}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
  2016-05-23  6:18 [gentoo-commits] dev/heroxbd:master " Benda XU
@ 2016-05-26  4:05 ` Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     f9104e06308a2f4ffe402469af42a4931dae3297
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 07:45:28 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sun May 22 07:45:28 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=f9104e06

toolchain-binutils.eclass: merged.
toolchain.eclass: move the tricks into profiles.

 eclass/toolchain-binutils.eclass | 507 ---------------------------------------
 eclass/toolchain.eclass          |   2 +-
 2 files changed, 1 insertion(+), 508 deletions(-)

diff --git a/eclass/toolchain-binutils.eclass b/eclass/toolchain-binutils.eclass
deleted file mode 100644
index e8ceca4..0000000
--- a/eclass/toolchain-binutils.eclass
+++ /dev/null
@@ -1,507 +0,0 @@
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-binutils.eclass,v 1.137 2014/11/08 17:12:09 vapier Exp $
-#
-# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-#
-# We install binutils into CTARGET-VERSION specific directories.  This lets
-# us easily merge multiple versions for multiple targets (if we wish) and
-# then switch the versions on the fly (with `binutils-config`).
-#
-# binutils-99999999       -> live cvs
-# binutils-9999           -> live git
-# binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
-# binutils-#              -> normal release
-
-extra_eclass=""
-if [[ -n ${BINUTILS_TYPE} ]] ; then
-	BTYPE=${BINUTILS_TYPE}
-else
-	case ${PV} in
-	99999999)  BTYPE="cvs";;
-	9999)      BTYPE="git";;
-	9999_pre*) BTYPE="snap";;
-	*.*.90)    BTYPE="snap";;
-	*.*.*.*.*) BTYPE="hjlu";;
-	*)         BTYPE="rel";;
-	esac
-fi
-
-case ${BTYPE} in
-cvs)
-	extra_eclass="cvs"
-	ECVS_SERVER="sourceware.org:/cvs/src"
-	ECVS_MODULE="binutils"
-	ECVS_USER="anoncvs"
-	ECVS_PASS="anoncvs"
-	BVER="cvs"
-	;;
-git)
-	extra_eclass="git-2"
-	BVER="git"
-	EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
-	;;
-snap)
-	BVER=${PV/9999_pre}
-	;;
-*)
-	BVER=${BINUTILS_VER:-${PV}}
-	;;
-esac
-
-inherit eutils libtool flag-o-matic gnuconfig multilib versionator unpacker ${extra_eclass}
-case ${EAPI:-0} in
-0|1)
-	EXPORT_FUNCTIONS src_unpack src_compile src_test src_install pkg_postinst pkg_postrm ;;
-2|3|4|5)
-	EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_postinst pkg_postrm ;;
-*) die "unsupported EAPI ${EAPI}" ;;
-esac
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} == ${CHOST} ]] ; then
-	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
-		export CTARGET=${CATEGORY/cross-}
-	fi
-fi
-is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
-
-DESCRIPTION="Tools necessary to build programs"
-HOMEPAGE="http://sourceware.org/binutils/"
-
-case ${BTYPE} in
-	cvs|git) SRC_URI="" ;;
-	snap)
-		SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
-			ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2" ;;
-	hjlu)
-		SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${BVER}.tar."
-		version_is_at_least 2.21.51.0.5 && SRC_URI+="xz" || SRC_URI+="bz2" ;;
-	rel) SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.bz2" ;;
-esac
-add_src_uri() {
-	[[ -z $2 ]] && return
-	local a=$1
-	if version_is_at_least 2.22.52.0.2 ; then
-		a+=".xz"
-	else
-		a+=".bz2"
-	fi
-	set -- mirror://gentoo http://dev.gentoo.org/~vapier/dist
-	SRC_URI="${SRC_URI} ${@/%//${a}}"
-}
-add_src_uri binutils-${BVER}-patches-${PATCHVER}.tar ${PATCHVER}
-add_src_uri binutils-${BVER}-uclibc-patches-${UCLIBC_PATCHVER}.tar ${UCLIBC_PATCHVER}
-add_src_uri elf2flt-${ELF2FLT_VER}.tar ${ELF2FLT_VER}
-
-if version_is_at_least 2.18 ; then
-	LICENSE="|| ( GPL-3 LGPL-3 )"
-else
-	LICENSE="|| ( GPL-2 LGPL-2 )"
-fi
-IUSE="cxx multislot multitarget nls static-libs test vanilla"
-if version_is_at_least 2.19 ; then
-	IUSE+=" zlib"
-fi
-if ! version_is_at_least 2.23.90 || [[ ${PV} == "9999" ]] || use multislot ; then
-	SLOT="${BVER}"
-else
-	SLOT="0"
-fi
-
-RDEPEND=">=sys-devel/binutils-config-3"
-in_iuse zlib && RDEPEND+=" zlib? ( sys-libs/zlib )"
-DEPEND="${RDEPEND}
-	test? ( dev-util/dejagnu )
-	nls? ( sys-devel/gettext )
-	sys-devel/flex
-	virtual/yacc"
-
-S=${WORKDIR}/binutils
-case ${BVER} in
-cvs|git) ;;
-*) S=${S}-${BVER} ;;
-esac
-
-LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
-INCPATH=${LIBPATH}/include
-DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER}
-MY_BUILDDIR=${WORKDIR}/build
-if is_cross ; then
-	BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
-else
-	BINPATH=/usr/${CTARGET}/binutils-bin/${BVER}
-fi
-
-tc-binutils_unpack() {
-	case ${BTYPE} in
-	cvs) cvs_src_unpack ;;
-	git) git-2_src_unpack ;;
-	*)   unpacker ${A} ;;
-	esac
-	mkdir -p "${MY_BUILDDIR}"
-	[[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
-}
-
-# In case the ebuild wants to add a few of their own.
-PATCHES=()
-
-tc-binutils_apply_patches() {
-	cd "${S}"
-
-	if ! use vanilla ; then
-		if [[ -n ${PATCHVER} ]] ; then
-			EPATCH_SOURCE=${WORKDIR}/patch
-			if [[ ${CTARGET} == mips* ]] ; then
-				# remove gnu-hash for mips (bug #233233)
-				EPATCH_EXCLUDE+=" 77_all_generate-gnu-hash.patch"
-			fi
-			[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
-				&& EPATCH_SUFFIX="patch.bz2" \
-				|| EPATCH_SUFFIX="patch"
-			epatch
-		fi
-		if [[ -n ${UCLIBC_PATCHVER} ]] ; then
-			EPATCH_SOURCE=${WORKDIR}/uclibc-patches
-			[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
-				&& EPATCH_SUFFIX="patch.bz2" \
-				|| EPATCH_SUFFIX="patch"
-			EPATCH_MULTI_MSG="Applying uClibc fixes ..." \
-			epatch
-		elif [[ ${CTARGET} == *-uclibc* ]] ; then
-			# starting with binutils-2.17.50.0.17, we no longer need
-			# uClibc patchsets :D
-			if grep -qs 'linux-gnu' "${S}"/ltconfig ; then
-				die "sorry, but this binutils doesn't yet support uClibc :("
-			fi
-		fi
-		[[ ${#PATCHES[@]} -gt 0 ]] && epatch "${PATCHES[@]}"
-		epatch_user
-	fi
-
-	# fix locale issues if possible #122216
-	if [[ -e ${FILESDIR}/binutils-configure-LANG.patch ]] ; then
-		einfo "Fixing misc issues in configure files"
-		for f in $(find "${S}" -name configure -exec grep -l 'autoconf version 2.13' {} +) ; do
-			ebegin "  Updating ${f/${S}\/}"
-			patch "${f}" "${FILESDIR}"/binutils-configure-LANG.patch >& "${T}"/configure-patch.log \
-				|| eerror "Please file a bug about this"
-			eend $?
-		done
-	fi
-	# fix conflicts with newer glibc #272594
-	if [[ -e libiberty/testsuite/test-demangle.c ]] ; then
-		sed -i 's:\<getline\>:get_line:g' libiberty/testsuite/test-demangle.c
-	fi
-
-	# Fix po Makefile generators
-	sed -i \
-		-e '/^datadir = /s:$(prefix)/@DATADIRNAME@:@datadir@:' \
-		-e '/^gnulocaledir = /s:$(prefix)/share:$(datadir):' \
-		*/po/Make-in || die "sed po's failed"
-
-	# Run misc portage update scripts
-	gnuconfig_update
-	elibtoolize --portage --no-uclibc
-}
-
-toolchain-binutils_src_unpack() {
-	tc-binutils_unpack
-	case ${EAPI:-0} in
-	0|1) toolchain-binutils_src_prepare ;;
-	esac
-}
-
-toolchain-binutils_src_prepare() {
-	tc-binutils_apply_patches
-}
-
-_eprefix_init() {
-	has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
-}
-
-# Intended for ebuilds to override to set their own versioning information.
-toolchain-binutils_bugurl() {
-	printf "http://bugs.gentoo.org/"
-}
-toolchain-binutils_pkgversion() {
-	printf "Gentoo ${BVER}"
-	[[ -n ${PATCHVER} ]] && printf " p${PATCHVER}"
-}
-
-toolchain-binutils_src_configure() {
-	_eprefix_init
-
-	# make sure we filter $LINGUAS so that only ones that
-	# actually work make it through #42033
-	strip-linguas -u */po
-
-	# keep things sane
-	strip-flags
-
-	local x
-	echo
-	for x in CATEGORY CBUILD CHOST CTARGET CFLAGS LDFLAGS ; do
-		einfo "$(printf '%10s' ${x}:) ${!x}"
-	done
-	echo
-
-	cd "${MY_BUILDDIR}"
-	local myconf=()
-
-	# enable gold if available (installed as ld.gold)
-	if use cxx ; then
-		if grep -q 'enable-gold=default' "${S}"/configure ; then
-			myconf+=( --enable-gold )
-		# old ways - remove when 2.21 is stable
-		elif grep -q 'enable-gold=both/ld' "${S}"/configure ; then
-			myconf+=( --enable-gold=both/ld )
-		elif grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
-			myconf+=( --enable-gold=both/bfd )
-		fi
-		if grep -q -e '--enable-plugins' "${S}"/ld/configure ; then
-			myconf+=( --enable-plugins )
-		fi
-	fi
-
-	use nls \
-		&& myconf+=( --without-included-gettext ) \
-		|| myconf+=( --disable-nls )
-
-	if in_iuse zlib ; then
-		# older versions did not have an explicit configure flag
-		export ac_cv_search_zlibVersion=$(usex zlib -lz no)
-		myconf+=( $(use_with zlib) )
-	fi
-
-	# For bi-arch systems, enable a 64bit bfd.  This matches
-	# the bi-arch logic in toolchain.eclass. #446946
-	# We used to do it for everyone, but it's slow on 32bit arches. #438522
-	case $(tc-arch) in
-	ppc|sparc|x86) myconf+=( --enable-64-bit-bfd ) ;;
-	esac
-
-	use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd )
-	[[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} )
-	is_cross && myconf+=( --with-sysroot="${EPREFIX}"/usr/${CTARGET} )
-
-	# glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+
-	# on everyone in alpha (for now), we'll just enable it when possible
-	has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt )
-	has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt )
-
-	myconf+=(
-		--prefix="${EPREFIX}"/usr
-		--host=${CHOST}
-		--target=${CTARGET}
-		--datadir="${EPREFIX}"${DATAPATH}
-		--infodir="${EPREFIX}"${DATAPATH}/info
-		--mandir="${EPREFIX}"${DATAPATH}/man
-		--bindir="${EPREFIX}"${BINPATH}
-		--libdir="${EPREFIX}"${LIBPATH}
-		--libexecdir="${EPREFIX}"${LIBPATH}
-		--includedir="${EPREFIX}"${INCPATH}
-		--enable-obsolete
-		--enable-shared
-		--enable-threads
-		# Newer versions (>=2.24) make this an explicit option. #497268
-		--enable-install-libiberty
-		--disable-werror
-		--with-bugurl="$(toolchain-binutils_bugurl)"
-		--with-pkgversion="$(toolchain-binutils_pkgversion)"
-		$(use_enable static-libs static)
-		${EXTRA_ECONF}
-		# Disable modules that are in a combined binutils/gdb tree. #490566
-		--disable-{gdb,libdecnumber,readline,sim}
-		# Strip out broken static link flags.
-		# https://gcc.gnu.org/PR56750
-		--without-stage1-ldflags
-	)
-	echo ./configure "${myconf[@]}"
-	"${S}"/configure "${myconf[@]}" || die
-
-	# Prevent makeinfo from running in releases.  It may not always be
-	# installed, and older binutils may fail with newer texinfo.
-	# Besides, we never patch the doc files anyways, so regenerating
-	# in the first place is useless. #193364
-	# For older versions, it means we don't get any info pages at all.
-	# Oh well, tough luck. #294617
-	if [[ -e ${S}/gas/doc/as.info ]] || ! version_is_at_least 2.24 ; then
-		sed -i \
-			-e '/^MAKEINFO/s:=.*:= true:' \
-			Makefile || die
-	fi
-}
-
-toolchain-binutils_src_compile() {
-	_eprefix_init
-	case ${EAPI:-0} in
-	0|1) toolchain-binutils_src_configure ;;
-	esac
-
-	cd "${MY_BUILDDIR}"
-	emake all || die "emake failed"
-
-	# only build info pages if we user wants them, and if
-	# we have makeinfo (may not exist when we bootstrap)
-	if type -p makeinfo > /dev/null ; then
-		emake info || die "make info failed"
-	fi
-	# we nuke the manpages when we're left with junk
-	# (like when we bootstrap, no perl -> no manpages)
-	find . -name '*.1' -a -size 0 -delete
-
-	# elf2flt only works on some arches / targets
-	if [[ -n ${ELF2FLT_VER} ]] && [[ ${CTARGET} == *linux* || ${CTARGET} == *-elf* ]] ; then
-		cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
-
-		local x supported_arches=$(sed -n '/defined(TARGET_/{s:^.*TARGET_::;s:)::;p}' elf2flt.c | sort -u)
-		for x in ${supported_arches} UNSUPPORTED ; do
-			[[ ${CTARGET} == ${x}* ]] && break
-		done
-
-		if [[ ${x} != "UNSUPPORTED" ]] ; then
-			append-flags -I"${S}"/include
-			myconf+=(
-				--with-bfd-include-dir=${MY_BUILDDIR}/bfd
-				--with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a
-				--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a
-				--with-binutils-ldscript-dir="${EPREFIX}"${LIBPATH}/ldscripts
-			)
-			echo ./configure "${myconf[@]}"
-			./configure "${myconf[@]}" || die
-			emake || die "make elf2flt failed"
-		fi
-	fi
-}
-
-toolchain-binutils_src_test() {
-	cd "${MY_BUILDDIR}"
-	emake -k check || die "check failed :("
-}
-
-toolchain-binutils_src_install() {
-	_eprefix_init
-	local x d
-
-	cd "${MY_BUILDDIR}"
-	emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install || die
-	rm -rf "${ED}"/${LIBPATH}/bin
-	use static-libs || find "${ED}" -name '*.la' -delete
-
-	# Newer versions of binutils get fancy with ${LIBPATH} #171905
-	cd "${ED}"/${LIBPATH}
-	for d in ../* ; do
-		[[ ${d} == ../${BVER} ]] && continue
-		mv ${d}/* . || die
-		rmdir ${d} || die
-	done
-
-	# Now we collect everything intp the proper SLOT-ed dirs
-	# When something is built to cross-compile, it installs into
-	# /usr/$CHOST/ by default ... we have to 'fix' that :)
-	if is_cross ; then
-		cd "${ED}"/${BINPATH}
-		for x in * ; do
-			mv ${x} ${x/${CTARGET}-}
-		done
-
-		if [[ -d ${ED}/usr/${CHOST}/${CTARGET} ]] ; then
-			mv "${ED}"/usr/${CHOST}/${CTARGET}/include "${ED}"/${INCPATH}
-			mv "${ED}"/usr/${CHOST}/${CTARGET}/lib/* "${ED}"/${LIBPATH}/
-			rm -r "${ED}"/usr/${CHOST}/{include,lib}
-		fi
-	fi
-	insinto ${INCPATH}
-	local libiberty_headers=(
-		# Not all the libiberty headers.  See libiberty/Makefile.in:install_to_libdir.
-		demangle.h
-		dyn-string.h
-		fibheap.h
-		hashtab.h
-		libiberty.h
-		objalloc.h
-		splay-tree.h
-	)
-	doins "${libiberty_headers[@]/#/${S}/include/}" || die
-	if [[ -d ${ED}/${LIBPATH}/lib ]] ; then
-		mv "${ED}"/${LIBPATH}/lib/* "${ED}"/${LIBPATH}/
-		rm -r "${ED}"/${LIBPATH}/lib
-	fi
-
-	# Insert elf2flt where appropriate
-	if [[ -x ${WORKDIR}/elf2flt-${ELF2FLT_VER}/elf2flt ]] ; then
-		cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
-		insinto ${LIBPATH}/ldscripts
-		doins elf2flt.ld || die "doins elf2flt.ld failed"
-		exeinto ${BINPATH}
-		doexe elf2flt flthdr || die "doexe elf2flt flthdr failed"
-		mv "${ED}"/${BINPATH}/{ld,ld.real} || die
-		newexe ld-elf2flt ld || die "doexe ld-elf2flt failed"
-		newdoc README README.elf2flt
-	fi
-
-	# Generate an env.d entry for this binutils
-	insinto /etc/env.d/binutils
-	cat <<-EOF > "${T}"/env.d
-		TARGET="${CTARGET}"
-		VER="${BVER}"
-		LIBPATH="${EPREFIX}${LIBPATH}"
-	EOF
-	newins "${T}"/env.d ${CTARGET}-${BVER}
-
-	# Handle documentation
-	if ! is_cross ; then
-		cd "${S}"
-		dodoc README
-		docinto bfd
-		dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO
-		docinto binutils
-		dodoc binutils/ChangeLog binutils/NEWS binutils/README
-		docinto gas
-		dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README*
-		docinto gprof
-		dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl
-		docinto ld
-		dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO
-		docinto libiberty
-		dodoc libiberty/ChangeLog* libiberty/README
-		docinto opcodes
-		dodoc opcodes/ChangeLog*
-	fi
-	# Remove shared info pages
-	rm -f "${ED}"/${DATAPATH}/info/{dir,configure.info,standards.info}
-	# Trim all empty dirs
-	find "${ED}" -depth -type d -exec rmdir {} + 2>/dev/null
-}
-
-toolchain-binutils_pkg_postinst() {
-	_eprefix_init
-	# Make sure this ${CTARGET} has a binutils version selected
-	[[ -e ${EROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0
-	binutils-config ${CTARGET}-${BVER}
-}
-
-toolchain-binutils_pkg_postrm() {
-	_eprefix_init
-	local current_profile=$(binutils-config -c ${CTARGET})
-
-	# If no other versions exist, then uninstall for this
-	# target ... otherwise, switch to the newest version
-	# Note: only do this if this version is unmerged.  We
-	#       rerun binutils-config if this is a remerge, as
-	#       we want the mtimes on the symlinks updated (if
-	#       it is the same as the current selected profile)
-	if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
-		local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
-		choice=${choice//$'\n'/ }
-		choice=${choice/* }
-		if [[ -z ${choice} ]] ; then
-			env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
-		else
-			binutils-config ${choice}
-		fi
-	elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${BVER} ]] ; then
-		binutils-config ${CTARGET}-${BVER}
-	fi
-}

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index b9088ca..aeb17b9 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -8,7 +8,7 @@ DESCRIPTION="The GNU Compiler Collection"
 HOMEPAGE="http://gcc.gnu.org/"
 RESTRICT="strip" # cross-compilers need controlled stripping
 
-inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator
+inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator prefix
 
 if [[ ${PV} == *_pre9999* ]] ; then
 	EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-05-26  4:05 Benda XU
  2016-05-26  4:04 ` [gentoo-commits] dev/heroxbd:master " Benda XU
  0 siblings, 1 reply; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     e3dbf227fb7126e54e7b151aac2ec4feffff5e24
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 04:03:51 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu May 26 04:03:51 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=e3dbf227

db.eclass: import from prefix tree.

 eclass/db.eclass | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 210 insertions(+)

diff --git a/eclass/db.eclass b/eclass/db.eclass
new file mode 100644
index 0000000..f7070d4
--- /dev/null
+++ b/eclass/db.eclass
@@ -0,0 +1,210 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/db.eclass,v 1.49 2013/07/21 09:23:45 pacho Exp $
+# This is a common location for functions used in the sys-libs/db ebuilds
+#
+# Bugs: maintainer-needed@gentoo.org
+
+inherit eutils multilib
+
+IUSE="doc test examples"
+
+EXPORT_FUNCTIONS src_test
+
+DEPEND="test? ( >=dev-lang/tcl-8.4 )"
+
+RDEPEND=""
+
+db_fix_so() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
+	LIB="${EROOT}/usr/$(get_libdir)"
+
+	cd "${LIB}"
+
+	# first clean up old symlinks
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+
+	# now rebuild all the correct ones
+	for ext in so a dylib sl; do
+		for name in libdb libdb_{cxx,tcl,java,sql,stl}; do
+			target=`find . -maxdepth 1 -type f -name "${name}-*.${ext}" |sort -n |tail -n 1`
+			[ -n "${target}" ] || continue;
+			case ${CHOST} in 
+			*-aix*)
+				aixdll --merge-runtime \
+					--keepdir=false \
+					--target="${name}.${ext}" \
+					--current="${target}" \
+					`find . -maxdepth 1 -type f -name "${name}-*.${ext}"`
+				;;
+			*)
+				ln -sf ${target//.\//} ${name}.${ext}
+				;;
+			esac;
+		done;
+	done;
+
+	# db[23] gets some extra-special stuff
+	if [ -f libdb1$(get_libname 2) ]; then
+		ln -sf libdb1$(get_libname 2) libdb$(get_libname 2)
+		ln -sf libdb1$(get_libname 2) libdb1$(get_libname)
+		ln -sf libdb1$(get_libname 2) libdb-1$(get_libame)
+	fi
+	# what do we do if we ever get 3.3 ?
+	for i in libdb libdb_{cxx,tcl,java,sql,stl}; do
+		if [ -f $i-3$(get_libname 2) ]; then
+			ln -sf $i-3$(get_libname 2) $i-3$(get_libname)
+			ln -sf $i-3$(get_libname 2) $i$(get_libname 3)
+		fi
+	done
+
+	# do the same for headers now
+	# but since there are only two of them, just overwrite them
+	cd "${EROOT}"/usr/include
+	target=`find . -maxdepth 1 -type d -name 'db[0-9]*' | sort -n |cut -d/ -f2- | tail -n1`
+	if [ -n "${target}" ] && [ -e "${target}/db.h" ] && ( ! [[ -e db.h ]] || [[ -h db.h ]] ); then
+		einfo "Creating db.h symlinks to ${target}"
+		ln -sf "${target}"/db.h .
+		ln -sf "${target}"/db_185.h .
+	elif [ ! -e "${target}/db.h" ]; then
+		if [ -n "${target}" ]; then
+			ewarn "Could not find ${target}/db.h"
+		elif [ -h db.h ]; then
+			einfo "Apparently you just removed the last instance of $PN. Removing the symlinks"
+			rm -f db.h db_185.h
+		fi
+	fi
+}
+
+db_src_install_doc() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# not everybody wants this wad of documentation as it is primarily API docs
+	if use doc; then
+		dodir /usr/share/doc/${PF}/html
+		mv "${ED}"/usr/docs/* "${ED}"/usr/share/doc/${PF}/html/
+		rm -rf "${ED}"/usr/docs
+	else
+		rm -rf "${ED}"/usr/docs
+	fi
+
+	db_src_install_examples
+}
+
+db_src_install_examples() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	if use examples ; then
+		local langs="c cxx stl"
+		[[ "${IUSE/java}" != "${IUSE}" ]] \
+			&& use java \
+			&& langs="${langs} java"
+		for i in $langs ; do
+			destdir="/usr/share/doc/${PF}/"
+			src="${S}/../examples_${i}/"
+			if [ -f "${src}" ]; then
+				dodir "${destdir}"
+				cp -ra "${src}" "${ED}${destdir}/"
+			fi
+		done
+	fi
+}
+
+db_src_install_usrbinslot() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# slot all program names to avoid overwriting
+	for fname in "${ED}"/usr/bin/db*
+	do
+		dn="$(dirname "${fname}")"
+		bn="$(basename "${fname}")"
+		bn="${bn/db/db${SLOT}}"
+		mv "${fname}" "${dn}/${bn}" || \
+			die "Failed to rename ${fname} to ${dn}/${bn}"
+	done
+}
+
+db_src_install_headerslot() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	# install all headers in a slotted location
+	dodir /usr/include/db${SLOT}
+	mv "${ED}"/usr/include/*.h "${ED}"/usr/include/db${SLOT}/
+}
+
+db_src_install_usrlibcleanup() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
+	LIB="${ED}/usr/$(get_libdir)"
+	# Clean out the symlinks so that they will not be recorded in the
+	# contents (bug #60732)
+
+	if [ "${ED}" = "" ]; then
+		die "Calling clean_links while \$ED not defined"
+	fi
+
+	if [ -e "${LIB}"/libdb.a ] && [ ! -e "${LIB}"/libdb-${SLOT}.a ]; then
+		einfo "Moving libdb.a to a versioned name"
+		mv "${LIB}/libdb.a" "${LIB}/libdb-${SLOT}.a"
+	fi
+
+	if [ -e "${LIB}"/libdb_cxx.a ] && [ ! -e "${LIB}"/libdb_cxx-${SLOT}.a ]; then
+		einfo "Moving libdb_cxx.a to a versioned name"
+		mv "${LIB}/libdb_cxx.a" "${LIB}/libdb_cxx-${SLOT}.a"
+	fi
+
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
+	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
+	einfo "removing unversioned static archives"
+	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+
+	rm -f \
+		"${ED}"/usr/include/{db,db_185}.h \
+		"${LIB}"/libdb{,_{cxx,sql,stl,java,tcl}}.a
+}
+
+db_src_test() {
+	if [[ $UID -eq 0 ]]; then
+		M="You must run the testsuite as non-root, skipping"
+		ewarn "${M}"
+		elog "${M}"
+		return 0
+	fi
+
+	if use tcl; then
+		einfo "Running sys-libs/db testsuite"
+		ewarn "This can take 6+ hours on modern machines"
+		# Fix stuff that fails with relative paths, and upstream moving files
+		# around...
+		local test_parallel=''
+		for t in \
+			"${S}"/test/parallel.tcl \
+			"${S}"/../test/parallel.tcl \
+			"${S}"/test/tcl/parallel.tcl \
+			"${S}"/../test/tcl/parallel.tcl \
+			; do
+			[[ -f "${t}" ]] && test_parallel="${t}" && break
+		done
+
+		sed -ri \
+			-e '/regsub .test_path ./s,(regsub),#\1,g' \
+			-e '/regsub .src_root ./s,(regsub),#\1,g' \
+			-e '/regsub .tcl_utils ./s,(regsub),#\1,g' \
+			"${test_parallel}"
+		cd "${S}"
+		for t in \
+			../test/test.tcl \
+			../test/tcl/test.tcl \
+			; do
+			[[ -f "${t}" ]] && testbase="${t}" && break
+		done
+		echo "source ${t}" > testrunner.tcl
+		echo "run_parallel $(makeopts_jobs) run_std" >> testrunner.tcl
+
+		tclsh testrunner.tcl
+		egrep -qs '^FAIL' ALL.OUT* && die "Some tests failed, please see ${S}/ALL.OUT*"
+	else
+		eerror "You must have USE=tcl to run the sys-libs/db testsuite."
+	fi
+}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-05-26  4:05 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-05-26  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     57177c6d001b16b81ed164de16b328d3a67cac08
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 04:03:20 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu May 26 04:03:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=57177c6d

user.eclass: not to fail under prefix.

 eclass/user.eclass | 466 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 466 insertions(+)

diff --git a/eclass/user.eclass b/eclass/user.eclass
new file mode 100644
index 0000000..860aba0
--- /dev/null
+++ b/eclass/user.eclass
@@ -0,0 +1,466 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: user.eclass
+# @MAINTAINER:
+# base-system@gentoo.org (Linux)
+# Joe Jezak <josejx@gmail.com> (OS X)
+# usata@gentoo.org (OS X)
+# Aaron Walker <ka0ttic@gentoo.org> (FreeBSD)
+# @BLURB: user management in ebuilds
+# @DESCRIPTION:
+# The user eclass contains a suite of functions that allow ebuilds
+# to quickly make sure users in the installed system are sane.
+
+if [[ -z ${_USER_ECLASS} ]]; then
+_USER_ECLASS=1
+
+# @FUNCTION: _assert_pkg_ebuild_phase
+# @INTERNAL
+# @USAGE: <calling func name>
+_assert_pkg_ebuild_phase() {
+	case ${EBUILD_PHASE} in
+	setup|preinst|postinst) ;;
+	*)
+		eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:"
+		eerror "You may only call from pkg_{setup,preinst,postinst} functions."
+		eerror "Package fails at QA and at life.  Please file a bug."
+		die "Bad package!  $1 is only for use in some pkg_* functions!"
+	esac
+}
+
+# @FUNCTION: egetent
+# @USAGE: <database> <key>
+# @DESCRIPTION:
+# Small wrapper for getent (Linux), nidump (< Mac OS X 10.5),
+# dscl (Mac OS X 10.5), and pw (FreeBSD) used in enewuser()/enewgroup().
+#
+# Supported databases: group passwd
+egetent() {
+	local db=$1 key=$2
+
+	[[ $# -ge 3 ]] && die "usage: egetent <database> <key>"
+
+	case ${db} in
+	passwd|group) ;;
+	*) die "sorry, database '${db}' not yet supported; file a bug" ;;
+	esac
+
+	case ${CHOST} in
+	*-darwin[678])
+		case ${key} in
+		*[!0-9]*) # Non numeric
+			nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
+			;;
+		*)	# Numeric
+			nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
+			;;
+		esac
+		;;
+	*-darwin*)
+		local mykey
+		case ${db} in
+		passwd) db="Users"  mykey="UniqueID" ;;
+		group)  db="Groups" mykey="PrimaryGroupID" ;;
+		esac
+
+		case ${key} in
+		*[!0-9]*) # Non numeric
+			dscl . -read /${db}/${key} 2>/dev/null |grep RecordName
+			;;
+		*)	# Numeric
+			dscl . -search /${db} ${mykey} ${key} 2>/dev/null
+			;;
+		esac
+		;;
+	*-freebsd*|*-dragonfly*)
+		case ${db} in
+		passwd) db="user" ;;
+		*) ;;
+		esac
+
+		# lookup by uid/gid
+		local opts
+		if [[ ${key} == [[:digit:]]* ]] ; then
+			[[ ${db} == "user" ]] && opts="-u" || opts="-g"
+		fi
+
+		pw show ${db} ${opts} "${key}" -q
+		;;
+	*-netbsd*|*-openbsd*)
+		grep "${key}:\*:" /etc/${db}
+		;;
+	*)
+		# ignore output if nscd doesn't exist, or we're not running as root
+		nscd -i "${db}" 2>/dev/null
+		getent "${db}" "${key}"
+		;;
+	esac
+}
+
+# @FUNCTION: enewuser
+# @USAGE: <user> [uid] [shell] [homedir] [groups]
+# @DESCRIPTION:
+# Same as enewgroup, you are not required to understand how to properly add
+# a user to the system.  The only required parameter is the username.
+# Default uid is (pass -1 for this) next available, default shell is
+# /bin/false, default homedir is /dev/null, and there are no default groups.
+enewuser() {
+	_assert_pkg_ebuild_phase ${FUNCNAME}
+
+	# get the username
+	local euser=$1; shift
+	if [[ -z ${euser} ]] ; then
+		eerror "No username specified !"
+		die "Cannot call enewuser without a username"
+	fi
+
+	# lets see if the username already exists
+	if [[ -n $(egetent passwd "${euser}") ]] ; then
+		return 0
+	fi
+	einfo "Adding user '${euser}' to your system ..."
+
+	# options to pass to useradd
+	local opts=()
+
+	# handle uid
+	local euid=$1; shift
+	if [[ -n ${euid} && ${euid} != -1 ]] ; then
+		if [[ ${euid} -gt 0 ]] ; then
+			if [[ -n $(egetent passwd ${euid}) ]] ; then
+				euid="next"
+			fi
+		else
+			eerror "Userid given but is not greater than 0 !"
+			die "${euid} is not a valid UID"
+		fi
+	else
+		euid="next"
+	fi
+	if [[ ${euid} == "next" ]] ; then
+		for ((euid = 101; euid <= 999; euid++)); do
+			[[ -z $(egetent passwd ${euid}) ]] && break
+		done
+	fi
+	opts+=( -u ${euid} )
+	einfo " - Userid: ${euid}"
+
+	# handle shell
+	local eshell=$1; shift
+	if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
+		if [[ ! -e ${ROOT}${eshell} ]] ; then
+			eerror "A shell was specified but it does not exist !"
+			die "${eshell} does not exist in ${ROOT}"
+		fi
+		if [[ ${eshell} == */false || ${eshell} == */nologin ]] ; then
+			eerror "Do not specify ${eshell} yourself, use -1"
+			die "Pass '-1' as the shell parameter"
+		fi
+	else
+		for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do
+			[[ -x ${ROOT}${eshell} ]] && break
+		done
+
+		if [[ ${eshell} == "/dev/null" ]] ; then
+			eerror "Unable to identify the shell to use, proceeding with userland default."
+			case ${USERLAND} in
+				GNU)    eshell="/bin/false" ;;
+				BSD)    eshell="/sbin/nologin" ;;
+				Darwin) eshell="/usr/sbin/nologin" ;;
+				*) die "Unable to identify the default shell for userland ${USERLAND}"
+			esac
+		fi
+	fi
+	einfo " - Shell: ${eshell}"
+	opts+=( -s "${eshell}" )
+
+	# handle homedir
+	local ehome=$1; shift
+	if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
+		ehome="/dev/null"
+	fi
+	einfo " - Home: ${ehome}"
+	opts+=( -d "${ehome}" )
+
+	# handle groups
+	local egroups=$1; shift
+	local g egroups_arr
+	IFS="," read -r -a egroups_arr <<<"${egroups}"
+	shift
+	if [[ ${#egroups_arr[@]} -gt 0 ]] ; then
+		local defgroup exgroups
+		for g in "${egroups_arr[@]}" ; do
+			if [[ -z $(egetent group "${g}") ]] ; then
+				eerror "You must add group ${g} to the system first"
+				die "${g} is not a valid GID"
+			fi
+			if [[ -z ${defgroup} ]] ; then
+				defgroup=${g}
+			else
+				exgroups+=",${g}"
+			fi
+		done
+		opts+=( -g "${defgroup}" )
+		if [[ ! -z ${exgroups} ]] ; then
+			opts+=( -G "${exgroups:1}" )
+		fi
+	fi
+	einfo " - Groups: ${egroups:-(none)}"
+
+	# handle extra args
+	if [[ $# -gt 0 ]] ; then
+		die "extra arguments no longer supported; please file a bug"
+	else
+		local comment="added by portage for ${PN}"
+		opts+=( -c "${comment}" )
+		einfo " - GECOS: ${comment}"
+	fi
+
+	# add the user
+	case ${CHOST} in
+	*-darwin*)
+		### Make the user
+		dscl . create "/users/${euser}" uid ${euid}
+		dscl . create "/users/${euser}" shell "${eshell}"
+		dscl . create "/users/${euser}" home "${ehome}"
+		dscl . create "/users/${euser}" realname "added by portage for ${PN}"
+		### Add the user to the groups specified
+		for g in "${egroups_arr[@]}" ; do
+			dscl . merge "/groups/${g}" users "${euser}"
+		done
+		;;
+
+	*-freebsd*|*-dragonfly*)
+		pw useradd "${euser}" "${opts[@]}" || die
+		;;
+
+	*-netbsd*)
+		useradd "${opts[@]}" "${euser}" || die
+		;;
+
+	*-openbsd*)
+		# all ops the same, except the -g vs -g/-G ...
+		useradd -u ${euid} -s "${eshell}" \
+			-d "${ehome}" -g "${egroups}" "${euser}" || die
+		;;
+
+	*)
+		useradd -r "${opts[@]}" "${euser}" || use prefix || die
+		;;
+	esac
+
+	if [[ ! -e ${ROOT}/${ehome} ]] ; then
+		einfo " - Creating ${ehome} in ${ROOT}"
+		mkdir -p "${ROOT}/${ehome}"
+		chown "${euser}" "${ROOT}/${ehome}"
+		chmod 755 "${ROOT}/${ehome}"
+	fi
+}
+
+# @FUNCTION: enewgroup
+# @USAGE: <group> [gid]
+# @DESCRIPTION:
+# This function does not require you to understand how to properly add a
+# group to the system.  Just give it a group name to add and enewgroup will
+# do the rest.  You may specify the gid for the group or allow the group to
+# allocate the next available one.
+enewgroup() {
+	_assert_pkg_ebuild_phase ${FUNCNAME}
+
+	# get the group
+	local egroup=$1; shift
+	if [[ -z ${egroup} ]] ; then
+		eerror "No group specified !"
+		die "Cannot call enewgroup without a group"
+	fi
+
+	# see if group already exists
+	if [[ -n $(egetent group "${egroup}") ]] ; then
+		return 0
+	fi
+	einfo "Adding group '${egroup}' to your system ..."
+
+	# handle gid
+	local egid=$1; shift
+	if [[ ! -z ${egid} ]] ; then
+		if [[ ${egid} -gt 0 ]] ; then
+			if [[ -n $(egetent group ${egid}) ]] ; then
+				egid="next available; requested gid taken"
+			fi
+		else
+			eerror "Groupid given but is not greater than 0 !"
+			die "${egid} is not a valid GID"
+		fi
+	else
+		egid="next available"
+	fi
+	einfo " - Groupid: ${egid}"
+
+	# handle extra
+	if [[ $# -gt 0 ]] ; then
+		die "extra arguments no longer supported; please file a bug"
+	fi
+
+	# Some targets need to find the next available GID manually
+	_enewgroup_next_gid() {
+		if [[ ${egid} == *[!0-9]* ]] ; then
+			# Non numeric
+			for ((egid = 101; egid <= 999; egid++)) ; do
+				[[ -z $(egetent group ${egid}) ]] && break
+			done
+		fi
+	}
+
+	# add the group
+	case ${CHOST} in
+	*-darwin*)
+		_enewgroup_next_gid
+		dscl . create "/groups/${egroup}" gid ${egid}
+		dscl . create "/groups/${egroup}" passwd '*'
+		;;
+
+	*-freebsd*|*-dragonfly*)
+		_enewgroup_next_gid
+		pw groupadd "${egroup}" -g ${egid} || die
+		;;
+
+	*-netbsd*)
+		_enewgroup_next_gid
+		groupadd -g ${egid} "${egroup}" || die
+		;;
+
+	*)
+		local opts
+		if [[ ${egid} == *[!0-9]* ]] ; then
+			# Non numeric; let groupadd figure out a GID for us
+			opts=""
+		else
+			opts="-g ${egid}"
+		fi
+		# We specify -r so that we get a GID in the system range from login.defs
+		groupadd -r ${opts} "${egroup}" || use prefix || die
+		;;
+	esac
+}
+
+# @FUNCTION: egethome
+# @USAGE: <user>
+# @DESCRIPTION:
+# Gets the home directory for the specified user.
+egethome() {
+	local pos
+
+	[[ $# -eq 1 ]] || die "usage: egethome <user>"
+
+	case ${CHOST} in
+	*-darwin*|*-freebsd*|*-dragonfly*)
+		pos=9
+		;;
+	*)	# Linux, NetBSD, OpenBSD, etc...
+		pos=6
+		;;
+	esac
+
+	egetent passwd "$1" | cut -d: -f${pos}
+}
+
+# @FUNCTION: egetshell
+# @USAGE: <user>
+# @DESCRIPTION:
+# Gets the shell for the specified user.
+egetshell() {
+	local pos
+
+	[[ $# -eq 1 ]] || die "usage: egetshell <user>"
+
+	case ${CHOST} in
+	*-darwin*|*-freebsd*|*-dragonfly*)
+		pos=10
+		;;
+	*)	# Linux, NetBSD, OpenBSD, etc...
+		pos=7
+		;;
+	esac
+
+	egetent passwd "$1" | cut -d: -f${pos}
+}
+
+# @FUNCTION: esethome
+# @USAGE: <user> <homedir>
+# @DESCRIPTION:
+# Update the home directory in a platform-agnostic way.
+# Required parameters is the username and the new home directory.
+# Specify -1 if you want to set home to the enewuser default
+# of /dev/null.
+# If the new home directory does not exist, it is created.
+# Any previously existing home directory is NOT moved.
+esethome() {
+	_assert_pkg_ebuild_phase ${FUNCNAME}
+
+	# get the username
+	local euser=$1; shift
+	if [[ -z ${euser} ]] ; then
+		eerror "No username specified !"
+		die "Cannot call esethome without a username"
+	fi
+
+	# lets see if the username already exists
+	if [[ -z $(egetent passwd "${euser}") ]] ; then
+		ewarn "User does not exist, cannot set home dir -- skipping."
+		return 1
+	fi
+
+	# handle homedir
+	local ehome=$1; shift
+	if [[ -z ${ehome} ]] ; then
+		eerror "No home directory specified !"
+		die "Cannot call esethome without a home directory or '-1'"
+	fi
+
+	if [[ ${ehome} == "-1" ]] ; then
+		ehome="/dev/null"
+	fi
+
+	# exit with no message if home dir is up to date
+	if [[ $(egethome "${euser}") == ${ehome} ]]; then
+		return 0
+	fi
+
+	einfo "Updating home for user '${euser}' ..."
+	einfo " - Home: ${ehome}"
+
+	# ensure home directory exists, otherwise update will fail
+	if [[ ! -e ${ROOT}/${ehome} ]] ; then
+		einfo " - Creating ${ehome} in ${ROOT}"
+		mkdir -p "${ROOT}/${ehome}"
+		chown "${euser}" "${ROOT}/${ehome}"
+		chmod 755 "${ROOT}/${ehome}"
+	fi
+
+	# update the home directory
+	case ${CHOST} in
+	*-darwin*)
+		dscl . change "/users/${euser}" home "${ehome}"
+		;;
+
+	*-freebsd*|*-dragonfly*)
+		pw usermod "${euser}" -d "${ehome}" && return 0
+		[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
+		eerror "There was an error when attempting to update the home directory for ${euser}"
+		eerror "Please update it manually on your system:"
+		eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
+		;;
+
+	*)
+		usermod -d "${ehome}" "${euser}" && return 0
+		[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
+		eerror "There was an error when attempting to update the home directory for ${euser}"
+		eerror "Please update it manually on your system (as root):"
+		eerror "\t usermod -d \"${ehome}\" \"${euser}\""
+		;;
+	esac
+}
+
+fi


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-06-07 10:48 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-06-07 10:48 UTC (permalink / raw
  To: gentoo-commits

commit:     6e9aaffe12c8db2bb8c23326325440668c68eb4c
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  7 10:47:43 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Tue Jun  7 10:47:43 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=6e9aaffe

toolchain.eclass: should preserve PATH to locate gcc-config.

 eclass/toolchain.eclass | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index aeb17b9..81bc4fb 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -50,8 +50,8 @@ is_crosscompile() {
 }
 
 if [[ ${EAPI:-0} == [012] ]] ; then
-        : ${ED:=${D}}
-        : ${EROOT:=${ROOT}}
+		: ${ED:=${D}}
+		: ${EROOT:=${ROOT}}
 fi
 
 # General purpose version check.  Without a second arg matches up to minor version (x.x.x)
@@ -1719,13 +1719,13 @@ toolchain_src_install() {
 	# Rather install the script, else portage with changing $FILESDIR
 	# between binary and source package borks things ....
 	if ! is_crosscompile ; then
-                cp "${GCC_FILESDIR}"/fix_libtool_files.sh "${T}"
-                cp "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la "${T}"
-                cp "${GCC_FILESDIR}"/awk/fixlafiles.awk "${T}"
+				cp "${GCC_FILESDIR}"/fix_libtool_files.sh "${T}"
+				cp "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la "${T}"
+				cp "${GCC_FILESDIR}"/awk/fixlafiles.awk "${T}"
 		eprefixify \
-                        "${T}"/fix_libtool_files.sh \
-                        "${T}"/fixlafiles.awk-no_gcc_la \
-                        "${T}"/fixlafiles.awk
+						"${T}"/fix_libtool_files.sh \
+						"${T}"/fixlafiles.awk-no_gcc_la \
+						"${T}"/fixlafiles.awk
 
 		insinto "${DATAPATH#${EPREFIX}}"
 		if tc_version_is_at_least 4.0 ; then
@@ -2031,13 +2031,13 @@ toolchain_pkg_postrm() {
 
 do_gcc_config() {
 	if ! should_we_gcc_config ; then
-		env -i ROOT="${ROOT}" gcc-config --use-old --force
+		env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config --use-old --force
 		return 0
 	fi
 
 	local current_gcc_config="" current_specs="" use_specs=""
 
-	current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
+	current_gcc_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
 	if [[ -n ${current_gcc_config} ]] ; then
 		# figure out which specs-specific config is active
 		current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
@@ -2061,12 +2061,12 @@ should_we_gcc_config() {
 	# if the current config is invalid, we definitely want a new one
 	# Note: due to bash quirkiness, the following must not be 1 line
 	local curr_config
-	curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
+	curr_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
 
 	# if the previously selected config has the same major.minor (branch) as
 	# the version we are installing, then it will probably be uninstalled
 	# for being in the same SLOT, make sure we run gcc-config.
-	local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
+	local curr_config_ver=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
 
 	local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
 


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-06-14  2:00 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-06-14  2:00 UTC (permalink / raw
  To: gentoo-commits

commit:     476e3eade829ef401bcc2eaf8ae7d0262f3d121f
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 01:59:53 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 01:59:53 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=476e3ead

user.eclass: gracefully return early on for enewgroup and enewuser.

 eclass/user.eclass | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/eclass/user.eclass b/eclass/user.eclass
index 860aba0..9fddbbb 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -107,6 +107,10 @@ egetent() {
 # Default uid is (pass -1 for this) next available, default shell is
 # /bin/false, default homedir is /dev/null, and there are no default groups.
 enewuser() {
+	if [[ ${EUID} != 0 ]] ; then
+		einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
+		return 0
+	fi
 	_assert_pkg_ebuild_phase ${FUNCNAME}
 
 	# get the username
@@ -247,7 +251,7 @@ enewuser() {
 		;;
 
 	*)
-		useradd -r "${opts[@]}" "${euser}" || use prefix || die
+		useradd -r "${opts[@]}" "${euser}" || die
 		;;
 	esac
 
@@ -267,6 +271,10 @@ enewuser() {
 # do the rest.  You may specify the gid for the group or allow the group to
 # allocate the next available one.
 enewgroup() {
+	if [[ ${EUID} != 0 ]] ; then
+		einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
+		return 0
+	fi
 	_assert_pkg_ebuild_phase ${FUNCNAME}
 
 	# get the group
@@ -340,7 +348,7 @@ enewgroup() {
 			opts="-g ${egid}"
 		fi
 		# We specify -r so that we get a GID in the system range from login.defs
-		groupadd -r ${opts} "${egroup}" || use prefix || die
+		groupadd -r ${opts} "${egroup}" || die
 		;;
 	esac
 }


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-06-15 10:56 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-06-15 10:56 UTC (permalink / raw
  To: gentoo-commits

commit:     ab80d9543ee6e002243e1d9cf5379c6fc0960e85
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 15 10:55:39 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Wed Jun 15 10:55:39 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=ab80d954

kernel-2.eclass, toolchain-funcs.eclass: merged.

 eclass/kernel-2.eclass        | 1321 -----------------------------------------
 eclass/toolchain-funcs.eclass |  840 --------------------------
 2 files changed, 2161 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
deleted file mode 100644
index e8cb8f2..0000000
--- a/eclass/kernel-2.eclass
+++ /dev/null
@@ -1,1321 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.297 2014/11/28 17:40:20 mpagano Exp $
-
-# Description: kernel.eclass rewrite for a clean base regarding the 2.6
-#              series of kernel with back-compatibility for 2.4
-#
-# Original author: John Mylchreest <johnm@gentoo.org>
-# Maintainer: kernel-misc@gentoo.org
-#
-# Please direct your bugs to the current eclass maintainer :)
-
-# added functionality:
-# unipatch		- a flexible, singular method to extract, add and remove patches.
-
-# A Couple of env vars are available to effect usage of this eclass
-# These are as follows:
-#
-# K_USEPV				- When setting the EXTRAVERSION variable, it should
-#						  add PV to the end.
-#						  this is useful for thigns like wolk. IE:
-#						  EXTRAVERSION would be something like : -wolk-4.19-r1
-# K_NOSETEXTRAVERSION	- if this is set then EXTRAVERSION will not be
-#						  automatically set within the kernel Makefile
-# K_NOUSENAME			- if this is set then EXTRAVERSION will not include the
-#						  first part of ${PN} in EXTRAVERSION
-# K_NOUSEPR				- if this is set then EXTRAVERSION will not include the
-#						  anything based on ${PR}.
-# K_PREPATCHED			- if the patchset is prepatched (ie: mm-sources,
-#						  ck-sources, ac-sources) it will use PR (ie: -r5) as
-#						  the patchset version for
-#						  and not use it as a true package revision
-# K_EXTRAEINFO			- this is a new-line seperated list of einfo displays in
-#						  postinst and can be used to carry additional postinst
-#						  messages
-# K_EXTRAELOG			- same as K_EXTRAEINFO except using elog instead of einfo
-# K_EXTRAEWARN			- same as K_EXTRAEINFO except using ewarn instead of einfo
-# K_SYMLINK				- if this is set, then forcably create symlink anyway
-#
-# K_DEFCONFIG			- Allow specifying a different defconfig target.
-#						  If length zero, defaults to "defconfig".
-# K_WANT_GENPATCHES		- Apply genpatches to kernel source. Provide any
-# 						  combination of "base", "extras" or "experimental".
-# K_EXP_GENPATCHES_PULL	- If set, we pull "experimental" regardless of the USE FLAG
-#						  but expect the ebuild maintainer to use K_EXP_GENPATCHES_LIST.
-# K_EXP_GENPATCHES_NOUSE	- If set, no USE flag will be provided for "experimental";
-# 						  as a result the user cannot choose to apply those patches.
-# K_EXP_GENPATCHES_LIST	- A list of patches to pick from "experimental" to apply when
-# 						  the USE flag is unset and K_EXP_GENPATCHES_PULL is set.
-# K_GENPATCHES_VER		- The version of the genpatches tarball(s) to apply.
-#						  A value of "5" would apply genpatches-2.6.12-5 to
-#						  my-sources-2.6.12.ebuild
-# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
-# K_DEBLOB_AVAILABLE	- A value of "0" will disable all of the optional deblob
-#						  code. If empty, will be set to "1" if deblobbing is
-#						  possible. Test ONLY for "1".
-# K_PREDEBLOBBED		- This kernel was already deblobbed elsewhere.
-#						  If false, either optional deblobbing will be available
-#						  or the license will note the inclusion of freedist
-#						  code.
-# K_LONGTERM			- If set, the eclass will search for the kernel source
-#						  in the long term directories on the upstream servers
-#						  as the location has been changed by upstream
-# H_SUPPORTEDARCH		- this should be a space separated list of ARCH's which
-#						  can be supported by the headers ebuild
-
-# UNIPATCH_LIST			- space delimetered list of patches to be applied to the
-#						  kernel
-# UNIPATCH_EXCLUDE		- an addition var to support exlusion based completely
-#						  on "<passedstring>*" and not "<passedno#>_*"
-#						- this should _NOT_ be used from the ebuild as this is
-#						  reserved for end users passing excludes from the cli
-# UNIPATCH_DOCS			- space delimemeted list of docs to be installed to
-#						  the doc dir
-# UNIPATCH_STRICTORDER	- if this is set places patches into directories of
-#						  order, so they are applied in the order passed
-
-# Changing any other variable in this eclass is not supported; you can request
-# for additional variables to be added by contacting the current maintainer.
-# If you do change them, there is a chance that we will not fix resulting bugs;
-# that of course does not mean we're not willing to help.
-
-PYTHON_COMPAT=( python{2_6,2_7} )
-
-inherit eutils toolchain-funcs versionator multilib python-any-r1
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
-
-# Added by Daniel Ostrow <dostrow@gentoo.org>
-# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
-# I will remove it when I come up with something more reasonable.
-[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
-	export CTARGET=${CATEGORY/cross-}
-fi
-
-HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
-: ${LICENSE:="GPL-2"}
-
-# This is the latest KV_PATCH of the deblob tool available from the
-# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
-# for ALL kernel-2 consumer packages where deblob is available.
-: ${DEBLOB_MAX_VERSION:=38}
-
-# No need to run scanelf/strip on kernel sources/headers (bug #134453).
-RESTRICT="binchecks strip"
-
-# set LINUX_HOSTCFLAGS if not already set
-: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
-
-# debugging functions
-#==============================================================
-# this function exists only to help debug kernel-2.eclass
-# if you are adding new functionality in, put a call to it
-# at the start of src_unpack, or during SRC_URI/dep generation.
-debug-print-kernel2-variables() {
-	for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
-			RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
-			UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do
-		debug-print "${v}: ${!v}"
-	done
-}
-
-#Eclass functions only from here onwards ...
-#==============================================================
-handle_genpatches() {
-	local tarball
-	[[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
-
-	debug-print "Inside handle_genpatches"
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	# for > 3.0 kernels, handle genpatches tarball name
-	# genpatches for 3.0 and 3.0.1 might be named
-	# genpatches-3.0-1.base.tar.xz and genpatches-3.0-2.base.tar.xz
-	# respectively.  Handle this.
-
-	for i in ${K_WANT_GENPATCHES} ; do
-		if [[ ${KV_MAJOR} -ge 3 ]]; then
-			if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-				tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.xz"
-			else
-				tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.xz"
-			fi
-		else
-			tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.xz"
-		fi
-
-		local use_cond_start="" use_cond_end=""
-
-		if [[ "${i}" == "experimental" && -z ${K_EXP_GENPATCHES_PULL} && -z ${K_EXP_GENPATCHES_NOUSE} ]] ; then
-			use_cond_start="experimental? ( "
-			use_cond_end=" )"
-
-			if use experimental ; then
-				UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
-				debug-print "genpatches tarball: $tarball"
-			fi
-		else
-			UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
-			debug-print "genpatches tarball: $tarball"
-		fi
-
-		GENPATCHES_URI+=" ${use_cond_start}mirror://gentoo/${tarball}${use_cond_end}"
-	done
-}
-
-detect_version() {
-	# this function will detect and set
-	# - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
-	# - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
-	# - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
-
-	# We've already run, so nothing to do here.
-	[[ -n ${KV_FULL} ]] && return 0
-
-	# CKV is used as a comparison kernel version, which is used when
-	# PV doesnt reflect the genuine kernel version.
-	# this gets set to the portage style versioning. ie:
-	#   CKV=2.6.11_rc4
-	CKV=${CKV:-${PV}}
-	OKV=${OKV:-${CKV}}
-	OKV=${OKV/_beta/-test}
-	OKV=${OKV/_rc/-rc}
-	OKV=${OKV/-r*}
-	OKV=${OKV/_p*}
-
-	KV_MAJOR=$(get_version_component_range 1 ${OKV})
-	# handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	# if KV_MAJOR >= 3, then we have no more KV_MINOR
-	#if [[ ${KV_MAJOR} -lt 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-		KV_MINOR=$(get_version_component_range 2 ${OKV})
-		KV_PATCH=$(get_version_component_range 3 ${OKV})
-		if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
-	        KV_EXTRA=$(get_version_component_range 4- ${OKV})
-	        KV_EXTRA=${KV_EXTRA/[-_]*}
-		else
-			KV_PATCH=$(get_version_component_range 3- ${OKV})
-		fi
-	else
-		KV_PATCH=$(get_version_component_range 2 ${OKV})
-		KV_EXTRA=$(get_version_component_range 3- ${OKV})
-		KV_EXTRA=${KV_EXTRA/[-_]*}
-	fi
-
-	debug-print "KV_EXTRA is ${KV_EXTRA}"
-
-	KV_PATCH=${KV_PATCH/[-_]*}
-
-	local v n=0 missing
-	#if [[ ${KV_MAJOR} -lt 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-		for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
-			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
-		done
-	else
-		for v in CKV OKV KV_{MAJOR,PATCH} ; do
-			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
-		done
-	fi
-
-	[[ $n -eq 1 ]] && \
-		eerror "Missing variables: ${missing}" && \
-		die "Failed to extract kernel version (try explicit CKV in ebuild)!"
-	unset v n missing
-
-#	if [[ ${KV_MAJOR} -ge 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then
-		KV_PATCH_ARR=(${KV_PATCH//\./ })
-
-		# at this point 031412, Linus is putting all 3.x kernels in a
-		# 3.x directory, may need to revisit when 4.x is released
-		KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
-
-		[[ -n "${K_LONGTERM}" ]] &&
-			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
-	else
-		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
-		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
-		if [[ ${KV_MAJOR} -ge 3 ]]; then
-			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
-		else
-			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
-		fi
-
-		[[ -n "${K_LONGTERM}" ]] &&
-			#KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
-			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-	fi
-
-	debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
-
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		# handle non genpatch using sources correctly
-		if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
-		fi
-		KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz"
-	else
-		KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-	fi
-
-	RELEASE=${CKV/${OKV}}
-	RELEASE=${RELEASE/_beta}
-	RELEASE=${RELEASE/_rc/-rc}
-	RELEASE=${RELEASE/_pre/-pre}
-	# We cannot trivally call kernel_is here, because it calls us to detect the
-	# version
-	#kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
-	[ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
-	RELEASETYPE=${RELEASE//[0-9]}
-
-	# Now we know that RELEASE is the -rc/-git
-	# and RELEASETYPE is the same but with its numerics stripped
-	# we can work on better sorting EXTRAVERSION.
-	# first of all, we add the release
-	EXTRAVERSION="${RELEASE}"
-	debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
-	[[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
-
-	debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
-	if [[ -n "${K_NOUSEPR}" ]]; then
-		# Don't add anything based on PR to EXTRAVERSION
-		debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
-	elif [[ -n ${K_PREPATCHED} ]]; then
-		debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
-		EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
-	elif [[ "${ETYPE}" = "sources" ]]; then
-		debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
-		# For some sources we want to use the PV in the extra version
-		# This is because upstream releases with a completely different
-		# versioning scheme.
-		case ${PN/-*} in
-		     wolk) K_USEPV=1;;
-		  vserver) K_USEPV=1;;
-		esac
-
-		[[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
-		[[ -n "${K_USEPV}" ]]     && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
-		[[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
-	fi
-	debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
-
-	# The only messing around which should actually effect this is for KV_EXTRA
-	# since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
-	# KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
-
-	if [[ -n ${KV_EXTRA} ]]; then
-		if [[ -n ${KV_MINOR} ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-		else
-			OKV="${KV_MAJOR}.${KV_PATCH}"
-		fi
-		KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.xz
-					${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-		UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
-	fi
-
-	# We need to set this using OKV, but we need to set it before we do any
-	# messing around with OKV based on RELEASETYPE
-	KV_FULL=${OKV}${EXTRAVERSION}
-
-	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
-	KV=${KV_FULL}
-
-	# -rc-git pulls can be achieved by specifying CKV
-	# for example:
-	#   CKV="2.6.11_rc3_pre2"
-	# will pull:
-	#   linux-2.6.10.tar.xz & patch-2.6.11-rc3.xz & patch-2.6.11-rc3-git2.xz
-
-	if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then
-
-		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
-			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -git ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -rc-git ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz
-						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz"
-		fi
-	else
-		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
-			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
-				OKV="2.6.39"
-			else
-				KV_PATCH_ARR=(${KV_PATCH//\./ })
-				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
-			fi
-			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -git ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -rc-git ]]; then
-			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
-				OKV="2.6.39"
-			else
-				KV_PATCH_ARR=(${KV_PATCH//\./ })
-				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
-			fi
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz
-						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz"
-		fi
-
-
-	fi
-
-
-	debug-print-kernel2-variables
-
-	handle_genpatches
-}
-
-# Note: duplicated in linux-info.eclass
-kernel_is() {
-	# ALL of these should be set before we can safely continue this function.
-	# some of the sources have in the past had only one set.
-	local v n=0
-	for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
-	[[ $n -eq 1 ]] && detect_version
-	unset v n
-
-	# Now we can continue
-	local operator test value
-
-	case ${1#-} in
-	  lt) operator="-lt"; shift;;
-	  gt) operator="-gt"; shift;;
-	  le) operator="-le"; shift;;
-	  ge) operator="-ge"; shift;;
-	  eq) operator="-eq"; shift;;
-	   *) operator="-eq";;
-	esac
-	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
-
-	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
-	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
-	[ ${test} ${operator} ${value} ]
-}
-
-kernel_is_2_4() {
-	kernel_is 2 4
-}
-
-kernel_is_2_6() {
-	kernel_is 2 6 || kernel_is 2 5
-}
-
-# Capture the sources type and set DEPENDs
-if [[ ${ETYPE} == sources ]]; then
-	DEPEND="!build? (
-		sys-apps/sed
-		>=sys-devel/binutils-2.11.90.0.31
-	)"
-	RDEPEND="!build? (
-		>=sys-libs/ncurses-5.2
-		sys-devel/make
-		dev-lang/perl
-		sys-devel/bc
-	)"
-	PDEPEND="!build? ( virtual/dev-manager )"
-
-	SLOT="${PVR}"
-	DESCRIPTION="Sources based on the Linux Kernel."
-	IUSE="symlink build"
-
-	# Bug #266157, deblob for libre support
-	if [[ -z ${K_PREDEBLOBBED} ]] ; then
-		# Bug #359865, force a call to detect_version if needed
-		kernel_is ge 2 6 27 && \
-			[[ -z "${K_DEBLOB_AVAILABLE}" ]] && \
-				kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
-					K_DEBLOB_AVAILABLE=1
-		if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
-			IUSE="${IUSE} deblob"
-
-			# Reflect that kernels contain firmware blobs unless otherwise
-			# stripped
-			LICENSE="${LICENSE} !deblob? ( freedist )"
-
-			DEPEND+=" deblob? ( ${PYTHON_DEPS} )"
-
-			if [[ -n KV_MINOR ]]; then
-				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-			else
-				DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}"
-			fi
-
-			if [[ ${KV_MAJOR} -ge 3 ]]; then
-				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}"
-			fi
-
-			DEBLOB_A="deblob-${DEBLOB_PV}"
-			DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
-			DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
-			DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
-			if ! has "${EAPI:-0}" 0 1 ; then
-				DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
-			else
-				DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
-			fi
-			DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
-			HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
-
-			KERNEL_URI="${KERNEL_URI}
-				deblob? (
-					${DEBLOB_URI}
-					${DEBLOB_CHECK_URI}
-				)"
-		else
-			# We have no way to deblob older kernels, so just mark them as
-			# tainted with non-libre materials.
-			LICENSE="${LICENSE} freedist"
-		fi
-	fi
-
-elif [[ ${ETYPE} == headers ]]; then
-	DESCRIPTION="Linux system headers"
-
-	# Since we should NOT honour KBUILD_OUTPUT in headers
-	# lets unset it here.
-	unset KBUILD_OUTPUT
-
-	SLOT="0"
-else
-	eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
-	die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
-fi
-
-# Cross-compile support functions
-#==============================================================
-kernel_header_destdir() {
-	[[ ${CTARGET} == ${CHOST} ]] \
-		&& echo "${EPREFIX}"/usr/include \
-		|| echo "${EPREFIX}"/usr/${CTARGET}/usr/include
-}
-
-cross_pre_c_headers() {
-	use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
-}
-
-env_setup_xmakeopts() {
-	# Kernel ARCH != portage ARCH
-	export KARCH=$(tc-arch-kernel)
-
-	# When cross-compiling, we need to set the ARCH/CROSS_COMPILE
-	# variables properly or bad things happen !
-	xmakeopts="ARCH=${KARCH}"
-	if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
-		xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
-	elif type -p ${CHOST}-ar > /dev/null ; then
-		xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
-	fi
-	export xmakeopts
-}
-
-# Unpack functions
-#==============================================================
-unpack_2_4() {
-	# this file is required for other things to build properly,
-	# so we autogenerate it
-	make -s mrproper ${xmakeopts} || die "make mrproper failed"
-	make -s symlinks ${xmakeopts} || die "make symlinks failed"
-	make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
-	echo ">>> version.h compiled successfully."
-}
-
-unpack_2_6() {
-	# this file is required for other things to build properly, so we
-	# autogenerate it ... generate a .config to keep version.h build from
-	# spitting out an annoying warning
-	make -s mrproper ${xmakeopts} 2>/dev/null \
-		|| die "make mrproper failed"
-
-	# quick fix for bug #132152 which triggers when it cannot include linux
-	# headers (ie, we have not installed it yet)
-	if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
-		touch .config
-		eerror "make defconfig failed."
-		eerror "assuming you dont have any headers installed yet and continuing"
-		epause 5
-	fi
-
-	make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
-		|| die "make include/linux/version.h failed"
-	rm -f .config >/dev/null
-}
-
-universal_unpack() {
-	debug-print "Inside universal_unpack"
-
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	cd "${WORKDIR}"
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.xz
-	else
-		unpack linux-${OKV}.tar.xz
-	fi
-
-	if [[ -d "linux" ]]; then
-		debug-print "Moving linux to linux-${KV_FULL}"
-		mv linux linux-${KV_FULL} \
-			|| die "Unable to move source tree to ${KV_FULL}."
-	elif [[ "${OKV}" != "${KV_FULL}" ]]; then
-		if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] &&
-			[[ "${ETYPE}" = "sources" ]]; then
-			debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} "
-			mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
-				|| die "Unable to move source tree to ${KV_FULL}."
-		else
-			debug-print "moving linux-${OKV} to linux-${KV_FULL} "
-			mv linux-${OKV} linux-${KV_FULL} \
-				|| die "Unable to move source tree to ${KV_FULL}."
-		fi
-	elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
-			|| die "Unable to move source tree to ${KV_FULL}."
-	fi
-	cd "${S}"
-
-	# remove all backup files
-	find . -iname "*~" -exec rm {} \; 2> /dev/null
-
-}
-
-unpack_set_extraversion() {
-	cd "${S}"
-	sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
-	cd "${OLDPWD}"
-}
-
-# Should be done after patches have been applied
-# Otherwise patches that modify the same area of Makefile will fail
-unpack_fix_install_path() {
-	cd "${S}"
-	sed	-i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
-}
-
-# Compile Functions
-#==============================================================
-compile_headers() {
-	env_setup_xmakeopts
-
-	# if we couldnt obtain HOSTCFLAGS from the Makefile,
-	# then set it to something sane
-	local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
-	HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
-
-	if kernel_is 2 4; then
-		yes "" | make oldconfig ${xmakeopts}
-		echo ">>> make oldconfig complete"
-		make dep ${xmakeopts}
-	elif kernel_is 2 6; then
-		# 2.6.18 introduces headers_install which means we dont need any
-		# of this crap anymore :D
-		kernel_is ge 2 6 18 && return 0
-
-		# autoconf.h isnt generated unless it already exists. plus, we have
-		# no guarantee that any headers are installed on the system...
-		[[ -f ${EROOT}/usr/include/linux/autoconf.h ]] \
-			|| touch include/linux/autoconf.h
-
-		# if K_DEFCONFIG isn't set, force to "defconfig"
-		# needed by mips
-		if [[ -z ${K_DEFCONFIG} ]]; then
-			if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
-				case ${CTARGET} in
-					powerpc64*)	K_DEFCONFIG="ppc64_defconfig";;
-					powerpc*)	K_DEFCONFIG="pmac32_defconfig";;
-					*)			K_DEFCONFIG="defconfig";;
-				esac
-			else
-				K_DEFCONFIG="defconfig"
-			fi
-		fi
-
-		# if there arent any installed headers, then there also isnt an asm
-		# symlink in /usr/include/, and make defconfig will fail, so we have
-		# to force an include path with $S.
-		HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
-		ln -sf asm-${KARCH} "${S}"/include/asm
-		cross_pre_c_headers && return 0
-
-		make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
-		if compile_headers_tweak_config ; then
-			yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
-		fi
-		make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
-		make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
-	fi
-}
-
-compile_headers_tweak_config() {
-	# some targets can be very very picky, so let's finesse the
-	# .config based upon any info we may have
-	case ${CTARGET} in
-	sh*)
-		sed -i '/CONFIG_CPU_SH/d' .config
-		echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
-		return 0;;
-	esac
-
-	# no changes, so lets do nothing
-	return 1
-}
-
-# install functions
-#==============================================================
-install_universal() {
-	# Fix silly permissions in tarball
-	cd "${WORKDIR}"
-	chown -R 0:0 * >& /dev/null
-	chmod -R a+r-w+X,u+w *
-	cd ${OLDPWD}
-}
-
-install_headers() {
-	local ddir=$(kernel_header_destdir)
-
-	# 2.6.18 introduces headers_install which means we dont need any
-	# of this crap anymore :D
-	if kernel_is ge 2 6 18 ; then
-		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
-
-		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
-		return 0
-	fi
-
-	# Do not use "linux/*" as that can cause problems with very long
-	# $S values where the cmdline to cp is too long
-	pushd "${S}" >/dev/null
-	dodir ${ddir#${EPREFIX}}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
-
-	dodir ${ddir#${EPREFIX}}/asm
-	cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm
-
-	if kernel_is 2 6 ; then
-		dodir ${ddir#${EPREFIX}}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
-	fi
-
-	# clean up
-	find "${D}" -name '*.orig' -exec rm -f {} \;
-
-	popd >/dev/null
-}
-
-install_sources() {
-	local file
-
-	cd "${S}"
-	dodir /usr/src
-	echo ">>> Copying sources ..."
-
-	file="$(find ${WORKDIR} -iname "docs" -type d)"
-	if [[ -n ${file} ]]; then
-		for file in $(find ${file} -type f); do
-			echo "${file//*docs\/}" >> "${S}"/patches.txt
-			echo "===================================================" >> "${S}"/patches.txt
-			cat ${file} >> "${S}"/patches.txt
-			echo "===================================================" >> "${S}"/patches.txt
-			echo "" >> "${S}"/patches.txt
-		done
-	fi
-
-	if [[ ! -f ${S}/patches.txt ]]; then
-		# patches.txt is empty so lets use our ChangeLog
-		[[ -f ${FILESDIR}/../ChangeLog ]] && \
-			echo "Please check the ebuild ChangeLog for more details." \
-			> "${S}"/patches.txt
-	fi
-
-	mv ${WORKDIR}/linux* "${ED}"/usr/src
-
-	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
-		for i in ${UNIPATCH_DOCS}; do
-			dodoc "${T}"/${i}
-		done
-	fi
-}
-
-# pkg_preinst functions
-#==============================================================
-preinst_headers() {
-	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
-}
-
-# pkg_postinst functions
-#==============================================================
-postinst_sources() {
-	local MAKELINK=0
-
-	# if we have USE=symlink, then force K_SYMLINK=1
-	use symlink && K_SYMLINK=1
-
-	# if we're using a deblobbed kernel, it's not supported
-	[[ $K_DEBLOB_AVAILABLE == 1 ]] && \
-		use deblob && \
-		K_SECURITY_UNSUPPORTED=deblob
-
-	# if we are to forcably symlink, delete it if it already exists first.
-	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux
-		MAKELINK=1
-	fi
-
-	# if the link doesnt exist, lets create it
-	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
-
-	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${EROOT}"usr/src
-		ln -sf linux-${KV_FULL} linux
-		cd ${OLDPWD}
-	fi
-
-	# Don't forget to make directory for sysfs
-	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}sys
-
-	echo
-	elog "If you are upgrading from a previous kernel, you may be interested"
-	elog "in the following document:"
-	elog "  - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
-	echo
-
-	# if K_EXTRAEINFO is set then lets display it now
-	if [[ -n ${K_EXTRAEINFO} ]]; then
-		echo ${K_EXTRAEINFO} | fmt |
-		while read -s ELINE; do	einfo "${ELINE}"; done
-	fi
-
-	# if K_EXTRAELOG is set then lets display it now
-	if [[ -n ${K_EXTRAELOG} ]]; then
-		echo ${K_EXTRAELOG} | fmt |
-		while read -s ELINE; do	elog "${ELINE}"; done
-	fi
-
-	# if K_EXTRAEWARN is set then lets display it now
-	if [[ -n ${K_EXTRAEWARN} ]]; then
-		echo ${K_EXTRAEWARN} | fmt |
-		while read -s ELINE; do ewarn "${ELINE}"; done
-	fi
-
-	# optionally display security unsupported message
-	#  Start with why
-	if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
-		ewarn "Deblobbed kernels may not be up-to-date security-wise"
-		ewarn "as they depend on external scripts."
-	elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
-		ewarn "${PN} is UNSUPPORTED by Gentoo Security."
-	fi
-	#  And now the general message.
-	if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
-		ewarn "This means that it is likely to be vulnerable to recent security issues."
-		ewarn "For specific information on why this kernel is unsupported, please read:"
-		ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
-	fi
-
-	# warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
-	KV_MAJOR=$(get_version_component_range 1 ${OKV})
-	KV_MINOR=$(get_version_component_range 2 ${OKV})
-	KV_PATCH=$(get_version_component_range 3 ${OKV})
-	if [[ "$(tc-arch)" = "sparc" ]]; then
-		if [[ $(gcc-major-version) -lt 4 && $(gcc-minor-version) -lt 4 ]]; then
-			if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] ; then
-				echo
-				elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
-				elog "you now need to do"
-				elog "  make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
-				elog "instead of just"
-				elog "  make"
-				elog "to compile the kernel. For more information please browse to"
-				elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
-				echo
-			fi
-		fi
-	fi
-}
-
-# pkg_setup functions
-#==============================================================
-setup_headers() {
-	[[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
-	for i in ${H_SUPPORTEDARCH}; do
-		[[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
-	done
-
-	if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
-		echo
-		eerror "This version of ${PN} does not support $(tc-arch)."
-		eerror "Please merge the appropriate sources, in most cases"
-		eerror "(but not all) this will be called $(tc-arch)-headers."
-		die "Package unsupported for $(tc-arch)"
-	fi
-}
-
-# unipatch
-#==============================================================
-unipatch() {
-	local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
-	local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
-
-	# set to a standard locale to ensure sorts are ordered properly.
-	myLC_ALL="${LC_ALL}"
-	myLANG="${LANG}"
-	LC_ALL="C"
-	LANG=""
-
-	[ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
-	[ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
-
-	# We're gonna need it when doing patches with a predefined patchlevel
-	eshopts_push -s extglob
-
-	# This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
-	# usage can be either via an env var or by params
-	# although due to the nature we pass this within this eclass
-	# it shall be by param only.
-	# -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
-	UNIPATCH_LIST="${@}"
-
-	#unpack any passed tarballs
-	for i in ${UNIPATCH_LIST}; do
-		if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
-			if [ -n "${UNIPATCH_STRICTORDER}" ]; then
-				unset z
-				STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
-				for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
-					do z="${z}0";
-				done
-				PATCH_ORDER="${z}${STRICT_COUNT}"
-
-				mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
-				pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
-				unpack ${i##*/}
-				popd >/dev/null
-			else
-				pushd "${KPATCH_DIR}" >/dev/null
-				unpack ${i##*/}
-				popd >/dev/null
-			fi
-
-			[[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
-		else
-			extention=${i/*./}
-			extention=${extention/:*/}
-			PIPE_CMD=""
-			case ${extention} in
-				     xz) PIPE_CMD="xz -dc";;
-				   lzma) PIPE_CMD="lzma -dc";;
-				    bz2) PIPE_CMD="bzip2 -dc";;
-				 patch*) PIPE_CMD="cat";;
-				   diff) PIPE_CMD="cat";;
-				 gz|Z|z) PIPE_CMD="gzip -dc";;
-				ZIP|zip) PIPE_CMD="unzip -p";;
-				      *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
-			esac
-
-			PATCH_LEVEL=${i/*([^:])?(:)}
-			i=${i/:*/}
-			x=${i/*\//}
-			x=${x/\.${extention}/}
-
-			if [ -n "${PIPE_CMD}" ]; then
-				if [ ! -r "${i}" ]; then
-					echo
-					eerror "FATAL: unable to locate:"
-					eerror "${i}"
-					eerror "for read-only. The file either has incorrect permissions"
-					eerror "or does not exist."
-					die Unable to locate ${i}
-				fi
-
-				if [ -n "${UNIPATCH_STRICTORDER}" ]; then
-					unset z
-					STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
-					for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
-						do z="${z}0";
-					done
-					PATCH_ORDER="${z}${STRICT_COUNT}"
-
-					mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
-					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
-				else
-					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
-				fi
-			fi
-		fi
-
-		# If experimental was not chosen by the user, drop experimental patches not in K_EXP_GENPATCHES_LIST.
-		if [[ "${i}" == *"genpatches-"*".experimental."* && -n ${K_EXP_GENPATCHES_PULL} ]] ; then
-			if [[ -z ${K_EXP_GENPATCHES_NOUSE} ]] && use experimental; then
-				continue
-			fi
-
-			local j
-			for j in ${KPATCH_DIR}/*/50*_*.patch*; do
-				for k in ${K_EXP_GENPATCHES_LIST} ; do
-					[[ "$(basename ${j})" == ${k}* ]] && continue 2
-				done
-				UNIPATCH_DROP+=" $(basename ${j})"
-			done
-		fi
-	done
-
-	#populate KPATCH_DIRS so we know where to look to remove the excludes
-	x=${KPATCH_DIR}
-	KPATCH_DIR=""
-	for i in $(find ${x} -type d | sort -n); do
-		KPATCH_DIR="${KPATCH_DIR} ${i}"
-	done
-
-	# do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
-	# bug #272676
-	if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
-		if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
-			UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
-			echo
-			ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
-			ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
-			ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
-			echo
-		fi
-	fi
-
-	#so now lets get rid of the patchno's we want to exclude
-	UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
-	for i in ${UNIPATCH_DROP}; do
-		ebegin "Excluding Patch #${i}"
-		for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
-		eend $?
-	done
-
-	# and now, finally, we patch it :)
-	for x in ${KPATCH_DIR}; do
-		for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
-			STDERR_T="${T}/${i/*\//}"
-			STDERR_T="${STDERR_T/.patch*/.err}"
-
-			[ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
-			#[ -z ${i/*.diff*/} ]  && PATCH_DEPTH=${i/*.diff/}
-
-			if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
-
-			####################################################################
-			# IMPORTANT: This is temporary code to support Linux git 3.15_rc1! #
-			#                                                                  #
-			# The patch contains a removal of a symlink, followed by addition  #
-			# of a file with the same name as the symlink in the same          #
-			# location; this causes the dry-run to fail, filed bug #507656.    #
-			#                                                                  #
-			# https://bugs.gentoo.org/show_bug.cgi?id=507656                   #
-			####################################################################
-			if [[ ${PN} == "git-sources" ]] ; then
-				if [[ ${KV_MAJOR}${KV_PATCH} -ge 315 && ${RELEASETYPE} == -rc ]] ; then
-					ebegin "Applying ${i/*\//} (-p1)"
-					if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
-						eend 0
-						rm ${STDERR_T}
-						break
-					else
-						eend 1
-						eerror "Failed to apply patch ${i/*\//}"
-						eerror "Please attach ${STDERR_T} to any bug you may post."
-						eshopts_pop
-						die "Failed to apply ${i/*\//} on patch depth 1."
-					fi
-				fi
-			fi
-			####################################################################
-
-			while [ ${PATCH_DEPTH} -lt 5 ]; do
-				echo "Attempting Dry-run:" >> ${STDERR_T}
-				echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
-				echo "=======================================================" >> ${STDERR_T}
-				if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
-					ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH})"
-					echo "Attempting patch:" > ${STDERR_T}
-					echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
-					echo "=======================================================" >> ${STDERR_T}
-					if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
-						eend 0
-						rm ${STDERR_T}
-						break
-					else
-						eend 1
-						eerror "Failed to apply patch ${i/*\//}"
-						eerror "Please attach ${STDERR_T} to any bug you may post."
-						eshopts_pop
-						die "Failed to apply ${i/*\//} on patch depth ${PATCH_DEPTH}."
-					fi
-				else
-					PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
-				fi
-			done
-			if [ ${PATCH_DEPTH} -eq 5 ]; then
-				eerror "Failed to dry-run patch ${i/*\//}"
-				eerror "Please attach ${STDERR_T} to any bug you may post."
-				eshopts_pop
-				die "Unable to dry-run patch on any patch depth lower than 5."
-			fi
-		done
-	done
-
-	# When genpatches is used, we want to install 0000_README which documents
-	# the patches that were used; such that the user can see them, bug #301478.
-	if [[ ! -z ${K_WANT_GENPATCHES} ]] ; then
-		UNIPATCH_DOCS="${UNIPATCH_DOCS} 0000_README"
-	fi
-
-	# When files listed in UNIPATCH_DOCS are found in KPATCH_DIR's, we copy it
-	# to the temporary directory and remember them in UNIPATCH_DOCS to install
-	# them during the install phase.
-	local tmp
-	for x in ${KPATCH_DIR}; do
-		for i in ${UNIPATCH_DOCS}; do
-			if [[ -f "${x}/${i}" ]] ; then
-				tmp="${tmp} ${i}"
-				cp -f "${x}/${i}" "${T}"/
-			fi
-		done
-	done
-	UNIPATCH_DOCS="${tmp}"
-
-	# clean up  KPATCH_DIR's - fixes bug #53610
-	for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
-
-	LC_ALL="${myLC_ALL}"
-	LANG="${myLANG}"
-	eshopts_pop
-}
-
-# getfilevar accepts 2 vars as follows:
-# getfilevar <VARIABLE> <CONFIGFILE>
-# pulled from linux-info
-
-getfilevar() {
-	local workingdir basefname basedname xarch=$(tc-arch-kernel)
-
-	if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
-		echo -e "\n"
-		eerror "getfilevar requires 2 variables, with the second a valid file."
-		eerror "   getfilevar <VARIABLE> <CONFIGFILE>"
-	else
-		workingdir=${PWD}
-		basefname=$(basename ${2})
-		basedname=$(dirname ${2})
-		unset ARCH
-
-		cd ${basedname}
-		echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
-			make ${BUILD_FIXES} -s -f - e 2>/dev/null
-		cd ${workingdir}
-
-		ARCH=${xarch}
-	fi
-}
-
-detect_arch() {
-	# This function sets ARCH_URI and ARCH_PATCH
-	# with the neccessary info for the arch sepecific compatibility
-	# patchsets.
-
-	local ALL_ARCH LOOP_ARCH COMPAT_URI i
-
-	# COMPAT_URI is the contents of ${ARCH}_URI
-	# ARCH_URI is the URI for all the ${ARCH}_URI patches
-	# ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
-
-	ARCH_URI=""
-	ARCH_PATCH=""
-	ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
-
-	for LOOP_ARCH in ${ALL_ARCH}; do
-		COMPAT_URI="${LOOP_ARCH}_URI"
-		COMPAT_URI="${!COMPAT_URI}"
-
-		[[ -n ${COMPAT_URI} ]] && \
-			ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
-
-		if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; 	then
-			for i in ${COMPAT_URI}; do
-				ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
-			done
-		fi
-	done
-}
-
-headers___fix() {
-	# Voodoo to partially fix broken upstream headers.
-	# note: do not put inline/asm/volatile together (breaks "inline asm volatile")
-	sed -i \
-		-e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
-		-e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
-		-e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
-		-e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
-		-e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
-		"$@"
-}
-
-# common functions
-#==============================================================
-kernel-2_src_unpack() {
-	universal_unpack
-	debug-print "Doing unipatch"
-
-	[[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
-		unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
-
-	debug-print "Doing premake"
-
-	# allow ebuilds to massage the source tree after patching but before
-	# we run misc `make` functions below
-	[[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
-
-	debug-print "Doing epatch_user"
-	epatch_user
-
-	debug-print "Doing unpack_set_extraversion"
-
-	[[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
-	unpack_fix_install_path
-
-	# Setup xmakeopts and cd into sourcetree.
-	env_setup_xmakeopts
-	cd "${S}"
-
-	# We dont need a version.h for anything other than headers
-	# at least, I should hope we dont. If this causes problems
-	# take out the if/fi block and inform me please.
-	# unpack_2_6 should now be 2.6.17 safe anyways
-	if [[ ${ETYPE} == headers ]]; then
-		kernel_is 2 4 && unpack_2_4
-		kernel_is 2 6 && unpack_2_6
-	fi
-
-	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
-		cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
-		cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
-		chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
-	fi
-
-	# fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
-	# only do this for kernel < 2.6.27 since this file does not exist in later
-	# kernels
-	if [[ -n ${KV_MINOR} &&  ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] ; then
-		sed -i \
-			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
-			"${S}"/arch/ppc/Makefile
-	else
-		sed -i \
-			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
-			"${S}"/arch/powerpc/Makefile
-	fi
-}
-
-kernel-2_src_compile() {
-	cd "${S}"
-	[[ ${ETYPE} == headers ]] && compile_headers
-
-	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
-		echo ">>> Running deblob script ..."
-		python_setup
-		sh "${T}/${DEBLOB_A}" --force || die "Deblob script failed to run!!!"
-	fi
-}
-
-# if you leave it to the default src_test, it will run make to
-# find whether test/check targets are present; since "make test"
-# actually produces a few support files, they are installed even
-# though the package is binchecks-restricted.
-#
-# Avoid this altogether by making the function moot.
-kernel-2_src_test() { :; }
-
-kernel-2_pkg_preinst() {
-	[[ ${ETYPE} == headers ]] && preinst_headers
-}
-
-kernel-2_src_install() {
-	install_universal
-	[[ ${ETYPE} == headers ]] && install_headers
-	[[ ${ETYPE} == sources ]] && install_sources
-}
-
-kernel-2_pkg_postinst() {
-	[[ ${ETYPE} == sources ]] && postinst_sources
-}
-
-kernel-2_pkg_setup() {
-	if kernel_is 2 4; then
-		if [[ $(gcc-major-version) -ge 4 ]] ; then
-			echo
-			ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
-			ewarn "Either switch to another gcc-version (via gcc-config) or use a"
-			ewarn "newer kernel that supports gcc-4."
-			echo
-			ewarn "Also be aware that bugreports about gcc-4 not working"
-			ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
-			echo
-			epause 10
-		fi
-	fi
-
-	ABI="${KERNEL_ABI}"
-	[[ ${ETYPE} == headers ]] && setup_headers
-	[[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
-}
-
-kernel-2_pkg_postrm() {
-	# This warning only makes sense for kernel sources.
-	[[ ${ETYPE} == headers ]] && return 0
-
-	# If there isn't anything left behind, then don't complain.
-	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
-	echo
-	ewarn "Note: Even though you have successfully unmerged "
-	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
-	ewarn "with modified files will remain behind. By design, package managers"
-	ewarn "will not remove these modified files and the directories they reside in."
-	echo
-}

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
deleted file mode 100644
index 59c2861..0000000
--- a/eclass/toolchain-funcs.eclass
+++ /dev/null
@@ -1,840 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: toolchain-funcs.eclass
-# @MAINTAINER:
-# Toolchain Ninjas <toolchain@gentoo.org>
-# @BLURB: functions to query common info about the toolchain
-# @DESCRIPTION:
-# The toolchain-funcs aims to provide a complete suite of functions
-# for gleaning useful information about the toolchain and to simplify
-# ugly things like cross-compiling and multilib.  All of this is done
-# in such a way that you can rely on the function always returning
-# something sane.
-
-if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then
-_TOOLCHAIN_FUNCS_ECLASS=1
-
-inherit multilib
-
-# tc-getPROG <VAR [search vars]> <default> [tuple]
-_tc-getPROG() {
-	local tuple=$1
-	local v var vars=$2
-	local prog=$3
-
-	var=${vars%% *}
-	for v in ${vars} ; do
-		if [[ -n ${!v} ]] ; then
-			export ${var}="${!v}"
-			echo "${!v}"
-			return 0
-		fi
-	done
-
-	local search=
-	[[ -n $4 ]] && search=$(type -p "$4-${prog}")
-	[[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}")
-	[[ -n ${search} ]] && prog=${search##*/}
-
-	export ${var}=${prog}
-	echo "${!var}"
-}
-tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"; }
-tc-getPROG() { _tc-getPROG CHOST "$@"; }
-
-# @FUNCTION: tc-getAR
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver
-tc-getAR() { tc-getPROG AR ar "$@"; }
-# @FUNCTION: tc-getAS
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the assembler
-tc-getAS() { tc-getPROG AS as "$@"; }
-# @FUNCTION: tc-getCC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C compiler
-tc-getCC() { tc-getPROG CC gcc "$@"; }
-# @FUNCTION: tc-getCPP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C preprocessor
-tc-getCPP() { tc-getPROG CPP cpp "$@"; }
-# @FUNCTION: tc-getCXX
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C++ compiler
-tc-getCXX() { tc-getPROG CXX g++ "$@"; }
-# @FUNCTION: tc-getLD
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the linker
-tc-getLD() { tc-getPROG LD ld "$@"; }
-# @FUNCTION: tc-getSTRIP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the strip program
-tc-getSTRIP() { tc-getPROG STRIP strip "$@"; }
-# @FUNCTION: tc-getNM
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the symbol/object thingy
-tc-getNM() { tc-getPROG NM nm "$@"; }
-# @FUNCTION: tc-getRANLIB
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver indexer
-tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
-# @FUNCTION: tc-getOBJCOPY
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object copier
-tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
-# @FUNCTION: tc-getOBJDUMP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object dumper
-tc-getOBJDUMP() { tc-getPROG OBJDUMP objdump "$@"; }
-# @FUNCTION: tc-getF77
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Fortran 77 compiler
-tc-getF77() { tc-getPROG F77 gfortran "$@"; }
-# @FUNCTION: tc-getFC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Fortran 90 compiler
-tc-getFC() { tc-getPROG FC gfortran "$@"; }
-# @FUNCTION: tc-getGCJ
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the java compiler
-tc-getGCJ() { tc-getPROG GCJ gcj "$@"; }
-# @FUNCTION: tc-getGO
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Go compiler
-tc-getGO() { tc-getPROG GO gccgo "$@"; }
-# @FUNCTION: tc-getPKG_CONFIG
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the pkg-config tool
-tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; }
-# @FUNCTION: tc-getRC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Windows resource compiler
-tc-getRC() { tc-getPROG RC windres "$@"; }
-# @FUNCTION: tc-getDLLWRAP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Windows dllwrap utility
-tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
-
-# @FUNCTION: tc-getBUILD_AR
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver for building binaries to run on the build machine
-tc-getBUILD_AR() { tc-getBUILD_PROG AR ar "$@"; }
-# @FUNCTION: tc-getBUILD_AS
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the assembler for building binaries to run on the build machine
-tc-getBUILD_AS() { tc-getBUILD_PROG AS as "$@"; }
-# @FUNCTION: tc-getBUILD_CC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C compiler for building binaries to run on the build machine
-tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; }
-# @FUNCTION: tc-getBUILD_CPP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C preprocessor for building binaries to run on the build machine
-tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; }
-# @FUNCTION: tc-getBUILD_CXX
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C++ compiler for building binaries to run on the build machine
-tc-getBUILD_CXX() { tc-getBUILD_PROG CXX g++ "$@"; }
-# @FUNCTION: tc-getBUILD_LD
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the linker for building binaries to run on the build machine
-tc-getBUILD_LD() { tc-getBUILD_PROG LD ld "$@"; }
-# @FUNCTION: tc-getBUILD_STRIP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the strip program for building binaries to run on the build machine
-tc-getBUILD_STRIP() { tc-getBUILD_PROG STRIP strip "$@"; }
-# @FUNCTION: tc-getBUILD_NM
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the symbol/object thingy for building binaries to run on the build machine
-tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; }
-# @FUNCTION: tc-getBUILD_RANLIB
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver indexer for building binaries to run on the build machine
-tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; }
-# @FUNCTION: tc-getBUILD_OBJCOPY
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object copier for building binaries to run on the build machine
-tc-getBUILD_OBJCOPY() { tc-getBUILD_PROG OBJCOPY objcopy "$@"; }
-# @FUNCTION: tc-getBUILD_PKG_CONFIG
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the pkg-config tool for building binaries to run on the build machine
-tc-getBUILD_PKG_CONFIG() { tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"; }
-
-# @FUNCTION: tc-export
-# @USAGE: <list of toolchain variables>
-# @DESCRIPTION:
-# Quick way to export a bunch of compiler vars at once.
-tc-export() {
-	local var
-	for var in "$@" ; do
-		[[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'"
-		eval tc-get${var} > /dev/null
-	done
-}
-
-# @FUNCTION: tc-is-cross-compiler
-# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise
-tc-is-cross-compiler() {
-	[[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
-}
-
-# @FUNCTION: tc-is-softfloat
-# @DESCRIPTION:
-# See if this toolchain is a softfloat based one.
-# @CODE
-# The possible return values:
-#  - only:   the target is always softfloat (never had fpu)
-#  - yes:    the target should support softfloat
-#  - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention
-#  - no:     the target doesn't support softfloat
-# @CODE
-# This allows us to react differently where packages accept
-# softfloat flags in the case where support is optional, but
-# rejects softfloat flags where the target always lacks an fpu.
-tc-is-softfloat() {
-	local CTARGET=${CTARGET:-${CHOST}}
-	case ${CTARGET} in
-		bfin*|h8300*)
-			echo "only" ;;
-		*)
-			if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
-				echo "yes"
-			elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
-				echo "softfp"
-			else
-				echo "no"
-			fi
-			;;
-	esac
-}
-
-# @FUNCTION: tc-is-static-only
-# @DESCRIPTION:
-# Return shell true if the target does not support shared libs, shell false
-# otherwise.
-tc-is-static-only() {
-	local host=${CTARGET:-${CHOST}}
-
-	# *MiNT doesn't have shared libraries, only platform so far
-	[[ ${host} == *-mint* ]]
-}
-
-# @FUNCTION: tc-export_build_env
-# @USAGE: [compiler variables]
-# @DESCRIPTION:
-# Export common build related compiler settings.
-tc-export_build_env() {
-	tc-export "$@"
-	# Some build envs will initialize vars like:
-	# : ${BUILD_LDFLAGS:-${LDFLAGS}}
-	# So make sure all variables are non-empty. #526734
-	: ${BUILD_CFLAGS:=-O1 -pipe}
-	: ${BUILD_CXXFLAGS:=-O1 -pipe}
-	: ${BUILD_CPPFLAGS:= }
-	: ${BUILD_LDFLAGS:= }
-	export BUILD_{C,CXX,CPP,LD}FLAGS
-
-	# Some packages use XXX_FOR_BUILD.
-	local v
-	for v in BUILD_{C,CXX,CPP,LD}FLAGS ; do
-		export ${v#BUILD_}_FOR_BUILD="${!v}"
-	done
-}
-
-# @FUNCTION: tc-env_build
-# @USAGE: <command> [command args]
-# @INTERNAL
-# @DESCRIPTION:
-# Setup the compile environment to the build tools and then execute the
-# specified command.  We use tc-getBUILD_XX here so that we work with
-# all of the semi-[non-]standard env vars like $BUILD_CC which often
-# the target build system does not check.
-tc-env_build() {
-	tc-export_build_env
-	CFLAGS=${BUILD_CFLAGS} \
-	CXXFLAGS=${BUILD_CXXFLAGS} \
-	CPPFLAGS=${BUILD_CPPFLAGS} \
-	LDFLAGS=${BUILD_LDFLAGS} \
-	AR=$(tc-getBUILD_AR) \
-	AS=$(tc-getBUILD_AS) \
-	CC=$(tc-getBUILD_CC) \
-	CPP=$(tc-getBUILD_CPP) \
-	CXX=$(tc-getBUILD_CXX) \
-	LD=$(tc-getBUILD_LD) \
-	NM=$(tc-getBUILD_NM) \
-	PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \
-	RANLIB=$(tc-getBUILD_RANLIB) \
-	"$@"
-}
-
-# @FUNCTION: econf_build
-# @USAGE: [econf flags]
-# @DESCRIPTION:
-# Sometimes we need to locally build up some tools to run on CBUILD because
-# the package has helper utils which are compiled+executed when compiling.
-# This won't work when cross-compiling as the CHOST is set to a target which
-# we cannot natively execute.
-#
-# For example, the python package will build up a local python binary using
-# a portable build system (configure+make), but then use that binary to run
-# local python scripts to build up other components of the overall python.
-# We cannot rely on the python binary in $PATH as that often times will be
-# a different version, or not even installed in the first place.  Instead,
-# we compile the code in a different directory to run on CBUILD, and then
-# use that binary when compiling the main package to run on CHOST.
-#
-# For example, with newer EAPIs, you'd do something like:
-# @CODE
-# src_configure() {
-# 	ECONF_SOURCE=${S}
-# 	if tc-is-cross-compiler ; then
-# 		mkdir "${WORKDIR}"/${CBUILD}
-# 		pushd "${WORKDIR}"/${CBUILD} >/dev/null
-# 		econf_build --disable-some-unused-stuff
-# 		popd >/dev/null
-# 	fi
-# 	... normal build paths ...
-# }
-# src_compile() {
-# 	if tc-is-cross-compiler ; then
-# 		pushd "${WORKDIR}"/${CBUILD} >/dev/null
-# 		emake one-or-two-build-tools
-# 		ln/mv build-tools to normal build paths in ${S}/
-# 		popd >/dev/null
-# 	fi
-# 	... normal build paths ...
-# }
-# @CODE
-econf_build() {
-	local CBUILD=${CBUILD:-${CHOST}}
-	tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
-}
-
-# @FUNCTION: tc-ld-is-gold
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# Return true if the current linker is set to gold.
-tc-ld-is-gold() {
-	local out
-
-	# First check the linker directly.
-	out=$($(tc-getLD "$@") --version 2>&1)
-	if [[ ${out} == *"GNU gold"* ]] ; then
-		return 0
-	fi
-
-	# Then see if they're selecting gold via compiler flags.
-	# Note: We're assuming they're using LDFLAGS to hold the
-	# options and not CFLAGS/CXXFLAGS.
-	local base="${T}/test-tc-gold"
-	cat <<-EOF > "${base}.c"
-	int main() { return 0; }
-	EOF
-	out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
-	rm -f "${base}"*
-	if [[ ${out} == *"GNU gold"* ]] ; then
-		return 0
-	fi
-
-	# No gold here!
-	return 1
-}
-
-# @FUNCTION: tc-ld-disable-gold
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# If the gold linker is currently selected, configure the compilation
-# settings so that we use the older bfd linker instead.
-tc-ld-disable-gold() {
-	if ! tc-ld-is-gold "$@" ; then
-		# They aren't using gold, so nothing to do!
-		return
-	fi
-
-	ewarn "Forcing usage of the BFD linker instead of GOLD"
-
-	# Set up LD to point directly to bfd if it's available.
-	# We need to extract the first word in case there are flags appended
-	# to its value (like multilib).  #545218
-	local ld=$(tc-getLD "$@")
-	local bfd_ld="${ld%% *}.bfd"
-	local path_ld=$(which "${bfd_ld}" 2>/dev/null)
-	[[ -e ${path_ld} ]] && export LD=${bfd_ld}
-
-	# Set up LDFLAGS to select gold based on the gcc version.
-	local major=$(gcc-major-version "$@")
-	local minor=$(gcc-minor-version "$@")
-	if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then
-		# <=gcc-4.7 requires some coercion.  Only works if bfd exists.
-		if [[ -e ${path_ld} ]] ; then
-			local d="${T}/bfd-linker"
-			mkdir -p "${d}"
-			ln -sf "${path_ld}" "${d}"/ld
-			export LDFLAGS="${LDFLAGS} -B${d}"
-		else
-			die "unable to locate a BFD linker to bypass gold"
-		fi
-	else
-		# gcc-4.8+ supports -fuse-ld directly.
-		export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
-	fi
-}
-
-# @FUNCTION: tc-has-openmp
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# See if the toolchain supports OpenMP.
-tc-has-openmp() {
-	local base="${T}/test-tc-openmp"
-	cat <<-EOF > "${base}.c"
-	#include <omp.h>
-	int main() {
-		int nthreads, tid, ret = 0;
-		#pragma omp parallel private(nthreads, tid)
-		{
-		tid = omp_get_thread_num();
-		nthreads = omp_get_num_threads(); ret += tid + nthreads;
-		}
-		return ret;
-	}
-	EOF
-	$(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null
-	local ret=$?
-	rm -f "${base}"*
-	return ${ret}
-}
-
-# @FUNCTION: tc-has-tls
-# @USAGE: [-s|-c|-l] [toolchain prefix]
-# @DESCRIPTION:
-# See if the toolchain supports thread local storage (TLS).  Use -s to test the
-# compiler, -c to also test the assembler, and -l to also test the C library
-# (the default).
-tc-has-tls() {
-	local base="${T}/test-tc-tls"
-	cat <<-EOF > "${base}.c"
-	int foo(int *i) {
-		static __thread int j = 0;
-		return *i ? j : *i;
-	}
-	EOF
-	local flags
-	case $1 in
-		-s) flags="-S";;
-		-c) flags="-c";;
-		-l) ;;
-		-*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";;
-	esac
-	: ${flags:=-fPIC -shared -Wl,-z,defs}
-	[[ $1 == -* ]] && shift
-	$(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null
-	local ret=$?
-	rm -f "${base}"*
-	return ${ret}
-}
-
-
-# Parse information from CBUILD/CHOST/CTARGET rather than
-# use external variables from the profile.
-tc-ninja_magic_to_arch() {
-ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
-
-	local type=$1
-	local host=$2
-	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
-
-	local KV=${KV:-${KV_FULL}}
-	[[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
-	ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info"
-
-	case ${host} in
-		aarch64*)	echo arm64;;
-		alpha*)		echo alpha;;
-		arm*)		echo arm;;
-		avr*)		ninj avr32 avr;;
-		bfin*)		ninj blackfin bfin;;
-		c6x*)		echo c6x;;
-		cris*)		echo cris;;
-		frv*)		echo frv;;
-		hexagon*)	echo hexagon;;
-		hppa*)		ninj parisc hppa;;
-		i?86*)
-			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
-			# trees have been unified into 'x86'.
-			# FreeBSD still uses i386
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then
-				echo i386
-			else
-				echo x86
-			fi
-			;;
-		ia64*)		echo ia64;;
-		m68*)		echo m68k;;
-		metag*)		echo metag;;
-		microblaze*)	echo microblaze;;
-		mips*)		echo mips;;
-		nios2*)		echo nios2;;
-		nios*)		echo nios;;
-		or32*)		echo openrisc;;
-		powerpc*)
-			# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
-			# have been unified into simply 'powerpc', but until 2.6.16,
-			# ppc32 is still using ARCH="ppc" as default
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
-				echo powerpc
-			elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then
-				if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
-					echo powerpc
-				else
-					echo ppc
-				fi
-			elif [[ ${host} == powerpc64* ]] ; then
-				echo ppc64
-			elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
-				ninj ppc64 ppc
-			else
-				echo ppc
-			fi
-			;;
-		riscv*)		echo riscv;;
-		s390*)		echo s390;;
-		score*)		echo score;;
-		sh64*)		ninj sh64 sh;;
-		sh*)		echo sh;;
-		sparc64*)	ninj sparc64 sparc;;
-		sparc*)		[[ ${PROFILE_ARCH} == "sparc64" ]] \
-						&& ninj sparc64 sparc \
-						|| echo sparc
-					;;
-		tile*)		echo tile;;
-		vax*)		echo vax;;
-		x86_64*freebsd*) echo amd64;;
-		x86_64*)
-			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
-			# trees have been unified into 'x86'.
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then
-				echo x86
-			else
-				ninj x86_64 amd64
-			fi
-			;;
-		xtensa*)	echo xtensa;;
-
-		# since our usage of tc-arch is largely concerned with
-		# normalizing inputs for testing ${CTARGET}, let's filter
-		# other cross targets (mingw and such) into the unknown.
-		*)			echo unknown;;
-	esac
-}
-# @FUNCTION: tc-arch-kernel
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the kernel arch according to the compiler target
-tc-arch-kernel() {
-	tc-ninja_magic_to_arch kern "$@"
-}
-# @FUNCTION: tc-arch
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the portage arch according to the compiler target
-tc-arch() {
-	tc-ninja_magic_to_arch portage "$@"
-}
-
-tc-endian() {
-	local host=$1
-	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
-	host=${host%%-*}
-
-	case ${host} in
-		aarch64*be)	echo big;;
-		aarch64)	echo little;;
-		alpha*)		echo big;;
-		arm*b*)		echo big;;
-		arm*)		echo little;;
-		cris*)		echo little;;
-		hppa*)		echo big;;
-		i?86*)		echo little;;
-		ia64*)		echo little;;
-		m68*)		echo big;;
-		mips*l*)	echo little;;
-		mips*)		echo big;;
-		powerpc*le)	echo little;;
-		powerpc*)	echo big;;
-		s390*)		echo big;;
-		sh*b*)		echo big;;
-		sh*)		echo little;;
-		sparc*)		echo big;;
-		x86_64*)	echo little;;
-		*)			echo wtf;;
-	esac
-}
-
-# Internal func.  The first argument is the version info to expand.
-# Query the preprocessor to improve compatibility across different
-# compilers rather than maintaining a --version flag matrix. #335943
-_gcc_fullversion() {
-	local ver="$1"; shift
-	set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`
-	eval echo "$ver"
-}
-
-# @FUNCTION: gcc-fullversion
-# @RETURN: compiler version (major.minor.micro: [3.4.6])
-gcc-fullversion() {
-	_gcc_fullversion '$1.$2.$3' "$@"
-}
-# @FUNCTION: gcc-version
-# @RETURN: compiler version (major.minor: [3.4].6)
-gcc-version() {
-	_gcc_fullversion '$1.$2' "$@"
-}
-# @FUNCTION: gcc-major-version
-# @RETURN: major compiler version (major: [3].4.6)
-gcc-major-version() {
-	_gcc_fullversion '$1' "$@"
-}
-# @FUNCTION: gcc-minor-version
-# @RETURN: minor compiler version (minor: 3.[4].6)
-gcc-minor-version() {
-	_gcc_fullversion '$2' "$@"
-}
-# @FUNCTION: gcc-micro-version
-# @RETURN: micro compiler version (micro: 3.4.[6])
-gcc-micro-version() {
-	_gcc_fullversion '$3' "$@"
-}
-
-# Returns the installation directory - internal toolchain
-# function for use by _gcc-specs-exists (for flag-o-matic).
-_gcc-install-dir() {
-	echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |\
-		awk '$1=="install:" {print $2}')"
-}
-# Returns true if the indicated specs file exists - internal toolchain
-# function for use by flag-o-matic.
-_gcc-specs-exists() {
-	[[ -f $(_gcc-install-dir)/$1 ]]
-}
-
-# Returns requested gcc specs directive unprocessed - for used by
-# gcc-specs-directive()
-# Note; later specs normally overwrite earlier ones; however if a later
-# spec starts with '+' then it appends.
-# gcc -dumpspecs is parsed first, followed by files listed by "gcc -v"
-# as "Reading <file>", in order.  Strictly speaking, if there's a
-# $(gcc_install_dir)/specs, the built-in specs aren't read, however by
-# the same token anything from 'gcc -dumpspecs' is overridden by
-# the contents of $(gcc_install_dir)/specs so the result is the
-# same either way.
-_gcc-specs-directive_raw() {
-	local cc=$(tc-getCC)
-	local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}')
-	${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 \
-'BEGIN	{ pspec=""; spec=""; outside=1 }
-$1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
-	outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
-	spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
-	{ spec=spec $0 }
-END	{ print spec }'
-	return 0
-}
-
-# Return the requested gcc specs directive, with all included
-# specs expanded.
-# Note, it does not check for inclusion loops, which cause it
-# to never finish - but such loops are invalid for gcc and we're
-# assuming gcc is operational.
-gcc-specs-directive() {
-	local directive subdname subdirective
-	directive="$(_gcc-specs-directive_raw $1)"
-	while [[ ${directive} == *%\(*\)* ]]; do
-		subdname=${directive/*%\(}
-		subdname=${subdname/\)*}
-		subdirective="$(_gcc-specs-directive_raw ${subdname})"
-		directive="${directive//\%(${subdname})/${subdirective}}"
-	done
-	echo "${directive}"
-	return 0
-}
-
-# Returns true if gcc sets relro
-gcc-specs-relro() {
-	local directive
-	directive=$(gcc-specs-directive link_command)
-	[[ "${directive/\{!norelro:}" != "${directive}" ]]
-}
-# Returns true if gcc sets now
-gcc-specs-now() {
-	local directive
-	directive=$(gcc-specs-directive link_command)
-	[[ "${directive/\{!nonow:}" != "${directive}" ]]
-}
-# Returns true if gcc builds PIEs
-gcc-specs-pie() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!nopie:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with the stack protector
-gcc-specs-ssp() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
-}
-# Returns true if gcc upgrades fstack-protector to fstack-protector-all
-gcc-specs-ssp-to-all() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with fno-strict-overflow
-gcc-specs-nostrict() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with fstack-check
-gcc-specs-stack-check() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
-}
-
-
-# @FUNCTION: gen_usr_ldscript
-# @USAGE: [-a] <list of libs to create linker scripts for>
-# @DESCRIPTION:
-# This function generate linker scripts in /usr/lib for dynamic
-# libs in /lib.  This is to fix linking problems when you have
-# the .so in /lib, and the .a in /usr/lib.  What happens is that
-# in some cases when linking dynamic, the .a in /usr/lib is used
-# instead of the .so in /lib due to gcc/libtool tweaking ld's
-# library search path.  This causes many builds to fail.
-# See bug #4411 for more info.
-#
-# Note that you should in general use the unversioned name of
-# the library (libfoo.so), as ldconfig should usually update it
-# correctly to point to the latest version of the library present.
-gen_usr_ldscript() {
-	local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname)
-	[[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
-
-	tc-is-static-only && return
-
-	# Eventually we'd like to get rid of this func completely #417451
-	case ${CTARGET:-${CHOST}} in
-	*-darwin*) ;;
-	*-android*) return 0 ;;
-	*linux*|*-freebsd*|*-openbsd*|*-netbsd*)
-		use prefix && return 0 ;;
-	*) return 0 ;;
-	esac
-
-	# Just make sure it exists
-	dodir /usr/${libdir}
-
-	if [[ $1 == "-a" ]] ; then
-		auto=true
-		shift
-		dodir /${libdir}
-	fi
-
-	# OUTPUT_FORMAT gives hints to the linker as to what binary format
-	# is referenced ... makes multilib saner
-	local flags=( ${CFLAGS} ${LDFLAGS} -Wl,--verbose )
-	if $(tc-getLD) --version | grep -q 'GNU gold' ; then
-		# If they're using gold, manually invoke the old bfd. #487696
-		local d="${T}/bfd-linker"
-		mkdir -p "${d}"
-		ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld
-		flags+=( -B"${d}" )
-	fi
-	output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
-	[[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
-
-	for lib in "$@" ; do
-		local tlib
-		if ${auto} ; then
-			lib="lib${lib}${suffix}"
-		else
-			# Ensure /lib/${lib} exists to avoid dangling scripts/symlinks.
-			# This especially is for AIX where $(get_libname) can return ".a",
-			# so /lib/${lib} might be moved to /usr/lib/${lib} (by accident).
-			[[ -r ${ED}/${libdir}/${lib} ]] || continue
-			#TODO: better die here?
-		fi
-
-		case ${CTARGET:-${CHOST}} in
-		*-darwin*)
-			if ${auto} ; then
-				tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
-			else
-				tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib})
-			fi
-			[[ -z ${tlib} ]] && die "unable to read install_name from ${lib}"
-			tlib=${tlib##*/}
-
-			if ${auto} ; then
-				mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die
-				# some install_names are funky: they encode a version
-				if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]] ; then
-					mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die
-				fi
-				rm -f "${ED}"/${libdir}/${lib}
-			fi
-
-			# Mach-O files have an id, which is like a soname, it tells how
-			# another object linking against this lib should reference it.
-			# Since we moved the lib from usr/lib into lib this reference is
-			# wrong.  Hence, we update it here.  We don't configure with
-			# libdir=/lib because that messes up libtool files.
-			# Make sure we don't lose the specific version, so just modify the
-			# existing install_name
-			if [[ ! -w "${ED}/${libdir}/${tlib}" ]] ; then
-				chmod u+w "${ED}${libdir}/${tlib}" # needed to write to it
-				local nowrite=yes
-			fi
-			install_name_tool \
-				-id "${EPREFIX}"/${libdir}/${tlib} \
-				"${ED}"/${libdir}/${tlib} || die "install_name_tool failed"
-			[[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}"
-			# Now as we don't use GNU binutils and our linker doesn't
-			# understand linker scripts, just create a symlink.
-			pushd "${ED}/usr/${libdir}" > /dev/null
-			ln -snf "../../${libdir}/${tlib}" "${lib}"
-			popd > /dev/null
-			;;
-		*)
-			if ${auto} ; then
-				tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
-				[[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
-				mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
-				# some SONAMEs are funky: they encode a version before the .so
-				if [[ ${tlib} != ${lib}* ]] ; then
-					mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
-				fi
-				rm -f "${ED}"/${libdir}/${lib}
-			else
-				tlib=${lib}
-			fi
-			cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
-			/* GNU ld script
-			   Since Gentoo has critical dynamic libraries in /lib, and the static versions
-			   in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
-			   run into linking problems.  This "fake" dynamic lib is a linker script that
-			   redirects the linker to the real lib.  And yes, this works in the cross-
-			   compiling scenario as the sysroot-ed linker will prepend the real path.
-
-			   See bug https://bugs.gentoo.org/4411 for more info.
-			 */
-			${output_format}
-			GROUP ( ${EPREFIX}/${libdir}/${tlib} )
-			END_LDSCRIPT
-			;;
-		esac
-		fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
-	done
-}
-
-fi


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-06-15 11:40 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-06-15 11:40 UTC (permalink / raw
  To: gentoo-commits

commit:     da9025cda8eacec9f8a6eb4cedb0567f7523bea7
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 15 10:55:39 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Wed Jun 15 11:40:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=da9025cd

kernel-2.eclass, toolchain-funcs.eclass: merged.

 eclass/kernel-2.eclass        | 1321 -----------------------------------------
 eclass/toolchain-funcs.eclass |  840 --------------------------
 2 files changed, 2161 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
deleted file mode 100644
index e8cb8f2..0000000
--- a/eclass/kernel-2.eclass
+++ /dev/null
@@ -1,1321 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.297 2014/11/28 17:40:20 mpagano Exp $
-
-# Description: kernel.eclass rewrite for a clean base regarding the 2.6
-#              series of kernel with back-compatibility for 2.4
-#
-# Original author: John Mylchreest <johnm@gentoo.org>
-# Maintainer: kernel-misc@gentoo.org
-#
-# Please direct your bugs to the current eclass maintainer :)
-
-# added functionality:
-# unipatch		- a flexible, singular method to extract, add and remove patches.
-
-# A Couple of env vars are available to effect usage of this eclass
-# These are as follows:
-#
-# K_USEPV				- When setting the EXTRAVERSION variable, it should
-#						  add PV to the end.
-#						  this is useful for thigns like wolk. IE:
-#						  EXTRAVERSION would be something like : -wolk-4.19-r1
-# K_NOSETEXTRAVERSION	- if this is set then EXTRAVERSION will not be
-#						  automatically set within the kernel Makefile
-# K_NOUSENAME			- if this is set then EXTRAVERSION will not include the
-#						  first part of ${PN} in EXTRAVERSION
-# K_NOUSEPR				- if this is set then EXTRAVERSION will not include the
-#						  anything based on ${PR}.
-# K_PREPATCHED			- if the patchset is prepatched (ie: mm-sources,
-#						  ck-sources, ac-sources) it will use PR (ie: -r5) as
-#						  the patchset version for
-#						  and not use it as a true package revision
-# K_EXTRAEINFO			- this is a new-line seperated list of einfo displays in
-#						  postinst and can be used to carry additional postinst
-#						  messages
-# K_EXTRAELOG			- same as K_EXTRAEINFO except using elog instead of einfo
-# K_EXTRAEWARN			- same as K_EXTRAEINFO except using ewarn instead of einfo
-# K_SYMLINK				- if this is set, then forcably create symlink anyway
-#
-# K_DEFCONFIG			- Allow specifying a different defconfig target.
-#						  If length zero, defaults to "defconfig".
-# K_WANT_GENPATCHES		- Apply genpatches to kernel source. Provide any
-# 						  combination of "base", "extras" or "experimental".
-# K_EXP_GENPATCHES_PULL	- If set, we pull "experimental" regardless of the USE FLAG
-#						  but expect the ebuild maintainer to use K_EXP_GENPATCHES_LIST.
-# K_EXP_GENPATCHES_NOUSE	- If set, no USE flag will be provided for "experimental";
-# 						  as a result the user cannot choose to apply those patches.
-# K_EXP_GENPATCHES_LIST	- A list of patches to pick from "experimental" to apply when
-# 						  the USE flag is unset and K_EXP_GENPATCHES_PULL is set.
-# K_GENPATCHES_VER		- The version of the genpatches tarball(s) to apply.
-#						  A value of "5" would apply genpatches-2.6.12-5 to
-#						  my-sources-2.6.12.ebuild
-# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
-# K_DEBLOB_AVAILABLE	- A value of "0" will disable all of the optional deblob
-#						  code. If empty, will be set to "1" if deblobbing is
-#						  possible. Test ONLY for "1".
-# K_PREDEBLOBBED		- This kernel was already deblobbed elsewhere.
-#						  If false, either optional deblobbing will be available
-#						  or the license will note the inclusion of freedist
-#						  code.
-# K_LONGTERM			- If set, the eclass will search for the kernel source
-#						  in the long term directories on the upstream servers
-#						  as the location has been changed by upstream
-# H_SUPPORTEDARCH		- this should be a space separated list of ARCH's which
-#						  can be supported by the headers ebuild
-
-# UNIPATCH_LIST			- space delimetered list of patches to be applied to the
-#						  kernel
-# UNIPATCH_EXCLUDE		- an addition var to support exlusion based completely
-#						  on "<passedstring>*" and not "<passedno#>_*"
-#						- this should _NOT_ be used from the ebuild as this is
-#						  reserved for end users passing excludes from the cli
-# UNIPATCH_DOCS			- space delimemeted list of docs to be installed to
-#						  the doc dir
-# UNIPATCH_STRICTORDER	- if this is set places patches into directories of
-#						  order, so they are applied in the order passed
-
-# Changing any other variable in this eclass is not supported; you can request
-# for additional variables to be added by contacting the current maintainer.
-# If you do change them, there is a chance that we will not fix resulting bugs;
-# that of course does not mean we're not willing to help.
-
-PYTHON_COMPAT=( python{2_6,2_7} )
-
-inherit eutils toolchain-funcs versionator multilib python-any-r1
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
-
-# Added by Daniel Ostrow <dostrow@gentoo.org>
-# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
-# I will remove it when I come up with something more reasonable.
-[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
-	export CTARGET=${CATEGORY/cross-}
-fi
-
-HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
-: ${LICENSE:="GPL-2"}
-
-# This is the latest KV_PATCH of the deblob tool available from the
-# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
-# for ALL kernel-2 consumer packages where deblob is available.
-: ${DEBLOB_MAX_VERSION:=38}
-
-# No need to run scanelf/strip on kernel sources/headers (bug #134453).
-RESTRICT="binchecks strip"
-
-# set LINUX_HOSTCFLAGS if not already set
-: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
-
-# debugging functions
-#==============================================================
-# this function exists only to help debug kernel-2.eclass
-# if you are adding new functionality in, put a call to it
-# at the start of src_unpack, or during SRC_URI/dep generation.
-debug-print-kernel2-variables() {
-	for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
-			RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
-			UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do
-		debug-print "${v}: ${!v}"
-	done
-}
-
-#Eclass functions only from here onwards ...
-#==============================================================
-handle_genpatches() {
-	local tarball
-	[[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
-
-	debug-print "Inside handle_genpatches"
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	# for > 3.0 kernels, handle genpatches tarball name
-	# genpatches for 3.0 and 3.0.1 might be named
-	# genpatches-3.0-1.base.tar.xz and genpatches-3.0-2.base.tar.xz
-	# respectively.  Handle this.
-
-	for i in ${K_WANT_GENPATCHES} ; do
-		if [[ ${KV_MAJOR} -ge 3 ]]; then
-			if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-				tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.xz"
-			else
-				tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.xz"
-			fi
-		else
-			tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.xz"
-		fi
-
-		local use_cond_start="" use_cond_end=""
-
-		if [[ "${i}" == "experimental" && -z ${K_EXP_GENPATCHES_PULL} && -z ${K_EXP_GENPATCHES_NOUSE} ]] ; then
-			use_cond_start="experimental? ( "
-			use_cond_end=" )"
-
-			if use experimental ; then
-				UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
-				debug-print "genpatches tarball: $tarball"
-			fi
-		else
-			UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
-			debug-print "genpatches tarball: $tarball"
-		fi
-
-		GENPATCHES_URI+=" ${use_cond_start}mirror://gentoo/${tarball}${use_cond_end}"
-	done
-}
-
-detect_version() {
-	# this function will detect and set
-	# - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
-	# - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
-	# - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
-
-	# We've already run, so nothing to do here.
-	[[ -n ${KV_FULL} ]] && return 0
-
-	# CKV is used as a comparison kernel version, which is used when
-	# PV doesnt reflect the genuine kernel version.
-	# this gets set to the portage style versioning. ie:
-	#   CKV=2.6.11_rc4
-	CKV=${CKV:-${PV}}
-	OKV=${OKV:-${CKV}}
-	OKV=${OKV/_beta/-test}
-	OKV=${OKV/_rc/-rc}
-	OKV=${OKV/-r*}
-	OKV=${OKV/_p*}
-
-	KV_MAJOR=$(get_version_component_range 1 ${OKV})
-	# handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	# if KV_MAJOR >= 3, then we have no more KV_MINOR
-	#if [[ ${KV_MAJOR} -lt 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-		KV_MINOR=$(get_version_component_range 2 ${OKV})
-		KV_PATCH=$(get_version_component_range 3 ${OKV})
-		if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
-	        KV_EXTRA=$(get_version_component_range 4- ${OKV})
-	        KV_EXTRA=${KV_EXTRA/[-_]*}
-		else
-			KV_PATCH=$(get_version_component_range 3- ${OKV})
-		fi
-	else
-		KV_PATCH=$(get_version_component_range 2 ${OKV})
-		KV_EXTRA=$(get_version_component_range 3- ${OKV})
-		KV_EXTRA=${KV_EXTRA/[-_]*}
-	fi
-
-	debug-print "KV_EXTRA is ${KV_EXTRA}"
-
-	KV_PATCH=${KV_PATCH/[-_]*}
-
-	local v n=0 missing
-	#if [[ ${KV_MAJOR} -lt 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
-		for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
-			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
-		done
-	else
-		for v in CKV OKV KV_{MAJOR,PATCH} ; do
-			[[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
-		done
-	fi
-
-	[[ $n -eq 1 ]] && \
-		eerror "Missing variables: ${missing}" && \
-		die "Failed to extract kernel version (try explicit CKV in ebuild)!"
-	unset v n missing
-
-#	if [[ ${KV_MAJOR} -ge 3 ]]; then
-	if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then
-		KV_PATCH_ARR=(${KV_PATCH//\./ })
-
-		# at this point 031412, Linus is putting all 3.x kernels in a
-		# 3.x directory, may need to revisit when 4.x is released
-		KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
-
-		[[ -n "${K_LONGTERM}" ]] &&
-			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
-	else
-		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
-		#KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
-		if [[ ${KV_MAJOR} -ge 3 ]]; then
-			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
-		else
-			KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
-		fi
-
-		[[ -n "${K_LONGTERM}" ]] &&
-			#KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
-			KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-	fi
-
-	debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
-
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		# handle non genpatch using sources correctly
-		if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
-		fi
-		KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz"
-	else
-		KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-	fi
-
-	RELEASE=${CKV/${OKV}}
-	RELEASE=${RELEASE/_beta}
-	RELEASE=${RELEASE/_rc/-rc}
-	RELEASE=${RELEASE/_pre/-pre}
-	# We cannot trivally call kernel_is here, because it calls us to detect the
-	# version
-	#kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
-	[ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
-	RELEASETYPE=${RELEASE//[0-9]}
-
-	# Now we know that RELEASE is the -rc/-git
-	# and RELEASETYPE is the same but with its numerics stripped
-	# we can work on better sorting EXTRAVERSION.
-	# first of all, we add the release
-	EXTRAVERSION="${RELEASE}"
-	debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
-	[[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
-
-	debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
-	if [[ -n "${K_NOUSEPR}" ]]; then
-		# Don't add anything based on PR to EXTRAVERSION
-		debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
-	elif [[ -n ${K_PREPATCHED} ]]; then
-		debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
-		EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
-	elif [[ "${ETYPE}" = "sources" ]]; then
-		debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
-		# For some sources we want to use the PV in the extra version
-		# This is because upstream releases with a completely different
-		# versioning scheme.
-		case ${PN/-*} in
-		     wolk) K_USEPV=1;;
-		  vserver) K_USEPV=1;;
-		esac
-
-		[[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
-		[[ -n "${K_USEPV}" ]]     && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
-		[[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
-	fi
-	debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
-
-	# The only messing around which should actually effect this is for KV_EXTRA
-	# since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
-	# KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
-
-	if [[ -n ${KV_EXTRA} ]]; then
-		if [[ -n ${KV_MINOR} ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-		else
-			OKV="${KV_MAJOR}.${KV_PATCH}"
-		fi
-		KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.xz
-					${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-		UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz"
-	fi
-
-	# We need to set this using OKV, but we need to set it before we do any
-	# messing around with OKV based on RELEASETYPE
-	KV_FULL=${OKV}${EXTRAVERSION}
-
-	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
-	KV=${KV_FULL}
-
-	# -rc-git pulls can be achieved by specifying CKV
-	# for example:
-	#   CKV="2.6.11_rc3_pre2"
-	# will pull:
-	#   linux-2.6.10.tar.xz & patch-2.6.11-rc3.xz & patch-2.6.11-rc3-git2.xz
-
-	if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then
-
-		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
-			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -git ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -rc-git ]]; then
-			OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz
-						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz"
-		fi
-	else
-		if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
-			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
-				OKV="2.6.39"
-			else
-				KV_PATCH_ARR=(${KV_PATCH//\./ })
-				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
-			fi
-			KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -git ]]; then
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz"
-		fi
-
-		if [[ ${RELEASETYPE} == -rc-git ]]; then
-			if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
-				OKV="2.6.39"
-			else
-				KV_PATCH_ARR=(${KV_PATCH//\./ })
-				OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
-			fi
-			KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz
-						${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz
-						${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
-
-			UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz"
-		fi
-
-
-	fi
-
-
-	debug-print-kernel2-variables
-
-	handle_genpatches
-}
-
-# Note: duplicated in linux-info.eclass
-kernel_is() {
-	# ALL of these should be set before we can safely continue this function.
-	# some of the sources have in the past had only one set.
-	local v n=0
-	for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
-	[[ $n -eq 1 ]] && detect_version
-	unset v n
-
-	# Now we can continue
-	local operator test value
-
-	case ${1#-} in
-	  lt) operator="-lt"; shift;;
-	  gt) operator="-gt"; shift;;
-	  le) operator="-le"; shift;;
-	  ge) operator="-ge"; shift;;
-	  eq) operator="-eq"; shift;;
-	   *) operator="-eq";;
-	esac
-	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
-
-	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
-	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
-	[ ${test} ${operator} ${value} ]
-}
-
-kernel_is_2_4() {
-	kernel_is 2 4
-}
-
-kernel_is_2_6() {
-	kernel_is 2 6 || kernel_is 2 5
-}
-
-# Capture the sources type and set DEPENDs
-if [[ ${ETYPE} == sources ]]; then
-	DEPEND="!build? (
-		sys-apps/sed
-		>=sys-devel/binutils-2.11.90.0.31
-	)"
-	RDEPEND="!build? (
-		>=sys-libs/ncurses-5.2
-		sys-devel/make
-		dev-lang/perl
-		sys-devel/bc
-	)"
-	PDEPEND="!build? ( virtual/dev-manager )"
-
-	SLOT="${PVR}"
-	DESCRIPTION="Sources based on the Linux Kernel."
-	IUSE="symlink build"
-
-	# Bug #266157, deblob for libre support
-	if [[ -z ${K_PREDEBLOBBED} ]] ; then
-		# Bug #359865, force a call to detect_version if needed
-		kernel_is ge 2 6 27 && \
-			[[ -z "${K_DEBLOB_AVAILABLE}" ]] && \
-				kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
-					K_DEBLOB_AVAILABLE=1
-		if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
-			IUSE="${IUSE} deblob"
-
-			# Reflect that kernels contain firmware blobs unless otherwise
-			# stripped
-			LICENSE="${LICENSE} !deblob? ( freedist )"
-
-			DEPEND+=" deblob? ( ${PYTHON_DEPS} )"
-
-			if [[ -n KV_MINOR ]]; then
-				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
-			else
-				DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}"
-			fi
-
-			if [[ ${KV_MAJOR} -ge 3 ]]; then
-				DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}"
-			fi
-
-			DEBLOB_A="deblob-${DEBLOB_PV}"
-			DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
-			DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
-			DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
-			if ! has "${EAPI:-0}" 0 1 ; then
-				DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
-			else
-				DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
-			fi
-			DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
-			HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
-
-			KERNEL_URI="${KERNEL_URI}
-				deblob? (
-					${DEBLOB_URI}
-					${DEBLOB_CHECK_URI}
-				)"
-		else
-			# We have no way to deblob older kernels, so just mark them as
-			# tainted with non-libre materials.
-			LICENSE="${LICENSE} freedist"
-		fi
-	fi
-
-elif [[ ${ETYPE} == headers ]]; then
-	DESCRIPTION="Linux system headers"
-
-	# Since we should NOT honour KBUILD_OUTPUT in headers
-	# lets unset it here.
-	unset KBUILD_OUTPUT
-
-	SLOT="0"
-else
-	eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
-	die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
-fi
-
-# Cross-compile support functions
-#==============================================================
-kernel_header_destdir() {
-	[[ ${CTARGET} == ${CHOST} ]] \
-		&& echo "${EPREFIX}"/usr/include \
-		|| echo "${EPREFIX}"/usr/${CTARGET}/usr/include
-}
-
-cross_pre_c_headers() {
-	use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
-}
-
-env_setup_xmakeopts() {
-	# Kernel ARCH != portage ARCH
-	export KARCH=$(tc-arch-kernel)
-
-	# When cross-compiling, we need to set the ARCH/CROSS_COMPILE
-	# variables properly or bad things happen !
-	xmakeopts="ARCH=${KARCH}"
-	if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
-		xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
-	elif type -p ${CHOST}-ar > /dev/null ; then
-		xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
-	fi
-	export xmakeopts
-}
-
-# Unpack functions
-#==============================================================
-unpack_2_4() {
-	# this file is required for other things to build properly,
-	# so we autogenerate it
-	make -s mrproper ${xmakeopts} || die "make mrproper failed"
-	make -s symlinks ${xmakeopts} || die "make symlinks failed"
-	make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
-	echo ">>> version.h compiled successfully."
-}
-
-unpack_2_6() {
-	# this file is required for other things to build properly, so we
-	# autogenerate it ... generate a .config to keep version.h build from
-	# spitting out an annoying warning
-	make -s mrproper ${xmakeopts} 2>/dev/null \
-		|| die "make mrproper failed"
-
-	# quick fix for bug #132152 which triggers when it cannot include linux
-	# headers (ie, we have not installed it yet)
-	if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
-		touch .config
-		eerror "make defconfig failed."
-		eerror "assuming you dont have any headers installed yet and continuing"
-		epause 5
-	fi
-
-	make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
-		|| die "make include/linux/version.h failed"
-	rm -f .config >/dev/null
-}
-
-universal_unpack() {
-	debug-print "Inside universal_unpack"
-
-	local OKV_ARRAY
-	IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
-	cd "${WORKDIR}"
-	if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.xz
-	else
-		unpack linux-${OKV}.tar.xz
-	fi
-
-	if [[ -d "linux" ]]; then
-		debug-print "Moving linux to linux-${KV_FULL}"
-		mv linux linux-${KV_FULL} \
-			|| die "Unable to move source tree to ${KV_FULL}."
-	elif [[ "${OKV}" != "${KV_FULL}" ]]; then
-		if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] &&
-			[[ "${ETYPE}" = "sources" ]]; then
-			debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} "
-			mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
-				|| die "Unable to move source tree to ${KV_FULL}."
-		else
-			debug-print "moving linux-${OKV} to linux-${KV_FULL} "
-			mv linux-${OKV} linux-${KV_FULL} \
-				|| die "Unable to move source tree to ${KV_FULL}."
-		fi
-	elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
-		mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
-			|| die "Unable to move source tree to ${KV_FULL}."
-	fi
-	cd "${S}"
-
-	# remove all backup files
-	find . -iname "*~" -exec rm {} \; 2> /dev/null
-
-}
-
-unpack_set_extraversion() {
-	cd "${S}"
-	sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
-	cd "${OLDPWD}"
-}
-
-# Should be done after patches have been applied
-# Otherwise patches that modify the same area of Makefile will fail
-unpack_fix_install_path() {
-	cd "${S}"
-	sed	-i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
-}
-
-# Compile Functions
-#==============================================================
-compile_headers() {
-	env_setup_xmakeopts
-
-	# if we couldnt obtain HOSTCFLAGS from the Makefile,
-	# then set it to something sane
-	local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
-	HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
-
-	if kernel_is 2 4; then
-		yes "" | make oldconfig ${xmakeopts}
-		echo ">>> make oldconfig complete"
-		make dep ${xmakeopts}
-	elif kernel_is 2 6; then
-		# 2.6.18 introduces headers_install which means we dont need any
-		# of this crap anymore :D
-		kernel_is ge 2 6 18 && return 0
-
-		# autoconf.h isnt generated unless it already exists. plus, we have
-		# no guarantee that any headers are installed on the system...
-		[[ -f ${EROOT}/usr/include/linux/autoconf.h ]] \
-			|| touch include/linux/autoconf.h
-
-		# if K_DEFCONFIG isn't set, force to "defconfig"
-		# needed by mips
-		if [[ -z ${K_DEFCONFIG} ]]; then
-			if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
-				case ${CTARGET} in
-					powerpc64*)	K_DEFCONFIG="ppc64_defconfig";;
-					powerpc*)	K_DEFCONFIG="pmac32_defconfig";;
-					*)			K_DEFCONFIG="defconfig";;
-				esac
-			else
-				K_DEFCONFIG="defconfig"
-			fi
-		fi
-
-		# if there arent any installed headers, then there also isnt an asm
-		# symlink in /usr/include/, and make defconfig will fail, so we have
-		# to force an include path with $S.
-		HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
-		ln -sf asm-${KARCH} "${S}"/include/asm
-		cross_pre_c_headers && return 0
-
-		make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
-		if compile_headers_tweak_config ; then
-			yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
-		fi
-		make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
-		make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
-	fi
-}
-
-compile_headers_tweak_config() {
-	# some targets can be very very picky, so let's finesse the
-	# .config based upon any info we may have
-	case ${CTARGET} in
-	sh*)
-		sed -i '/CONFIG_CPU_SH/d' .config
-		echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
-		return 0;;
-	esac
-
-	# no changes, so lets do nothing
-	return 1
-}
-
-# install functions
-#==============================================================
-install_universal() {
-	# Fix silly permissions in tarball
-	cd "${WORKDIR}"
-	chown -R 0:0 * >& /dev/null
-	chmod -R a+r-w+X,u+w *
-	cd ${OLDPWD}
-}
-
-install_headers() {
-	local ddir=$(kernel_header_destdir)
-
-	# 2.6.18 introduces headers_install which means we dont need any
-	# of this crap anymore :D
-	if kernel_is ge 2 6 18 ; then
-		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
-
-		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
-		return 0
-	fi
-
-	# Do not use "linux/*" as that can cause problems with very long
-	# $S values where the cmdline to cp is too long
-	pushd "${S}" >/dev/null
-	dodir ${ddir#${EPREFIX}}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
-
-	dodir ${ddir#${EPREFIX}}/asm
-	cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm
-
-	if kernel_is 2 6 ; then
-		dodir ${ddir#${EPREFIX}}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
-	fi
-
-	# clean up
-	find "${D}" -name '*.orig' -exec rm -f {} \;
-
-	popd >/dev/null
-}
-
-install_sources() {
-	local file
-
-	cd "${S}"
-	dodir /usr/src
-	echo ">>> Copying sources ..."
-
-	file="$(find ${WORKDIR} -iname "docs" -type d)"
-	if [[ -n ${file} ]]; then
-		for file in $(find ${file} -type f); do
-			echo "${file//*docs\/}" >> "${S}"/patches.txt
-			echo "===================================================" >> "${S}"/patches.txt
-			cat ${file} >> "${S}"/patches.txt
-			echo "===================================================" >> "${S}"/patches.txt
-			echo "" >> "${S}"/patches.txt
-		done
-	fi
-
-	if [[ ! -f ${S}/patches.txt ]]; then
-		# patches.txt is empty so lets use our ChangeLog
-		[[ -f ${FILESDIR}/../ChangeLog ]] && \
-			echo "Please check the ebuild ChangeLog for more details." \
-			> "${S}"/patches.txt
-	fi
-
-	mv ${WORKDIR}/linux* "${ED}"/usr/src
-
-	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
-		for i in ${UNIPATCH_DOCS}; do
-			dodoc "${T}"/${i}
-		done
-	fi
-}
-
-# pkg_preinst functions
-#==============================================================
-preinst_headers() {
-	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
-}
-
-# pkg_postinst functions
-#==============================================================
-postinst_sources() {
-	local MAKELINK=0
-
-	# if we have USE=symlink, then force K_SYMLINK=1
-	use symlink && K_SYMLINK=1
-
-	# if we're using a deblobbed kernel, it's not supported
-	[[ $K_DEBLOB_AVAILABLE == 1 ]] && \
-		use deblob && \
-		K_SECURITY_UNSUPPORTED=deblob
-
-	# if we are to forcably symlink, delete it if it already exists first.
-	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux
-		MAKELINK=1
-	fi
-
-	# if the link doesnt exist, lets create it
-	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
-
-	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${EROOT}"usr/src
-		ln -sf linux-${KV_FULL} linux
-		cd ${OLDPWD}
-	fi
-
-	# Don't forget to make directory for sysfs
-	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}sys
-
-	echo
-	elog "If you are upgrading from a previous kernel, you may be interested"
-	elog "in the following document:"
-	elog "  - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
-	echo
-
-	# if K_EXTRAEINFO is set then lets display it now
-	if [[ -n ${K_EXTRAEINFO} ]]; then
-		echo ${K_EXTRAEINFO} | fmt |
-		while read -s ELINE; do	einfo "${ELINE}"; done
-	fi
-
-	# if K_EXTRAELOG is set then lets display it now
-	if [[ -n ${K_EXTRAELOG} ]]; then
-		echo ${K_EXTRAELOG} | fmt |
-		while read -s ELINE; do	elog "${ELINE}"; done
-	fi
-
-	# if K_EXTRAEWARN is set then lets display it now
-	if [[ -n ${K_EXTRAEWARN} ]]; then
-		echo ${K_EXTRAEWARN} | fmt |
-		while read -s ELINE; do ewarn "${ELINE}"; done
-	fi
-
-	# optionally display security unsupported message
-	#  Start with why
-	if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
-		ewarn "Deblobbed kernels may not be up-to-date security-wise"
-		ewarn "as they depend on external scripts."
-	elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
-		ewarn "${PN} is UNSUPPORTED by Gentoo Security."
-	fi
-	#  And now the general message.
-	if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
-		ewarn "This means that it is likely to be vulnerable to recent security issues."
-		ewarn "For specific information on why this kernel is unsupported, please read:"
-		ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
-	fi
-
-	# warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
-	KV_MAJOR=$(get_version_component_range 1 ${OKV})
-	KV_MINOR=$(get_version_component_range 2 ${OKV})
-	KV_PATCH=$(get_version_component_range 3 ${OKV})
-	if [[ "$(tc-arch)" = "sparc" ]]; then
-		if [[ $(gcc-major-version) -lt 4 && $(gcc-minor-version) -lt 4 ]]; then
-			if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] ; then
-				echo
-				elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
-				elog "you now need to do"
-				elog "  make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
-				elog "instead of just"
-				elog "  make"
-				elog "to compile the kernel. For more information please browse to"
-				elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
-				echo
-			fi
-		fi
-	fi
-}
-
-# pkg_setup functions
-#==============================================================
-setup_headers() {
-	[[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
-	for i in ${H_SUPPORTEDARCH}; do
-		[[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
-	done
-
-	if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
-		echo
-		eerror "This version of ${PN} does not support $(tc-arch)."
-		eerror "Please merge the appropriate sources, in most cases"
-		eerror "(but not all) this will be called $(tc-arch)-headers."
-		die "Package unsupported for $(tc-arch)"
-	fi
-}
-
-# unipatch
-#==============================================================
-unipatch() {
-	local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
-	local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
-
-	# set to a standard locale to ensure sorts are ordered properly.
-	myLC_ALL="${LC_ALL}"
-	myLANG="${LANG}"
-	LC_ALL="C"
-	LANG=""
-
-	[ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
-	[ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
-
-	# We're gonna need it when doing patches with a predefined patchlevel
-	eshopts_push -s extglob
-
-	# This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
-	# usage can be either via an env var or by params
-	# although due to the nature we pass this within this eclass
-	# it shall be by param only.
-	# -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
-	UNIPATCH_LIST="${@}"
-
-	#unpack any passed tarballs
-	for i in ${UNIPATCH_LIST}; do
-		if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
-			if [ -n "${UNIPATCH_STRICTORDER}" ]; then
-				unset z
-				STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
-				for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
-					do z="${z}0";
-				done
-				PATCH_ORDER="${z}${STRICT_COUNT}"
-
-				mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
-				pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
-				unpack ${i##*/}
-				popd >/dev/null
-			else
-				pushd "${KPATCH_DIR}" >/dev/null
-				unpack ${i##*/}
-				popd >/dev/null
-			fi
-
-			[[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
-		else
-			extention=${i/*./}
-			extention=${extention/:*/}
-			PIPE_CMD=""
-			case ${extention} in
-				     xz) PIPE_CMD="xz -dc";;
-				   lzma) PIPE_CMD="lzma -dc";;
-				    bz2) PIPE_CMD="bzip2 -dc";;
-				 patch*) PIPE_CMD="cat";;
-				   diff) PIPE_CMD="cat";;
-				 gz|Z|z) PIPE_CMD="gzip -dc";;
-				ZIP|zip) PIPE_CMD="unzip -p";;
-				      *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
-			esac
-
-			PATCH_LEVEL=${i/*([^:])?(:)}
-			i=${i/:*/}
-			x=${i/*\//}
-			x=${x/\.${extention}/}
-
-			if [ -n "${PIPE_CMD}" ]; then
-				if [ ! -r "${i}" ]; then
-					echo
-					eerror "FATAL: unable to locate:"
-					eerror "${i}"
-					eerror "for read-only. The file either has incorrect permissions"
-					eerror "or does not exist."
-					die Unable to locate ${i}
-				fi
-
-				if [ -n "${UNIPATCH_STRICTORDER}" ]; then
-					unset z
-					STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
-					for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
-						do z="${z}0";
-					done
-					PATCH_ORDER="${z}${STRICT_COUNT}"
-
-					mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
-					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
-				else
-					$(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
-				fi
-			fi
-		fi
-
-		# If experimental was not chosen by the user, drop experimental patches not in K_EXP_GENPATCHES_LIST.
-		if [[ "${i}" == *"genpatches-"*".experimental."* && -n ${K_EXP_GENPATCHES_PULL} ]] ; then
-			if [[ -z ${K_EXP_GENPATCHES_NOUSE} ]] && use experimental; then
-				continue
-			fi
-
-			local j
-			for j in ${KPATCH_DIR}/*/50*_*.patch*; do
-				for k in ${K_EXP_GENPATCHES_LIST} ; do
-					[[ "$(basename ${j})" == ${k}* ]] && continue 2
-				done
-				UNIPATCH_DROP+=" $(basename ${j})"
-			done
-		fi
-	done
-
-	#populate KPATCH_DIRS so we know where to look to remove the excludes
-	x=${KPATCH_DIR}
-	KPATCH_DIR=""
-	for i in $(find ${x} -type d | sort -n); do
-		KPATCH_DIR="${KPATCH_DIR} ${i}"
-	done
-
-	# do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
-	# bug #272676
-	if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
-		if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
-			UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
-			echo
-			ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
-			ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
-			ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
-			echo
-		fi
-	fi
-
-	#so now lets get rid of the patchno's we want to exclude
-	UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
-	for i in ${UNIPATCH_DROP}; do
-		ebegin "Excluding Patch #${i}"
-		for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
-		eend $?
-	done
-
-	# and now, finally, we patch it :)
-	for x in ${KPATCH_DIR}; do
-		for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
-			STDERR_T="${T}/${i/*\//}"
-			STDERR_T="${STDERR_T/.patch*/.err}"
-
-			[ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
-			#[ -z ${i/*.diff*/} ]  && PATCH_DEPTH=${i/*.diff/}
-
-			if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
-
-			####################################################################
-			# IMPORTANT: This is temporary code to support Linux git 3.15_rc1! #
-			#                                                                  #
-			# The patch contains a removal of a symlink, followed by addition  #
-			# of a file with the same name as the symlink in the same          #
-			# location; this causes the dry-run to fail, filed bug #507656.    #
-			#                                                                  #
-			# https://bugs.gentoo.org/show_bug.cgi?id=507656                   #
-			####################################################################
-			if [[ ${PN} == "git-sources" ]] ; then
-				if [[ ${KV_MAJOR}${KV_PATCH} -ge 315 && ${RELEASETYPE} == -rc ]] ; then
-					ebegin "Applying ${i/*\//} (-p1)"
-					if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
-						eend 0
-						rm ${STDERR_T}
-						break
-					else
-						eend 1
-						eerror "Failed to apply patch ${i/*\//}"
-						eerror "Please attach ${STDERR_T} to any bug you may post."
-						eshopts_pop
-						die "Failed to apply ${i/*\//} on patch depth 1."
-					fi
-				fi
-			fi
-			####################################################################
-
-			while [ ${PATCH_DEPTH} -lt 5 ]; do
-				echo "Attempting Dry-run:" >> ${STDERR_T}
-				echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
-				echo "=======================================================" >> ${STDERR_T}
-				if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
-					ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH})"
-					echo "Attempting patch:" > ${STDERR_T}
-					echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
-					echo "=======================================================" >> ${STDERR_T}
-					if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
-						eend 0
-						rm ${STDERR_T}
-						break
-					else
-						eend 1
-						eerror "Failed to apply patch ${i/*\//}"
-						eerror "Please attach ${STDERR_T} to any bug you may post."
-						eshopts_pop
-						die "Failed to apply ${i/*\//} on patch depth ${PATCH_DEPTH}."
-					fi
-				else
-					PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
-				fi
-			done
-			if [ ${PATCH_DEPTH} -eq 5 ]; then
-				eerror "Failed to dry-run patch ${i/*\//}"
-				eerror "Please attach ${STDERR_T} to any bug you may post."
-				eshopts_pop
-				die "Unable to dry-run patch on any patch depth lower than 5."
-			fi
-		done
-	done
-
-	# When genpatches is used, we want to install 0000_README which documents
-	# the patches that were used; such that the user can see them, bug #301478.
-	if [[ ! -z ${K_WANT_GENPATCHES} ]] ; then
-		UNIPATCH_DOCS="${UNIPATCH_DOCS} 0000_README"
-	fi
-
-	# When files listed in UNIPATCH_DOCS are found in KPATCH_DIR's, we copy it
-	# to the temporary directory and remember them in UNIPATCH_DOCS to install
-	# them during the install phase.
-	local tmp
-	for x in ${KPATCH_DIR}; do
-		for i in ${UNIPATCH_DOCS}; do
-			if [[ -f "${x}/${i}" ]] ; then
-				tmp="${tmp} ${i}"
-				cp -f "${x}/${i}" "${T}"/
-			fi
-		done
-	done
-	UNIPATCH_DOCS="${tmp}"
-
-	# clean up  KPATCH_DIR's - fixes bug #53610
-	for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
-
-	LC_ALL="${myLC_ALL}"
-	LANG="${myLANG}"
-	eshopts_pop
-}
-
-# getfilevar accepts 2 vars as follows:
-# getfilevar <VARIABLE> <CONFIGFILE>
-# pulled from linux-info
-
-getfilevar() {
-	local workingdir basefname basedname xarch=$(tc-arch-kernel)
-
-	if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
-		echo -e "\n"
-		eerror "getfilevar requires 2 variables, with the second a valid file."
-		eerror "   getfilevar <VARIABLE> <CONFIGFILE>"
-	else
-		workingdir=${PWD}
-		basefname=$(basename ${2})
-		basedname=$(dirname ${2})
-		unset ARCH
-
-		cd ${basedname}
-		echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
-			make ${BUILD_FIXES} -s -f - e 2>/dev/null
-		cd ${workingdir}
-
-		ARCH=${xarch}
-	fi
-}
-
-detect_arch() {
-	# This function sets ARCH_URI and ARCH_PATCH
-	# with the neccessary info for the arch sepecific compatibility
-	# patchsets.
-
-	local ALL_ARCH LOOP_ARCH COMPAT_URI i
-
-	# COMPAT_URI is the contents of ${ARCH}_URI
-	# ARCH_URI is the URI for all the ${ARCH}_URI patches
-	# ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
-
-	ARCH_URI=""
-	ARCH_PATCH=""
-	ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
-
-	for LOOP_ARCH in ${ALL_ARCH}; do
-		COMPAT_URI="${LOOP_ARCH}_URI"
-		COMPAT_URI="${!COMPAT_URI}"
-
-		[[ -n ${COMPAT_URI} ]] && \
-			ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
-
-		if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; 	then
-			for i in ${COMPAT_URI}; do
-				ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
-			done
-		fi
-	done
-}
-
-headers___fix() {
-	# Voodoo to partially fix broken upstream headers.
-	# note: do not put inline/asm/volatile together (breaks "inline asm volatile")
-	sed -i \
-		-e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
-		-e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
-		-e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
-		-e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
-		-e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
-		"$@"
-}
-
-# common functions
-#==============================================================
-kernel-2_src_unpack() {
-	universal_unpack
-	debug-print "Doing unipatch"
-
-	[[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
-		unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
-
-	debug-print "Doing premake"
-
-	# allow ebuilds to massage the source tree after patching but before
-	# we run misc `make` functions below
-	[[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
-
-	debug-print "Doing epatch_user"
-	epatch_user
-
-	debug-print "Doing unpack_set_extraversion"
-
-	[[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
-	unpack_fix_install_path
-
-	# Setup xmakeopts and cd into sourcetree.
-	env_setup_xmakeopts
-	cd "${S}"
-
-	# We dont need a version.h for anything other than headers
-	# at least, I should hope we dont. If this causes problems
-	# take out the if/fi block and inform me please.
-	# unpack_2_6 should now be 2.6.17 safe anyways
-	if [[ ${ETYPE} == headers ]]; then
-		kernel_is 2 4 && unpack_2_4
-		kernel_is 2 6 && unpack_2_6
-	fi
-
-	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
-		cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
-		cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
-		chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
-	fi
-
-	# fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
-	# only do this for kernel < 2.6.27 since this file does not exist in later
-	# kernels
-	if [[ -n ${KV_MINOR} &&  ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] ; then
-		sed -i \
-			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
-			"${S}"/arch/ppc/Makefile
-	else
-		sed -i \
-			-e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
-			"${S}"/arch/powerpc/Makefile
-	fi
-}
-
-kernel-2_src_compile() {
-	cd "${S}"
-	[[ ${ETYPE} == headers ]] && compile_headers
-
-	if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
-		echo ">>> Running deblob script ..."
-		python_setup
-		sh "${T}/${DEBLOB_A}" --force || die "Deblob script failed to run!!!"
-	fi
-}
-
-# if you leave it to the default src_test, it will run make to
-# find whether test/check targets are present; since "make test"
-# actually produces a few support files, they are installed even
-# though the package is binchecks-restricted.
-#
-# Avoid this altogether by making the function moot.
-kernel-2_src_test() { :; }
-
-kernel-2_pkg_preinst() {
-	[[ ${ETYPE} == headers ]] && preinst_headers
-}
-
-kernel-2_src_install() {
-	install_universal
-	[[ ${ETYPE} == headers ]] && install_headers
-	[[ ${ETYPE} == sources ]] && install_sources
-}
-
-kernel-2_pkg_postinst() {
-	[[ ${ETYPE} == sources ]] && postinst_sources
-}
-
-kernel-2_pkg_setup() {
-	if kernel_is 2 4; then
-		if [[ $(gcc-major-version) -ge 4 ]] ; then
-			echo
-			ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
-			ewarn "Either switch to another gcc-version (via gcc-config) or use a"
-			ewarn "newer kernel that supports gcc-4."
-			echo
-			ewarn "Also be aware that bugreports about gcc-4 not working"
-			ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
-			echo
-			epause 10
-		fi
-	fi
-
-	ABI="${KERNEL_ABI}"
-	[[ ${ETYPE} == headers ]] && setup_headers
-	[[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
-}
-
-kernel-2_pkg_postrm() {
-	# This warning only makes sense for kernel sources.
-	[[ ${ETYPE} == headers ]] && return 0
-
-	# If there isn't anything left behind, then don't complain.
-	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
-	echo
-	ewarn "Note: Even though you have successfully unmerged "
-	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
-	ewarn "with modified files will remain behind. By design, package managers"
-	ewarn "will not remove these modified files and the directories they reside in."
-	echo
-}

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
deleted file mode 100644
index 59c2861..0000000
--- a/eclass/toolchain-funcs.eclass
+++ /dev/null
@@ -1,840 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: toolchain-funcs.eclass
-# @MAINTAINER:
-# Toolchain Ninjas <toolchain@gentoo.org>
-# @BLURB: functions to query common info about the toolchain
-# @DESCRIPTION:
-# The toolchain-funcs aims to provide a complete suite of functions
-# for gleaning useful information about the toolchain and to simplify
-# ugly things like cross-compiling and multilib.  All of this is done
-# in such a way that you can rely on the function always returning
-# something sane.
-
-if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then
-_TOOLCHAIN_FUNCS_ECLASS=1
-
-inherit multilib
-
-# tc-getPROG <VAR [search vars]> <default> [tuple]
-_tc-getPROG() {
-	local tuple=$1
-	local v var vars=$2
-	local prog=$3
-
-	var=${vars%% *}
-	for v in ${vars} ; do
-		if [[ -n ${!v} ]] ; then
-			export ${var}="${!v}"
-			echo "${!v}"
-			return 0
-		fi
-	done
-
-	local search=
-	[[ -n $4 ]] && search=$(type -p "$4-${prog}")
-	[[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}")
-	[[ -n ${search} ]] && prog=${search##*/}
-
-	export ${var}=${prog}
-	echo "${!var}"
-}
-tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"; }
-tc-getPROG() { _tc-getPROG CHOST "$@"; }
-
-# @FUNCTION: tc-getAR
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver
-tc-getAR() { tc-getPROG AR ar "$@"; }
-# @FUNCTION: tc-getAS
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the assembler
-tc-getAS() { tc-getPROG AS as "$@"; }
-# @FUNCTION: tc-getCC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C compiler
-tc-getCC() { tc-getPROG CC gcc "$@"; }
-# @FUNCTION: tc-getCPP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C preprocessor
-tc-getCPP() { tc-getPROG CPP cpp "$@"; }
-# @FUNCTION: tc-getCXX
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C++ compiler
-tc-getCXX() { tc-getPROG CXX g++ "$@"; }
-# @FUNCTION: tc-getLD
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the linker
-tc-getLD() { tc-getPROG LD ld "$@"; }
-# @FUNCTION: tc-getSTRIP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the strip program
-tc-getSTRIP() { tc-getPROG STRIP strip "$@"; }
-# @FUNCTION: tc-getNM
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the symbol/object thingy
-tc-getNM() { tc-getPROG NM nm "$@"; }
-# @FUNCTION: tc-getRANLIB
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver indexer
-tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
-# @FUNCTION: tc-getOBJCOPY
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object copier
-tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
-# @FUNCTION: tc-getOBJDUMP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object dumper
-tc-getOBJDUMP() { tc-getPROG OBJDUMP objdump "$@"; }
-# @FUNCTION: tc-getF77
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Fortran 77 compiler
-tc-getF77() { tc-getPROG F77 gfortran "$@"; }
-# @FUNCTION: tc-getFC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Fortran 90 compiler
-tc-getFC() { tc-getPROG FC gfortran "$@"; }
-# @FUNCTION: tc-getGCJ
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the java compiler
-tc-getGCJ() { tc-getPROG GCJ gcj "$@"; }
-# @FUNCTION: tc-getGO
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Go compiler
-tc-getGO() { tc-getPROG GO gccgo "$@"; }
-# @FUNCTION: tc-getPKG_CONFIG
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the pkg-config tool
-tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; }
-# @FUNCTION: tc-getRC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Windows resource compiler
-tc-getRC() { tc-getPROG RC windres "$@"; }
-# @FUNCTION: tc-getDLLWRAP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the Windows dllwrap utility
-tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
-
-# @FUNCTION: tc-getBUILD_AR
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver for building binaries to run on the build machine
-tc-getBUILD_AR() { tc-getBUILD_PROG AR ar "$@"; }
-# @FUNCTION: tc-getBUILD_AS
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the assembler for building binaries to run on the build machine
-tc-getBUILD_AS() { tc-getBUILD_PROG AS as "$@"; }
-# @FUNCTION: tc-getBUILD_CC
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C compiler for building binaries to run on the build machine
-tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; }
-# @FUNCTION: tc-getBUILD_CPP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C preprocessor for building binaries to run on the build machine
-tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; }
-# @FUNCTION: tc-getBUILD_CXX
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the C++ compiler for building binaries to run on the build machine
-tc-getBUILD_CXX() { tc-getBUILD_PROG CXX g++ "$@"; }
-# @FUNCTION: tc-getBUILD_LD
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the linker for building binaries to run on the build machine
-tc-getBUILD_LD() { tc-getBUILD_PROG LD ld "$@"; }
-# @FUNCTION: tc-getBUILD_STRIP
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the strip program for building binaries to run on the build machine
-tc-getBUILD_STRIP() { tc-getBUILD_PROG STRIP strip "$@"; }
-# @FUNCTION: tc-getBUILD_NM
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the symbol/object thingy for building binaries to run on the build machine
-tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; }
-# @FUNCTION: tc-getBUILD_RANLIB
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the archiver indexer for building binaries to run on the build machine
-tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; }
-# @FUNCTION: tc-getBUILD_OBJCOPY
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the object copier for building binaries to run on the build machine
-tc-getBUILD_OBJCOPY() { tc-getBUILD_PROG OBJCOPY objcopy "$@"; }
-# @FUNCTION: tc-getBUILD_PKG_CONFIG
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the pkg-config tool for building binaries to run on the build machine
-tc-getBUILD_PKG_CONFIG() { tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"; }
-
-# @FUNCTION: tc-export
-# @USAGE: <list of toolchain variables>
-# @DESCRIPTION:
-# Quick way to export a bunch of compiler vars at once.
-tc-export() {
-	local var
-	for var in "$@" ; do
-		[[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'"
-		eval tc-get${var} > /dev/null
-	done
-}
-
-# @FUNCTION: tc-is-cross-compiler
-# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise
-tc-is-cross-compiler() {
-	[[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
-}
-
-# @FUNCTION: tc-is-softfloat
-# @DESCRIPTION:
-# See if this toolchain is a softfloat based one.
-# @CODE
-# The possible return values:
-#  - only:   the target is always softfloat (never had fpu)
-#  - yes:    the target should support softfloat
-#  - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention
-#  - no:     the target doesn't support softfloat
-# @CODE
-# This allows us to react differently where packages accept
-# softfloat flags in the case where support is optional, but
-# rejects softfloat flags where the target always lacks an fpu.
-tc-is-softfloat() {
-	local CTARGET=${CTARGET:-${CHOST}}
-	case ${CTARGET} in
-		bfin*|h8300*)
-			echo "only" ;;
-		*)
-			if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
-				echo "yes"
-			elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
-				echo "softfp"
-			else
-				echo "no"
-			fi
-			;;
-	esac
-}
-
-# @FUNCTION: tc-is-static-only
-# @DESCRIPTION:
-# Return shell true if the target does not support shared libs, shell false
-# otherwise.
-tc-is-static-only() {
-	local host=${CTARGET:-${CHOST}}
-
-	# *MiNT doesn't have shared libraries, only platform so far
-	[[ ${host} == *-mint* ]]
-}
-
-# @FUNCTION: tc-export_build_env
-# @USAGE: [compiler variables]
-# @DESCRIPTION:
-# Export common build related compiler settings.
-tc-export_build_env() {
-	tc-export "$@"
-	# Some build envs will initialize vars like:
-	# : ${BUILD_LDFLAGS:-${LDFLAGS}}
-	# So make sure all variables are non-empty. #526734
-	: ${BUILD_CFLAGS:=-O1 -pipe}
-	: ${BUILD_CXXFLAGS:=-O1 -pipe}
-	: ${BUILD_CPPFLAGS:= }
-	: ${BUILD_LDFLAGS:= }
-	export BUILD_{C,CXX,CPP,LD}FLAGS
-
-	# Some packages use XXX_FOR_BUILD.
-	local v
-	for v in BUILD_{C,CXX,CPP,LD}FLAGS ; do
-		export ${v#BUILD_}_FOR_BUILD="${!v}"
-	done
-}
-
-# @FUNCTION: tc-env_build
-# @USAGE: <command> [command args]
-# @INTERNAL
-# @DESCRIPTION:
-# Setup the compile environment to the build tools and then execute the
-# specified command.  We use tc-getBUILD_XX here so that we work with
-# all of the semi-[non-]standard env vars like $BUILD_CC which often
-# the target build system does not check.
-tc-env_build() {
-	tc-export_build_env
-	CFLAGS=${BUILD_CFLAGS} \
-	CXXFLAGS=${BUILD_CXXFLAGS} \
-	CPPFLAGS=${BUILD_CPPFLAGS} \
-	LDFLAGS=${BUILD_LDFLAGS} \
-	AR=$(tc-getBUILD_AR) \
-	AS=$(tc-getBUILD_AS) \
-	CC=$(tc-getBUILD_CC) \
-	CPP=$(tc-getBUILD_CPP) \
-	CXX=$(tc-getBUILD_CXX) \
-	LD=$(tc-getBUILD_LD) \
-	NM=$(tc-getBUILD_NM) \
-	PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \
-	RANLIB=$(tc-getBUILD_RANLIB) \
-	"$@"
-}
-
-# @FUNCTION: econf_build
-# @USAGE: [econf flags]
-# @DESCRIPTION:
-# Sometimes we need to locally build up some tools to run on CBUILD because
-# the package has helper utils which are compiled+executed when compiling.
-# This won't work when cross-compiling as the CHOST is set to a target which
-# we cannot natively execute.
-#
-# For example, the python package will build up a local python binary using
-# a portable build system (configure+make), but then use that binary to run
-# local python scripts to build up other components of the overall python.
-# We cannot rely on the python binary in $PATH as that often times will be
-# a different version, or not even installed in the first place.  Instead,
-# we compile the code in a different directory to run on CBUILD, and then
-# use that binary when compiling the main package to run on CHOST.
-#
-# For example, with newer EAPIs, you'd do something like:
-# @CODE
-# src_configure() {
-# 	ECONF_SOURCE=${S}
-# 	if tc-is-cross-compiler ; then
-# 		mkdir "${WORKDIR}"/${CBUILD}
-# 		pushd "${WORKDIR}"/${CBUILD} >/dev/null
-# 		econf_build --disable-some-unused-stuff
-# 		popd >/dev/null
-# 	fi
-# 	... normal build paths ...
-# }
-# src_compile() {
-# 	if tc-is-cross-compiler ; then
-# 		pushd "${WORKDIR}"/${CBUILD} >/dev/null
-# 		emake one-or-two-build-tools
-# 		ln/mv build-tools to normal build paths in ${S}/
-# 		popd >/dev/null
-# 	fi
-# 	... normal build paths ...
-# }
-# @CODE
-econf_build() {
-	local CBUILD=${CBUILD:-${CHOST}}
-	tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
-}
-
-# @FUNCTION: tc-ld-is-gold
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# Return true if the current linker is set to gold.
-tc-ld-is-gold() {
-	local out
-
-	# First check the linker directly.
-	out=$($(tc-getLD "$@") --version 2>&1)
-	if [[ ${out} == *"GNU gold"* ]] ; then
-		return 0
-	fi
-
-	# Then see if they're selecting gold via compiler flags.
-	# Note: We're assuming they're using LDFLAGS to hold the
-	# options and not CFLAGS/CXXFLAGS.
-	local base="${T}/test-tc-gold"
-	cat <<-EOF > "${base}.c"
-	int main() { return 0; }
-	EOF
-	out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
-	rm -f "${base}"*
-	if [[ ${out} == *"GNU gold"* ]] ; then
-		return 0
-	fi
-
-	# No gold here!
-	return 1
-}
-
-# @FUNCTION: tc-ld-disable-gold
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# If the gold linker is currently selected, configure the compilation
-# settings so that we use the older bfd linker instead.
-tc-ld-disable-gold() {
-	if ! tc-ld-is-gold "$@" ; then
-		# They aren't using gold, so nothing to do!
-		return
-	fi
-
-	ewarn "Forcing usage of the BFD linker instead of GOLD"
-
-	# Set up LD to point directly to bfd if it's available.
-	# We need to extract the first word in case there are flags appended
-	# to its value (like multilib).  #545218
-	local ld=$(tc-getLD "$@")
-	local bfd_ld="${ld%% *}.bfd"
-	local path_ld=$(which "${bfd_ld}" 2>/dev/null)
-	[[ -e ${path_ld} ]] && export LD=${bfd_ld}
-
-	# Set up LDFLAGS to select gold based on the gcc version.
-	local major=$(gcc-major-version "$@")
-	local minor=$(gcc-minor-version "$@")
-	if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then
-		# <=gcc-4.7 requires some coercion.  Only works if bfd exists.
-		if [[ -e ${path_ld} ]] ; then
-			local d="${T}/bfd-linker"
-			mkdir -p "${d}"
-			ln -sf "${path_ld}" "${d}"/ld
-			export LDFLAGS="${LDFLAGS} -B${d}"
-		else
-			die "unable to locate a BFD linker to bypass gold"
-		fi
-	else
-		# gcc-4.8+ supports -fuse-ld directly.
-		export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
-	fi
-}
-
-# @FUNCTION: tc-has-openmp
-# @USAGE: [toolchain prefix]
-# @DESCRIPTION:
-# See if the toolchain supports OpenMP.
-tc-has-openmp() {
-	local base="${T}/test-tc-openmp"
-	cat <<-EOF > "${base}.c"
-	#include <omp.h>
-	int main() {
-		int nthreads, tid, ret = 0;
-		#pragma omp parallel private(nthreads, tid)
-		{
-		tid = omp_get_thread_num();
-		nthreads = omp_get_num_threads(); ret += tid + nthreads;
-		}
-		return ret;
-	}
-	EOF
-	$(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null
-	local ret=$?
-	rm -f "${base}"*
-	return ${ret}
-}
-
-# @FUNCTION: tc-has-tls
-# @USAGE: [-s|-c|-l] [toolchain prefix]
-# @DESCRIPTION:
-# See if the toolchain supports thread local storage (TLS).  Use -s to test the
-# compiler, -c to also test the assembler, and -l to also test the C library
-# (the default).
-tc-has-tls() {
-	local base="${T}/test-tc-tls"
-	cat <<-EOF > "${base}.c"
-	int foo(int *i) {
-		static __thread int j = 0;
-		return *i ? j : *i;
-	}
-	EOF
-	local flags
-	case $1 in
-		-s) flags="-S";;
-		-c) flags="-c";;
-		-l) ;;
-		-*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";;
-	esac
-	: ${flags:=-fPIC -shared -Wl,-z,defs}
-	[[ $1 == -* ]] && shift
-	$(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null
-	local ret=$?
-	rm -f "${base}"*
-	return ${ret}
-}
-
-
-# Parse information from CBUILD/CHOST/CTARGET rather than
-# use external variables from the profile.
-tc-ninja_magic_to_arch() {
-ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
-
-	local type=$1
-	local host=$2
-	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
-
-	local KV=${KV:-${KV_FULL}}
-	[[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
-	ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info"
-
-	case ${host} in
-		aarch64*)	echo arm64;;
-		alpha*)		echo alpha;;
-		arm*)		echo arm;;
-		avr*)		ninj avr32 avr;;
-		bfin*)		ninj blackfin bfin;;
-		c6x*)		echo c6x;;
-		cris*)		echo cris;;
-		frv*)		echo frv;;
-		hexagon*)	echo hexagon;;
-		hppa*)		ninj parisc hppa;;
-		i?86*)
-			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
-			# trees have been unified into 'x86'.
-			# FreeBSD still uses i386
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then
-				echo i386
-			else
-				echo x86
-			fi
-			;;
-		ia64*)		echo ia64;;
-		m68*)		echo m68k;;
-		metag*)		echo metag;;
-		microblaze*)	echo microblaze;;
-		mips*)		echo mips;;
-		nios2*)		echo nios2;;
-		nios*)		echo nios;;
-		or32*)		echo openrisc;;
-		powerpc*)
-			# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
-			# have been unified into simply 'powerpc', but until 2.6.16,
-			# ppc32 is still using ARCH="ppc" as default
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
-				echo powerpc
-			elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then
-				if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
-					echo powerpc
-				else
-					echo ppc
-				fi
-			elif [[ ${host} == powerpc64* ]] ; then
-				echo ppc64
-			elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
-				ninj ppc64 ppc
-			else
-				echo ppc
-			fi
-			;;
-		riscv*)		echo riscv;;
-		s390*)		echo s390;;
-		score*)		echo score;;
-		sh64*)		ninj sh64 sh;;
-		sh*)		echo sh;;
-		sparc64*)	ninj sparc64 sparc;;
-		sparc*)		[[ ${PROFILE_ARCH} == "sparc64" ]] \
-						&& ninj sparc64 sparc \
-						|| echo sparc
-					;;
-		tile*)		echo tile;;
-		vax*)		echo vax;;
-		x86_64*freebsd*) echo amd64;;
-		x86_64*)
-			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
-			# trees have been unified into 'x86'.
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then
-				echo x86
-			else
-				ninj x86_64 amd64
-			fi
-			;;
-		xtensa*)	echo xtensa;;
-
-		# since our usage of tc-arch is largely concerned with
-		# normalizing inputs for testing ${CTARGET}, let's filter
-		# other cross targets (mingw and such) into the unknown.
-		*)			echo unknown;;
-	esac
-}
-# @FUNCTION: tc-arch-kernel
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the kernel arch according to the compiler target
-tc-arch-kernel() {
-	tc-ninja_magic_to_arch kern "$@"
-}
-# @FUNCTION: tc-arch
-# @USAGE: [toolchain prefix]
-# @RETURN: name of the portage arch according to the compiler target
-tc-arch() {
-	tc-ninja_magic_to_arch portage "$@"
-}
-
-tc-endian() {
-	local host=$1
-	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
-	host=${host%%-*}
-
-	case ${host} in
-		aarch64*be)	echo big;;
-		aarch64)	echo little;;
-		alpha*)		echo big;;
-		arm*b*)		echo big;;
-		arm*)		echo little;;
-		cris*)		echo little;;
-		hppa*)		echo big;;
-		i?86*)		echo little;;
-		ia64*)		echo little;;
-		m68*)		echo big;;
-		mips*l*)	echo little;;
-		mips*)		echo big;;
-		powerpc*le)	echo little;;
-		powerpc*)	echo big;;
-		s390*)		echo big;;
-		sh*b*)		echo big;;
-		sh*)		echo little;;
-		sparc*)		echo big;;
-		x86_64*)	echo little;;
-		*)			echo wtf;;
-	esac
-}
-
-# Internal func.  The first argument is the version info to expand.
-# Query the preprocessor to improve compatibility across different
-# compilers rather than maintaining a --version flag matrix. #335943
-_gcc_fullversion() {
-	local ver="$1"; shift
-	set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`
-	eval echo "$ver"
-}
-
-# @FUNCTION: gcc-fullversion
-# @RETURN: compiler version (major.minor.micro: [3.4.6])
-gcc-fullversion() {
-	_gcc_fullversion '$1.$2.$3' "$@"
-}
-# @FUNCTION: gcc-version
-# @RETURN: compiler version (major.minor: [3.4].6)
-gcc-version() {
-	_gcc_fullversion '$1.$2' "$@"
-}
-# @FUNCTION: gcc-major-version
-# @RETURN: major compiler version (major: [3].4.6)
-gcc-major-version() {
-	_gcc_fullversion '$1' "$@"
-}
-# @FUNCTION: gcc-minor-version
-# @RETURN: minor compiler version (minor: 3.[4].6)
-gcc-minor-version() {
-	_gcc_fullversion '$2' "$@"
-}
-# @FUNCTION: gcc-micro-version
-# @RETURN: micro compiler version (micro: 3.4.[6])
-gcc-micro-version() {
-	_gcc_fullversion '$3' "$@"
-}
-
-# Returns the installation directory - internal toolchain
-# function for use by _gcc-specs-exists (for flag-o-matic).
-_gcc-install-dir() {
-	echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |\
-		awk '$1=="install:" {print $2}')"
-}
-# Returns true if the indicated specs file exists - internal toolchain
-# function for use by flag-o-matic.
-_gcc-specs-exists() {
-	[[ -f $(_gcc-install-dir)/$1 ]]
-}
-
-# Returns requested gcc specs directive unprocessed - for used by
-# gcc-specs-directive()
-# Note; later specs normally overwrite earlier ones; however if a later
-# spec starts with '+' then it appends.
-# gcc -dumpspecs is parsed first, followed by files listed by "gcc -v"
-# as "Reading <file>", in order.  Strictly speaking, if there's a
-# $(gcc_install_dir)/specs, the built-in specs aren't read, however by
-# the same token anything from 'gcc -dumpspecs' is overridden by
-# the contents of $(gcc_install_dir)/specs so the result is the
-# same either way.
-_gcc-specs-directive_raw() {
-	local cc=$(tc-getCC)
-	local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}')
-	${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 \
-'BEGIN	{ pspec=""; spec=""; outside=1 }
-$1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
-	outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
-	spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
-	{ spec=spec $0 }
-END	{ print spec }'
-	return 0
-}
-
-# Return the requested gcc specs directive, with all included
-# specs expanded.
-# Note, it does not check for inclusion loops, which cause it
-# to never finish - but such loops are invalid for gcc and we're
-# assuming gcc is operational.
-gcc-specs-directive() {
-	local directive subdname subdirective
-	directive="$(_gcc-specs-directive_raw $1)"
-	while [[ ${directive} == *%\(*\)* ]]; do
-		subdname=${directive/*%\(}
-		subdname=${subdname/\)*}
-		subdirective="$(_gcc-specs-directive_raw ${subdname})"
-		directive="${directive//\%(${subdname})/${subdirective}}"
-	done
-	echo "${directive}"
-	return 0
-}
-
-# Returns true if gcc sets relro
-gcc-specs-relro() {
-	local directive
-	directive=$(gcc-specs-directive link_command)
-	[[ "${directive/\{!norelro:}" != "${directive}" ]]
-}
-# Returns true if gcc sets now
-gcc-specs-now() {
-	local directive
-	directive=$(gcc-specs-directive link_command)
-	[[ "${directive/\{!nonow:}" != "${directive}" ]]
-}
-# Returns true if gcc builds PIEs
-gcc-specs-pie() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!nopie:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with the stack protector
-gcc-specs-ssp() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
-}
-# Returns true if gcc upgrades fstack-protector to fstack-protector-all
-gcc-specs-ssp-to-all() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with fno-strict-overflow
-gcc-specs-nostrict() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
-}
-# Returns true if gcc builds with fstack-check
-gcc-specs-stack-check() {
-	local directive
-	directive=$(gcc-specs-directive cc1)
-	[[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
-}
-
-
-# @FUNCTION: gen_usr_ldscript
-# @USAGE: [-a] <list of libs to create linker scripts for>
-# @DESCRIPTION:
-# This function generate linker scripts in /usr/lib for dynamic
-# libs in /lib.  This is to fix linking problems when you have
-# the .so in /lib, and the .a in /usr/lib.  What happens is that
-# in some cases when linking dynamic, the .a in /usr/lib is used
-# instead of the .so in /lib due to gcc/libtool tweaking ld's
-# library search path.  This causes many builds to fail.
-# See bug #4411 for more info.
-#
-# Note that you should in general use the unversioned name of
-# the library (libfoo.so), as ldconfig should usually update it
-# correctly to point to the latest version of the library present.
-gen_usr_ldscript() {
-	local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname)
-	[[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
-
-	tc-is-static-only && return
-
-	# Eventually we'd like to get rid of this func completely #417451
-	case ${CTARGET:-${CHOST}} in
-	*-darwin*) ;;
-	*-android*) return 0 ;;
-	*linux*|*-freebsd*|*-openbsd*|*-netbsd*)
-		use prefix && return 0 ;;
-	*) return 0 ;;
-	esac
-
-	# Just make sure it exists
-	dodir /usr/${libdir}
-
-	if [[ $1 == "-a" ]] ; then
-		auto=true
-		shift
-		dodir /${libdir}
-	fi
-
-	# OUTPUT_FORMAT gives hints to the linker as to what binary format
-	# is referenced ... makes multilib saner
-	local flags=( ${CFLAGS} ${LDFLAGS} -Wl,--verbose )
-	if $(tc-getLD) --version | grep -q 'GNU gold' ; then
-		# If they're using gold, manually invoke the old bfd. #487696
-		local d="${T}/bfd-linker"
-		mkdir -p "${d}"
-		ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld
-		flags+=( -B"${d}" )
-	fi
-	output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
-	[[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
-
-	for lib in "$@" ; do
-		local tlib
-		if ${auto} ; then
-			lib="lib${lib}${suffix}"
-		else
-			# Ensure /lib/${lib} exists to avoid dangling scripts/symlinks.
-			# This especially is for AIX where $(get_libname) can return ".a",
-			# so /lib/${lib} might be moved to /usr/lib/${lib} (by accident).
-			[[ -r ${ED}/${libdir}/${lib} ]] || continue
-			#TODO: better die here?
-		fi
-
-		case ${CTARGET:-${CHOST}} in
-		*-darwin*)
-			if ${auto} ; then
-				tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
-			else
-				tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib})
-			fi
-			[[ -z ${tlib} ]] && die "unable to read install_name from ${lib}"
-			tlib=${tlib##*/}
-
-			if ${auto} ; then
-				mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die
-				# some install_names are funky: they encode a version
-				if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]] ; then
-					mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die
-				fi
-				rm -f "${ED}"/${libdir}/${lib}
-			fi
-
-			# Mach-O files have an id, which is like a soname, it tells how
-			# another object linking against this lib should reference it.
-			# Since we moved the lib from usr/lib into lib this reference is
-			# wrong.  Hence, we update it here.  We don't configure with
-			# libdir=/lib because that messes up libtool files.
-			# Make sure we don't lose the specific version, so just modify the
-			# existing install_name
-			if [[ ! -w "${ED}/${libdir}/${tlib}" ]] ; then
-				chmod u+w "${ED}${libdir}/${tlib}" # needed to write to it
-				local nowrite=yes
-			fi
-			install_name_tool \
-				-id "${EPREFIX}"/${libdir}/${tlib} \
-				"${ED}"/${libdir}/${tlib} || die "install_name_tool failed"
-			[[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}"
-			# Now as we don't use GNU binutils and our linker doesn't
-			# understand linker scripts, just create a symlink.
-			pushd "${ED}/usr/${libdir}" > /dev/null
-			ln -snf "../../${libdir}/${tlib}" "${lib}"
-			popd > /dev/null
-			;;
-		*)
-			if ${auto} ; then
-				tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
-				[[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
-				mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
-				# some SONAMEs are funky: they encode a version before the .so
-				if [[ ${tlib} != ${lib}* ]] ; then
-					mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
-				fi
-				rm -f "${ED}"/${libdir}/${lib}
-			else
-				tlib=${lib}
-			fi
-			cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
-			/* GNU ld script
-			   Since Gentoo has critical dynamic libraries in /lib, and the static versions
-			   in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
-			   run into linking problems.  This "fake" dynamic lib is a linker script that
-			   redirects the linker to the real lib.  And yes, this works in the cross-
-			   compiling scenario as the sysroot-ed linker will prepend the real path.
-
-			   See bug https://bugs.gentoo.org/4411 for more info.
-			 */
-			${output_format}
-			GROUP ( ${EPREFIX}/${libdir}/${tlib} )
-			END_LDSCRIPT
-			;;
-		esac
-		fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
-	done
-}
-
-fi


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-06-24  3:07 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-06-24  3:07 UTC (permalink / raw
  To: gentoo-commits

commit:     c147c553072030cd06f55f6bde6360199bb1c9f9
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 24 03:07:13 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Fri Jun 24 03:07:13 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=c147c553

toolchain.eclass: prefixify cross compile parts.

 eclass/toolchain.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 44ec160..b6df2da 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1833,8 +1833,8 @@ gcc_movelibs() {
 	# that you want to link against when building tools rather than building
 	# code to run on the target.
 	if tc_version_is_at_least 5 && is_crosscompile ; then
-		dodir "${HOSTLIBPATH}"
-		mv "${D}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
+		dodir "${HOSTLIBPATH#${EPREFIX}}"
+		mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
 	fi
 
 	# For all the libs that are built for CTARGET, move them into the


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
  2016-07-21  2:23 [gentoo-commits] dev/heroxbd:master " Benda XU
@ 2016-07-21  2:19 ` Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-07-21  2:19 UTC (permalink / raw
  To: gentoo-commits

commit:     f940e6ec473b0e918c6bde8801ca17d88f9834b0
Author:     Benda Xu <heroxbd <AT> gmail <DOT> com>
AuthorDate: Sun Jul 17 07:47:55 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sun Jul 17 07:47:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=f940e6ec

prefix.eclass: split the heuristics into hprefixify.

 eclass/prefix.eclass | 79 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 18 deletions(-)

diff --git a/eclass/prefix.eclass b/eclass/prefix.eclass
index 40e5097..411b365 100644
--- a/eclass/prefix.eclass
+++ b/eclass/prefix.eclass
@@ -27,25 +27,17 @@ fi
 # @FUNCTION: eprefixify
 # @USAGE: <list of to be eprefixified files>
 # @DESCRIPTION:
-# replaces @GENTOO_PORTAGE_EPREFIX@ with ${EPREFIX} for the given files,
-# tries a set of heuristics if @GENTOO_PORTAGE_EPREFIX@ is not found,
-# dies if no arguments are given, a file does not exist, or changing a
+# Replaces @GENTOO_PORTAGE_EPREFIX@ with ${EPREFIX} for the given files,
+# Dies if no arguments are given, a file does not exist, or changing a
 # file failed.
 eprefixify() {
-	[[ $# -lt 1 ]] && die "at least one argument required"
-
+	[[ $# -lt 1 ]] && die "at least one file operand is required"
 	einfo "Adjusting to prefix ${EPREFIX:-/}"
 	local x
 	for x in "$@" ; do
 		if [[ -e ${x} ]] ; then
 			ebegin "  ${x##*/}"
-			if grep -q @GENTOO_PORTAGE_EPREFIX@ "${x}" ; then
-				sed -i -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" "${x}"
-			else
-				sed -r \
-					-e "s,([^[:alnum:]}])/(usr|etc|bin|sbin|var|opt)/,\1${EPREFIX}/\2/,g" \
-					-i "${x}"
-			fi
+			sed -i -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" "${x}"
 			eend $? || die "failed to eprefixify ${x}"
 		else
 			die "${x} does not exist"
@@ -55,28 +47,78 @@ eprefixify() {
 	return 0
 }
 
+# @FUNCTION: hprefixify
+# @USAGE: [ -w <line matching regex> ] [-e <extended regex>] <list of files>
+# @DESCRIPTION:
+#
+# Tries a set of heuristics to prefixify the given files, Dies if no
+# arguments are given, a file does not exist, or changing a file failed.
+#
+# Additional extended regular expression can be passed by -e or
+# environment variable PREFIX_EXTRA_REGEX.  The default heuristics can
+# be constrained to lines matching regular expressions passed by -w or
+# environment variable PREFIX_LINE_MATCH.
+hprefixify() {
+	local PREFIX_EXTRA_REGEX PREFIX_LINE_MATCH xl=() x
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			-e)
+				PREFIX_EXTRA_REGEX="$2"
+				shift
+				;;
+			-w)
+				PREFIX_LINE_MATCHING="$2"
+				shift
+				;;
+			*)
+				xl+=( "$1" )
+				;;
+		esac
+		shift
+	done
+
+	[[ ${#xl[@]} -lt 1 ]] && die "at least one file operand is required"
+	einfo "Adjusting to prefix ${EPREFIX:-/}"
+	for x in "${xl[@]}" ; do
+		if [[ -e ${x} ]] ; then
+			ebegin "  ${x##*/}"
+			sed -r \
+				-e "${PREFIX_LINE_MATCH}s,([^[:alnum:]}\)\.])/(usr|lib(|[onx]?32|n?64)|etc|bin|sbin|var|opt),\1${EPREFIX}/\2,g" \
+				-e "${PREFIX_EXTRA_REGEX}" \
+				-i "${x}"
+			eend $? || die "failed to prefixify ${x}"
+		else
+			die "${x} does not exist"
+		fi
+	done
+}
+
 # @FUNCTION: __temp_prefixify
-# @USAGE: on a single file
+# @USAGE: a single file. Internal use only.
 # @DESCRIPTION:
 # copies the files to ${T}, calls eprefixify, echos the new file.
 __temp_prefixify() {
 	if [[ -e $1 ]] ; then
 		local f=${1##*/}
 		cp "$1" "${T}" || die "failed to copy file"
-		eprefixify "${T}"/${f} > /dev/null
-		echo "${T}"/${f}
+		local x="${T}"/${f}
+		if grep -qs @GENTOO_PORTAGE_EPREFIX@ "${x}" ; then
+			eprefixify "${T}"/${f} > /dev/null
+		else
+			hprefixify "${T}"/${f} > /dev/null
+		fi
+		echo "${x}"
 	else
 		die "$1 does not exist"
 	fi
 }
 
 # @FUNCTION: fprefixify
-# @USAGE: fprefixfy function files
+# @USAGE: <function> <files>
 # @DESCRIPTION:
 # prefixify a function call.
 # copies the files to ${T}, calls eprefixify, and calls the function.
-#
-# For example:
+# @EXAMPLE:
 # fprefixify doexe ${FILESDIR}/fix_libtool_files.sh
 # fprefixify epatch ${FILESDIR}/${PN}-4.0.2-path.patch
 fprefixify() {
@@ -100,6 +142,7 @@ fprefixify() {
 				${func} "${f}"
 				eend $? || die "failed to execute ${func}"
 			done
+			;;
 	esac
 
 	return 0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-07-21  2:19 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-07-21  2:19 UTC (permalink / raw
  To: gentoo-commits

commit:     f237ba70585b97ba8e45882bb2f5926323b3e658
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 02:16:13 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 02:16:13 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=f237ba70

toolchain.eclass: a couple of ED fixes.

 eclass/toolchain.eclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index b6df2da..5a4c92d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1711,7 +1711,7 @@ toolchain_src_install() {
 	# Now do the fun stripping stuff
 	env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
 	is_crosscompile && \
-		env RESTRICT="" CHOST=${CHOST} prepstrip "${D}/${HOSTLIBPATH}"
+		env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${HOSTLIBPATH}"
 	env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
 	# gcc used to install helper binaries in lib/ but then moved to libexec/
 	[[ -d ${D}${PREFIX}/libexec/gcc ]] && \
@@ -1719,7 +1719,7 @@ toolchain_src_install() {
 
 	cd "${S}"
 	if is_crosscompile; then
-		rm -rf "${D}"/usr/share/{man,info}
+		rm -rf "${ED}"usr/share/{man,info}
 		rm -rf "${D}"${DATAPATH}/{man,info}
 	else
 		if tc_version_is_at_least 3.0 ; then
@@ -1729,10 +1729,10 @@ toolchain_src_install() {
 			fi
 		fi
 		has noinfo ${FEATURES} \
-			&& rm -r "${D}/${DATAPATH}"/info \
+			&& rm -r "${D}${DATAPATH}"/info \
 			|| prepinfo "${DATAPATH#${EPREFIX}}"
 		has noman ${FEATURES} \
-			&& rm -r "${D}/${DATAPATH}"/man \
+			&& rm -r "${D}${DATAPATH}"/man \
 			|| prepman "${DATAPATH#${EPREFIX}}"
 	fi
 	# prune empty dirs left behind
@@ -1834,7 +1834,7 @@ gcc_movelibs() {
 	# code to run on the target.
 	if tc_version_is_at_least 5 && is_crosscompile ; then
 		dodir "${HOSTLIBPATH#${EPREFIX}}"
-		mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
+		mv "${ED}"usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
 	fi
 
 	# For all the libs that are built for CTARGET, move them into the


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-07-21 12:38 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-07-21 12:38 UTC (permalink / raw
  To: gentoo-commits

commit:     f9f6d9ab8a0c41373d665bed3d016653948f5da9
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 12:38:01 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 12:38:01 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=f9f6d9ab

toolchain.eclass: migrate from fprefixify to prefixify_ro.

 eclass/toolchain.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 5a4c92d..0d0fac9 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1749,9 +1749,9 @@ toolchain_src_install() {
 	# between binary and source package borks things ....
 	if ! is_crosscompile ; then
 		insinto "${DATAPATH#${EPREFIX}}"
-		fprefixify newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
+		newins "$(prefixify_ro "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
 		exeinto "${DATAPATH#${EPREFIX}}"
-		fprefixify doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
+		doexe "$(prefixify_ro "${GCC_FILESDIR}"/fix_libtool_files.sh)" || die
 		doexe "${GCC_FILESDIR}"/c{89,99} || die
 	fi
 


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2016-10-24 12:30 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2016-10-24 12:30 UTC (permalink / raw
  To: gentoo-commits

commit:     c9eefea43ef844ba33fff731b2ba6c48e9133fcd
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 12:29:49 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 12:29:49 2016 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=c9eefea4

toolchain.eclass: prefixify the config shell.

 eclass/toolchain.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 0d0fac9..27ff44a 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1251,7 +1251,7 @@ toolchain_src_configure() {
 	echo "${S}"/configure "${confgcc[@]}"
 	# Older gcc versions did not detect bash and re-exec itself, so force the
 	# use of bash.  Newer ones will auto-detect, but this is not harmeful.
-	CONFIG_SHELL="/bin/bash" \
+	CONFIG_SHELL="${EPREFIX}/bin/bash" \
 	bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
 
 	# return to whatever directory we were in before


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2017-01-07 14:29 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2017-01-07 14:29 UTC (permalink / raw
  To: gentoo-commits

commit:     7003d2b7a7b5f93d3eefc996c2863d5decbf2b39
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  7 14:27:50 2017 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sat Jan  7 14:27:50 2017 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=7003d2b7

track.

toolchain.eclass refresh before commit.

 eclass/R-packages.eclass   |   51 +
 eclass/java-utils-2.eclass | 2888 ++++++++++++++++++++++++++++++++++++++++++++
 eclass/linux-info.eclass   |  925 ++++++++++++++
 eclass/toolchain.eclass    |  106 +-
 4 files changed, 3930 insertions(+), 40 deletions(-)

diff --git a/eclass/R-packages.eclass b/eclass/R-packages.eclass
new file mode 100644
index 0000000..cea7eba
--- /dev/null
+++ b/eclass/R-packages.eclass
@@ -0,0 +1,51 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+inherit eutils
+
+EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst
+
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="byte-compile"
+
+DEPEND="dev-lang/R"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}"
+
+R-packages_src_unpack() {
+	unpack ${A}
+	mv ${PN//_/.} ${P}
+}
+
+R-packages_src_prepare() {
+	cd ${P}
+	epatch_user
+}
+
+R-packages_src_compile() {
+	einfo "R CMD INSTALL ${S}/${P} -l . $(use byte-compile && echo --byte-compile)"
+	MAKEFLAGS="CFLAGS=${CFLAGS// /\\ } CXXFLAGS=${CXXFLAGS// /\\ } FFLAGS=${FFLAGS// /\\ } FCFLAGS=${FCFLAGS// /\\ } LDFLAGS=${LDFLAGS// /\\ }" \
+		R CMD INSTALL ${S}/${P} -l . $(use byte-compile && echo --byte-compile)
+}
+
+R-packages_src_install() {
+	insinto /usr/$(get_libdir)/R/site-library
+	doins -r ${PN//_/.}
+}
+
+R-packages_pkg_postinst() {
+	if [[ "${_UNRESOLVABLE_PACKAGES:-}" ]]; then
+		# _UNRESOLVABLE_PACKAGES is only set if it has more than zero items
+		local _max=${#_UNRESOLVABLE_PACKAGES[*]} i=
+
+		einfo "Dependency(-ies):"
+		for (( i=0; i<${_max}; i++ )); do
+			einfo "- ${_UNRESOLVABLE_PACKAGES[$i]}"
+		done
+		einfo 'are (is) suggested by upstream but could not be found.'
+		einfo 'Please install it manually from the R interpreter if you need it.'
+	fi
+}

diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
new file mode 100644
index 0000000..b4246b3
--- /dev/null
+++ b/eclass/java-utils-2.eclass
@@ -0,0 +1,2888 @@
+# Copyright 2004-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: java-utils-2.eclass
+# @MAINTAINER:
+# java@gentoo.org
+# @AUTHOR:
+# Thomas Matthijs <axxo@gentoo.org>, Karl Trygve Kalleberg <karltk@gentoo.org>
+# @BLURB: Base eclass for Java packages
+# @DESCRIPTION:
+# This eclass provides functionality which is used by java-pkg-2.eclass,
+# java-pkg-opt-2.eclass and java-ant-2 eclass, as well as from ebuilds.
+#
+# This eclass should not be inherited this directly from an ebuild. Instead,
+# you should inherit java-pkg-2 for Java packages or java-pkg-opt-2 for packages
+# that have optional Java support. In addition you can inherit java-ant-2 for
+# Ant-based packages.
+inherit eutils versionator multilib
+
+IUSE="elibc_FreeBSD"
+
+# Make sure we use java-config-2
+export WANT_JAVA_CONFIG="2"
+
+# @VARIABLE: JAVA_PKG_PORTAGE_DEP
+# @INTERNAL
+# @DESCRIPTION:
+# The version of portage we need to function properly. Previously it was
+# portage with phase hooks support but now we use a version with proper env
+# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
+has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
+
+# @VARIABLE: JAVA_PKG_E_DEPEND
+# @INTERNAL
+# @DESCRIPTION:
+# This is a convience variable to be used from the other java eclasses. This is
+# the version of java-config we want to use. Usually the latest stable version
+# so that ebuilds can use new features without depending on specific versions.
+JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3 ${JAVA_PKG_PORTAGE_DEP}"
+has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
+
+# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The version of bootclasspath the package needs to work. Translates to a proper
+# dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath
+if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
+	if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
+		JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
+	else
+		eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
+		# since die in global scope doesn't work, this will make repoman fail
+		JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
+	fi
+fi
+
+# @ECLASS-VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE
+# @DESCRIPTION:
+# Allow this eclass to change the active VM?
+# If your system VM isn't sufficient for the package, the build will fail
+# instead of trying to switch to another VM.
+#
+# Overriding the default can be useful for testing specific VMs locally, but
+# should not be used in the final ebuild.
+JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
+
+# @ECLASS-VARIABLE: JAVA_PKG_FORCE_VM
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Explicitly set a particular VM to use. If its not valid, it'll fall back to
+# whatever /etc/java-config-2/build/jdk.conf would elect to use.
+#
+# Should only be used for testing and debugging.
+#
+# Example: use sun-jdk-1.5 to emerge foo:
+# @CODE
+#	JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
+# @CODE
+
+# @ECLASS-VARIABLE: JAVA_PKG_WANT_BUILD_VM
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A list of VM handles to choose a build VM from. If the list contains the
+# currently active VM use that one, otherwise step through the list till a
+# usable/installed VM is found.
+#
+# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
+# Users of this variable must make sure at least one of the listed handles is
+# covered by DEPEND.
+# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
+
+# @ECLASS-VARIABLE: JAVA_PKG_WANT_SOURCE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Specify a non-standard Java source version for compilation (via javac -source
+# parameter or Ant equivalent via build.xml rewriting done by java-ant-2 eclass).
+# Normally this is determined from the jdk version specified in DEPEND.
+# See java-pkg_get-source function below.
+#
+# Should generally only be used for testing and debugging.
+#
+# Use 1.4 source to emerge baz
+# @CODE
+#	JAVA_PKG_WANT_SOURCE=1.4 emerge baz
+# @CODE
+
+# @ECLASS-VARIABLE: JAVA_PKG_WANT_TARGET
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Same as JAVA_PKG_WANT_SOURCE (see above) but for javac -target parameter,
+# which affects the version of generated bytecode.
+# Normally this is determined from the jre/jdk version specified in RDEPEND.
+# See java-pkg_get-target function below.
+#
+# Should generallyonly be used for testing and debugging.
+#
+# emerge bar to be compatible with 1.3
+# @CODE
+#	JAVA_PKG_WANT_TARGET=1.3 emerge bar
+# @CODE
+
+# @ECLASS-VARIABLE: JAVA_PKG_DEBUG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A variable to be set with "yes" or "y", or ANY string of length non equal to
+# zero. When set, verbosity across java eclasses is increased and extra
+# logging is displayed.
+# @CODE
+#	JAVA_PKG_DEBUG="yes"
+# @CODE
+
+# @ECLASS-VARIABLE: JAVA_RM_FILES
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# An array containing a list of files to remove. If defined, this array will be
+# automatically handed over to java-pkg_rm_files for processing during the
+# src_prepare phase.
+#
+# @CODE
+#	JAVA_RM_FILES=(
+#		path/to/File1.java
+#		DELETEME.txt
+#	)
+# @CODE
+
+# @VARIABLE: JAVA_PKG_COMPILER_DIR
+# @INTERNAL
+# @DESCRIPTION:
+# Directory where compiler settings are saved, without trailing slash.
+# You probably shouldn't touch this variable except local testing.
+JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
+
+# @VARIABLE: JAVA_PKG_COMPILERS_CONF
+# @INTERNAL
+# @DESCRIPTION:
+# Path to file containing information about which compiler to use.
+# Can be overloaded, but it should be overloaded only for local testing.
+JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"}
+
+# @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER
+# @INTERNAL
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Explicitly set a list of compilers to choose from. This is normally read from
+# JAVA_PKG_COMPILERS_CONF.
+#
+# Useful for local testing.
+#
+# Use jikes and javac, in that order
+# @CODE
+#	JAVA_PKG_FORCE_COMPILER="jikes javac"
+# @CODE
+
+# @ECLASS-VARIABLE: JAVA_PKG_FORCE_ANT_TASKS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# An $IFS separated list of ant tasks. Can be set in environment before calling
+# emerge/ebuild to override variables set in ebuild, mainly for testing before
+# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
+# eant() call, not the dependencies specified in WANT_ANT_TASKS.
+#
+# @CODE
+# JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
+# 	ebuild foo.ebuild compile
+# @CODE
+
+# TODO document me
+JAVA_PKG_QA_VIOLATIONS=0
+
+# @FUNCTION: java-pkg_doexamples
+# @USAGE: [--subdir <subdir>] <file1/dir1> [<file2> ...]
+# @DESCRIPTION:
+# Installs given arguments to /usr/share/doc/${PF}/examples
+# If you give it only one parameter and it is a directory it will install
+# everything in that directory to the examples directory.
+#
+# @CODE
+# Parameters:
+# --subdir - If the examples need a certain directory structure
+# $* - list of files to install
+#
+# Examples:
+#	java-pkg_doexamples demo
+#	java-pkg_doexamples demo/* examples/*
+# @CODE
+java-pkg_doexamples() {
+	debug-print-function ${FUNCNAME} $*
+
+	[[ ${#} -lt 1 ]] && die "At least one argument needed"
+
+	java-pkg_check-phase install
+	java-pkg_init_paths_
+
+	local dest=/usr/share/doc/${PF}/examples
+	if [[ ${1} == --subdir ]]; then
+		local dest=${dest}/${2}
+		dodir ${dest}
+		shift 2
+	fi
+
+	if [[ ${#} = 1 && -d ${1} ]]; then
+		( # dont want to pollute calling env
+			insinto "${dest}"
+			doins -r ${1}/*
+		) || die "Installing examples failed"
+	else
+		( # dont want to pollute calling env
+			insinto "${dest}"
+			doins -r "$@"
+		) || die "Installing examples failed"
+	fi
+
+	# Let's make a symlink to the directory we have everything else under
+	dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
+}
+
+# @FUNCTION: java-pkg_addres
+# @USAGE: <jar> <dir> [<find arguments> ...]
+# @DESCRIPTION:
+# Adds resource files to an existing jar.
+# It is important that the directory given is actually the root of the
+# corresponding resource tree. The target directory as well as
+# sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are
+# automatically excluded. Symlinks are always followed. Additional
+# arguments are passed through to find.
+#
+# @CODE
+#	java-pkg_addres ${PN}.jar resources ! -name "*.html"
+# @CODE
+#
+# @param $1 - jar file
+# @param $2 - resource tree directory
+# @param $* - arguments to pass to find
+java-pkg_addres() {
+	debug-print-function ${FUNCNAME} $*
+
+	[[ ${#} -lt 2 ]] && die "at least two arguments needed"
+
+	local jar=$(realpath "$1" || die "realpath $1 failed")
+	local dir="$2"
+	shift 2
+
+	pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
+	find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -r0 jar uf "${jar}" || die "jar failed"
+	popd > /dev/null || die "popd failed"
+}
+
+# @FUNCTION: java-pkg_rm_files
+# @USAGE: java-pkg_rm_files File1.java File2.java ...
+# @DESCRIPTION:
+# Remove unneeded files in ${S}.
+#
+# Every now and then, you'll run into situations whereby a file needs removing,
+# be it a unit test or a regular java class.
+#
+# You can use this function by either:
+# - calling it yourself in java_prepare() and feeding java-pkg_rm_files with
+# the list of files you wish to remove.
+# - defining an array in the ebuild named JAVA_RM_FILES with the list of files
+# you wish to remove.
+#
+# Both way work and it is left to the developer's preferences. If the
+# JAVA_RM_FILES array is defined, it will be automatically handed over to
+# java-pkg_rm_files during the src_prepare phase.
+#
+# See java-utils-2_src_prepare.
+#
+# @CODE
+#	java-pkg_rm_files File1.java File2.java
+# @CODE
+#
+# @param $* - list of files to remove.
+java-pkg_rm_files() {
+	debug-print-function ${FUNCNAME} $*
+	local IFS="\n"
+	for filename in "$@"; do
+		[[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting."
+		einfo "Removing unneeded file ${filename}"
+		rm -f "${S}/${filename}" || die "cannot remove ${filename}"
+		eend $?
+	done
+}
+
+# @FUNCTION: java-pkg_dojar
+# @USAGE: <jar1> [<jar2> ...]
+# @DESCRIPTION:
+# Installs any number of jars.
+# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
+# You can use java-pkg_jarinto to change this path.
+# You should never install a jar with a package version in the filename.
+# Instead, use java-pkg_newjar defined below.
+#
+# @CODE
+#	java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
+# @CODE
+#
+# @param $* - list of jars to install
+java-pkg_dojar() {
+	debug-print-function ${FUNCNAME} $*
+
+	[[ ${#} -lt 1 ]] && die "At least one argument needed"
+
+	java-pkg_check-phase install
+	java-pkg_init_paths_
+
+	# Create JARDEST if it doesn't exist
+	dodir ${JAVA_PKG_JARDEST}
+
+	local jar
+	# for each jar
+	for jar in "${@}"; do
+		local jar_basename=$(basename "${jar}")
+
+		java-pkg_check-versioned-jar ${jar_basename}
+
+		# check if it exists
+		if [[ -e "${jar}" ]] ; then
+			# Don't overwrite if jar has already been installed with the same
+			# name
+			local dest="${ED}${JAVA_PKG_JARDEST}/${jar_basename}"
+			if [[ -e "${dest}" ]]; then
+				ewarn "Overwriting ${dest}"
+			fi
+
+			# install it into JARDEST if it's a non-symlink
+			if [[ ! -L "${jar}" ]] ; then
+				#but first check class version when in strict mode.
+				is-java-strict && java-pkg_verify-classes "${jar}"
+
+				(
+					insinto "${JAVA_PKG_JARDEST}"
+					doins "${jar}"
+				) || die "failed to install ${jar}"
+				java-pkg_append_ JAVA_PKG_CLASSPATH "${EPREFIX}/${JAVA_PKG_JARDEST}/${jar_basename}"
+				debug-print "installed ${jar} to ${ED}${JAVA_PKG_JARDEST}"
+			# make a symlink to the original jar if it's symlink
+			else
+				# TODO use dosym, once we find something that could use it
+				# -nichoj
+				ln -s "$(readlink "${jar}")" "${ED}${JAVA_PKG_JARDEST}/${jar_basename}"
+				debug-print "${jar} is a symlink, linking accordingly"
+			fi
+		else
+			die "${jar} does not exist"
+		fi
+	done
+
+	# Extra logging if enabled.
+	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
+		einfo "Verbose logging for \"${FUNCNAME}\" function"
+		einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}"
+		einfo "Jar file(s) created: ${@}"
+		einfo "Complete command:"
+		einfo "${FUNCNAME} ${@}"
+	fi
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_regjar
+# @USAGE: </path/to/installed/jar>
+# @DESCRIPTION:
+# Records an already installed (in ${D}) jar in the package.env
+# This would mostly be used if the package has make or a custom script to
+# install things.
+#
+# WARNING:
+# if you want to use shell expansion, you have to use ${D}/... as the for in
+# this function will not be able to expand the path, here's an example:
+#
+# @CODE
+#   java-pkg_regjar ${D}/opt/my-java/lib/*.jar
+# @CODE
+#
+
+# TODO should we be making sure the jar is present on ${D} or wherever?
+java-pkg_regjar() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} -lt 1 ]] && die "at least one argument needed"
+
+	java-pkg_init_paths_
+
+	local jar jar_dir jar_file
+	for jar in "${@}"; do
+		# TODO use java-pkg_check-versioned-jar
+		if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
+			[[ -d "${jar}" || -d "${D}${jar}" ]] \
+				&& die "Called ${FUNCNAME} on a	directory $*"
+
+			#check that class version correct when in strict mode
+			is-java-strict && java-pkg_verify-classes "${jar}"
+
+			# nelchael: we should strip ${D} in this case too, here's why:
+			# imagine such call:
+			#    java-pkg_regjar ${D}/opt/java/*.jar
+			# such call will fall into this case (-e ${jar}) and will
+			# record paths with ${D} in package.env
+			java-pkg_append_ JAVA_PKG_CLASSPATH	"${jar#${D}}"
+		else
+			if [[ ${jar} = *\** ]]; then
+				eerror "The argument ${jar} to ${FUNCNAME}"
+				eerror "has * in it. If you want it to glob in"
+				eerror '${D} add ${D} to the argument.'
+			fi
+			debug-print "${jar} or ${D}${jar} not found"
+			die "${jar} does not exist"
+		fi
+	done
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_newjar
+# @USAGE: <path/to/oldname.jar> [<newname.jar>]
+# @DESCRIPTION:
+# Installs a jar with a new name (defaults to $PN.jar)
+#
+# For example, installs a versioned jar without the version
+java-pkg_newjar() {
+	debug-print-function ${FUNCNAME} $*
+
+	local original_jar="${1}"
+	local new_jar="${2:-${PN}.jar}"
+	local new_jar_dest="${T}/${new_jar}"
+
+	[[ -z ${original_jar} ]] && die "Must specify a jar to install"
+	[[ ! -f ${original_jar} ]] \
+		&& die "${original_jar} does not exist or is not a file!"
+
+	rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
+	cp "${original_jar}" "${new_jar_dest}" \
+		|| die "Failed to copy ${original_jar} to ${new_jar_dest}"
+	java-pkg_dojar "${new_jar_dest}"
+}
+
+# @FUNCTION: java-pkg_addcp
+# @USAGE: <classpath>
+# @DESCRIPTION:
+# Add something to the package's classpath. For jars, you should use dojar,
+# newjar, or regjar. This is typically used to add directories to the classpath.
+# The parameters of this function are appended to JAVA_PKG_CLASSPATH
+java-pkg_addcp() {
+	java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_doso
+# @USAGE: <path/to/file1.so> [...]
+# @DESCRIPTION:
+# Installs any number of JNI libraries
+# They will be installed into /usr/lib by default, but java-pkg_sointo
+# can be used change this path
+#
+# @CODE
+# Example:
+#	java-pkg_doso *.so
+# @CODE
+java-pkg_doso() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
+
+	java-pkg_init_paths_
+
+	local lib
+	# for each lib
+	for lib in "$@" ; do
+		# if the lib exists...
+		if [[ -e "${lib}" ]] ; then
+			# install if it isn't a symlink
+			if [[ ! -L "${lib}" ]] ; then
+				(
+					insinto "${JAVA_PKG_LIBDEST}"
+					insopts -m0755
+					doins "${lib}"
+				) || die "failed to install ${lib}"
+				java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
+				debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
+			# otherwise make a symlink to the symlink's origin
+			else
+				dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
+				debug-print "${lib} is a symlink, linking accordantly"
+			fi
+		# otherwise die
+		else
+			die "${lib} does not exist"
+		fi
+	done
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_regso
+# @USAGE: <file1.so> [...]
+# @DESCRIPTION:
+# Registers an already installed JNI library in package.env.
+#
+# @CODE
+# Parameters:
+# $@ - JNI libraries to register
+#
+# Example:
+#	java-pkg_regso *.so /path/*.so
+# @CODE
+java-pkg_regso() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
+
+	java-pkg_init_paths_
+
+	local lib target_dir
+	for lib in "$@" ; do
+		# Check the absolute path of the lib
+		if [[ -e "${lib}" ]] ; then
+			target_dir="$(java-pkg_expand_dir_ ${lib})"
+			java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}"
+		# Check the path of the lib relative to ${D}
+		elif [[ -e "${D}${lib}" ]]; then
+			target_dir="$(java-pkg_expand_dir_ ${D}${lib})"
+			java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}"
+		else
+			die "${lib} does not exist"
+		fi
+	done
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_jarinto
+# @USAGE: </path/to/install/jars/into>
+# @DESCRIPTION:
+# Changes the path jars are installed into via subsequent java-pkg_dojar calls.
+java-pkg_jarinto() {
+	debug-print-function ${FUNCNAME} $*
+
+	JAVA_PKG_JARDEST="${1}"
+}
+
+# @FUNCTION: java-pkg_sointo
+# @USAGE: </path/to/install/sofiles/into>
+# @DESCRIPTION:
+# Changes the path that JNI libraries are installed into via subsequent
+# java-pkg_doso calls.
+java-pkg_sointo() {
+	debug-print-function ${FUNCNAME} $*
+
+	JAVA_PKG_LIBDEST="${1}"
+}
+
+# @FUNCTION: java-pkg_dohtml
+# @USAGE: <path/to/javadoc/documentation> [...]
+# @DESCRIPTION:
+# Install Javadoc HTML documentation. Usage of java-pkg_dojavadoc is preferred.
+#
+# @CODE
+#	java-pkg_dohtml dist/docs/
+# @CODE
+java-pkg_dohtml() {
+	debug-print-function ${FUNCNAME} $*
+
+	[[ ${#} -lt 1 ]] &&  die "At least one argument required for ${FUNCNAME}"
+
+	# from /usr/lib/portage/bin/dohtml -h
+	#  -f   Set list of allowed extensionless file names.
+	dohtml -f package-list "$@"
+
+	# this probably shouldn't be here but it provides
+	# a reasonable way to catch # docs for all of the
+	# old ebuilds.
+	java-pkg_recordjavadoc
+}
+
+# @FUNCTION: java-pkg_dojavadoc
+# @USAGE: [--symlink destination] <path/to/javadocs/root>
+# @DESCRIPTION:
+# Installs javadoc documentation. This should be controlled by the doc use flag.
+#
+# @CODE
+# Parameters:
+# $1: optional --symlink creates to symlink like this for html
+#            documentation bundles.
+# $2: - The javadoc root directory.
+#
+# Examples:
+#	java-pkg_dojavadoc docs/api
+#	java-pkg_dojavadoc --symlink apidocs docs/api
+# @CODE
+java-pkg_dojavadoc() {
+	debug-print-function ${FUNCNAME} $*
+
+	# For html documentation bundles that link to Javadoc
+	local symlink
+	if [[ ${1} = --symlink ]]; then
+		symlink=${2}
+		shift 2
+	fi
+
+	local dir="$1"
+	local dest=/usr/share/doc/${PF}/html
+
+	# QA checks
+
+	java-pkg_check-phase install
+	java-pkg_init_paths_
+
+	[[ -z "${dir}" ]] && die "Must specify a directory!"
+	[[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
+	if [[ ! -e "${dir}/index.html" ]]; then
+		local msg="No index.html in javadoc directory"
+		ewarn "${msg}"
+		is-java-strict && die "${msg}"
+	fi
+
+	if [[ -e ${D}/${dest}/api ]]; then
+		eerror "${dest} already exists. Will not overwrite."
+		die "${dest}"
+	fi
+
+	# Renaming to match our directory layout
+
+	local dir_to_install="${dir}"
+	if [[ "$(basename "${dir}")" != "api" ]]; then
+		dir_to_install="${T}/api"
+		# TODO use doins
+		cp -r "${dir}" "${dir_to_install}" || die "cp failed"
+	fi
+
+	# Actual installation
+	java-pkg_dohtml -r "${dir_to_install}"
+
+	# Let's make a symlink to the directory we have everything else under
+	dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
+
+	if [[ ${symlink} ]]; then
+		debug-print "symlinking ${dest}/{api,${symlink}}"
+		dosym ${dest}/{api,${symlink}} || die
+	fi
+
+	# Extra logging if enabled.
+	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
+		einfo "Verbose logging for \"${FUNCNAME}\" function"
+		einfo "Documentation destination: ${dest}"
+		einfo "Directory to install: ${dir_to_install}"
+		einfo "Complete command:"
+		einfo "${FUNCNAME} ${@}"
+	fi
+}
+
+# @FUNCTION: java-pkg_dosrc
+# @USAGE: <path/to/sources> [...]
+# @DESCRIPTION:
+# Installs a zip containing the source for a package, so it can used in
+# from IDEs like eclipse and netbeans.
+# Ebuild needs to DEPEND on app-arch/zip to use this. It also should be controlled by USE=source.
+#
+# @CODE
+# Example:
+# java-pkg_dosrc src/*
+# @CODE
+
+# TODO change so it the arguments it takes are the base directories containing
+# source -nichoj
+#
+# TODO should we be able to handle multiple calls to dosrc? -nichoj
+#
+# TODO maybe we can take an existing zip/jar? -nichoj
+#
+# FIXME apparently this fails if you give it an empty directories
+java-pkg_dosrc() {
+	debug-print-function ${FUNCNAME} $*
+
+	[ ${#} -lt 1 ] && die "At least one argument needed"
+
+	java-pkg_check-phase install
+
+	[[ ${#} -lt 1 ]] && die "At least one argument needed"
+
+	if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
+		local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
+		java-pkg_announce-qa-violation ${msg}
+	fi
+
+	java-pkg_init_paths_
+
+	local zip_name="${PN}-src.zip"
+	local zip_path="${T}/${zip_name}"
+	local dir
+	for dir in "${@}"; do
+		local dir_parent=$(dirname "${dir}")
+		local dir_name=$(basename "${dir}")
+		pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
+		zip -q -r ${zip_path} ${dir_name} -i '*.java'
+		local result=$?
+		# 12 means zip has nothing to do
+		if [[ ${result} != 12 && ${result} != 0 ]]; then
+			die "failed to zip ${dir_name}"
+		fi
+		popd >/dev/null || die
+	done
+
+	# Install the zip
+	(
+		insinto "${JAVA_PKG_SOURCESPATH}"
+		doins ${zip_path}
+	) || die "Failed to install source"
+
+	JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
+
+	# Extra logging if enabled.
+	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
+		einfo "Verbose logging for \"${FUNCNAME}\" function"
+		einfo "Zip filename created: ${zip_name}"
+		einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}"
+		einfo "Directories zipped: ${@}"
+		einfo "Complete command:"
+		einfo "${FUNCNAME} ${@}"
+	fi
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_dolauncher
+# @USAGE: <filename> [options]
+# @DESCRIPTION:
+# Make a wrapper script to lauch/start this package
+# If necessary, the wrapper will switch to the appropriate VM.
+#
+# Can be called without parameters if the package installs only one jar
+# that has the Main-class attribute set. The wrapper will be named ${PN}.
+#
+# @CODE
+# Parameters:
+# $1 - filename of launcher to create
+# $2 - options, as follows:
+#  --main the.main.class.to.start
+#  --jar /the/jar/too/launch.jar or just <name>.jar
+#  --java_args 'Extra arguments to pass to java'
+#  --pkg_args 'Extra arguments to pass to the package'
+#  --pwd Directory the launcher changes to before executing java
+#  -into Directory to install the launcher to, instead of /usr/bin
+#  -pre Prepend contents of this file to the launcher
+# @CODE
+java-pkg_dolauncher() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+	java-pkg_init_paths_
+
+	if [[ ${#} = 0 ]]; then
+		local name="${PN}"
+	else
+		local name="${1}"
+		shift
+	fi
+
+	# TODO rename to launcher
+	local target="${T}/${name}"
+	local var_tmp="${T}/launcher_variables_tmp"
+	local target_dir pre
+
+	# Process the other the rest of the arguments
+	while [[ -n "${1}" && -n "${2}" ]]; do
+		local var="${1}" value="${2}"
+		if [[ "${var:0:2}" == "--" ]]; then
+			local var=${var:2}
+			echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
+			local gjl_${var}="${value}"
+		elif [[ "${var}" == "-into" ]]; then
+			target_dir="${value}"
+		elif [[ "${var}" == "-pre" ]]; then
+			pre="${value}"
+		fi
+		shift 2
+	done
+
+	# Test if no --jar and --main arguments were given and
+	# in that case check if the package only installs one jar
+	# and use that jar.
+	if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
+		local cp="${JAVA_PKG_CLASSPATH}"
+		if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
+			echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
+		else
+			local msg="Not enough information to create a launcher given."
+			msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
+			die "${msg}"
+		fi
+	fi
+
+	# Write the actual script
+	echo "#!/bin/bash" > "${target}"
+	if [[ -n "${pre}" ]]; then
+		if [[ -f "${pre}" ]]; then
+			cat "${pre}" >> "${target}"
+		else
+			die "-pre specified file '${pre}' does not exist"
+		fi
+	fi
+	echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
+	cat "${var_tmp}" >> "${target}"
+	rm -f "${var_tmp}"
+	echo "source ${EPREFIX}/usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
+
+	if [[ -n "${target_dir}" ]]; then
+		(
+			into "${target_dir}"
+			dobin "${target}"
+		)
+		local ret=$?
+		return ${ret}
+	else
+		dobin "${target}"
+	fi
+}
+
+# @FUNCTION: java-pkg_dowar
+# @DESCRIPTION:
+# Install war files.
+# TODO document
+java-pkg_dowar() {
+	debug-print-function ${FUNCNAME} $*
+
+	# Check for arguments
+	[[ ${#} -lt 1 ]] && die "At least one argument needed"
+	java-pkg_check-phase install
+
+	java-pkg_init_paths_
+
+	local war
+	for war in $* ; do
+		local warpath
+		# TODO evaluate if we want to handle symlinks differently -nichoj
+		# Check for symlink
+		if [[ -L "${war}" ]] ; then
+			cp "${war}" "${T}"
+			warpath="${T}$(basename "${war}")"
+		# Check for directory
+		# TODO evaluate if we want to handle directories differently -nichoj
+		elif [[ -d "${war}" ]] ; then
+			echo "dowar: warning, skipping directory ${war}"
+			continue
+		else
+			warpath="${war}"
+		fi
+
+		# Install those files like you mean it
+		(
+			insopts -m0644
+			insinto "${JAVA_PKG_WARDEST}"
+			doins ${warpath}
+		)
+	done
+}
+
+# @FUNCTION: java-pkg_recordjavadoc
+# @INTERNAL
+# @DESCRIPTION:
+# Scan for JavaDocs, and record their existence in the package.env file
+
+# TODO make sure this in the proper section
+java-pkg_recordjavadoc()
+{
+	debug-print-function ${FUNCNAME} $*
+	# the find statement is important
+	# as some packages include multiple trees of javadoc
+	JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')"
+	# remove $D - TODO: check this is ok with all cases of the above
+	JAVADOC_PATH="${JAVADOC_PATH//${D}}"
+	if [[ -n "${JAVADOC_PATH}" ]] ; then
+		debug-print "javadocs found in ${JAVADOC_PATH%:}"
+		java-pkg_do_write_
+	else
+		debug-print "No javadocs found"
+	fi
+}
+
+
+# @FUNCTION: java-pkg_jar-from
+# @USAGE: [--build-only] [--with-dependencies] [--virtual] [--into dir] <package> [<package.jar>] [<destination.jar>]
+# @DESCRIPTION:
+# Makes a symlink to a jar from a certain package
+# A lot of java packages include dependencies in a lib/ directory
+# You can use this function to replace these bundled dependencies.
+# The dependency is recorded into package.env DEPEND line, unless "--build-only"
+# is passed as the very first argument, for jars that have to be present only
+# at build time and are not needed on runtime (junit testing etc).
+#
+# @CODE
+# Example: get all jars from xerces slot 2
+#	java-pkg_jar-from xerces-2
+#
+# Example: get a specific jar from xerces slot 2
+# 	java-pkg_jar-from xerces-2 xml-apis.jar
+#
+# Example: get a specific jar from xerces slot 2, and name it diffrently
+# 	java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
+#
+# Example: get junit.jar which is needed only for building
+#	java-pkg_jar-from --build-only junit junit.jar
+# @CODE
+#
+# @CODE
+# Parameters
+#	--build-only - makes the jar(s) not added into package.env DEPEND line.
+#	  (assumed automatically when called inside src_test)
+#	--with-dependencies - get jars also from requested package's dependencies
+#	  transitively.
+#	--virtual - Packages passed to this function are to be handled as virtuals
+#	  and will not have individual jar dependencies recorded.
+#	--into $dir - symlink jar(s) into $dir (must exist) instead of .
+# $1 - Package to get jars from, or comma-separated list of packages in
+#	case other parameters are not used.
+# $2 - jar from package. If not specified, all jars will be used.
+# $3 - When a single jar is specified, destination filename of the
+#	symlink. Defaults to the name of the jar.
+# @CODE
+
+# TODO could probably be cleaned up a little
+java-pkg_jar-from() {
+	debug-print-function ${FUNCNAME} $*
+
+	local build_only=""
+	local destdir="."
+	local deep=""
+	local virtual=""
+	local record_jar=""
+
+	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
+
+	while [[ "${1}" == --* ]]; do
+		if [[ "${1}" = "--build-only" ]]; then
+			build_only="build"
+		elif [[ "${1}" = "--with-dependencies" ]]; then
+			deep="--with-dependencies"
+		elif [[ "${1}" = "--virtual" ]]; then
+			virtual="true"
+		elif [[ "${1}" = "--into" ]]; then
+			destdir="${2}"
+			shift
+		else
+			die "java-pkg_jar-from called with unknown parameter: ${1}"
+		fi
+		shift
+	done
+
+	local target_pkg="${1}" target_jar="${2}" destjar="${3}"
+
+	[[ -z ${target_pkg} ]] && die "Must specify a package"
+
+	if [[ "${EAPI}" == "1" ]]; then
+		target_pkg="${target_pkg//:/-}"
+	fi
+
+	# default destjar to the target jar
+	[[ -z "${destjar}" ]] && destjar="${target_jar}"
+
+	local error_msg="There was a problem getting the classpath for ${target_pkg}."
+	local classpath
+	classpath="$(java-config ${deep} --classpath=${target_pkg})"
+	[[ $? != 0 ]] && die ${error_msg}
+
+	# When we have commas this functions is called to bring jars from multiple
+	# packages. This affects recording of dependencencies performed later
+	# which expects one package only, so we do it here.
+	if [[ ${target_pkg} = *,* ]]; then
+		for pkg in ${target_pkg//,/ }; do
+			java-pkg_ensure-dep "${build_only}" "${pkg}"
+			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
+		done
+		# setting this disables further record-jar_ calls later
+		record_jar="true"
+	else
+		java-pkg_ensure-dep "${build_only}" "${target_pkg}"
+	fi
+
+	# Record the entire virtual as a dependency so that
+	# no jars are missed.
+	if [[ -z "${build_only}" && -n "${virtual}" ]]; then
+		java-pkg_record-jar_ "${target_pkg}"
+		# setting this disables further record-jars_ calls later
+		record_jar="true"
+	fi
+
+	pushd ${destdir} > /dev/null \
+		|| die "failed to change directory to ${destdir}"
+
+	local jar
+	for jar in ${classpath//:/ }; do
+		local jar_name=$(basename "${jar}")
+		if [[ ! -f "${jar}" ]] ; then
+			debug-print "${jar} from ${target_pkg} does not exist"
+			die "Installation problems with jars in ${target_pkg} - is it installed?"
+		fi
+		# If no specific target jar was indicated, link it
+		if [[ -z "${target_jar}" ]] ; then
+			[[ -f "${target_jar}" ]]  && rm "${target_jar}"
+			ln -snf "${jar}" \
+				|| die "Failed to make symlink from ${jar} to ${jar_name}"
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${target_pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
+				fi
+			fi
+		# otherwise, if the current jar is the target jar, link it
+		elif [[ "${jar_name}" == "${target_jar}" ]] ; then
+			[[ -f "${destjar}" ]]  && rm "${destjar}"
+			ln -snf "${jar}" "${destjar}" \
+				|| die "Failed to make symlink from ${jar} to ${destjar}"
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${target_pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
+				fi
+			fi
+			popd > /dev/null || die
+			return 0
+		fi
+	done
+	popd > /dev/null || die
+	# if no target was specified, we're ok
+	if [[ -z "${target_jar}" ]] ; then
+		return 0
+	# otherwise, die bitterly
+	else
+		die "Failed to find ${target_jar:-jar} in ${target_pkg}"
+	fi
+}
+
+# @FUNCTION: java-pkg_jarfrom
+# @DESCRIPTION:
+# See java-pkg_jar-from
+java-pkg_jarfrom() {
+	java-pkg_jar-from "$@"
+}
+
+# @FUNCTION: java-pkg_getjars
+# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
+# @DESCRIPTION:
+# Get the classpath provided by any number of packages
+# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
+# The providing packages are recorded as dependencies into package.env DEPEND
+# line, unless "--build-only" is passed as the very first argument, for jars
+# that have to be present only at build time and are not needed on runtime
+# (junit testing etc).
+#
+# @CODE
+# Example: Get the classpath for xerces-2 and xalan,
+#	java-pkg_getjars xerces-2,xalan
+#
+# Example Return:
+#	/usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
+#
+#
+# Parameters:
+#	--build-only - makes the jar(s) not added into package.env DEPEND line.
+#	  (assumed automatically when called inside src_test)
+#	--with-dependencies - get jars also from requested package's dependencies
+#	  transitively.
+# $1 - list of packages to get jars from
+#   (passed to java-config --classpath)
+# @CODE
+java-pkg_getjars() {
+	debug-print-function ${FUNCNAME} $*
+
+	local build_only=""
+	local deep=""
+
+	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
+
+	while [[ "${1}" == --* ]]; do
+		if [[ "${1}" = "--build-only" ]]; then
+			build_only="build"
+		elif [[ "${1}" = "--with-dependencies" ]]; then
+			deep="--with-dependencies"
+		else
+			die "java-pkg_jar-from called with unknown parameter: ${1}"
+		fi
+		shift
+	done
+
+	[[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
+
+
+	local pkgs="${1}"
+
+	if [[ "${EAPI}" == "1" ]]; then
+		pkgs="${pkgs//:/-}"
+	fi
+
+	jars="$(java-config ${deep} --classpath=${pkgs})"
+	[[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
+	debug-print "${pkgs}:${jars}"
+
+	for pkg in ${pkgs//,/ }; do
+		java-pkg_ensure-dep "${build_only}" "${pkg}"
+	done
+
+	for pkg in ${pkgs//,/ }; do
+		if [[ -z "${build_only}" ]]; then
+			java-pkg_record-jar_ "${pkg}"
+		else
+			java-pkg_record-jar_ --build-only "${pkg}"
+		fi
+	done
+
+	echo "${jars}"
+}
+
+# @FUNCTION: java-pkg_getjar
+# @USAGE: [--build-only] [--virtual] <package> <jarfile>
+# @DESCRIPTION:
+# Get the complete path of a single jar from a package
+# The providing package is recorded as runtime dependency into package.env
+# DEPEND line, unless "--build-only" is passed as the very first argument, for
+# jars that have to be present only at build time and are not needed on runtime
+# (junit testing etc).
+#
+# @CODE
+# Example:
+#	java-pkg_getjar xerces-2 xml-apis.jar
+# returns
+#	/usr/share/xerces-2/lib/xml-apis.jar
+#
+# Parameters:
+#	--build-only - makes the jar not added into package.env DEPEND line.
+#	--virtual - Packages passed to this function are to be handled as virtuals
+#	  and will not have individual jar dependencies recorded.
+# $1 - package to use
+# $2 - jar to get
+# @CODE
+java-pkg_getjar() {
+	debug-print-function ${FUNCNAME} $*
+
+	local build_only=""
+	local virtual=""
+	local record_jar=""
+
+	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
+
+	while [[ "${1}" == --* ]]; do
+		if [[ "${1}" = "--build-only" ]]; then
+			build_only="build"
+		elif [[ "${1}" == "--virtual" ]]; then
+			virtual="true"
+		else
+			die "java-pkg_getjar called with unknown parameter: ${1}"
+		fi
+		shift
+	done
+
+	[[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
+
+	local pkg="${1}" target_jar="${2}" jar
+
+	if [[ "${EAPI}" == "1" ]]; then
+		pkg="${pkg//:/-}"
+	fi
+
+	[[ -z ${pkg} ]] && die "Must specify package to get a jar from"
+	[[ -z ${target_jar} ]] && die "Must specify jar to get"
+
+	local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
+	local classpath
+	classpath=$(java-config --classpath=${pkg})
+	[[ $? != 0 ]] && die ${error_msg}
+
+	java-pkg_ensure-dep "${build_only}" "${pkg}"
+
+	# Record the package(Virtual) as a dependency and then set build_only
+	# So that individual jars are not recorded.
+	if [[ -n "${virtual}" ]]; then
+		if [[ -z "${build_only}" ]]; then
+			java-pkg_record-jar_ "${pkg}"
+		else
+			java-pkg_record-jar_ --build-only "${pkg}"
+		fi
+		record_jar="true"
+	fi
+
+	for jar in ${classpath//:/ }; do
+		if [[ ! -f "${jar}" ]] ; then
+			die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
+		fi
+
+		if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
+			# Only record jars that aren't build-only
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
+				fi
+			fi
+			echo "${jar}"
+			return 0
+		fi
+	done
+
+	die "Could not find ${target_jar} in ${pkg}"
+	return 1
+}
+
+# @FUNCTION: java-pkg_register-dependency
+# @USAGE: <package>[,<package2>...] [<jarfile>]
+# @DESCRIPTION:
+# Registers runtime dependency on a package, list of packages, or a single jar
+# from a package, into package.env DEPEND line. Can only be called in
+# src_install phase.
+# Intended for binary packages where you don't need to symlink the jars or get
+# their classpath during build. As such, the dependencies only need to be
+# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
+#
+# @CODE
+# Parameters:
+# $1 - comma-separated list of packages, or a single package
+# $2 - if param $1 is a single package, optionally specify the jar
+#   to depend on
+#
+# Examples:
+# Record the dependency on whole xerces-2 and xalan,
+#	java-pkg_register-dependency xerces-2,xalan
+#
+# Record the dependency on ant.jar from ant-core
+#	java-pkg_register-dependency ant-core ant.jar
+# @CODE
+#
+# Note: Passing both list of packages as the first parameter AND specifying the
+# jar as the second is not allowed and will cause the function to die. We assume
+# that there's more chance one passes such combination as a mistake, than that
+# there are more packages providing identically named jar without class
+# collisions.
+java-pkg_register-dependency() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
+
+	local pkgs="${1}"
+	local jar="${2}"
+
+	[[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
+
+	if [[ "${EAPI}" == "1" ]]; then
+		pkgs="${pkgs//:/-}"
+	fi
+
+	if [[ -z "${jar}" ]]; then
+		for pkg in ${pkgs//,/ }; do
+			java-pkg_ensure-dep runtime "${pkg}"
+			java-pkg_record-jar_ "${pkg}"
+		done
+	else
+		[[ ${pkgs} == *,* ]] && \
+			die "${FUNCNAME} called with both package list and jar name"
+		java-pkg_ensure-dep runtime "${pkgs}"
+		java-pkg_record-jar_ "${pkgs}" "${jar}"
+	fi
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_register-optional-dependency
+# @USAGE: <package>[,<package2>...] [<jarfile>]
+# @DESCRIPTION:
+# Registers optional runtime dependency on a package, list of packages, or a
+# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
+# called in src_install phase.
+# Intended for packages that can use other packages when those are in classpath.
+# Will be put on classpath by launcher if they are installed. Typical case is
+# JDBC implementations for various databases. It's better than having USE flag
+# for each implementation triggering hard dependency.
+#
+# @CODE
+# Parameters:
+# $1 - comma-separated list of packages, or a single package
+# $2 - if param $1 is a single package, optionally specify the jar to depend on
+#
+# Example:
+# Record the optional dependency on some jdbc providers
+#	java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
+# @CODE
+#
+# Note: Passing both list of packages as the first parameter AND specifying the
+# jar as the second is not allowed and will cause the function to die. We assume
+# that there's more chance one passes such combination as a mistake, than that
+# there are more packages providing identically named jar without class
+# collisions.
+java-pkg_register-optional-dependency() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
+
+	local pkgs="${1}"
+	local jar="${2}"
+
+	[[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
+
+	if [[ "${EAPI}" == "1" ]]; then
+		pkgs="${pkgs//:/-}"
+	fi
+
+	if [[ -z "${jar}" ]]; then
+		for pkg in ${pkgs//,/ }; do
+			java-pkg_record-jar_ --optional "${pkg}"
+		done
+	else
+		[[ ${pkgs} == *,* ]] && \
+			die "${FUNCNAME} called with both package list and jar name"
+		java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
+	fi
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_register-environment-variable
+# @USAGE: <name> <value>
+# @DESCRIPTION:
+# Register an arbitrary environment variable into package.env. The gjl launcher
+# for this package or any package depending on this will export it into
+# environement before executing java command.
+# Must only be called in src_install phase.
+JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
+JAVA_PKG_EXTRA_ENV_VARS=""
+java-pkg_register-environment-variable() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_check-phase install
+
+	[[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
+
+	echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
+	JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
+
+	java-pkg_do_write_
+}
+
+# @FUNCTION: java-pkg_get-bootclasspath
+# @USAGE: <version>
+# @DESCRIPTION:
+# Returns classpath of a given bootclasspath-providing package version.
+#
+# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
+#             of the current JDK
+java-pkg_get-bootclasspath() {
+	local version="${1}"
+
+	local bcp
+	case "${version}" in
+		auto)
+			bcp="$(java-config -g BOOTCLASSPATH)"
+			;;
+		1.5)
+			bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
+			;;
+		*)
+			eerror "unknown parameter of java-pkg_get-bootclasspath"
+			die "unknown parameter of java-pkg_get-bootclasspath"
+			;;
+	esac
+
+	echo "${bcp}"
+}
+
+
+# This function reads stdin, and based on that input, figures out how to
+# populate jars from the filesystem.
+# Need to figure out a good way of making use of this, ie be able to use a
+# string that was built instead of stdin
+# NOTE: this isn't quite ready for primetime.
+#java-pkg_populate-jars() {
+#	local line
+#
+#	read line
+#	while [[ -n "${line}" ]]; do
+#		# Ignore comments
+#		[[ ${line%%#*} == "" ]] && continue
+#
+#		# get rid of any spaces
+#		line="${line// /}"
+#
+#		# format: path=jarinfo
+#		local path=${line%%=*}
+#		local jarinfo=${line##*=}
+#
+#		# format: jar@package
+#		local jar=${jarinfo%%@*}.jar
+#		local package=${jarinfo##*@}
+#		if [[ -n ${replace_only} ]]; then
+#			[[ ! -f $path ]] && die "No jar exists at ${path}"
+#		fi
+#		if [[ -n ${create_parent} ]]; then
+#			local parent=$(dirname ${path})
+#			mkdir -p "${parent}"
+#		fi
+#		java-pkg_jar-from "${package}" "${jar}" "${path}"
+#
+#		read line
+#	done
+#}
+
+# @FUNCTION: java-pkg_find-normal-jars
+# @USAGE: [<path/to/directory>]
+# @DESCRIPTION:
+# Find the files with suffix .jar file in the given directory (default: $WORKDIR)
+java-pkg_find-normal-jars() {
+	local dir=$1
+	[[ "${dir}" ]] || dir="${WORKDIR}"
+	local found
+	for jar in $(find "${dir}" -name "*.jar" -type f); do
+		echo "${jar}"
+		found="true"
+	done
+	[[ "${found}" ]]
+	return $?
+}
+
+# @FUNCTION: java-pkg_ensure-no-bundled-jars
+# @DESCRIPTION:
+# Try to locate bundled jar files in ${WORKDIR} and die if found.
+# This function should be called after WORKDIR has been populated with symlink
+# to system jar files or bundled jars removed.
+java-pkg_ensure-no-bundled-jars() {
+	debug-print-function ${FUNCNAME} $*
+
+	local bundled_jars=$(java-pkg_find-normal-jars)
+	if [[ -n ${bundled_jars} ]]; then
+		echo "Bundled jars found:"
+		local jar
+		for jar in ${bundled_jars}; do
+			echo $(pwd)${jar/./}
+		done
+		die "Bundled jars found!"
+	fi
+}
+
+# @FUNCTION: java-pkg_ensure-vm-version-sufficient
+# @INTERNAL
+# @DESCRIPTION:
+# Checks if we have a sufficient VM and dies if we don't.
+java-pkg_ensure-vm-version-sufficient() {
+	debug-print-function ${FUNCNAME} $*
+
+	if ! java-pkg_is-vm-version-sufficient; then
+		debug-print "VM is not suffient"
+		eerror "Current Java VM cannot build this package"
+		einfo "Please use java-config -S to set the correct one"
+		die "Active Java VM cannot build this package"
+	fi
+}
+
+# @FUNCTION: java-pkg_is-vm-version-sufficient
+# @INTERNAL
+# @DESCRIPTION:
+# @RETURN: zero - VM is sufficient; non-zero - VM is not sufficient
+java-pkg_is-vm-version-sufficient() {
+	debug-print-function ${FUNCNAME} $*
+
+	depend-java-query --is-sufficient "${DEPEND}" > /dev/null
+	return $?
+}
+
+# @FUNCTION: java-pkg_ensure-vm-version-eq
+# @INTERNAL
+# @DESCRIPTION:
+# Die if the current VM is not equal to the argument passed.
+#
+# @param $@ - Desired VM version to ensure
+java-pkg_ensure-vm-version-eq() {
+	debug-print-function ${FUNCNAME} $*
+
+	if ! java-pkg_is-vm-version-eq $@ ; then
+		debug-print "VM is not suffient"
+		eerror "This package requires a Java VM version = $@"
+		einfo "Please use java-config -S to set the correct one"
+		die "Active Java VM too old"
+	fi
+}
+
+# @FUNCTION: java-pkg_is-vm-version-eq
+# @USAGE: <version>
+# @INTERNAL
+# @RETURN: zero - VM versions are equal; non-zero - VM version are not equal
+java-pkg_is-vm-version-eq() {
+	debug-print-function ${FUNCNAME} $*
+
+	local needed_version="$@"
+
+	[[ -z "${needed_version}" ]] && die "need an argument"
+
+	local vm_version="$(java-pkg_get-vm-version)"
+
+	vm_version="$(get_version_component_range 1-2 "${vm_version}")"
+	needed_version="$(get_version_component_range 1-2 "${needed_version}")"
+
+	if [[ -z "${vm_version}" ]]; then
+		debug-print "Could not get JDK version from DEPEND"
+		return 1
+	else
+		if [[ "${vm_version}" == "${needed_version}" ]]; then
+			debug-print "Detected a JDK(${vm_version}) = ${needed_version}"
+			return 0
+		else
+			debug-print "Detected a JDK(${vm_version}) != ${needed_version}"
+			return 1
+		fi
+	fi
+}
+
+# @FUNCTION: java-pkg_ensure-vm-version-ge
+# @INTERNAL
+# @DESCRIPTION:
+# Die if the current VM is not greater than the desired version
+#
+# @param $@ - VM version to compare current to
+java-pkg_ensure-vm-version-ge() {
+	debug-print-function ${FUNCNAME} $*
+
+	if ! java-pkg_is-vm-version-ge "$@" ; then
+		debug-print "vm is not suffient"
+		eerror "This package requires a Java VM version >= $@"
+		einfo "Please use java-config -S to set the correct one"
+		die "Active Java VM too old"
+	fi
+}
+
+# @FUNCTION: java-pkg_is-vm-version-ge
+# @INTERNAL
+# @DESCRIPTION:
+# @CODE
+# Parameters:
+# $@ - VM version to compare current VM to
+# @CODE
+# @RETURN: zero - current VM version is greater than checked version;
+# 	non-zero - current VM version is not greater than checked version
+java-pkg_is-vm-version-ge() {
+	debug-print-function ${FUNCNAME} $*
+
+	local needed_version=$@
+	local vm_version=$(java-pkg_get-vm-version)
+	if [[ -z "${vm_version}" ]]; then
+		debug-print "Could not get JDK version from DEPEND"
+		return 1
+	else
+		if version_is_at_least "${needed_version}" "${vm_version}"; then
+			debug-print "Detected a JDK(${vm_version}) >= ${needed_version}"
+			return 0
+		else
+			debug-print "Detected a JDK(${vm_version}) < ${needed_version}"
+			return 1
+		fi
+	fi
+}
+
+java-pkg_set-current-vm() {
+	export GENTOO_VM=${1}
+}
+
+java-pkg_get-current-vm() {
+	echo ${GENTOO_VM}
+}
+
+java-pkg_current-vm-matches() {
+	has $(java-pkg_get-current-vm) ${@}
+	return $?
+}
+
+# @FUNCTION: java-pkg_get-source
+# @DESCRIPTION:
+# Determines what source version should be used, for passing to -source.
+# Unless you want to break things you probably shouldn't set _WANT_SOURCE
+#
+# @RETURN: string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
+java-pkg_get-source() {
+	echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
+}
+
+# @FUNCTION: java-pkg_get-target
+# @DESCRIPTION:
+# Determines what target version should be used, for passing to -target.
+# If you don't care about lower versions, you can set _WANT_TARGET to the
+# version of your JDK.
+#
+# @RETURN: string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
+java-pkg_get-target() {
+	echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
+}
+
+# @FUNCTION: java-pkg_get-javac
+# @DESCRIPTION:
+# Returns the compiler executable
+java-pkg_get-javac() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-pkg_init-compiler_
+	local compiler="${GENTOO_COMPILER}"
+
+	local compiler_executable
+	if [[ "${compiler}" = "javac" ]]; then
+		# nothing fancy needs to be done for javac
+		compiler_executable="javac"
+	else
+		# for everything else, try to determine from an env file
+
+		local compiler_env="/usr/share/java-config-2/compiler/${compiler}"
+		if [[ -f ${compiler_env} ]]; then
+			local old_javac=${JAVAC}
+			unset JAVAC
+			# try to get value of JAVAC
+			compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
+			export JAVAC=${old_javac}
+
+			if [[ -z ${compiler_executable} ]]; then
+				die "JAVAC is empty or undefined in ${compiler_env}"
+			fi
+
+			# check that it's executable
+			if [[ ! -x ${compiler_executable} ]]; then
+				die "${compiler_executable} doesn't exist, or isn't executable"
+			fi
+		else
+			die "Could not find environment file for ${compiler}"
+		fi
+	fi
+	echo ${compiler_executable}
+}
+
+# @FUNCTION: java-pkg_javac-args
+# @DESCRIPTION:
+# If an ebuild uses javac directly, instead of using ejavac, it should call this
+# to know what -source/-target to use.
+#
+# @RETURN: string - arguments to pass to javac, complete with -target and -source
+java-pkg_javac-args() {
+	debug-print-function ${FUNCNAME} $*
+
+	local want_source="$(java-pkg_get-source)"
+	local want_target="$(java-pkg_get-target)"
+
+	local source_str="-source ${want_source}"
+	local target_str="-target ${want_target}"
+
+	debug-print "want source: ${want_source}"
+	debug-print "want target: ${want_target}"
+
+	if [[ -z "${want_source}" || -z "${want_target}" ]]; then
+		die "Could not find valid -source/-target values for javac"
+	else
+		echo "${source_str} ${target_str}"
+	fi
+}
+
+# @FUNCTION: java-pkg_get-jni-cflags
+# @DESCRIPTION:
+# Echos the CFLAGS for JNI compilations
+java-pkg_get-jni-cflags() {
+	local flags="-I${JAVA_HOME}/include"
+
+	local platform="linux"
+	use elibc_FreeBSD && platform="freebsd"
+
+	# TODO do a check that the directories are valid
+	flags="${flags} -I${JAVA_HOME}/include/${platform}"
+
+	echo ${flags}
+}
+
+java-pkg_ensure-gcj() {
+	# was enforcing sys-devel/gcc[gcj]
+	die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
+}
+
+java-pkg_ensure-test() {
+	# was enforcing USE=test if FEATURES=test
+	die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
+}
+
+# @FUNCTION: java-pkg_register-ant-task
+# @USAGE: [--version x.y] [<name>]
+# @DESCRIPTION:
+# Register this package as ant task, so that ant will load it when no specific
+# ANT_TASKS are specified. Note that even without this registering, all packages
+# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
+# packages, but can be also used by other ebuilds that used to symlink their
+# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
+# compatibility.
+#
+# @CODE
+# Parameters
+# --version x.y Register only for ant version x.y (otherwise for any ant
+#		version). Used by the ant-* packages to prevent loading of mismatched
+#		ant-core ant tasks after core was updated, before the tasks are updated,
+#		without a need for blockers.
+# $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
+# @CODE
+java-pkg_register-ant-task() {
+	local TASKS_DIR="tasks"
+
+	# check for --version x.y parameters
+	while [[ -n "${1}" && -n "${2}" ]]; do
+		local var="${1#--}"
+		local val="${2}"
+		if [[ "${var}" == "version" ]]; then
+			TASKS_DIR="tasks-${val}"
+		else
+			die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
+		fi
+		shift 2
+	done
+
+	local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
+
+	dodir /usr/share/ant/${TASKS_DIR}
+	touch "${ED}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
+}
+
+# @FUNCTION: java-pkg_ant-tasks-depend
+# @INTERNAL
+# @DESCRIPTION:
+# Translates the WANT_ANT_TASKS variable into valid dependencies.
+java-pkg_ant-tasks-depend() {
+	debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
+
+	if [[ -n "${WANT_ANT_TASKS}" ]]; then
+		local DEP=""
+		for i in ${WANT_ANT_TASKS}
+		do
+			if [[ ${i} = ant-* ]]; then
+				DEP="${DEP}dev-java/${i} "
+			elif [[ ${i} = */*:* ]]; then
+				DEP="${DEP}${i} "
+			else
+				echo "Invalid atom in WANT_ANT_TASKS: ${i}"
+				return 1
+			fi
+		done
+		echo ${DEP}
+		return 0
+	else
+		return 0
+	fi
+}
+
+
+# @FUNCTION: ejunit_
+# @INTERNAL
+# @DESCRIPTION:
+# Internal Junit wrapper function. Makes it easier to run the tests and checks for
+# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
+# @CODE
+# Parameters:
+# $1 - junit package (junit or junit-4)
+# $2 - -cp or -classpath
+# $3 - classpath; junit and recorded dependencies get appended
+# $@ - the rest of the parameters are passed to java
+# @CODE
+ejunit_() {
+	debug-print-function ${FUNCNAME} $*
+
+	local pkgs
+	if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
+		for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
+			pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
+		done
+	fi
+
+	local junit=${1}
+	shift 1
+
+	local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
+	if [[ ${1} = -cp || ${1} = -classpath ]]; then
+		cp="${2}:${cp}"
+		shift 2
+	else
+		cp=".:${cp}"
+	fi
+
+	local runner=junit.textui.TestRunner
+	if [[ "${junit}" == "junit-4" ]] ; then
+		runner=org.junit.runner.JUnitCore
+	fi
+	debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}"
+	java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
+}
+
+# @FUNCTION: ejunit
+# @DESCRIPTION:
+# Junit wrapper function. Makes it easier to run the tests and checks for
+# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
+#
+# @CODE
+# Parameters:
+# $1 - -cp or -classpath
+# $2 - classpath; junit and recorded dependencies get appended
+# $@ - the rest of the parameters are passed to java
+#
+# Examples:
+# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
+# ejunit org.blinkenlights.jid3.test.AllTests
+# ejunit org.blinkenlights.jid3.test.FirstTest org.blinkenlights.jid3.test.SecondTest
+# @CODE
+ejunit() {
+	debug-print-function ${FUNCNAME} $*
+
+	ejunit_ "junit" "${@}"
+}
+
+# @FUNCTION: ejunit4
+# @DESCRIPTION:
+# Junit4 wrapper function. Makes it easier to run the tests and checks for
+# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
+#
+# @CODE
+# Parameters:
+# $1 - -cp or -classpath
+# $2 - classpath; junit and recorded dependencies get appended
+# $@ - the rest of the parameters are passed to java
+#
+# Examples:
+# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
+# ejunit4 org.blinkenlights.jid3.test.AllTests
+# ejunit4 org.blinkenlights.jid3.test.FirstTest \
+#         org.blinkenlights.jid3.test.SecondTest
+# @CODE
+ejunit4() {
+	debug-print-function ${FUNCNAME} $*
+
+	ejunit_ "junit-4" "${@}"
+}
+
+# @FUNCTION: java-utils-2_src_prepare
+# @DESCRIPTION:
+# src_prepare Searches for bundled jars
+# Don't call directly, but via java-pkg-2_src_prepare!
+java-utils-2_src_prepare() {
+	java-pkg_func-exists java_prepare && java_prepare
+
+	# Check for files in JAVA_RM_FILES array.
+	if [[ ${JAVA_RM_FILES[@]} ]]; then
+		debug-print "$FUNCNAME: removing unneeded files"
+		java-pkg_rm_files "${JAVA_RM_FILES[@]}"
+	fi
+
+	if is-java-strict; then
+		echo "Searching for bundled jars:"
+		java-pkg_find-normal-jars || echo "None found."
+		echo "Searching for bundled classes (no output if none found):"
+		find "${WORKDIR}" -name "*.class"
+		echo "Search done."
+	fi
+}
+
+# @FUNCTION: java-utils-2_pkg_preinst
+# @DESCRIPTION:
+# pkg_preinst Searches for missing and unneeded dependencies
+# Don't call directly, but via java-pkg-2_pkg_preinst!
+java-utils-2_pkg_preinst() {
+	if is-java-strict; then
+		if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
+			return
+		fi
+
+		if has_version dev-java/java-dep-check; then
+			local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
+			[[ ${output} ]] && ewarn "${output}"
+		else
+			eerror "Install dev-java/java-dep-check for dependency checking"
+		fi
+	fi
+}
+
+# @FUNCTION: eant
+# @USAGE: <ant_build_target(s)>
+# @DESCRIPTION:
+# Ant wrapper function. Will use the appropriate compiler, based on user-defined
+# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
+# variables:
+#
+# @CODE
+# Variables:
+# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
+# 		gentoo.classpath property. Be sure to call java-ant_rewrite-classpath in src_unpack.
+# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
+# 		for build-time purposes, the dependency is not recorded to
+# 		package.env!
+# ANT_TASKS - used to determine ANT_TASKS before calling Ant.
+# @CODE
+eant() {
+	debug-print-function ${FUNCNAME} $*
+
+	if [[ ${EBUILD_PHASE} = compile ]]; then
+		java-ant-2_src_configure
+	fi
+
+	if ! has java-ant-2 ${INHERITED}; then
+		local msg="You should inherit java-ant-2 when using eant"
+		java-pkg_announce-qa-violation "${msg}"
+	fi
+
+	local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
+
+	java-pkg_init-compiler_
+	local compiler="${GENTOO_COMPILER}"
+
+	local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
+	local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
+	if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
+		die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
+	fi
+
+	if [[ ${compiler} != "javac" ]]; then
+		antflags="${antflags} -Dbuild.compiler=${build_compiler}"
+		# Figure out any extra stuff to put on the classpath for compilers aside
+		# from javac
+		# ANT_BUILD_COMPILER_DEPS should be something that could be passed to
+		# java-config -p
+		local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
+		if [[ -n ${build_compiler_deps} ]]; then
+			antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
+		fi
+	fi
+
+	for arg in "${@}"; do
+		if [[ ${arg} = -lib ]]; then
+			if is-java-strict; then
+				eerror "You should not use the -lib argument to eant because it will fail"
+				eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
+				eerror "or ant properties to make dependencies available."
+				eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
+				eerror "split ant (>=dev-java/ant-core-1.7)."
+				die "eant -lib is deprecated/forbidden"
+			else
+				echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
+				echo "more info."
+			fi
+		fi
+	done
+
+	# parse WANT_ANT_TASKS for atoms
+	local want_ant_tasks
+	for i in ${WANT_ANT_TASKS}; do
+		if [[ ${i} = */*:* ]]; then
+			i=${i#*/}
+			i=${i%:0}
+			want_ant_tasks+="${i/:/-} "
+		else
+			want_ant_tasks+="${i} "
+		fi
+	done
+	# default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
+	ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
+
+	# override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
+	ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
+
+	# if ant-tasks is not set by ebuild or forced, use none
+	ANT_TASKS="${ANT_TASKS:-none}"
+
+	# at this point, ANT_TASKS should be "all", "none" or explicit list
+	if [[ "${ANT_TASKS}" == "all" ]]; then
+		einfo "Using all available ANT_TASKS"
+	elif [[ "${ANT_TASKS}" == "none" ]]; then
+		einfo "Disabling all optional ANT_TASKS"
+	else
+		einfo "Using following ANT_TASKS: ${ANT_TASKS}"
+	fi
+
+	export ANT_TASKS
+
+	[[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
+	[[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
+
+	local gcp="${EANT_GENTOO_CLASSPATH}"
+	local getjarsarg=""
+
+	if [[ ${EBUILD_PHASE} = "test" ]]; then
+		antflags="${antflags} -DJunit.present=true"
+		getjarsarg="--with-dependencies"
+
+		local re="\bant-junit4?([-:]\S+)?\b"
+		[[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}"
+	else
+		antflags="${antflags} -Dmaven.test.skip=true"
+	fi
+
+	local cp
+
+	for atom in ${gcp}; do
+		cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})"
+	done
+
+	[[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)"
+	[[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}"
+
+	if [[ ${cp#:} ]]; then
+		# It seems ant does not like single quotes around ${cp}
+		antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
+	fi
+
+	[[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
+	debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
+	ant ${antflags} "${@}" || die "eant failed"
+}
+
+# @FUNCTION: ejavac
+# @USAGE: <javac_arguments>
+# @DESCRIPTION:
+# Javac wrapper function. Will use the appropriate compiler, based on
+# /etc/java-config/compilers.conf
+ejavac() {
+	debug-print-function ${FUNCNAME} $*
+
+	local compiler_executable
+	compiler_executable=$(java-pkg_get-javac)
+
+	local javac_args
+	javac_args="$(java-pkg_javac-args)"
+
+	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
+		einfo "Verbose logging for \"${FUNCNAME}\" function"
+		einfo "Compiler executable: ${compiler_executable}"
+		einfo "Extra arguments: ${javac_args}"
+		einfo "Complete command:"
+		einfo "${compiler_executable} ${javac_args} ${@}"
+	fi
+
+	ebegin "Compiling"
+	${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
+}
+
+# @FUNCTION: ejavadoc
+# @USAGE: <javadoc_arguments>
+# @DESCRIPTION:
+# javadoc wrapper function. Will set some flags based on the VM version
+# due to strict javadoc rules in 1.8.
+ejavadoc() {
+	debug-print-function ${FUNCNAME} $*
+
+	local javadoc_args=""
+
+	if java-pkg_is-vm-version-ge "1.8" ; then
+		javadoc_args="-Xdoclint:none"
+	fi
+
+	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
+		einfo "Verbose logging for \"${FUNCNAME}\" function"
+		einfo "Javadoc executable: javadoc"
+		einfo "Extra arguments: ${javadoc_args}"
+		einfo "Complete command:"
+		einfo "javadoc ${javadoc_args} ${@}"
+	fi
+
+	ebegin "Generating JavaDoc"
+	javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
+}
+
+# @FUNCTION: java-pkg_filter-compiler
+# @USAGE: <compiler(s)_to_filter>
+# @DESCRIPTION:
+# Used to prevent the use of some compilers. Should be used in src_compile.
+# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
+java-pkg_filter-compiler() {
+	JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
+}
+
+# @FUNCTION: java-pkg_force-compiler
+# @USAGE: <compiler(s)_to_force>
+# @DESCRIPTION:
+# Used to force the use of particular compilers. Should be used in src_compile.
+# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
+# OutOfMemoryErrors that may come up.
+java-pkg_force-compiler() {
+	JAVA_PKG_FORCE_COMPILER="$@"
+}
+
+# @FUNCTION: use_doc
+# @DESCRIPTION:
+#
+# Helper function for getting ant to build javadocs. If the user has USE=doc,
+# then 'javadoc' or the argument are returned. Otherwise, there is no return.
+#
+# The output of this should be passed to ant.
+# @CODE
+# Parameters:
+# $@ - Option value to return. Defaults to 'javadoc'
+#
+# Examples:
+# build javadocs by calling 'javadoc' target
+#	eant $(use_doc)
+#
+# build javadocs by calling 'apidoc' target
+#	eant $(use_doc apidoc)
+# @CODE
+# @RETURN string - Name of the target to create javadocs
+use_doc() {
+	use doc && echo ${@:-javadoc}
+}
+
+
+# @FUNCTION: java-pkg_init
+# @INTERNAL
+# @DESCRIPTION:
+# The purpose of this function, as the name might imply, is to initialize the
+# Java environment. It ensures that that there aren't any environment variables
+# that'll muss things up. It initializes some variables, which are used
+# internally. And most importantly, it'll switch the VM if necessary.
+#
+# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
+# call it during each of the phases of the merge process.
+java-pkg_init() {
+	debug-print-function ${FUNCNAME} $*
+
+	# Don't set up build environment if installing from binary. #206024 #258423
+	[[ "${MERGE_TYPE}" == "binary" ]] && return
+	# Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
+	# work nothing is lost.
+	has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
+
+	unset JAVAC
+	unset JAVA_HOME
+
+	java-config --help >/dev/null || {
+		eerror ""
+		eerror "Can't run java-config --help"
+		eerror "Have you upgraded python recently but haven't"
+		eerror "run python-updater yet?"
+		die "Can't run java-config --help"
+	}
+
+	# People do all kinds of weird things.
+	# https://forums.gentoo.org/viewtopic-p-3943166.html
+	local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
+	local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
+	if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
+		ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
+		ewarn "sun-jdk vms and and as such break configure scripts that"
+		ewarn "use it (for example app-office/openoffice) so we filter it out."
+		ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
+		ewarn "make.conf for example) to silence this warning or"
+		ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
+	fi
+
+	if [[ -z ${accept} ]]; then
+		# export _JAVA_OPTIONS= doesn't work because it will show up in java
+		# -version output
+		unset _JAVA_OPTIONS
+		# phase hooks make this run many times without this
+		I_WANT_GLOBAL_JAVA_OPTIONS="true"
+	fi
+
+	if java-pkg_func-exists ant_src_unpack; then
+		java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
+	fi
+
+	java-pkg_switch-vm
+	PATH=${JAVA_HOME}/bin:${PATH}
+
+	# TODO we will probably want to set JAVAC and JAVACFLAGS
+
+	# Do some QA checks
+	java-pkg_check-jikes
+
+	# Can't use unset here because Portage does not save the unset
+	# see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
+
+	# When users have crazy classpaths some packages can fail to compile.
+	# and everything should work with empty CLASSPATH.
+	# This also helps prevent unexpected dependencies on random things
+	# from the CLASSPATH.
+	export CLASSPATH=
+
+	# Unset external ANT_ stuff
+	export ANT_TASKS=
+	export ANT_OPTS=
+	export ANT_RESPECT_JAVA_HOME=
+}
+
+# @FUNCTION: java-pkg-init-compiler_
+# @INTERNAL
+# @DESCRIPTION:
+# This function attempts to figure out what compiler should be used. It does
+# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
+# COMPILERS variable defined there.
+# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
+#
+# It will go through the list of compilers, and verify that it supports the
+# target and source that are needed. If it is not suitable, then the next
+# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
+# isn't done.
+#
+# Once the which compiler to use has been figured out, it is set to
+# GENTOO_COMPILER.
+#
+# If you hadn't guessed, JAVA_PKG_FORCE_COMPILER is for testing only.
+#
+# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
+# suitable compiler was found there, then the default is to use javac provided
+# by the current VM.
+#
+#
+# @RETURN name of the compiler to use
+java-pkg_init-compiler_() {
+	debug-print-function ${FUNCNAME} $*
+
+	if [[ -n ${GENTOO_COMPILER} ]]; then
+		debug-print "GENTOO_COMPILER already set"
+		return
+	fi
+
+	local compilers;
+	if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
+		compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo	${COMPILERS})"
+	else
+		compilers=${JAVA_PKG_FORCE_COMPILER}
+	fi
+
+	debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
+
+	# Figure out if we should announce what compiler we're using
+	local compiler
+	for compiler in ${compilers}; do
+		debug-print "Checking ${compiler}..."
+		# javac should always be alright
+		if [[ ${compiler} = "javac" ]]; then
+			debug-print "Found javac... breaking"
+			export GENTOO_COMPILER="javac"
+			break
+		fi
+
+		if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
+			if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
+				einfo "Filtering ${compiler}" >&2
+				continue
+			fi
+		fi
+
+		# for non-javac, we need to make sure it supports the right target and
+		# source
+		local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
+		if [[ -f ${compiler_env} ]]; then
+			local desired_target="$(java-pkg_get-target)"
+			local desired_source="$(java-pkg_get-source)"
+
+
+			# Verify that the compiler supports target
+			local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET})
+			if ! has ${desired_target} ${supported_target}; then
+				ewarn "${compiler} does not support -target ${desired_target},	skipping"
+				continue
+			fi
+
+			# Verify that the compiler supports source
+			local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
+			if ! has ${desired_source} ${supported_source}; then
+				ewarn "${compiler} does not support -source ${desired_source}, skipping"
+				continue
+			fi
+
+			# if you get here, then the compiler should be good to go
+			export GENTOO_COMPILER="${compiler}"
+			break
+		else
+			ewarn "Could not find configuration for ${compiler}, skipping"
+			ewarn "Perhaps it is not installed?"
+			continue
+		fi
+	done
+
+	# If it hasn't been defined already, default to javac
+	if [[ -z ${GENTOO_COMPILER} ]]; then
+		if [[ -n ${compilers} ]]; then
+			einfo "No suitable compiler found: defaulting to JDK default for compilation" >&2
+		else
+			# probably don't need to notify users about the default.
+			:;#einfo "Defaulting to javac for compilation" >&2
+		fi
+		if java-config -g GENTOO_COMPILER 2> /dev/null; then
+			export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
+		else
+			export GENTOO_COMPILER=javac
+		fi
+	else
+		einfo "Using ${GENTOO_COMPILER} for compilation" >&2
+	fi
+
+}
+
+# @FUNCTION: init_paths_
+# @INTERNAL
+# @DESCRIPTION:
+# Initializes some variables that will be used. These variables are mostly used
+# to determine where things will eventually get installed.
+java-pkg_init_paths_() {
+	debug-print-function ${FUNCNAME} $*
+
+	local pkg_name
+	if [[ "${SLOT%/*}" == "0" ]] ; then
+		JAVA_PKG_NAME="${PN}"
+	else
+		JAVA_PKG_NAME="${PN}-${SLOT%/*}"
+	fi
+
+	JAVA_PKG_SHAREPATH="/usr/share/${JAVA_PKG_NAME}"
+	JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
+	JAVA_PKG_ENV="${ED}${JAVA_PKG_SHAREPATH}/package.env"
+	JAVA_PKG_VIRTUALS_PATH="/usr/share/java-config-2/virtuals"
+	JAVA_PKG_VIRTUAL_PROVIDER="${ED}${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
+
+	[[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
+	[[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="/usr/$(get_libdir)/${JAVA_PKG_NAME}"
+	[[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
+
+	# TODO maybe only print once?
+	debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}"
+	debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}"
+	debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
+	debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
+	debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
+}
+
+# @FUNCTION: java-pkg_do_write_
+# @INTERNAL
+# @DESCRIPTION:
+# Writes the package.env out to disk.
+#
+# TODO change to do-write, to match everything else
+java-pkg_do_write_() {
+	debug-print-function ${FUNCNAME} $*
+	java-pkg_init_paths_
+	# Create directory for package.env
+	dodir "${JAVA_PKG_SHAREPATH}"
+
+	# Create package.env
+	(
+		echo "DESCRIPTION=\"${DESCRIPTION}\""
+		echo "GENERATION=\"2\""
+		echo "SLOT=\"${SLOT}\""
+		echo "CATEGORY=\"${CATEGORY}\""
+		echo "PVR=\"${PVR}\""
+
+		[[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
+		[[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
+		[[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
+		[[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
+			&& echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
+		[[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
+			&& echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
+		echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
+		[[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
+			&& echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
+	) > "${JAVA_PKG_ENV}"
+
+	# register target/source
+	local target="$(java-pkg_get-target)"
+	local source="$(java-pkg_get-source)"
+	[[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
+	[[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
+
+	# register javadoc info
+	[[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \
+		>> ${JAVA_PKG_ENV}
+	# register source archives
+	[[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \
+		>> ${JAVA_PKG_ENV}
+
+	echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
+	[[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
+
+	# extra env variables
+	if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
+		cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
+		# nested echo to remove leading/trailing spaces
+		echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
+			>> "${JAVA_PKG_ENV}" || die
+	fi
+
+	# Strip unnecessary leading and trailing colons
+	# TODO try to cleanup if possible
+	sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
+}
+
+# @FUNCTION: java-pkg_record-jar_
+# @INTERNAL
+# @DESCRIPTION:
+# Record an (optional) dependency to the package.env
+# @CODE
+# Parameters:
+# --optional - record dependency as optional
+# --build - record dependency as build_only
+# $1 - package to record
+# $2 - (optional) jar of package to record
+# @CODE
+JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
+JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
+JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
+
+java-pkg_record-jar_() {
+	debug-print-function ${FUNCNAME} $*
+
+	local depend_file="${JAVA_PKG_DEPEND_FILE}"
+	case "${1}" in
+		"--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
+		"--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
+	esac
+
+	local pkg=${1} jar=${2} append
+	if [[ -z "${jar}" ]]; then
+		append="${pkg}"
+	else
+		append="$(basename ${jar})@${pkg}"
+	fi
+
+	echo "${append}" >> "${depend_file}"
+}
+
+# @FUNCTION: java-pkg_append_
+# @INTERNAL
+# @DESCRIPTION:
+# Appends a value to a variable
+#
+# @CODE
+# Parameters:
+# $1 variable name to modify
+# $2 value to append
+#
+# Examples:
+#	java-pkg_append_ CLASSPATH foo.jar
+# @CODE
+java-pkg_append_() {
+	debug-print-function ${FUNCNAME} $*
+
+	local var="${1}" value="${2}"
+	if [[ -z "${!var}" ]] ; then
+		export ${var}="${value}"
+	else
+		local oldIFS=${IFS} cur haveit
+		IFS=':'
+		for cur in ${!var}; do
+			if [[ ${cur} == ${value} ]]; then
+				haveit="yes"
+				break
+			fi
+		done
+		[[ -z ${haveit} ]] && export ${var}="${!var}:${value}"
+		IFS=${oldIFS}
+	fi
+}
+
+# @FUNCTION: java-pkg_expand_dir_
+# @INTERNAL
+# @DESCRIPTION:
+# Gets the full path of the file/directory's parent.
+# @CODE
+# Parameters:
+# $1 - file/directory to find parent directory for
+# @CODE
+# @RETURN: path to $1's parent directory
+java-pkg_expand_dir_() {
+	pushd "$(dirname "${1}")" >/dev/null 2>&1 || die
+	pwd
+	popd >/dev/null 2>&1 || die
+}
+
+# @FUNCTION: java-pkg_func-exists
+# @INTERNAL
+# @DESCRIPTION:
+# Does the indicated function exist?
+# @RETURN: 0 - function is declared, 1 - function is undeclared
+java-pkg_func-exists() {
+	declare -F ${1} > /dev/null
+}
+
+# @FUNCTION: java-pkg_setup-vm
+# @INTERNAL
+# @DESCRIPTION:
+# Sets up the environment for a specific VM
+java-pkg_setup-vm() {
+	debug-print-function ${FUNCNAME} $*
+
+	local vendor="$(java-pkg_get-vm-vendor)"
+	if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
+		addpredict "/dev/random"
+	elif [[ "${vendor}" == "ibm" ]]; then
+		addpredict "/proc/self/maps"
+		addpredict "/proc/cpuinfo"
+		addpredict "/proc/self/coredump_filter"
+	elif [[ "${vendor}" == "oracle" ]]; then
+		addpredict "/dev/random"
+		addpredict "/proc/self/coredump_filter"
+	elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
+		addpredict "/dev/random"
+		addpredict "/proc/self/coredump_filter"
+	elif [[ "${vendor}" == "jrockit" ]]; then
+		addpredict "/proc/cpuinfo"
+	fi
+}
+
+# @FUNCTION: java-pkg_needs-vm
+# @INTERNAL
+# @DESCRIPTION:
+# Does the current package depend on virtual/jdk or does it set
+# JAVA_PKG_WANT_BUILD_VM?
+#
+# @RETURN: 0 - Package depends on virtual/jdk; 1 - Package does not depend on virtual/jdk
+java-pkg_needs-vm() {
+	debug-print-function ${FUNCNAME} $*
+
+	if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
+		return 0
+	fi
+
+	[[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
+
+	return 1
+}
+
+# @FUNCTION: java-pkg_get-current-vm
+# @INTERNAL
+# @RETURN - The current VM being used
+java-pkg_get-current-vm() {
+	java-config -f
+}
+
+# @FUNCTION: java-pkg_get-vm-vendor
+# @INTERNAL
+# @RETURN - The vendor of the current VM
+java-pkg_get-vm-vendor() {
+	debug-print-function ${FUNCNAME} $*
+
+	local vm="$(java-pkg_get-current-vm)"
+	vm="${vm/-*/}"
+	echo "${vm}"
+}
+
+# @FUNCTION: java-pkg_get-vm-version
+# @INTERNAL
+# @RETURN - The version of the current VM
+java-pkg_get-vm-version() {
+	debug-print-function ${FUNCNAME} $*
+
+	java-config -g PROVIDES_VERSION
+}
+
+# @FUNCTION: java-pkg_build-vm-from-handle
+# @INTERNAL
+# @DESCRIPTION:
+# Selects a build vm from a list of vm handles. First checks for the system-vm
+# beeing usable, then steps through the listed handles till a suitable vm is
+# found.
+#
+# @RETURN - VM handle of an available JDK
+java-pkg_build-vm-from-handle() {
+	debug-print-function ${FUNCNAME} "$*"
+
+	local vm
+	vm=$(java-pkg_get-current-vm 2>/dev/null)
+	if [[ $? -eq 0 ]]; then
+		if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
+			echo ${vm}
+			return 0
+		fi
+	fi
+
+	for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
+		if java-config-2 --select-vm=${vm} 2>/dev/null; then
+			echo ${vm}
+			return 0
+		fi
+	done
+
+	eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
+	return 1
+}
+
+# @FUNCTION: java-pkg_switch-vm
+# @INTERNAL
+# @DESCRIPTION:
+# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
+# verify that the current VM is sufficient.
+# Setup the environment for the VM being used.
+java-pkg_switch-vm() {
+	debug-print-function ${FUNCNAME} $*
+
+	if java-pkg_needs-vm; then
+		# Use the VM specified by JAVA_PKG_FORCE_VM
+		if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
+			# If you're forcing the VM, I hope you know what your doing...
+			debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
+			export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
+		# if we're allowed to switch the vm...
+		elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
+			# if there is an explicit list of handles to choose from
+			if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
+				debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
+				GENTOO_VM=$(java-pkg_build-vm-from-handle)
+				if [[ $? != 0 ]]; then
+					eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
+					die "${FUNCNAME}: Failed to determine VM for building"
+				fi
+				# JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
+				# they can't be deduced from handles.
+				if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
+					eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
+					die "Specify JAVA_PKG_WANT_SOURCE"
+				fi
+				if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
+					eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
+					die "Specify JAVA_PKG_WANT_TARGET"
+				fi
+			# otherwise determine a vm from dep string
+			else
+				debug-print "depend-java-query:  NV_DEPEND:	${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
+				GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
+				if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
+					eerror "Unable to determine VM for building from dependencies:"
+					echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
+					die "Failed to determine VM for building."
+				fi
+			fi
+			export GENTOO_VM
+		# otherwise just make sure the current VM is sufficient
+		else
+			java-pkg_ensure-vm-version-sufficient
+		fi
+		debug-print "Using: $(java-config -f)"
+
+		java-pkg_setup-vm
+
+		export JAVA=$(java-config --java)
+		export JAVAC=$(java-config --javac)
+		JAVACFLAGS="$(java-pkg_javac-args)"
+		[[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
+		export JAVACFLAGS
+
+		export JAVA_HOME="$(java-config -g JAVA_HOME)"
+		export JDK_HOME=${JAVA_HOME}
+
+		#TODO If you know a better solution let us know.
+		java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
+
+		local tann="${T}/announced-vm"
+		# With the hooks we should only get here once from pkg_setup but better safe than sorry
+		# if people have for example modified eclasses some where
+		if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
+			einfo "Using: $(java-config -f)"
+			[[ ! -f "${tann}" ]] && touch "${tann}"
+		fi
+
+	else
+		[[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
+	fi
+}
+
+# @FUNCTION: java-pkg_die
+# @INTERNAL
+# @DESCRIPTION:
+# Enhanced die for Java packages, which displays some information that may be
+# useful for debugging bugs on bugzilla.
+#register_die_hook java-pkg_die
+if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
+	EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
+fi
+
+java-pkg_die() {
+	echo "!!! When you file a bug report, please include the following information:" >&2
+	echo "GENTOO_VM=${GENTOO_VM}  CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
+	echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
+	echo "and of course, the output of emerge --info =${P}" >&2
+}
+
+
+# TODO document
+# List jars in the source directory, ${S}
+java-pkg_jar-list() {
+	if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
+		einfo "Linked Jars"
+		find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
+		einfo "Jars"
+		find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
+		einfo "Classes"
+		find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
+	fi
+}
+
+# @FUNCTION: java-pkg_verify-classes
+# @INTERNAL
+# @DESCRIPTION:
+# Verify that the classes were compiled for the right source / target. Dies if
+# not.
+# @CODE
+# $1 (optional) - the file to check, otherwise checks whole ${D}
+# @CODE
+java-pkg_verify-classes() {
+	#$(find ${ED} -type f -name '*.jar' -o -name '*.class')
+
+	local version_verify="/usr/bin/class-version-verify.py"
+
+	if [[ ! -x "${version_verify}" ]]; then
+		version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
+	fi
+
+	if [[ ! -x "${version_verify}" ]]; then
+		ewarn "Unable to perform class version checks as"
+		ewarn "class-version-verify.py is unavailable"
+		ewarn "Please install dev-java/javatoolkit."
+		return
+	fi
+
+	local target=$(java-pkg_get-target)
+	local result
+	local log="${T}/class-version-verify.log"
+	if [[ -n "${1}" ]]; then
+		${version_verify} -v -t ${target} "${1}" > "${log}"
+		result=$?
+	else
+		ebegin "Verifying java class versions (target: ${target})"
+		${version_verify} -v -t ${target} -r "${ED}" > "${log}"
+		result=$?
+		eend ${result}
+	fi
+	[[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
+	if [[ ${result} != 0 ]]; then
+		eerror "Incorrect bytecode version found"
+		[[ -n "${1}" ]] && eerror "in file: ${1}"
+		eerror "See ${log} for more details."
+		die "Incorrect bytecode found"
+	fi
+}
+
+# @FUNCTION: java-pkg_ensure-dep
+# @INTERNAL
+# @DESCRIPTION:
+# Check that a package being used in jarfrom, getjars and getjar is contained
+# within DEPEND or RDEPEND with the correct SLOT. See this mail for details:
+# https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e
+# @CODE
+# Parameters:
+# $1 - empty - check both vars; "runtime" or "build" - check only
+#	RDEPEND, resp. DEPEND
+# $2 - Package name and slot.
+# @CODE
+java-pkg_ensure-dep() {
+	debug-print-function ${FUNCNAME} $*
+
+	local limit_to="${1}"
+	local target_pkg="${2}"
+	local dev_error=""
+
+	# Transform into a regular expression to look for a matching package
+	# and SLOT. SLOTs don't have to be numeric so foo-bar could either
+	# mean foo-bar:0 or foo:bar. So you want to get your head around the
+	# line below?
+	#
+	# * The target package first has any dots escaped, e.g. foo-1.2
+	#   becomes foo-1\.2.
+	#
+	# * sed then looks at the component following the last - or :
+	#   character, or the whole string if there is no - or :
+	#   character. It uses this to build a new regexp with two
+	#   significant branches.
+	#
+	# * The first checks for the whole target package string, optionally
+	#   followed by a version number, and then :0.
+	#
+	# * The second checks for the first part of the target package
+	#   string, optionally followed by a version number, followed by the
+	#   aforementioned component, treating that as a SLOT.
+	#
+	local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b
+
+	debug-print "Matching against: ${stripped_pkg}"
+
+	# Uncomment the lines below once we've dealt with more of these
+	# otherwise we'll be tempted to turn JAVA_PKG_STRICT off while
+	# getting hit with a wave of bug reports. :(
+
+	if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
+		dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
+		dev_error+="declared with a SLOT in DEPEND."
+#		if is-java-strict; then
+#			die "${dev_error}"
+#		else
+			eqawarn "java-pkg_ensure-dep: ${dev_error}"
+#			eerror "Because you have ${target_pkg} installed,"
+#			eerror "the package will build without problems, but please"
+#			eerror "report this to https://bugs.gentoo.org."
+#		fi
+	elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
+		dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
+		dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given."
+#		if is-java-strict; then
+#			die "${dev_error}"
+#		else
+			eqawarn "java-pkg_ensure-dep: ${dev_error}"
+#			eerror "The package will build without problems, but may fail to run"
+#			eerror "if you don't have ${target_pkg} installed,"
+#			eerror "so please report this to https://bugs.gentoo.org."
+#		fi
+	fi
+}
+
+java-pkg_check-phase() {
+	local phase=${1}
+	local funcname=${FUNCNAME[1]}
+	if [[ ${EBUILD_PHASE} != ${phase} ]]; then
+		local msg="${funcname} used outside of src_${phase}"
+		java-pkg_announce-qa-violation "${msg}"
+	fi
+}
+
+java-pkg_check-versioned-jar() {
+	local jar=${1}
+
+	if [[ ${jar} =~ ${PV} ]]; then
+		java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
+	fi
+}
+
+java-pkg_check-jikes() {
+	if has jikes ${IUSE}; then
+		java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
+	fi
+}
+
+java-pkg_announce-qa-violation() {
+	local nodie
+	if [[ ${1} == "--nodie" ]]; then
+		nodie="true"
+		shift
+	fi
+	echo "Java QA Notice: $@" >&2
+	increment-qa-violations
+	[[ -z "${nodie}" ]] && is-java-strict && die "${@}"
+}
+
+increment-qa-violations() {
+	let "JAVA_PKG_QA_VIOLATIONS+=1"
+	export JAVA_PKG_QA_VIOLATIONS
+}
+
+is-java-strict() {
+	[[ -n ${JAVA_PKG_STRICT} ]]
+	return $?
+}
+
+# @FUNCTION: java-pkg_clean
+# @DESCRIPTION:
+# Java package cleaner function. This will remove all *.class and *.jar
+# files, removing any bundled dependencies.
+java-pkg_clean() {
+	if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then
+		find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die
+	fi
+}

diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
new file mode 100644
index 0000000..5267bd1
--- /dev/null
+++ b/eclass/linux-info.eclass
@@ -0,0 +1,925 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: linux-info.eclass
+# @MAINTAINER:
+# kernel@gentoo.org
+# @AUTHOR:
+# Original author: John Mylchreest <johnm@gentoo.org>
+# @BLURB: eclass used for accessing kernel related information
+# @DESCRIPTION:
+# This eclass is used as a central eclass for accessing kernel
+# related information for source or binary already installed.
+# It is vital for linux-mod.eclass to function correctly, and is split
+# out so that any ebuild behaviour "templates" are abstracted out
+# using additional eclasses.
+#
+# "kernel config" in this file means:
+# The .config of the currently installed sources is used as the first
+# preference, with a fall-back to bundled config (/proc/config.gz) if available.
+#
+# Before using any of the config-handling functions in this eclass, you must
+# ensure that one of the following functions has been called (in order of
+# preference), otherwise you will get bugs like #364041):
+# linux-info_pkg_setup
+# linux-info_get_any_version
+# get_version
+# get_running_version
+
+# A Couple of env vars are available to effect usage of this eclass
+# These are as follows:
+
+# @ECLASS-VARIABLE: KERNEL_DIR
+# @DESCRIPTION:
+# A string containing the directory of the target kernel sources. The default value is
+# "/usr/src/linux"
+
+# @ECLASS-VARIABLE: CONFIG_CHECK
+# @DESCRIPTION:
+# A string containing a list of .config options to check for before
+# proceeding with the install.
+#
+#   e.g.: CONFIG_CHECK="MTRR"
+#
+# You can also check that an option doesn't exist by
+# prepending it with an exclamation mark (!).
+#
+#   e.g.: CONFIG_CHECK="!MTRR"
+#
+# To simply warn about a missing option, prepend a '~'.
+# It may be combined with '!'.
+#
+# In general, most checks should be non-fatal. The only time fatal checks should
+# be used is for building kernel modules or cases that a compile will fail
+# without the option.
+#
+# This is to allow usage of binary kernels, and minimal systems without kernel
+# sources.
+
+# @ECLASS-VARIABLE: ERROR_<CFG>
+# @DESCRIPTION:
+# A string containing the error message to display when the check against CONFIG_CHECK
+# fails. <CFG> should reference the appropriate option used in CONFIG_CHECK.
+#
+#   e.g.: ERROR_MTRR="MTRR exists in the .config but shouldn't!!"
+
+# @ECLASS-VARIABLE: KBUILD_OUTPUT
+# @DESCRIPTION:
+# A string passed on commandline, or set from the kernel makefile. It contains the directory
+# which is to be used as the kernel object directory.
+
+# There are also a couple of variables which are set by this, and shouldn't be
+# set by hand. These are as follows:
+
+# @ECLASS-VARIABLE: KV_FULL
+# @DESCRIPTION:
+# A read-only variable. It's a string containing the full kernel version. ie: 2.6.9-gentoo-johnm-r1
+
+# @ECLASS-VARIABLE: KV_MAJOR
+# @DESCRIPTION:
+# A read-only variable. It's an integer containing the kernel major version. ie: 2
+
+# @ECLASS-VARIABLE: KV_MINOR
+# @DESCRIPTION:
+# A read-only variable. It's an integer containing the kernel minor version. ie: 6
+
+# @ECLASS-VARIABLE: KV_PATCH
+# @DESCRIPTION:
+# A read-only variable. It's an integer containing the kernel patch version. ie: 9
+
+# @ECLASS-VARIABLE: KV_EXTRA
+# @DESCRIPTION:
+# A read-only variable. It's a string containing the kernel EXTRAVERSION. ie: -gentoo
+
+# @ECLASS-VARIABLE: KV_LOCAL
+# @DESCRIPTION:
+# A read-only variable. It's a string containing the kernel LOCALVERSION concatenation. ie: -johnm
+
+# @ECLASS-VARIABLE: KV_DIR
+# @DESCRIPTION:
+# A read-only variable. It's a string containing the kernel source directory, will be null if
+# KERNEL_DIR is invalid.
+
+# @ECLASS-VARIABLE: KV_OUT_DIR
+# @DESCRIPTION:
+# A read-only variable. It's a string containing the kernel object directory, will be KV_DIR unless
+# KBUILD_OUTPUT is used. This should be used for referencing .config.
+
+# And to ensure all the weirdness with crosscompile
+inherit toolchain-funcs versionator
+
+EXPORT_FUNCTIONS pkg_setup
+
+# Overwritable environment Var's
+# ---------------------------------------
+KERNEL_DIR="${KERNEL_DIR:-${EROOT}usr/src/linux}"
+
+
+# Bug fixes
+# fix to bug #75034
+case ${ARCH} in
+	ppc)	BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
+	ppc64)	BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
+esac
+
+# @FUNCTION: set_arch_to_kernel
+# @DESCRIPTION:
+# Set the env ARCH to match what the kernel expects.
+set_arch_to_kernel() { export ARCH=$(tc-arch-kernel); }
+# @FUNCTION: set_arch_to_portage
+# @DESCRIPTION:
+# Set the env ARCH to match what portage expects.
+set_arch_to_portage() { export ARCH=$(tc-arch); }
+
+# qeinfo "Message"
+# -------------------
+# qeinfo is a quiet einfo call when EBUILD_PHASE
+# should not have visible output.
+qout() {
+	local outputmsg type
+	type=${1}
+	shift
+	outputmsg="${@}"
+	case "${EBUILD_PHASE}" in
+		depend)  unset outputmsg;;
+		clean)   unset outputmsg;;
+		preinst) unset outputmsg;;
+	esac
+	[ -n "${outputmsg}" ] && ${type} "${outputmsg}"
+}
+
+qeinfo() { qout einfo "${@}" ; }
+qewarn() { qout ewarn "${@}" ; }
+qeerror() { qout eerror "${@}" ; }
+
+# File Functions
+# ---------------------------------------
+
+# @FUNCTION: getfilevar
+# @USAGE: variable configfile
+# @RETURN: the value of the variable
+# @DESCRIPTION:
+# It detects the value of the variable defined in the file configfile. This is
+# done by including the configfile, and printing the variable with Make.
+# It WILL break if your makefile has missing dependencies!
+getfilevar() {
+	local ERROR basefname basedname myARCH="${ARCH}" M="${S}"
+	ERROR=0
+
+	[ -z "${1}" ] && ERROR=1
+	[ ! -f "${2}" ] && ERROR=1
+
+	if [ "${ERROR}" = 1 ]
+	then
+		echo -e "\n"
+		eerror "getfilevar requires 2 variables, with the second a valid file."
+		eerror "   getfilevar <VARIABLE> <CONFIGFILE>"
+	else
+		basefname="$(basename ${2})"
+		basedname="$(dirname ${2})"
+		unset ARCH
+
+		# We use nonfatal because we want the caller to take care of things #373151
+		[[ ${EAPI:-0} == [0123] ]] && nonfatal() { "$@"; }
+		case ${EBUILD_PHASE_FUNC} in
+			pkg_info|pkg_nofetch|pkg_pretend) M="${T}" ;;
+		esac
+		echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \
+			nonfatal emake -C "${basedname}" M="${M}" ${BUILD_FIXES} -s -f - 2>/dev/null
+
+		ARCH=${myARCH}
+	fi
+}
+
+# @FUNCTION: getfilevar_noexec
+# @USAGE: variable configfile
+# @RETURN: the value of the variable
+# @DESCRIPTION:
+# It detects the value of the variable defined in the file configfile.
+# This is done with sed matching an expression only. If the variable is defined,
+# you will run into problems. See getfilevar for those cases.
+getfilevar_noexec() {
+	local ERROR basefname basedname mycat myARCH="${ARCH}"
+	ERROR=0
+	mycat='cat'
+
+	[ -z "${1}" ] && ERROR=1
+	[ ! -f "${2}" ] && ERROR=1
+	[ "${2%.gz}" != "${2}" ] && mycat='zcat'
+
+	if [ "${ERROR}" = 1 ]
+	then
+		echo -e "\n"
+		eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
+		eerror "   getfilevar_noexec <VARIABLE> <CONFIGFILE>"
+	else
+		${mycat} "${2}" | \
+		sed -n \
+		-e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
+			s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
+			s,[[:space:]]*\$,,g ;
+			p
+		}"
+	fi
+}
+
+# @ECLASS-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
+# @INTERNAL
+# @DESCRIPTION:
+# This is only set if one of the linux_config_*exists functions has been called.
+# We use it for a QA warning that the check for a config has not been performed,
+# as linux_chkconfig* in non-legacy mode WILL return an undefined value if no
+# config is available at all.
+_LINUX_CONFIG_EXISTS_DONE=
+
+linux_config_qa_check() {
+	local f="$1"
+	if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
+		ewarn "QA: You called $f before any linux_config_exists!"
+		ewarn "QA: The return value of $f will NOT guaranteed later!"
+	fi
+}
+
+# @FUNCTION: linux_config_src_exists
+# @RETURN: true or false
+# @DESCRIPTION:
+# It returns true if .config exists in a build directory otherwise false
+linux_config_src_exists() {
+	export _LINUX_CONFIG_EXISTS_DONE=1
+	[[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
+}
+
+# @FUNCTION: linux_config_bin_exists
+# @RETURN: true or false
+# @DESCRIPTION:
+# It returns true if .config exists in /proc, otherwise false
+linux_config_bin_exists() {
+	export _LINUX_CONFIG_EXISTS_DONE=1
+	[[ -s /proc/config.gz ]]
+}
+
+# @FUNCTION: linux_config_exists
+# @RETURN: true or false
+# @DESCRIPTION:
+# It returns true if .config exists otherwise false
+#
+# This function MUST be checked before using any of the linux_chkconfig_*
+# functions.
+linux_config_exists() {
+	linux_config_src_exists || linux_config_bin_exists
+}
+
+# @FUNCTION: linux_config_path
+# @DESCRIPTION:
+# Echo the name of the config file to use.  If none are found,
+# then return false.
+linux_config_path() {
+	if linux_config_src_exists; then
+		echo "${KV_OUT_DIR}/.config"
+	elif linux_config_bin_exists; then
+		echo "/proc/config.gz"
+	else
+		return 1
+	fi
+}
+
+# @FUNCTION: require_configured_kernel
+# @DESCRIPTION:
+# This function verifies that the current kernel is configured (it checks against the existence of .config)
+# otherwise it dies.
+require_configured_kernel() {
+	if ! linux_config_src_exists; then
+		qeerror "Could not find a usable .config in the kernel source directory."
+		qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
+		qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
+		qeerror "it points to the necessary object directory so that it might find .config."
+		die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
+	fi
+}
+
+# @FUNCTION: linux_chkconfig_present
+# @USAGE: option
+# @RETURN: true or false
+# @DESCRIPTION:
+# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
+# If linux_config_exists returns false, the results of this are UNDEFINED. You
+# MUST call linux_config_exists first.
+linux_chkconfig_present() {
+	linux_config_qa_check linux_chkconfig_present
+	[[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
+}
+
+# @FUNCTION: linux_chkconfig_module
+# @USAGE: option
+# @RETURN: true or false
+# @DESCRIPTION:
+# It checks that CONFIG_<option>=m is present in the current kernel .config
+# If linux_config_exists returns false, the results of this are UNDEFINED. You
+# MUST call linux_config_exists first.
+linux_chkconfig_module() {
+	linux_config_qa_check linux_chkconfig_module
+	[[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
+}
+
+# @FUNCTION: linux_chkconfig_builtin
+# @USAGE: option
+# @RETURN: true or false
+# @DESCRIPTION:
+# It checks that CONFIG_<option>=y is present in the current kernel .config
+# If linux_config_exists returns false, the results of this are UNDEFINED. You
+# MUST call linux_config_exists first.
+linux_chkconfig_builtin() {
+	linux_config_qa_check linux_chkconfig_builtin
+	[[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
+}
+
+# @FUNCTION: linux_chkconfig_string
+# @USAGE: option
+# @RETURN: CONFIG_<option>
+# @DESCRIPTION:
+# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
+# If linux_config_exists returns false, the results of this are UNDEFINED. You
+# MUST call linux_config_exists first.
+linux_chkconfig_string() {
+	linux_config_qa_check linux_chkconfig_string
+	getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
+}
+
+# Versioning Functions
+# ---------------------------------------
+
+# @FUNCTION: kernel_is
+# @USAGE: [-lt -gt -le -ge -eq] major_number [minor_number patch_number]
+# @RETURN: true or false
+# @DESCRIPTION:
+# It returns true when the current kernel version satisfies the comparison against the passed version.
+# -eq is the default comparison.
+#
+# @CODE
+# For Example where KV = 2.6.9
+# kernel_is 2 4   returns false
+# kernel_is 2     returns true
+# kernel_is 2 6   returns true
+# kernel_is 2 6 8 returns false
+# kernel_is 2 6 9 returns true
+# @CODE
+
+# Note: duplicated in kernel-2.eclass
+kernel_is() {
+	# if we haven't determined the version yet, we need to.
+	linux-info_get_any_version
+
+	# Now we can continue
+	local operator test value
+
+	case ${1#-} in
+	  lt) operator="-lt"; shift;;
+	  gt) operator="-gt"; shift;;
+	  le) operator="-le"; shift;;
+	  ge) operator="-ge"; shift;;
+	  eq) operator="-eq"; shift;;
+	   *) operator="-eq";;
+	esac
+	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
+
+	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
+	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
+	[ ${test} ${operator} ${value} ]
+}
+
+get_localversion() {
+	local lv_list i x
+
+	# ignore files with ~ in it.
+	for i in $(ls ${1}/localversion* 2>/dev/null); do
+		[[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}"
+	done
+
+	for i in ${lv_list}; do
+		x="${x}$(<${i})"
+	done
+	x=${x/ /}
+	echo ${x}
+}
+
+# Check if the Makefile is valid for direct parsing.
+# Check status results:
+# - PASS, use 'getfilevar' to extract values
+# - FAIL, use 'getfilevar_noexec' to extract values
+# The check may fail if:
+# - make is not present
+# - corruption exists in the kernel makefile
+get_makefile_extract_function() {
+	local a='' b='' mkfunc='getfilevar'
+	a="$(getfilevar VERSION ${KERNEL_MAKEFILE})"
+	b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})"
+	[[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec'
+	echo "${mkfunc}"
+}
+
+# internal variable, so we know to only print the warning once
+get_version_warning_done=
+
+# @FUNCTION: get_version
+# @DESCRIPTION:
+# It gets the version of the kernel inside KERNEL_DIR and populates the KV_FULL variable
+# (if KV_FULL is already set it does nothing).
+#
+# The kernel version variables (KV_MAJOR, KV_MINOR, KV_PATCH, KV_EXTRA and KV_LOCAL) are also set.
+#
+# The KV_DIR is set using the KERNEL_DIR env var, the KV_DIR_OUT is set using a valid
+# KBUILD_OUTPUT (in a decreasing priority list, we look for the env var, makefile var or the
+# symlink /lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build).
+get_version() {
+	local tmplocal
+
+	# no need to execute this twice assuming KV_FULL is populated.
+	# we can force by unsetting KV_FULL
+	[ -n "${KV_FULL}" ] && return 0
+
+	# if we dont know KV_FULL, then we need too.
+	# make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
+	unset KV_DIR
+
+	# KV_DIR will contain the full path to the sources directory we should use
+	[ -z "${get_version_warning_done}" ] && \
+	qeinfo "Determining the location of the kernel source code"
+	[ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
+	[ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
+
+	if [ -z "${KV_DIR}" ]
+	then
+		if [ -z "${get_version_warning_done}" ]; then
+			get_version_warning_done=1
+			qewarn "Unable to find kernel sources at ${KERNEL_DIR}"
+			#qeinfo "This package requires Linux sources."
+			if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then
+				qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, "
+				qeinfo "(or the kernel you wish to build against)."
+				qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location"
+			else
+				qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against."
+			fi
+		fi
+		return 1
+	fi
+
+	# See if the kernel dir is actually an output dir. #454294
+	if [ -z "${KBUILD_OUTPUT}" -a -L "${KERNEL_DIR}/source" ]; then
+		KBUILD_OUTPUT=${KERNEL_DIR}
+		KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source")
+		KV_DIR=${KERNEL_DIR}
+	fi
+
+	if [ -z "${get_version_warning_done}" ]; then
+		qeinfo "Found kernel source directory:"
+		qeinfo "    ${KV_DIR}"
+	fi
+
+	if [ ! -s "${KV_DIR}/Makefile" ]
+	then
+		if [ -z "${get_version_warning_done}" ]; then
+			get_version_warning_done=1
+			qeerror "Could not find a Makefile in the kernel source directory."
+			qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources"
+		fi
+		return 1
+	fi
+
+	# OK so now we know our sources directory, but they might be using
+	# KBUILD_OUTPUT, and we need this for .config and localversions-*
+	# so we better find it eh?
+	# do we pass KBUILD_OUTPUT on the CLI?
+	local OUTPUT_DIR=${KBUILD_OUTPUT}
+
+	# keep track of it
+	KERNEL_MAKEFILE="${KV_DIR}/Makefile"
+
+	if [[ -z ${OUTPUT_DIR} ]]; then
+		# Decide the function used to extract makefile variables.
+		local mkfunc=$(get_makefile_extract_function "${KERNEL_MAKEFILE}")
+
+		# And if we didn't pass it, we can take a nosey in the Makefile.
+		OUTPUT_DIR=$(${mkfunc} KBUILD_OUTPUT "${KERNEL_MAKEFILE}")
+	fi
+
+	# And contrary to existing functions I feel we shouldn't trust the
+	# directory name to find version information as this seems insane.
+	# So we parse ${KERNEL_MAKEFILE}.  We should be able to trust that
+	# the Makefile is simple enough to use the noexec extract function.
+	# This has been true for every release thus far, and it's faster
+	# than using make to evaluate the Makefile every time.
+	KV_MAJOR=$(getfilevar_noexec VERSION "${KERNEL_MAKEFILE}")
+	KV_MINOR=$(getfilevar_noexec PATCHLEVEL "${KERNEL_MAKEFILE}")
+	KV_PATCH=$(getfilevar_noexec SUBLEVEL "${KERNEL_MAKEFILE}")
+	KV_EXTRA=$(getfilevar_noexec EXTRAVERSION "${KERNEL_MAKEFILE}")
+
+	if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
+	then
+		if [ -z "${get_version_warning_done}" ]; then
+			get_version_warning_done=1
+			qeerror "Could not detect kernel version."
+			qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
+		fi
+		return 1
+	fi
+
+	# and in newer versions we can also pull LOCALVERSION if it is set.
+	# but before we do this, we need to find if we use a different object directory.
+	# This *WILL* break if the user is using localversions, but we assume it was
+	# caught before this if they are.
+	if [[ -z ${OUTPUT_DIR} ]] ; then
+		# Try to locate a kernel that is most relevant for us.
+		for OUTPUT_DIR in "${SYSROOT}" "${ROOT}" "" ; do
+			OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build"
+			if [[ -e ${OUTPUT_DIR} ]] ; then
+				break
+			fi
+		done
+	fi
+
+	[ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
+	[ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
+	if [ -n "${KV_OUT_DIR}" ];
+	then
+		qeinfo "Found kernel object directory:"
+		qeinfo "    ${KV_OUT_DIR}"
+	fi
+	# and if we STILL have not got it, then we better just set it to KV_DIR
+	KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
+
+	# Grab the kernel release from the output directory.
+	# TODO: we MUST detect kernel.release being out of date, and 'return 1' from
+	# this function.
+	if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
+		KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release)
+	elif [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
+		KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease)
+	else
+		KV_LOCAL=
+	fi
+
+	# KV_LOCAL currently contains the full release; discard the first bits.
+	tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}}
+
+	# If the updated local version was not changed, the tree is not prepared.
+	# Clear out KV_LOCAL in that case.
+	# TODO: this does not detect a change in the localversion part between
+	# kernel.release and the value that would be generated.
+	if [ "$KV_LOCAL" = "$tmplocal" ]; then
+		KV_LOCAL=
+	else
+		KV_LOCAL=$tmplocal
+	fi
+
+	# And we should set KV_FULL to the full expanded version
+	KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
+
+	qeinfo "Found sources for kernel version:"
+	qeinfo "    ${KV_FULL}"
+
+	return 0
+}
+
+# @FUNCTION: get_running_version
+# @DESCRIPTION:
+# It gets the version of the current running kernel and the result is the same as get_version() if the
+# function can find the sources.
+get_running_version() {
+	KV_FULL=$(uname -r)
+
+	if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+		KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
+		KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+		unset KV_FULL
+		get_version
+		return $?
+	elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
+		KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
+		unset KV_FULL
+		get_version
+		return $?
+	elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+		KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+		unset KV_FULL
+		get_version
+		return $?
+	else
+		# This handles a variety of weird kernel versions.  Make sure to update
+		# tests/linux-info_get_running_version.sh if you want to change this.
+		local kv_full=${KV_FULL//[-+_]*}
+		KV_MAJOR=$(get_version_component_range 1 ${kv_full})
+		KV_MINOR=$(get_version_component_range 2 ${kv_full})
+		KV_PATCH=$(get_version_component_range 3 ${kv_full})
+		KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
+		: ${KV_PATCH:=0}
+	fi
+	return 0
+}
+
+# This next function is named with the eclass prefix to avoid conflicts with
+# some old versionator-like eclass functions.
+
+# @FUNCTION: linux-info_get_any_version
+# @DESCRIPTION:
+# This attempts to find the version of the sources, and otherwise falls back to
+# the version of the running kernel.
+linux-info_get_any_version() {
+	get_version
+	if [[ $? -ne 0 ]]; then
+		ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
+		get_running_version
+	fi
+}
+
+
+# ebuild check functions
+# ---------------------------------------
+
+# @FUNCTION: check_kernel_built
+# @DESCRIPTION:
+# This function verifies that the current kernel sources have been already prepared otherwise it dies.
+check_kernel_built() {
+	# if we haven't determined the version yet, we need to
+	require_configured_kernel
+	get_version
+
+	local versionh_path
+	if kernel_is -ge 3 7; then
+		versionh_path="include/generated/uapi/linux/version.h"
+	else
+		versionh_path="include/linux/version.h"
+	fi
+
+	if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]
+	then
+		eerror "These sources have not yet been prepared."
+		eerror "We cannot build against an unprepared tree."
+		eerror "To resolve this, please type the following:"
+		eerror
+		eerror "# cd ${KV_DIR}"
+		eerror "# make oldconfig"
+		eerror "# make modules_prepare"
+		eerror
+		eerror "Then please try merging this module again."
+		die "Kernel sources need compiling first"
+	fi
+}
+
+# @FUNCTION: check_modules_supported
+# @DESCRIPTION:
+# This function verifies that the current kernel support modules (it checks CONFIG_MODULES=y) otherwise it dies.
+check_modules_supported() {
+	# if we haven't determined the version yet, we need too.
+	require_configured_kernel
+	get_version
+
+	if ! linux_chkconfig_builtin "MODULES"; then
+		eerror "These sources do not support loading external modules."
+		eerror "to be able to use this module please enable \"Loadable modules support\""
+		eerror "in your kernel, recompile and then try merging this module again."
+		die "No support for external modules in ${KV_FULL} config"
+	fi
+}
+
+# @FUNCTION: check_extra_config
+# @DESCRIPTION:
+# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e.
+# the prefix ~ is not used) doesn't satisfy the directive.
+check_extra_config() {
+	local config negate die error reworkmodulenames
+	local soft_errors_count=0 hard_errors_count=0 config_required=0
+	# store the value of the QA check, because otherwise we won't catch usages
+	# after if check_extra_config is called AND other direct calls are done
+	# later.
+	local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}"
+
+	# if we haven't determined the version yet, we need to
+	linux-info_get_any_version
+
+	# Determine if we really need a .config. The only time when we don't need
+	# one is when all of the CONFIG_CHECK options are prefixed with "~".
+	for config in ${CONFIG_CHECK}; do
+		if [[ "${config:0:1}" != "~" ]]; then
+			config_required=1
+			break
+		fi
+	done
+
+	if [[ ${config_required} == 0 ]]; then
+		# In the case where we don't require a .config, we can now bail out
+		# if the user has no .config as there is nothing to do. Otherwise
+		# code later will cause a failure due to missing .config.
+		if ! linux_config_exists; then
+			ewarn "Unable to check for the following kernel config options due"
+			ewarn "to absence of any configured kernel sources or compiled"
+			ewarn "config:"
+			for config in ${CONFIG_CHECK}; do
+				config=${config#\~}
+				config=${config#\!}
+				local_error="ERROR_${config}"
+				msg="${!local_error}"
+				if [[ -z ${msg} ]]; then
+					local_error="WARNING_${config}"
+					msg="${!local_error}"
+				fi
+				ewarn " - ${config}${msg:+ - }${msg}"
+			done
+			ewarn "You're on your own to make sure they are set if needed."
+			export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
+			return 0
+		fi
+	else
+		require_configured_kernel
+	fi
+
+	einfo "Checking for suitable kernel configuration options..."
+
+	for config in ${CONFIG_CHECK}
+	do
+		# if we specify any fatal, ensure we honor them
+		die=1
+		error=0
+		negate=0
+		reworkmodulenames=0
+
+		if [[ ${config:0:1} == "~" ]]; then
+			die=0
+			config=${config:1}
+		elif [[ ${config:0:1} == "@" ]]; then
+			die=0
+			reworkmodulenames=1
+			config=${config:1}
+		fi
+		if [[ ${config:0:1} == "!" ]]; then
+			negate=1
+			config=${config:1}
+		fi
+
+		if [[ ${negate} == 1 ]]; then
+			linux_chkconfig_present ${config} && error=2
+		elif [[ ${reworkmodulenames} == 1 ]]; then
+			local temp_config="${config//*:}" i n
+			config="${config//:*}"
+			if linux_chkconfig_present ${config}; then
+				for i in ${MODULE_NAMES}; do
+					n="${i//${temp_config}}"
+					[[ -z ${n//\(*} ]] && \
+						MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}"
+				done
+				error=2
+			fi
+		else
+			linux_chkconfig_present ${config} || error=1
+		fi
+
+		if [[ ${error} > 0 ]]; then
+			local report_func="eerror" local_error
+			local_error="ERROR_${config}"
+			local_error="${!local_error}"
+
+			if [[ -z "${local_error}" ]]; then
+				# using old, deprecated format.
+				local_error="${config}_ERROR"
+				local_error="${!local_error}"
+			fi
+			if [[ ${die} == 0 && -z "${local_error}" ]]; then
+				#soft errors can be warnings
+				local_error="WARNING_${config}"
+				local_error="${!local_error}"
+				if [[ -n "${local_error}" ]] ; then
+					report_func="ewarn"
+				fi
+			fi
+
+			if [[ -z "${local_error}" ]]; then
+				[[ ${error} == 1 ]] \
+					&& local_error="is not set when it should be." \
+					|| local_error="should not be set. But it is."
+				local_error="CONFIG_${config}:\t ${local_error}"
+			fi
+			if [[ ${die} == 0 ]]; then
+				${report_func} "  ${local_error}"
+				soft_errors_count=$[soft_errors_count + 1]
+			else
+				${report_func} "  ${local_error}"
+				hard_errors_count=$[hard_errors_count + 1]
+			fi
+		fi
+	done
+
+	if [[ ${hard_errors_count} > 0 ]]; then
+		eerror "Please check to make sure these options are set correctly."
+		eerror "Failure to do so may cause unexpected problems."
+		eerror "Once you have satisfied these options, please try merging"
+		eerror "this package again."
+		export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
+		die "Incorrect kernel configuration options"
+	elif [[ ${soft_errors_count} > 0 ]]; then
+		ewarn "Please check to make sure these options are set correctly."
+		ewarn "Failure to do so may cause unexpected problems."
+	else
+		eend 0
+	fi
+	export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
+}
+
+check_zlibinflate() {
+	# if we haven't determined the version yet, we need to
+	require_configured_kernel
+	get_version
+
+	# although I restructured this code - I really really really dont support it!
+
+	# bug #27882 - zlib routines are only linked into the kernel
+	# if something compiled into the kernel calls them
+	#
+	# plus, for the cloop module, it appears that there's no way
+	# to get cloop.o to include a static zlib if CONFIG_MODVERSIONS
+	# is on
+
+	local INFLATE
+	local DEFLATE
+
+	einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
+
+	ebegin "checking ZLIB_INFLATE"
+	linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
+	eend $?
+	[ "$?" != 0 ] && die
+
+	ebegin "checking ZLIB_DEFLATE"
+	linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
+	eend $?
+	[ "$?" != 0 ] && die
+
+	local LINENO_START
+	local LINENO_END
+	local SYMBOLS
+	local x
+
+	LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)"
+	LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)"
+	(( LINENO_AMOUNT = $LINENO_END - $LINENO_START ))
+	(( LINENO_END = $LINENO_END - 1 ))
+	SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')"
+
+	# okay, now we have a list of symbols
+	# we need to check each one in turn, to see whether it is set or not
+	for x in $SYMBOLS ; do
+		if [ "${!x}" = "y" ]; then
+			# we have a winner!
+			einfo "${x} ensures zlib is linked into your kernel - excellent"
+			return 0
+		fi
+	done
+
+	eerror
+	eerror "This kernel module requires ZLIB library support."
+	eerror "You have enabled zlib support in your kernel, but haven't enabled"
+	eerror "enabled any option that will ensure that zlib is linked into your"
+	eerror "kernel."
+	eerror
+	eerror "Please ensure that you enable at least one of these options:"
+	eerror
+
+	for x in $SYMBOLS ; do
+		eerror "  * $x"
+	done
+
+	eerror
+	eerror "Please remember to recompile and install your kernel, and reboot"
+	eerror "into your new kernel before attempting to load this kernel module."
+
+	die "Kernel doesn't include zlib support"
+}
+
+################################
+# Default pkg_setup
+# Also used when inheriting linux-mod to force a get_version call
+# @FUNCTION: linux-info_pkg_setup
+# @DESCRIPTION:
+# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured
+# to support the options specified in CONFIG_CHECK (if not null)
+linux-info_pkg_setup() {
+	linux-info_get_any_version
+
+	if kernel_is 2 4; then
+		if [ "$( gcc-major-version )" -eq "4" ] ; then
+			echo
+			ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with"
+			ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!"
+			echo
+			ewarn "Either switch to another gcc-version (via gcc-config) or use a"
+			ewarn "newer kernel that supports gcc-4."
+			echo
+			ewarn "Also be aware that bugreports about gcc-4 not working"
+			ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
+			echo
+			epause 10
+		fi
+	fi
+
+	[ -n "${CONFIG_CHECK}" ] && check_extra_config;
+}

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 27ff44a..ca64091 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -136,7 +136,7 @@ else
 	LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
 fi
 
-IUSE="multislot regression-test vanilla"
+IUSE="regression-test vanilla"
 IUSE_DEF=( nls nptl )
 
 if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
@@ -159,7 +159,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
 	tc_version_is_at_least 4.8 && IUSE+=" graphite" IUSE_DEF+=( sanitize )
 	tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv"
 	tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
-	tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
+	tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch"
 fi
 
 IUSE+=" ${IUSE_DEF[*]/#/+}"
@@ -631,6 +631,50 @@ do_gcc_PIE_patches() {
 
 # configure to build with the hardened GCC specs as the default
 make_gcc_hard() {
+
+	local gcc_hard_flags=""
+	# Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
+	if tc_version_is_at_least 6.0 ; then
+		if use pie ; then
+			einfo "Updating gcc to use automatic PIE building ..."
+		fi
+		if use ssp ; then
+			einfo "Updating gcc to use automatic SSP building ..."
+		fi
+		if use hardened ; then
+			# Will add some optimatizion as default.
+			gcc_hard_flags+=" -DEXTRA_OPTIONS"
+			# rebrand to make bug reports easier
+			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+		fi
+	else
+		if use hardened ; then
+			# rebrand to make bug reports easier
+			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+			if hardened_gcc_works ; then
+				einfo "Updating gcc to use automatic PIE + SSP building ..."
+				gcc_hard_flags+=" -DEFAULT_PIE_SSP"
+			elif hardened_gcc_works pie ; then
+				einfo "Updating gcc to use automatic PIE building ..."
+				ewarn "SSP has not been enabled by default"
+				gcc_hard_flags+=" -DEFAULT_PIE"
+			elif hardened_gcc_works ssp ; then
+				einfo "Updating gcc to use automatic SSP building ..."
+				ewarn "PIE has not been enabled by default"
+				gcc_hard_flags+=" -DEFAULT_SSP"
+			else
+				# do nothing if hardened isn't supported, but don't die either
+				ewarn "hardened is not supported for this arch in this gcc version"
+				return 0
+			fi
+		else
+			if hardened_gcc_works ssp ; then
+				einfo "Updating gcc to use automatic SSP building ..."
+				gcc_hard_flags+=" -DEFAULT_SSP"
+			fi
+		fi
+	fi
+
 	# we want to be able to control the pie patch logic via something other
 	# than ALL_CFLAGS...
 	sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
@@ -639,36 +683,8 @@ make_gcc_hard() {
 	# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
 	if tc_version_is_at_least 4.7 ; then
 		sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
-						-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-						-i "${S}"/gcc/Makefile.in
-	fi
-
-	# defaults to enable for all toolchains
-	local gcc_hard_flags=""
-	if use hardened ; then
-		if hardened_gcc_works ; then
-			einfo "Updating gcc to use automatic PIE + SSP building ..."
-			gcc_hard_flags+=" -DEFAULT_PIE_SSP"
-		elif hardened_gcc_works pie ; then
-			einfo "Updating gcc to use automatic PIE building ..."
-			ewarn "SSP has not been enabled by default"
-			gcc_hard_flags+=" -DEFAULT_PIE"
-		elif hardened_gcc_works ssp ; then
-			einfo "Updating gcc to use automatic SSP building ..."
-			ewarn "PIE has not been enabled by default"
-			gcc_hard_flags+=" -DEFAULT_SSP"
-		else
-			# do nothing if hardened isn't supported, but don't die either
-			ewarn "hardened is not supported for this arch in this gcc version"
-			return 0
-		fi
-		# rebrand to make bug reports easier
-		BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
-	else
-		if hardened_gcc_works ssp ; then
-			einfo "Updating gcc to use automatic SSP building ..."
-			gcc_hard_flags+=" -DEFAULT_SSP"
-		fi
+			-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
+			-i "${S}"/gcc/Makefile.in
 	fi
 
 	sed -i \
@@ -904,6 +920,11 @@ toolchain_src_configure() {
 		confgcc+=( --enable-libstdcxx-time )
 	fi
 
+	# Support to disable pch when building libstdcxx
+	if tc_version_is_at_least 6.0 && ! use pch ; then
+		confgcc+=( --disable-libstdcxx-pch )
+	fi
+
 	# The jit language requires this.
 	is_jit && confgcc+=( --enable-host-shared )
 
@@ -1862,7 +1883,7 @@ gcc_movelibs() {
 			if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
 				local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
 				if [[ -n ${files} ]] ; then
-					mv ${files} "${TODIR}"
+					mv ${files} "${TODIR}" || die
 				fi
 			fi
 		done
@@ -1940,7 +1961,7 @@ create_gcc_env_entry() {
 		local mdir mosdir abi ldpath
 		for abi in $(get_all_abis TARGET) ; do
 			mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
-			ldpath="${LIBPATH}"
+			ldpath=${LIBPATH}
 			[[ ${mdir} != "." ]] && ldpath+="/${mdir}"
 			ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
 
@@ -1949,7 +1970,7 @@ create_gcc_env_entry() {
 		done
 	else
 		# Older gcc's didn't do multilib, so logic is simple.
-		ldpaths="${LIBPATH}"
+		ldpaths=${LIBPATH}
 	fi
 
 	cat <<-EOF > ${gcc_envd_file}
@@ -1967,6 +1988,11 @@ create_gcc_env_entry() {
 }
 
 copy_minispecs_gcc_specs() {
+	# on gcc 6 we don't need minispecs
+	if tc_version_is_at_least 6.0 ; then
+		return 0
+	fi
+
 	# setup the hardenedno* specs files and the vanilla specs file.
 	if hardened_gcc_works ; then
 		create_gcc_env_entry hardenednopiessp
@@ -2148,10 +2174,6 @@ should_we_gcc_config() {
 
 	local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
 
-	# If we're using multislot, just run gcc-config if we're installing
-	# to the same profile as the current one.
-	use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
-
 	if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
 		return 0
 	else
@@ -2312,6 +2334,10 @@ hardened_gcc_is_stable() {
 }
 
 want_minispecs() {
+	# on gcc 6 we don't need minispecs
+	if tc_version_is_at_least 6.0 ; then
+		return 0
+	fi
 	if tc_version_is_at_least 4.3.2 && use hardened ; then
 		if ! want_pie ; then
 			ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2017-02-09  4:52 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2017-02-09  4:52 UTC (permalink / raw
  To: gentoo-commits

commit:     53e9bfd4ab6a03c036ec7f95e666cd45fc466e63
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu Feb  9 04:51:55 2017 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu Feb  9 04:51:55 2017 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=53e9bfd4

java-utils-2.eclass: merged.

 eclass/java-utils-2.eclass | 2888 --------------------------------------------
 1 file changed, 2888 deletions(-)

diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
deleted file mode 100644
index b4246b3..0000000
--- a/eclass/java-utils-2.eclass
+++ /dev/null
@@ -1,2888 +0,0 @@
-# Copyright 2004-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: java-utils-2.eclass
-# @MAINTAINER:
-# java@gentoo.org
-# @AUTHOR:
-# Thomas Matthijs <axxo@gentoo.org>, Karl Trygve Kalleberg <karltk@gentoo.org>
-# @BLURB: Base eclass for Java packages
-# @DESCRIPTION:
-# This eclass provides functionality which is used by java-pkg-2.eclass,
-# java-pkg-opt-2.eclass and java-ant-2 eclass, as well as from ebuilds.
-#
-# This eclass should not be inherited this directly from an ebuild. Instead,
-# you should inherit java-pkg-2 for Java packages or java-pkg-opt-2 for packages
-# that have optional Java support. In addition you can inherit java-ant-2 for
-# Ant-based packages.
-inherit eutils versionator multilib
-
-IUSE="elibc_FreeBSD"
-
-# Make sure we use java-config-2
-export WANT_JAVA_CONFIG="2"
-
-# @VARIABLE: JAVA_PKG_PORTAGE_DEP
-# @INTERNAL
-# @DESCRIPTION:
-# The version of portage we need to function properly. Previously it was
-# portage with phase hooks support but now we use a version with proper env
-# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
-has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
-
-# @VARIABLE: JAVA_PKG_E_DEPEND
-# @INTERNAL
-# @DESCRIPTION:
-# This is a convience variable to be used from the other java eclasses. This is
-# the version of java-config we want to use. Usually the latest stable version
-# so that ebuilds can use new features without depending on specific versions.
-JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3 ${JAVA_PKG_PORTAGE_DEP}"
-has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
-
-# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# The version of bootclasspath the package needs to work. Translates to a proper
-# dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath
-if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
-	if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
-		JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
-	else
-		eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
-		# since die in global scope doesn't work, this will make repoman fail
-		JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
-	fi
-fi
-
-# @ECLASS-VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE
-# @DESCRIPTION:
-# Allow this eclass to change the active VM?
-# If your system VM isn't sufficient for the package, the build will fail
-# instead of trying to switch to another VM.
-#
-# Overriding the default can be useful for testing specific VMs locally, but
-# should not be used in the final ebuild.
-JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
-
-# @ECLASS-VARIABLE: JAVA_PKG_FORCE_VM
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Explicitly set a particular VM to use. If its not valid, it'll fall back to
-# whatever /etc/java-config-2/build/jdk.conf would elect to use.
-#
-# Should only be used for testing and debugging.
-#
-# Example: use sun-jdk-1.5 to emerge foo:
-# @CODE
-#	JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
-# @CODE
-
-# @ECLASS-VARIABLE: JAVA_PKG_WANT_BUILD_VM
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# A list of VM handles to choose a build VM from. If the list contains the
-# currently active VM use that one, otherwise step through the list till a
-# usable/installed VM is found.
-#
-# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
-# Users of this variable must make sure at least one of the listed handles is
-# covered by DEPEND.
-# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
-
-# @ECLASS-VARIABLE: JAVA_PKG_WANT_SOURCE
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Specify a non-standard Java source version for compilation (via javac -source
-# parameter or Ant equivalent via build.xml rewriting done by java-ant-2 eclass).
-# Normally this is determined from the jdk version specified in DEPEND.
-# See java-pkg_get-source function below.
-#
-# Should generally only be used for testing and debugging.
-#
-# Use 1.4 source to emerge baz
-# @CODE
-#	JAVA_PKG_WANT_SOURCE=1.4 emerge baz
-# @CODE
-
-# @ECLASS-VARIABLE: JAVA_PKG_WANT_TARGET
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Same as JAVA_PKG_WANT_SOURCE (see above) but for javac -target parameter,
-# which affects the version of generated bytecode.
-# Normally this is determined from the jre/jdk version specified in RDEPEND.
-# See java-pkg_get-target function below.
-#
-# Should generallyonly be used for testing and debugging.
-#
-# emerge bar to be compatible with 1.3
-# @CODE
-#	JAVA_PKG_WANT_TARGET=1.3 emerge bar
-# @CODE
-
-# @ECLASS-VARIABLE: JAVA_PKG_DEBUG
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# A variable to be set with "yes" or "y", or ANY string of length non equal to
-# zero. When set, verbosity across java eclasses is increased and extra
-# logging is displayed.
-# @CODE
-#	JAVA_PKG_DEBUG="yes"
-# @CODE
-
-# @ECLASS-VARIABLE: JAVA_RM_FILES
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# An array containing a list of files to remove. If defined, this array will be
-# automatically handed over to java-pkg_rm_files for processing during the
-# src_prepare phase.
-#
-# @CODE
-#	JAVA_RM_FILES=(
-#		path/to/File1.java
-#		DELETEME.txt
-#	)
-# @CODE
-
-# @VARIABLE: JAVA_PKG_COMPILER_DIR
-# @INTERNAL
-# @DESCRIPTION:
-# Directory where compiler settings are saved, without trailing slash.
-# You probably shouldn't touch this variable except local testing.
-JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
-
-# @VARIABLE: JAVA_PKG_COMPILERS_CONF
-# @INTERNAL
-# @DESCRIPTION:
-# Path to file containing information about which compiler to use.
-# Can be overloaded, but it should be overloaded only for local testing.
-JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"}
-
-# @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER
-# @INTERNAL
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Explicitly set a list of compilers to choose from. This is normally read from
-# JAVA_PKG_COMPILERS_CONF.
-#
-# Useful for local testing.
-#
-# Use jikes and javac, in that order
-# @CODE
-#	JAVA_PKG_FORCE_COMPILER="jikes javac"
-# @CODE
-
-# @ECLASS-VARIABLE: JAVA_PKG_FORCE_ANT_TASKS
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# An $IFS separated list of ant tasks. Can be set in environment before calling
-# emerge/ebuild to override variables set in ebuild, mainly for testing before
-# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
-# eant() call, not the dependencies specified in WANT_ANT_TASKS.
-#
-# @CODE
-# JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
-# 	ebuild foo.ebuild compile
-# @CODE
-
-# TODO document me
-JAVA_PKG_QA_VIOLATIONS=0
-
-# @FUNCTION: java-pkg_doexamples
-# @USAGE: [--subdir <subdir>] <file1/dir1> [<file2> ...]
-# @DESCRIPTION:
-# Installs given arguments to /usr/share/doc/${PF}/examples
-# If you give it only one parameter and it is a directory it will install
-# everything in that directory to the examples directory.
-#
-# @CODE
-# Parameters:
-# --subdir - If the examples need a certain directory structure
-# $* - list of files to install
-#
-# Examples:
-#	java-pkg_doexamples demo
-#	java-pkg_doexamples demo/* examples/*
-# @CODE
-java-pkg_doexamples() {
-	debug-print-function ${FUNCNAME} $*
-
-	[[ ${#} -lt 1 ]] && die "At least one argument needed"
-
-	java-pkg_check-phase install
-	java-pkg_init_paths_
-
-	local dest=/usr/share/doc/${PF}/examples
-	if [[ ${1} == --subdir ]]; then
-		local dest=${dest}/${2}
-		dodir ${dest}
-		shift 2
-	fi
-
-	if [[ ${#} = 1 && -d ${1} ]]; then
-		( # dont want to pollute calling env
-			insinto "${dest}"
-			doins -r ${1}/*
-		) || die "Installing examples failed"
-	else
-		( # dont want to pollute calling env
-			insinto "${dest}"
-			doins -r "$@"
-		) || die "Installing examples failed"
-	fi
-
-	# Let's make a symlink to the directory we have everything else under
-	dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
-}
-
-# @FUNCTION: java-pkg_addres
-# @USAGE: <jar> <dir> [<find arguments> ...]
-# @DESCRIPTION:
-# Adds resource files to an existing jar.
-# It is important that the directory given is actually the root of the
-# corresponding resource tree. The target directory as well as
-# sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are
-# automatically excluded. Symlinks are always followed. Additional
-# arguments are passed through to find.
-#
-# @CODE
-#	java-pkg_addres ${PN}.jar resources ! -name "*.html"
-# @CODE
-#
-# @param $1 - jar file
-# @param $2 - resource tree directory
-# @param $* - arguments to pass to find
-java-pkg_addres() {
-	debug-print-function ${FUNCNAME} $*
-
-	[[ ${#} -lt 2 ]] && die "at least two arguments needed"
-
-	local jar=$(realpath "$1" || die "realpath $1 failed")
-	local dir="$2"
-	shift 2
-
-	pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
-	find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -r0 jar uf "${jar}" || die "jar failed"
-	popd > /dev/null || die "popd failed"
-}
-
-# @FUNCTION: java-pkg_rm_files
-# @USAGE: java-pkg_rm_files File1.java File2.java ...
-# @DESCRIPTION:
-# Remove unneeded files in ${S}.
-#
-# Every now and then, you'll run into situations whereby a file needs removing,
-# be it a unit test or a regular java class.
-#
-# You can use this function by either:
-# - calling it yourself in java_prepare() and feeding java-pkg_rm_files with
-# the list of files you wish to remove.
-# - defining an array in the ebuild named JAVA_RM_FILES with the list of files
-# you wish to remove.
-#
-# Both way work and it is left to the developer's preferences. If the
-# JAVA_RM_FILES array is defined, it will be automatically handed over to
-# java-pkg_rm_files during the src_prepare phase.
-#
-# See java-utils-2_src_prepare.
-#
-# @CODE
-#	java-pkg_rm_files File1.java File2.java
-# @CODE
-#
-# @param $* - list of files to remove.
-java-pkg_rm_files() {
-	debug-print-function ${FUNCNAME} $*
-	local IFS="\n"
-	for filename in "$@"; do
-		[[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting."
-		einfo "Removing unneeded file ${filename}"
-		rm -f "${S}/${filename}" || die "cannot remove ${filename}"
-		eend $?
-	done
-}
-
-# @FUNCTION: java-pkg_dojar
-# @USAGE: <jar1> [<jar2> ...]
-# @DESCRIPTION:
-# Installs any number of jars.
-# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
-# You can use java-pkg_jarinto to change this path.
-# You should never install a jar with a package version in the filename.
-# Instead, use java-pkg_newjar defined below.
-#
-# @CODE
-#	java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
-# @CODE
-#
-# @param $* - list of jars to install
-java-pkg_dojar() {
-	debug-print-function ${FUNCNAME} $*
-
-	[[ ${#} -lt 1 ]] && die "At least one argument needed"
-
-	java-pkg_check-phase install
-	java-pkg_init_paths_
-
-	# Create JARDEST if it doesn't exist
-	dodir ${JAVA_PKG_JARDEST}
-
-	local jar
-	# for each jar
-	for jar in "${@}"; do
-		local jar_basename=$(basename "${jar}")
-
-		java-pkg_check-versioned-jar ${jar_basename}
-
-		# check if it exists
-		if [[ -e "${jar}" ]] ; then
-			# Don't overwrite if jar has already been installed with the same
-			# name
-			local dest="${ED}${JAVA_PKG_JARDEST}/${jar_basename}"
-			if [[ -e "${dest}" ]]; then
-				ewarn "Overwriting ${dest}"
-			fi
-
-			# install it into JARDEST if it's a non-symlink
-			if [[ ! -L "${jar}" ]] ; then
-				#but first check class version when in strict mode.
-				is-java-strict && java-pkg_verify-classes "${jar}"
-
-				(
-					insinto "${JAVA_PKG_JARDEST}"
-					doins "${jar}"
-				) || die "failed to install ${jar}"
-				java-pkg_append_ JAVA_PKG_CLASSPATH "${EPREFIX}/${JAVA_PKG_JARDEST}/${jar_basename}"
-				debug-print "installed ${jar} to ${ED}${JAVA_PKG_JARDEST}"
-			# make a symlink to the original jar if it's symlink
-			else
-				# TODO use dosym, once we find something that could use it
-				# -nichoj
-				ln -s "$(readlink "${jar}")" "${ED}${JAVA_PKG_JARDEST}/${jar_basename}"
-				debug-print "${jar} is a symlink, linking accordingly"
-			fi
-		else
-			die "${jar} does not exist"
-		fi
-	done
-
-	# Extra logging if enabled.
-	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
-		einfo "Verbose logging for \"${FUNCNAME}\" function"
-		einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}"
-		einfo "Jar file(s) created: ${@}"
-		einfo "Complete command:"
-		einfo "${FUNCNAME} ${@}"
-	fi
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_regjar
-# @USAGE: </path/to/installed/jar>
-# @DESCRIPTION:
-# Records an already installed (in ${D}) jar in the package.env
-# This would mostly be used if the package has make or a custom script to
-# install things.
-#
-# WARNING:
-# if you want to use shell expansion, you have to use ${D}/... as the for in
-# this function will not be able to expand the path, here's an example:
-#
-# @CODE
-#   java-pkg_regjar ${D}/opt/my-java/lib/*.jar
-# @CODE
-#
-
-# TODO should we be making sure the jar is present on ${D} or wherever?
-java-pkg_regjar() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} -lt 1 ]] && die "at least one argument needed"
-
-	java-pkg_init_paths_
-
-	local jar jar_dir jar_file
-	for jar in "${@}"; do
-		# TODO use java-pkg_check-versioned-jar
-		if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
-			[[ -d "${jar}" || -d "${D}${jar}" ]] \
-				&& die "Called ${FUNCNAME} on a	directory $*"
-
-			#check that class version correct when in strict mode
-			is-java-strict && java-pkg_verify-classes "${jar}"
-
-			# nelchael: we should strip ${D} in this case too, here's why:
-			# imagine such call:
-			#    java-pkg_regjar ${D}/opt/java/*.jar
-			# such call will fall into this case (-e ${jar}) and will
-			# record paths with ${D} in package.env
-			java-pkg_append_ JAVA_PKG_CLASSPATH	"${jar#${D}}"
-		else
-			if [[ ${jar} = *\** ]]; then
-				eerror "The argument ${jar} to ${FUNCNAME}"
-				eerror "has * in it. If you want it to glob in"
-				eerror '${D} add ${D} to the argument.'
-			fi
-			debug-print "${jar} or ${D}${jar} not found"
-			die "${jar} does not exist"
-		fi
-	done
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_newjar
-# @USAGE: <path/to/oldname.jar> [<newname.jar>]
-# @DESCRIPTION:
-# Installs a jar with a new name (defaults to $PN.jar)
-#
-# For example, installs a versioned jar without the version
-java-pkg_newjar() {
-	debug-print-function ${FUNCNAME} $*
-
-	local original_jar="${1}"
-	local new_jar="${2:-${PN}.jar}"
-	local new_jar_dest="${T}/${new_jar}"
-
-	[[ -z ${original_jar} ]] && die "Must specify a jar to install"
-	[[ ! -f ${original_jar} ]] \
-		&& die "${original_jar} does not exist or is not a file!"
-
-	rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
-	cp "${original_jar}" "${new_jar_dest}" \
-		|| die "Failed to copy ${original_jar} to ${new_jar_dest}"
-	java-pkg_dojar "${new_jar_dest}"
-}
-
-# @FUNCTION: java-pkg_addcp
-# @USAGE: <classpath>
-# @DESCRIPTION:
-# Add something to the package's classpath. For jars, you should use dojar,
-# newjar, or regjar. This is typically used to add directories to the classpath.
-# The parameters of this function are appended to JAVA_PKG_CLASSPATH
-java-pkg_addcp() {
-	java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_doso
-# @USAGE: <path/to/file1.so> [...]
-# @DESCRIPTION:
-# Installs any number of JNI libraries
-# They will be installed into /usr/lib by default, but java-pkg_sointo
-# can be used change this path
-#
-# @CODE
-# Example:
-#	java-pkg_doso *.so
-# @CODE
-java-pkg_doso() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
-
-	java-pkg_init_paths_
-
-	local lib
-	# for each lib
-	for lib in "$@" ; do
-		# if the lib exists...
-		if [[ -e "${lib}" ]] ; then
-			# install if it isn't a symlink
-			if [[ ! -L "${lib}" ]] ; then
-				(
-					insinto "${JAVA_PKG_LIBDEST}"
-					insopts -m0755
-					doins "${lib}"
-				) || die "failed to install ${lib}"
-				java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
-				debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
-			# otherwise make a symlink to the symlink's origin
-			else
-				dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
-				debug-print "${lib} is a symlink, linking accordantly"
-			fi
-		# otherwise die
-		else
-			die "${lib} does not exist"
-		fi
-	done
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_regso
-# @USAGE: <file1.so> [...]
-# @DESCRIPTION:
-# Registers an already installed JNI library in package.env.
-#
-# @CODE
-# Parameters:
-# $@ - JNI libraries to register
-#
-# Example:
-#	java-pkg_regso *.so /path/*.so
-# @CODE
-java-pkg_regso() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
-
-	java-pkg_init_paths_
-
-	local lib target_dir
-	for lib in "$@" ; do
-		# Check the absolute path of the lib
-		if [[ -e "${lib}" ]] ; then
-			target_dir="$(java-pkg_expand_dir_ ${lib})"
-			java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}"
-		# Check the path of the lib relative to ${D}
-		elif [[ -e "${D}${lib}" ]]; then
-			target_dir="$(java-pkg_expand_dir_ ${D}${lib})"
-			java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}"
-		else
-			die "${lib} does not exist"
-		fi
-	done
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_jarinto
-# @USAGE: </path/to/install/jars/into>
-# @DESCRIPTION:
-# Changes the path jars are installed into via subsequent java-pkg_dojar calls.
-java-pkg_jarinto() {
-	debug-print-function ${FUNCNAME} $*
-
-	JAVA_PKG_JARDEST="${1}"
-}
-
-# @FUNCTION: java-pkg_sointo
-# @USAGE: </path/to/install/sofiles/into>
-# @DESCRIPTION:
-# Changes the path that JNI libraries are installed into via subsequent
-# java-pkg_doso calls.
-java-pkg_sointo() {
-	debug-print-function ${FUNCNAME} $*
-
-	JAVA_PKG_LIBDEST="${1}"
-}
-
-# @FUNCTION: java-pkg_dohtml
-# @USAGE: <path/to/javadoc/documentation> [...]
-# @DESCRIPTION:
-# Install Javadoc HTML documentation. Usage of java-pkg_dojavadoc is preferred.
-#
-# @CODE
-#	java-pkg_dohtml dist/docs/
-# @CODE
-java-pkg_dohtml() {
-	debug-print-function ${FUNCNAME} $*
-
-	[[ ${#} -lt 1 ]] &&  die "At least one argument required for ${FUNCNAME}"
-
-	# from /usr/lib/portage/bin/dohtml -h
-	#  -f   Set list of allowed extensionless file names.
-	dohtml -f package-list "$@"
-
-	# this probably shouldn't be here but it provides
-	# a reasonable way to catch # docs for all of the
-	# old ebuilds.
-	java-pkg_recordjavadoc
-}
-
-# @FUNCTION: java-pkg_dojavadoc
-# @USAGE: [--symlink destination] <path/to/javadocs/root>
-# @DESCRIPTION:
-# Installs javadoc documentation. This should be controlled by the doc use flag.
-#
-# @CODE
-# Parameters:
-# $1: optional --symlink creates to symlink like this for html
-#            documentation bundles.
-# $2: - The javadoc root directory.
-#
-# Examples:
-#	java-pkg_dojavadoc docs/api
-#	java-pkg_dojavadoc --symlink apidocs docs/api
-# @CODE
-java-pkg_dojavadoc() {
-	debug-print-function ${FUNCNAME} $*
-
-	# For html documentation bundles that link to Javadoc
-	local symlink
-	if [[ ${1} = --symlink ]]; then
-		symlink=${2}
-		shift 2
-	fi
-
-	local dir="$1"
-	local dest=/usr/share/doc/${PF}/html
-
-	# QA checks
-
-	java-pkg_check-phase install
-	java-pkg_init_paths_
-
-	[[ -z "${dir}" ]] && die "Must specify a directory!"
-	[[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
-	if [[ ! -e "${dir}/index.html" ]]; then
-		local msg="No index.html in javadoc directory"
-		ewarn "${msg}"
-		is-java-strict && die "${msg}"
-	fi
-
-	if [[ -e ${D}/${dest}/api ]]; then
-		eerror "${dest} already exists. Will not overwrite."
-		die "${dest}"
-	fi
-
-	# Renaming to match our directory layout
-
-	local dir_to_install="${dir}"
-	if [[ "$(basename "${dir}")" != "api" ]]; then
-		dir_to_install="${T}/api"
-		# TODO use doins
-		cp -r "${dir}" "${dir_to_install}" || die "cp failed"
-	fi
-
-	# Actual installation
-	java-pkg_dohtml -r "${dir_to_install}"
-
-	# Let's make a symlink to the directory we have everything else under
-	dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
-
-	if [[ ${symlink} ]]; then
-		debug-print "symlinking ${dest}/{api,${symlink}}"
-		dosym ${dest}/{api,${symlink}} || die
-	fi
-
-	# Extra logging if enabled.
-	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
-		einfo "Verbose logging for \"${FUNCNAME}\" function"
-		einfo "Documentation destination: ${dest}"
-		einfo "Directory to install: ${dir_to_install}"
-		einfo "Complete command:"
-		einfo "${FUNCNAME} ${@}"
-	fi
-}
-
-# @FUNCTION: java-pkg_dosrc
-# @USAGE: <path/to/sources> [...]
-# @DESCRIPTION:
-# Installs a zip containing the source for a package, so it can used in
-# from IDEs like eclipse and netbeans.
-# Ebuild needs to DEPEND on app-arch/zip to use this. It also should be controlled by USE=source.
-#
-# @CODE
-# Example:
-# java-pkg_dosrc src/*
-# @CODE
-
-# TODO change so it the arguments it takes are the base directories containing
-# source -nichoj
-#
-# TODO should we be able to handle multiple calls to dosrc? -nichoj
-#
-# TODO maybe we can take an existing zip/jar? -nichoj
-#
-# FIXME apparently this fails if you give it an empty directories
-java-pkg_dosrc() {
-	debug-print-function ${FUNCNAME} $*
-
-	[ ${#} -lt 1 ] && die "At least one argument needed"
-
-	java-pkg_check-phase install
-
-	[[ ${#} -lt 1 ]] && die "At least one argument needed"
-
-	if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
-		local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
-		java-pkg_announce-qa-violation ${msg}
-	fi
-
-	java-pkg_init_paths_
-
-	local zip_name="${PN}-src.zip"
-	local zip_path="${T}/${zip_name}"
-	local dir
-	for dir in "${@}"; do
-		local dir_parent=$(dirname "${dir}")
-		local dir_name=$(basename "${dir}")
-		pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
-		zip -q -r ${zip_path} ${dir_name} -i '*.java'
-		local result=$?
-		# 12 means zip has nothing to do
-		if [[ ${result} != 12 && ${result} != 0 ]]; then
-			die "failed to zip ${dir_name}"
-		fi
-		popd >/dev/null || die
-	done
-
-	# Install the zip
-	(
-		insinto "${JAVA_PKG_SOURCESPATH}"
-		doins ${zip_path}
-	) || die "Failed to install source"
-
-	JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
-
-	# Extra logging if enabled.
-	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
-		einfo "Verbose logging for \"${FUNCNAME}\" function"
-		einfo "Zip filename created: ${zip_name}"
-		einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}"
-		einfo "Directories zipped: ${@}"
-		einfo "Complete command:"
-		einfo "${FUNCNAME} ${@}"
-	fi
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_dolauncher
-# @USAGE: <filename> [options]
-# @DESCRIPTION:
-# Make a wrapper script to lauch/start this package
-# If necessary, the wrapper will switch to the appropriate VM.
-#
-# Can be called without parameters if the package installs only one jar
-# that has the Main-class attribute set. The wrapper will be named ${PN}.
-#
-# @CODE
-# Parameters:
-# $1 - filename of launcher to create
-# $2 - options, as follows:
-#  --main the.main.class.to.start
-#  --jar /the/jar/too/launch.jar or just <name>.jar
-#  --java_args 'Extra arguments to pass to java'
-#  --pkg_args 'Extra arguments to pass to the package'
-#  --pwd Directory the launcher changes to before executing java
-#  -into Directory to install the launcher to, instead of /usr/bin
-#  -pre Prepend contents of this file to the launcher
-# @CODE
-java-pkg_dolauncher() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-	java-pkg_init_paths_
-
-	if [[ ${#} = 0 ]]; then
-		local name="${PN}"
-	else
-		local name="${1}"
-		shift
-	fi
-
-	# TODO rename to launcher
-	local target="${T}/${name}"
-	local var_tmp="${T}/launcher_variables_tmp"
-	local target_dir pre
-
-	# Process the other the rest of the arguments
-	while [[ -n "${1}" && -n "${2}" ]]; do
-		local var="${1}" value="${2}"
-		if [[ "${var:0:2}" == "--" ]]; then
-			local var=${var:2}
-			echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
-			local gjl_${var}="${value}"
-		elif [[ "${var}" == "-into" ]]; then
-			target_dir="${value}"
-		elif [[ "${var}" == "-pre" ]]; then
-			pre="${value}"
-		fi
-		shift 2
-	done
-
-	# Test if no --jar and --main arguments were given and
-	# in that case check if the package only installs one jar
-	# and use that jar.
-	if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
-		local cp="${JAVA_PKG_CLASSPATH}"
-		if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
-			echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
-		else
-			local msg="Not enough information to create a launcher given."
-			msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
-			die "${msg}"
-		fi
-	fi
-
-	# Write the actual script
-	echo "#!/bin/bash" > "${target}"
-	if [[ -n "${pre}" ]]; then
-		if [[ -f "${pre}" ]]; then
-			cat "${pre}" >> "${target}"
-		else
-			die "-pre specified file '${pre}' does not exist"
-		fi
-	fi
-	echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
-	cat "${var_tmp}" >> "${target}"
-	rm -f "${var_tmp}"
-	echo "source ${EPREFIX}/usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
-
-	if [[ -n "${target_dir}" ]]; then
-		(
-			into "${target_dir}"
-			dobin "${target}"
-		)
-		local ret=$?
-		return ${ret}
-	else
-		dobin "${target}"
-	fi
-}
-
-# @FUNCTION: java-pkg_dowar
-# @DESCRIPTION:
-# Install war files.
-# TODO document
-java-pkg_dowar() {
-	debug-print-function ${FUNCNAME} $*
-
-	# Check for arguments
-	[[ ${#} -lt 1 ]] && die "At least one argument needed"
-	java-pkg_check-phase install
-
-	java-pkg_init_paths_
-
-	local war
-	for war in $* ; do
-		local warpath
-		# TODO evaluate if we want to handle symlinks differently -nichoj
-		# Check for symlink
-		if [[ -L "${war}" ]] ; then
-			cp "${war}" "${T}"
-			warpath="${T}$(basename "${war}")"
-		# Check for directory
-		# TODO evaluate if we want to handle directories differently -nichoj
-		elif [[ -d "${war}" ]] ; then
-			echo "dowar: warning, skipping directory ${war}"
-			continue
-		else
-			warpath="${war}"
-		fi
-
-		# Install those files like you mean it
-		(
-			insopts -m0644
-			insinto "${JAVA_PKG_WARDEST}"
-			doins ${warpath}
-		)
-	done
-}
-
-# @FUNCTION: java-pkg_recordjavadoc
-# @INTERNAL
-# @DESCRIPTION:
-# Scan for JavaDocs, and record their existence in the package.env file
-
-# TODO make sure this in the proper section
-java-pkg_recordjavadoc()
-{
-	debug-print-function ${FUNCNAME} $*
-	# the find statement is important
-	# as some packages include multiple trees of javadoc
-	JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')"
-	# remove $D - TODO: check this is ok with all cases of the above
-	JAVADOC_PATH="${JAVADOC_PATH//${D}}"
-	if [[ -n "${JAVADOC_PATH}" ]] ; then
-		debug-print "javadocs found in ${JAVADOC_PATH%:}"
-		java-pkg_do_write_
-	else
-		debug-print "No javadocs found"
-	fi
-}
-
-
-# @FUNCTION: java-pkg_jar-from
-# @USAGE: [--build-only] [--with-dependencies] [--virtual] [--into dir] <package> [<package.jar>] [<destination.jar>]
-# @DESCRIPTION:
-# Makes a symlink to a jar from a certain package
-# A lot of java packages include dependencies in a lib/ directory
-# You can use this function to replace these bundled dependencies.
-# The dependency is recorded into package.env DEPEND line, unless "--build-only"
-# is passed as the very first argument, for jars that have to be present only
-# at build time and are not needed on runtime (junit testing etc).
-#
-# @CODE
-# Example: get all jars from xerces slot 2
-#	java-pkg_jar-from xerces-2
-#
-# Example: get a specific jar from xerces slot 2
-# 	java-pkg_jar-from xerces-2 xml-apis.jar
-#
-# Example: get a specific jar from xerces slot 2, and name it diffrently
-# 	java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
-#
-# Example: get junit.jar which is needed only for building
-#	java-pkg_jar-from --build-only junit junit.jar
-# @CODE
-#
-# @CODE
-# Parameters
-#	--build-only - makes the jar(s) not added into package.env DEPEND line.
-#	  (assumed automatically when called inside src_test)
-#	--with-dependencies - get jars also from requested package's dependencies
-#	  transitively.
-#	--virtual - Packages passed to this function are to be handled as virtuals
-#	  and will not have individual jar dependencies recorded.
-#	--into $dir - symlink jar(s) into $dir (must exist) instead of .
-# $1 - Package to get jars from, or comma-separated list of packages in
-#	case other parameters are not used.
-# $2 - jar from package. If not specified, all jars will be used.
-# $3 - When a single jar is specified, destination filename of the
-#	symlink. Defaults to the name of the jar.
-# @CODE
-
-# TODO could probably be cleaned up a little
-java-pkg_jar-from() {
-	debug-print-function ${FUNCNAME} $*
-
-	local build_only=""
-	local destdir="."
-	local deep=""
-	local virtual=""
-	local record_jar=""
-
-	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
-
-	while [[ "${1}" == --* ]]; do
-		if [[ "${1}" = "--build-only" ]]; then
-			build_only="build"
-		elif [[ "${1}" = "--with-dependencies" ]]; then
-			deep="--with-dependencies"
-		elif [[ "${1}" = "--virtual" ]]; then
-			virtual="true"
-		elif [[ "${1}" = "--into" ]]; then
-			destdir="${2}"
-			shift
-		else
-			die "java-pkg_jar-from called with unknown parameter: ${1}"
-		fi
-		shift
-	done
-
-	local target_pkg="${1}" target_jar="${2}" destjar="${3}"
-
-	[[ -z ${target_pkg} ]] && die "Must specify a package"
-
-	if [[ "${EAPI}" == "1" ]]; then
-		target_pkg="${target_pkg//:/-}"
-	fi
-
-	# default destjar to the target jar
-	[[ -z "${destjar}" ]] && destjar="${target_jar}"
-
-	local error_msg="There was a problem getting the classpath for ${target_pkg}."
-	local classpath
-	classpath="$(java-config ${deep} --classpath=${target_pkg})"
-	[[ $? != 0 ]] && die ${error_msg}
-
-	# When we have commas this functions is called to bring jars from multiple
-	# packages. This affects recording of dependencencies performed later
-	# which expects one package only, so we do it here.
-	if [[ ${target_pkg} = *,* ]]; then
-		for pkg in ${target_pkg//,/ }; do
-			java-pkg_ensure-dep "${build_only}" "${pkg}"
-			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
-		done
-		# setting this disables further record-jar_ calls later
-		record_jar="true"
-	else
-		java-pkg_ensure-dep "${build_only}" "${target_pkg}"
-	fi
-
-	# Record the entire virtual as a dependency so that
-	# no jars are missed.
-	if [[ -z "${build_only}" && -n "${virtual}" ]]; then
-		java-pkg_record-jar_ "${target_pkg}"
-		# setting this disables further record-jars_ calls later
-		record_jar="true"
-	fi
-
-	pushd ${destdir} > /dev/null \
-		|| die "failed to change directory to ${destdir}"
-
-	local jar
-	for jar in ${classpath//:/ }; do
-		local jar_name=$(basename "${jar}")
-		if [[ ! -f "${jar}" ]] ; then
-			debug-print "${jar} from ${target_pkg} does not exist"
-			die "Installation problems with jars in ${target_pkg} - is it installed?"
-		fi
-		# If no specific target jar was indicated, link it
-		if [[ -z "${target_jar}" ]] ; then
-			[[ -f "${target_jar}" ]]  && rm "${target_jar}"
-			ln -snf "${jar}" \
-				|| die "Failed to make symlink from ${jar} to ${jar_name}"
-			if [[ -z "${record_jar}" ]]; then
-				if [[ -z "${build_only}" ]]; then
-					java-pkg_record-jar_ "${target_pkg}" "${jar}"
-				else
-					java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
-				fi
-			fi
-		# otherwise, if the current jar is the target jar, link it
-		elif [[ "${jar_name}" == "${target_jar}" ]] ; then
-			[[ -f "${destjar}" ]]  && rm "${destjar}"
-			ln -snf "${jar}" "${destjar}" \
-				|| die "Failed to make symlink from ${jar} to ${destjar}"
-			if [[ -z "${record_jar}" ]]; then
-				if [[ -z "${build_only}" ]]; then
-					java-pkg_record-jar_ "${target_pkg}" "${jar}"
-				else
-					java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
-				fi
-			fi
-			popd > /dev/null || die
-			return 0
-		fi
-	done
-	popd > /dev/null || die
-	# if no target was specified, we're ok
-	if [[ -z "${target_jar}" ]] ; then
-		return 0
-	# otherwise, die bitterly
-	else
-		die "Failed to find ${target_jar:-jar} in ${target_pkg}"
-	fi
-}
-
-# @FUNCTION: java-pkg_jarfrom
-# @DESCRIPTION:
-# See java-pkg_jar-from
-java-pkg_jarfrom() {
-	java-pkg_jar-from "$@"
-}
-
-# @FUNCTION: java-pkg_getjars
-# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
-# @DESCRIPTION:
-# Get the classpath provided by any number of packages
-# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
-# The providing packages are recorded as dependencies into package.env DEPEND
-# line, unless "--build-only" is passed as the very first argument, for jars
-# that have to be present only at build time and are not needed on runtime
-# (junit testing etc).
-#
-# @CODE
-# Example: Get the classpath for xerces-2 and xalan,
-#	java-pkg_getjars xerces-2,xalan
-#
-# Example Return:
-#	/usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
-#
-#
-# Parameters:
-#	--build-only - makes the jar(s) not added into package.env DEPEND line.
-#	  (assumed automatically when called inside src_test)
-#	--with-dependencies - get jars also from requested package's dependencies
-#	  transitively.
-# $1 - list of packages to get jars from
-#   (passed to java-config --classpath)
-# @CODE
-java-pkg_getjars() {
-	debug-print-function ${FUNCNAME} $*
-
-	local build_only=""
-	local deep=""
-
-	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
-
-	while [[ "${1}" == --* ]]; do
-		if [[ "${1}" = "--build-only" ]]; then
-			build_only="build"
-		elif [[ "${1}" = "--with-dependencies" ]]; then
-			deep="--with-dependencies"
-		else
-			die "java-pkg_jar-from called with unknown parameter: ${1}"
-		fi
-		shift
-	done
-
-	[[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
-
-
-	local pkgs="${1}"
-
-	if [[ "${EAPI}" == "1" ]]; then
-		pkgs="${pkgs//:/-}"
-	fi
-
-	jars="$(java-config ${deep} --classpath=${pkgs})"
-	[[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
-	debug-print "${pkgs}:${jars}"
-
-	for pkg in ${pkgs//,/ }; do
-		java-pkg_ensure-dep "${build_only}" "${pkg}"
-	done
-
-	for pkg in ${pkgs//,/ }; do
-		if [[ -z "${build_only}" ]]; then
-			java-pkg_record-jar_ "${pkg}"
-		else
-			java-pkg_record-jar_ --build-only "${pkg}"
-		fi
-	done
-
-	echo "${jars}"
-}
-
-# @FUNCTION: java-pkg_getjar
-# @USAGE: [--build-only] [--virtual] <package> <jarfile>
-# @DESCRIPTION:
-# Get the complete path of a single jar from a package
-# The providing package is recorded as runtime dependency into package.env
-# DEPEND line, unless "--build-only" is passed as the very first argument, for
-# jars that have to be present only at build time and are not needed on runtime
-# (junit testing etc).
-#
-# @CODE
-# Example:
-#	java-pkg_getjar xerces-2 xml-apis.jar
-# returns
-#	/usr/share/xerces-2/lib/xml-apis.jar
-#
-# Parameters:
-#	--build-only - makes the jar not added into package.env DEPEND line.
-#	--virtual - Packages passed to this function are to be handled as virtuals
-#	  and will not have individual jar dependencies recorded.
-# $1 - package to use
-# $2 - jar to get
-# @CODE
-java-pkg_getjar() {
-	debug-print-function ${FUNCNAME} $*
-
-	local build_only=""
-	local virtual=""
-	local record_jar=""
-
-	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
-
-	while [[ "${1}" == --* ]]; do
-		if [[ "${1}" = "--build-only" ]]; then
-			build_only="build"
-		elif [[ "${1}" == "--virtual" ]]; then
-			virtual="true"
-		else
-			die "java-pkg_getjar called with unknown parameter: ${1}"
-		fi
-		shift
-	done
-
-	[[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
-
-	local pkg="${1}" target_jar="${2}" jar
-
-	if [[ "${EAPI}" == "1" ]]; then
-		pkg="${pkg//:/-}"
-	fi
-
-	[[ -z ${pkg} ]] && die "Must specify package to get a jar from"
-	[[ -z ${target_jar} ]] && die "Must specify jar to get"
-
-	local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
-	local classpath
-	classpath=$(java-config --classpath=${pkg})
-	[[ $? != 0 ]] && die ${error_msg}
-
-	java-pkg_ensure-dep "${build_only}" "${pkg}"
-
-	# Record the package(Virtual) as a dependency and then set build_only
-	# So that individual jars are not recorded.
-	if [[ -n "${virtual}" ]]; then
-		if [[ -z "${build_only}" ]]; then
-			java-pkg_record-jar_ "${pkg}"
-		else
-			java-pkg_record-jar_ --build-only "${pkg}"
-		fi
-		record_jar="true"
-	fi
-
-	for jar in ${classpath//:/ }; do
-		if [[ ! -f "${jar}" ]] ; then
-			die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
-		fi
-
-		if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
-			# Only record jars that aren't build-only
-			if [[ -z "${record_jar}" ]]; then
-				if [[ -z "${build_only}" ]]; then
-					java-pkg_record-jar_ "${pkg}" "${jar}"
-				else
-					java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
-				fi
-			fi
-			echo "${jar}"
-			return 0
-		fi
-	done
-
-	die "Could not find ${target_jar} in ${pkg}"
-	return 1
-}
-
-# @FUNCTION: java-pkg_register-dependency
-# @USAGE: <package>[,<package2>...] [<jarfile>]
-# @DESCRIPTION:
-# Registers runtime dependency on a package, list of packages, or a single jar
-# from a package, into package.env DEPEND line. Can only be called in
-# src_install phase.
-# Intended for binary packages where you don't need to symlink the jars or get
-# their classpath during build. As such, the dependencies only need to be
-# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
-#
-# @CODE
-# Parameters:
-# $1 - comma-separated list of packages, or a single package
-# $2 - if param $1 is a single package, optionally specify the jar
-#   to depend on
-#
-# Examples:
-# Record the dependency on whole xerces-2 and xalan,
-#	java-pkg_register-dependency xerces-2,xalan
-#
-# Record the dependency on ant.jar from ant-core
-#	java-pkg_register-dependency ant-core ant.jar
-# @CODE
-#
-# Note: Passing both list of packages as the first parameter AND specifying the
-# jar as the second is not allowed and will cause the function to die. We assume
-# that there's more chance one passes such combination as a mistake, than that
-# there are more packages providing identically named jar without class
-# collisions.
-java-pkg_register-dependency() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
-
-	local pkgs="${1}"
-	local jar="${2}"
-
-	[[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
-
-	if [[ "${EAPI}" == "1" ]]; then
-		pkgs="${pkgs//:/-}"
-	fi
-
-	if [[ -z "${jar}" ]]; then
-		for pkg in ${pkgs//,/ }; do
-			java-pkg_ensure-dep runtime "${pkg}"
-			java-pkg_record-jar_ "${pkg}"
-		done
-	else
-		[[ ${pkgs} == *,* ]] && \
-			die "${FUNCNAME} called with both package list and jar name"
-		java-pkg_ensure-dep runtime "${pkgs}"
-		java-pkg_record-jar_ "${pkgs}" "${jar}"
-	fi
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_register-optional-dependency
-# @USAGE: <package>[,<package2>...] [<jarfile>]
-# @DESCRIPTION:
-# Registers optional runtime dependency on a package, list of packages, or a
-# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
-# called in src_install phase.
-# Intended for packages that can use other packages when those are in classpath.
-# Will be put on classpath by launcher if they are installed. Typical case is
-# JDBC implementations for various databases. It's better than having USE flag
-# for each implementation triggering hard dependency.
-#
-# @CODE
-# Parameters:
-# $1 - comma-separated list of packages, or a single package
-# $2 - if param $1 is a single package, optionally specify the jar to depend on
-#
-# Example:
-# Record the optional dependency on some jdbc providers
-#	java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
-# @CODE
-#
-# Note: Passing both list of packages as the first parameter AND specifying the
-# jar as the second is not allowed and will cause the function to die. We assume
-# that there's more chance one passes such combination as a mistake, than that
-# there are more packages providing identically named jar without class
-# collisions.
-java-pkg_register-optional-dependency() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
-
-	local pkgs="${1}"
-	local jar="${2}"
-
-	[[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
-
-	if [[ "${EAPI}" == "1" ]]; then
-		pkgs="${pkgs//:/-}"
-	fi
-
-	if [[ -z "${jar}" ]]; then
-		for pkg in ${pkgs//,/ }; do
-			java-pkg_record-jar_ --optional "${pkg}"
-		done
-	else
-		[[ ${pkgs} == *,* ]] && \
-			die "${FUNCNAME} called with both package list and jar name"
-		java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
-	fi
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_register-environment-variable
-# @USAGE: <name> <value>
-# @DESCRIPTION:
-# Register an arbitrary environment variable into package.env. The gjl launcher
-# for this package or any package depending on this will export it into
-# environement before executing java command.
-# Must only be called in src_install phase.
-JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
-JAVA_PKG_EXTRA_ENV_VARS=""
-java-pkg_register-environment-variable() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_check-phase install
-
-	[[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
-
-	echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
-	JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
-
-	java-pkg_do_write_
-}
-
-# @FUNCTION: java-pkg_get-bootclasspath
-# @USAGE: <version>
-# @DESCRIPTION:
-# Returns classpath of a given bootclasspath-providing package version.
-#
-# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
-#             of the current JDK
-java-pkg_get-bootclasspath() {
-	local version="${1}"
-
-	local bcp
-	case "${version}" in
-		auto)
-			bcp="$(java-config -g BOOTCLASSPATH)"
-			;;
-		1.5)
-			bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
-			;;
-		*)
-			eerror "unknown parameter of java-pkg_get-bootclasspath"
-			die "unknown parameter of java-pkg_get-bootclasspath"
-			;;
-	esac
-
-	echo "${bcp}"
-}
-
-
-# This function reads stdin, and based on that input, figures out how to
-# populate jars from the filesystem.
-# Need to figure out a good way of making use of this, ie be able to use a
-# string that was built instead of stdin
-# NOTE: this isn't quite ready for primetime.
-#java-pkg_populate-jars() {
-#	local line
-#
-#	read line
-#	while [[ -n "${line}" ]]; do
-#		# Ignore comments
-#		[[ ${line%%#*} == "" ]] && continue
-#
-#		# get rid of any spaces
-#		line="${line// /}"
-#
-#		# format: path=jarinfo
-#		local path=${line%%=*}
-#		local jarinfo=${line##*=}
-#
-#		# format: jar@package
-#		local jar=${jarinfo%%@*}.jar
-#		local package=${jarinfo##*@}
-#		if [[ -n ${replace_only} ]]; then
-#			[[ ! -f $path ]] && die "No jar exists at ${path}"
-#		fi
-#		if [[ -n ${create_parent} ]]; then
-#			local parent=$(dirname ${path})
-#			mkdir -p "${parent}"
-#		fi
-#		java-pkg_jar-from "${package}" "${jar}" "${path}"
-#
-#		read line
-#	done
-#}
-
-# @FUNCTION: java-pkg_find-normal-jars
-# @USAGE: [<path/to/directory>]
-# @DESCRIPTION:
-# Find the files with suffix .jar file in the given directory (default: $WORKDIR)
-java-pkg_find-normal-jars() {
-	local dir=$1
-	[[ "${dir}" ]] || dir="${WORKDIR}"
-	local found
-	for jar in $(find "${dir}" -name "*.jar" -type f); do
-		echo "${jar}"
-		found="true"
-	done
-	[[ "${found}" ]]
-	return $?
-}
-
-# @FUNCTION: java-pkg_ensure-no-bundled-jars
-# @DESCRIPTION:
-# Try to locate bundled jar files in ${WORKDIR} and die if found.
-# This function should be called after WORKDIR has been populated with symlink
-# to system jar files or bundled jars removed.
-java-pkg_ensure-no-bundled-jars() {
-	debug-print-function ${FUNCNAME} $*
-
-	local bundled_jars=$(java-pkg_find-normal-jars)
-	if [[ -n ${bundled_jars} ]]; then
-		echo "Bundled jars found:"
-		local jar
-		for jar in ${bundled_jars}; do
-			echo $(pwd)${jar/./}
-		done
-		die "Bundled jars found!"
-	fi
-}
-
-# @FUNCTION: java-pkg_ensure-vm-version-sufficient
-# @INTERNAL
-# @DESCRIPTION:
-# Checks if we have a sufficient VM and dies if we don't.
-java-pkg_ensure-vm-version-sufficient() {
-	debug-print-function ${FUNCNAME} $*
-
-	if ! java-pkg_is-vm-version-sufficient; then
-		debug-print "VM is not suffient"
-		eerror "Current Java VM cannot build this package"
-		einfo "Please use java-config -S to set the correct one"
-		die "Active Java VM cannot build this package"
-	fi
-}
-
-# @FUNCTION: java-pkg_is-vm-version-sufficient
-# @INTERNAL
-# @DESCRIPTION:
-# @RETURN: zero - VM is sufficient; non-zero - VM is not sufficient
-java-pkg_is-vm-version-sufficient() {
-	debug-print-function ${FUNCNAME} $*
-
-	depend-java-query --is-sufficient "${DEPEND}" > /dev/null
-	return $?
-}
-
-# @FUNCTION: java-pkg_ensure-vm-version-eq
-# @INTERNAL
-# @DESCRIPTION:
-# Die if the current VM is not equal to the argument passed.
-#
-# @param $@ - Desired VM version to ensure
-java-pkg_ensure-vm-version-eq() {
-	debug-print-function ${FUNCNAME} $*
-
-	if ! java-pkg_is-vm-version-eq $@ ; then
-		debug-print "VM is not suffient"
-		eerror "This package requires a Java VM version = $@"
-		einfo "Please use java-config -S to set the correct one"
-		die "Active Java VM too old"
-	fi
-}
-
-# @FUNCTION: java-pkg_is-vm-version-eq
-# @USAGE: <version>
-# @INTERNAL
-# @RETURN: zero - VM versions are equal; non-zero - VM version are not equal
-java-pkg_is-vm-version-eq() {
-	debug-print-function ${FUNCNAME} $*
-
-	local needed_version="$@"
-
-	[[ -z "${needed_version}" ]] && die "need an argument"
-
-	local vm_version="$(java-pkg_get-vm-version)"
-
-	vm_version="$(get_version_component_range 1-2 "${vm_version}")"
-	needed_version="$(get_version_component_range 1-2 "${needed_version}")"
-
-	if [[ -z "${vm_version}" ]]; then
-		debug-print "Could not get JDK version from DEPEND"
-		return 1
-	else
-		if [[ "${vm_version}" == "${needed_version}" ]]; then
-			debug-print "Detected a JDK(${vm_version}) = ${needed_version}"
-			return 0
-		else
-			debug-print "Detected a JDK(${vm_version}) != ${needed_version}"
-			return 1
-		fi
-	fi
-}
-
-# @FUNCTION: java-pkg_ensure-vm-version-ge
-# @INTERNAL
-# @DESCRIPTION:
-# Die if the current VM is not greater than the desired version
-#
-# @param $@ - VM version to compare current to
-java-pkg_ensure-vm-version-ge() {
-	debug-print-function ${FUNCNAME} $*
-
-	if ! java-pkg_is-vm-version-ge "$@" ; then
-		debug-print "vm is not suffient"
-		eerror "This package requires a Java VM version >= $@"
-		einfo "Please use java-config -S to set the correct one"
-		die "Active Java VM too old"
-	fi
-}
-
-# @FUNCTION: java-pkg_is-vm-version-ge
-# @INTERNAL
-# @DESCRIPTION:
-# @CODE
-# Parameters:
-# $@ - VM version to compare current VM to
-# @CODE
-# @RETURN: zero - current VM version is greater than checked version;
-# 	non-zero - current VM version is not greater than checked version
-java-pkg_is-vm-version-ge() {
-	debug-print-function ${FUNCNAME} $*
-
-	local needed_version=$@
-	local vm_version=$(java-pkg_get-vm-version)
-	if [[ -z "${vm_version}" ]]; then
-		debug-print "Could not get JDK version from DEPEND"
-		return 1
-	else
-		if version_is_at_least "${needed_version}" "${vm_version}"; then
-			debug-print "Detected a JDK(${vm_version}) >= ${needed_version}"
-			return 0
-		else
-			debug-print "Detected a JDK(${vm_version}) < ${needed_version}"
-			return 1
-		fi
-	fi
-}
-
-java-pkg_set-current-vm() {
-	export GENTOO_VM=${1}
-}
-
-java-pkg_get-current-vm() {
-	echo ${GENTOO_VM}
-}
-
-java-pkg_current-vm-matches() {
-	has $(java-pkg_get-current-vm) ${@}
-	return $?
-}
-
-# @FUNCTION: java-pkg_get-source
-# @DESCRIPTION:
-# Determines what source version should be used, for passing to -source.
-# Unless you want to break things you probably shouldn't set _WANT_SOURCE
-#
-# @RETURN: string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
-java-pkg_get-source() {
-	echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
-}
-
-# @FUNCTION: java-pkg_get-target
-# @DESCRIPTION:
-# Determines what target version should be used, for passing to -target.
-# If you don't care about lower versions, you can set _WANT_TARGET to the
-# version of your JDK.
-#
-# @RETURN: string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
-java-pkg_get-target() {
-	echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
-}
-
-# @FUNCTION: java-pkg_get-javac
-# @DESCRIPTION:
-# Returns the compiler executable
-java-pkg_get-javac() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-pkg_init-compiler_
-	local compiler="${GENTOO_COMPILER}"
-
-	local compiler_executable
-	if [[ "${compiler}" = "javac" ]]; then
-		# nothing fancy needs to be done for javac
-		compiler_executable="javac"
-	else
-		# for everything else, try to determine from an env file
-
-		local compiler_env="/usr/share/java-config-2/compiler/${compiler}"
-		if [[ -f ${compiler_env} ]]; then
-			local old_javac=${JAVAC}
-			unset JAVAC
-			# try to get value of JAVAC
-			compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
-			export JAVAC=${old_javac}
-
-			if [[ -z ${compiler_executable} ]]; then
-				die "JAVAC is empty or undefined in ${compiler_env}"
-			fi
-
-			# check that it's executable
-			if [[ ! -x ${compiler_executable} ]]; then
-				die "${compiler_executable} doesn't exist, or isn't executable"
-			fi
-		else
-			die "Could not find environment file for ${compiler}"
-		fi
-	fi
-	echo ${compiler_executable}
-}
-
-# @FUNCTION: java-pkg_javac-args
-# @DESCRIPTION:
-# If an ebuild uses javac directly, instead of using ejavac, it should call this
-# to know what -source/-target to use.
-#
-# @RETURN: string - arguments to pass to javac, complete with -target and -source
-java-pkg_javac-args() {
-	debug-print-function ${FUNCNAME} $*
-
-	local want_source="$(java-pkg_get-source)"
-	local want_target="$(java-pkg_get-target)"
-
-	local source_str="-source ${want_source}"
-	local target_str="-target ${want_target}"
-
-	debug-print "want source: ${want_source}"
-	debug-print "want target: ${want_target}"
-
-	if [[ -z "${want_source}" || -z "${want_target}" ]]; then
-		die "Could not find valid -source/-target values for javac"
-	else
-		echo "${source_str} ${target_str}"
-	fi
-}
-
-# @FUNCTION: java-pkg_get-jni-cflags
-# @DESCRIPTION:
-# Echos the CFLAGS for JNI compilations
-java-pkg_get-jni-cflags() {
-	local flags="-I${JAVA_HOME}/include"
-
-	local platform="linux"
-	use elibc_FreeBSD && platform="freebsd"
-
-	# TODO do a check that the directories are valid
-	flags="${flags} -I${JAVA_HOME}/include/${platform}"
-
-	echo ${flags}
-}
-
-java-pkg_ensure-gcj() {
-	# was enforcing sys-devel/gcc[gcj]
-	die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
-}
-
-java-pkg_ensure-test() {
-	# was enforcing USE=test if FEATURES=test
-	die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
-}
-
-# @FUNCTION: java-pkg_register-ant-task
-# @USAGE: [--version x.y] [<name>]
-# @DESCRIPTION:
-# Register this package as ant task, so that ant will load it when no specific
-# ANT_TASKS are specified. Note that even without this registering, all packages
-# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
-# packages, but can be also used by other ebuilds that used to symlink their
-# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
-# compatibility.
-#
-# @CODE
-# Parameters
-# --version x.y Register only for ant version x.y (otherwise for any ant
-#		version). Used by the ant-* packages to prevent loading of mismatched
-#		ant-core ant tasks after core was updated, before the tasks are updated,
-#		without a need for blockers.
-# $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
-# @CODE
-java-pkg_register-ant-task() {
-	local TASKS_DIR="tasks"
-
-	# check for --version x.y parameters
-	while [[ -n "${1}" && -n "${2}" ]]; do
-		local var="${1#--}"
-		local val="${2}"
-		if [[ "${var}" == "version" ]]; then
-			TASKS_DIR="tasks-${val}"
-		else
-			die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
-		fi
-		shift 2
-	done
-
-	local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
-
-	dodir /usr/share/ant/${TASKS_DIR}
-	touch "${ED}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
-}
-
-# @FUNCTION: java-pkg_ant-tasks-depend
-# @INTERNAL
-# @DESCRIPTION:
-# Translates the WANT_ANT_TASKS variable into valid dependencies.
-java-pkg_ant-tasks-depend() {
-	debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
-
-	if [[ -n "${WANT_ANT_TASKS}" ]]; then
-		local DEP=""
-		for i in ${WANT_ANT_TASKS}
-		do
-			if [[ ${i} = ant-* ]]; then
-				DEP="${DEP}dev-java/${i} "
-			elif [[ ${i} = */*:* ]]; then
-				DEP="${DEP}${i} "
-			else
-				echo "Invalid atom in WANT_ANT_TASKS: ${i}"
-				return 1
-			fi
-		done
-		echo ${DEP}
-		return 0
-	else
-		return 0
-	fi
-}
-
-
-# @FUNCTION: ejunit_
-# @INTERNAL
-# @DESCRIPTION:
-# Internal Junit wrapper function. Makes it easier to run the tests and checks for
-# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
-# @CODE
-# Parameters:
-# $1 - junit package (junit or junit-4)
-# $2 - -cp or -classpath
-# $3 - classpath; junit and recorded dependencies get appended
-# $@ - the rest of the parameters are passed to java
-# @CODE
-ejunit_() {
-	debug-print-function ${FUNCNAME} $*
-
-	local pkgs
-	if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
-		for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
-			pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
-		done
-	fi
-
-	local junit=${1}
-	shift 1
-
-	local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
-	if [[ ${1} = -cp || ${1} = -classpath ]]; then
-		cp="${2}:${cp}"
-		shift 2
-	else
-		cp=".:${cp}"
-	fi
-
-	local runner=junit.textui.TestRunner
-	if [[ "${junit}" == "junit-4" ]] ; then
-		runner=org.junit.runner.JUnitCore
-	fi
-	debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}"
-	java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
-}
-
-# @FUNCTION: ejunit
-# @DESCRIPTION:
-# Junit wrapper function. Makes it easier to run the tests and checks for
-# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
-#
-# @CODE
-# Parameters:
-# $1 - -cp or -classpath
-# $2 - classpath; junit and recorded dependencies get appended
-# $@ - the rest of the parameters are passed to java
-#
-# Examples:
-# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
-# ejunit org.blinkenlights.jid3.test.AllTests
-# ejunit org.blinkenlights.jid3.test.FirstTest org.blinkenlights.jid3.test.SecondTest
-# @CODE
-ejunit() {
-	debug-print-function ${FUNCNAME} $*
-
-	ejunit_ "junit" "${@}"
-}
-
-# @FUNCTION: ejunit4
-# @DESCRIPTION:
-# Junit4 wrapper function. Makes it easier to run the tests and checks for
-# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
-#
-# @CODE
-# Parameters:
-# $1 - -cp or -classpath
-# $2 - classpath; junit and recorded dependencies get appended
-# $@ - the rest of the parameters are passed to java
-#
-# Examples:
-# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
-# ejunit4 org.blinkenlights.jid3.test.AllTests
-# ejunit4 org.blinkenlights.jid3.test.FirstTest \
-#         org.blinkenlights.jid3.test.SecondTest
-# @CODE
-ejunit4() {
-	debug-print-function ${FUNCNAME} $*
-
-	ejunit_ "junit-4" "${@}"
-}
-
-# @FUNCTION: java-utils-2_src_prepare
-# @DESCRIPTION:
-# src_prepare Searches for bundled jars
-# Don't call directly, but via java-pkg-2_src_prepare!
-java-utils-2_src_prepare() {
-	java-pkg_func-exists java_prepare && java_prepare
-
-	# Check for files in JAVA_RM_FILES array.
-	if [[ ${JAVA_RM_FILES[@]} ]]; then
-		debug-print "$FUNCNAME: removing unneeded files"
-		java-pkg_rm_files "${JAVA_RM_FILES[@]}"
-	fi
-
-	if is-java-strict; then
-		echo "Searching for bundled jars:"
-		java-pkg_find-normal-jars || echo "None found."
-		echo "Searching for bundled classes (no output if none found):"
-		find "${WORKDIR}" -name "*.class"
-		echo "Search done."
-	fi
-}
-
-# @FUNCTION: java-utils-2_pkg_preinst
-# @DESCRIPTION:
-# pkg_preinst Searches for missing and unneeded dependencies
-# Don't call directly, but via java-pkg-2_pkg_preinst!
-java-utils-2_pkg_preinst() {
-	if is-java-strict; then
-		if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
-			return
-		fi
-
-		if has_version dev-java/java-dep-check; then
-			local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
-			[[ ${output} ]] && ewarn "${output}"
-		else
-			eerror "Install dev-java/java-dep-check for dependency checking"
-		fi
-	fi
-}
-
-# @FUNCTION: eant
-# @USAGE: <ant_build_target(s)>
-# @DESCRIPTION:
-# Ant wrapper function. Will use the appropriate compiler, based on user-defined
-# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
-# variables:
-#
-# @CODE
-# Variables:
-# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
-# 		gentoo.classpath property. Be sure to call java-ant_rewrite-classpath in src_unpack.
-# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
-# 		for build-time purposes, the dependency is not recorded to
-# 		package.env!
-# ANT_TASKS - used to determine ANT_TASKS before calling Ant.
-# @CODE
-eant() {
-	debug-print-function ${FUNCNAME} $*
-
-	if [[ ${EBUILD_PHASE} = compile ]]; then
-		java-ant-2_src_configure
-	fi
-
-	if ! has java-ant-2 ${INHERITED}; then
-		local msg="You should inherit java-ant-2 when using eant"
-		java-pkg_announce-qa-violation "${msg}"
-	fi
-
-	local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
-
-	java-pkg_init-compiler_
-	local compiler="${GENTOO_COMPILER}"
-
-	local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
-	local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
-	if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
-		die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
-	fi
-
-	if [[ ${compiler} != "javac" ]]; then
-		antflags="${antflags} -Dbuild.compiler=${build_compiler}"
-		# Figure out any extra stuff to put on the classpath for compilers aside
-		# from javac
-		# ANT_BUILD_COMPILER_DEPS should be something that could be passed to
-		# java-config -p
-		local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
-		if [[ -n ${build_compiler_deps} ]]; then
-			antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
-		fi
-	fi
-
-	for arg in "${@}"; do
-		if [[ ${arg} = -lib ]]; then
-			if is-java-strict; then
-				eerror "You should not use the -lib argument to eant because it will fail"
-				eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
-				eerror "or ant properties to make dependencies available."
-				eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
-				eerror "split ant (>=dev-java/ant-core-1.7)."
-				die "eant -lib is deprecated/forbidden"
-			else
-				echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
-				echo "more info."
-			fi
-		fi
-	done
-
-	# parse WANT_ANT_TASKS for atoms
-	local want_ant_tasks
-	for i in ${WANT_ANT_TASKS}; do
-		if [[ ${i} = */*:* ]]; then
-			i=${i#*/}
-			i=${i%:0}
-			want_ant_tasks+="${i/:/-} "
-		else
-			want_ant_tasks+="${i} "
-		fi
-	done
-	# default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
-	ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
-
-	# override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
-	ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
-
-	# if ant-tasks is not set by ebuild or forced, use none
-	ANT_TASKS="${ANT_TASKS:-none}"
-
-	# at this point, ANT_TASKS should be "all", "none" or explicit list
-	if [[ "${ANT_TASKS}" == "all" ]]; then
-		einfo "Using all available ANT_TASKS"
-	elif [[ "${ANT_TASKS}" == "none" ]]; then
-		einfo "Disabling all optional ANT_TASKS"
-	else
-		einfo "Using following ANT_TASKS: ${ANT_TASKS}"
-	fi
-
-	export ANT_TASKS
-
-	[[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
-	[[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
-
-	local gcp="${EANT_GENTOO_CLASSPATH}"
-	local getjarsarg=""
-
-	if [[ ${EBUILD_PHASE} = "test" ]]; then
-		antflags="${antflags} -DJunit.present=true"
-		getjarsarg="--with-dependencies"
-
-		local re="\bant-junit4?([-:]\S+)?\b"
-		[[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}"
-	else
-		antflags="${antflags} -Dmaven.test.skip=true"
-	fi
-
-	local cp
-
-	for atom in ${gcp}; do
-		cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})"
-	done
-
-	[[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)"
-	[[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}"
-
-	if [[ ${cp#:} ]]; then
-		# It seems ant does not like single quotes around ${cp}
-		antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
-	fi
-
-	[[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
-	debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
-	ant ${antflags} "${@}" || die "eant failed"
-}
-
-# @FUNCTION: ejavac
-# @USAGE: <javac_arguments>
-# @DESCRIPTION:
-# Javac wrapper function. Will use the appropriate compiler, based on
-# /etc/java-config/compilers.conf
-ejavac() {
-	debug-print-function ${FUNCNAME} $*
-
-	local compiler_executable
-	compiler_executable=$(java-pkg_get-javac)
-
-	local javac_args
-	javac_args="$(java-pkg_javac-args)"
-
-	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
-		einfo "Verbose logging for \"${FUNCNAME}\" function"
-		einfo "Compiler executable: ${compiler_executable}"
-		einfo "Extra arguments: ${javac_args}"
-		einfo "Complete command:"
-		einfo "${compiler_executable} ${javac_args} ${@}"
-	fi
-
-	ebegin "Compiling"
-	${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
-}
-
-# @FUNCTION: ejavadoc
-# @USAGE: <javadoc_arguments>
-# @DESCRIPTION:
-# javadoc wrapper function. Will set some flags based on the VM version
-# due to strict javadoc rules in 1.8.
-ejavadoc() {
-	debug-print-function ${FUNCNAME} $*
-
-	local javadoc_args=""
-
-	if java-pkg_is-vm-version-ge "1.8" ; then
-		javadoc_args="-Xdoclint:none"
-	fi
-
-	if [[ -n ${JAVA_PKG_DEBUG} ]]; then
-		einfo "Verbose logging for \"${FUNCNAME}\" function"
-		einfo "Javadoc executable: javadoc"
-		einfo "Extra arguments: ${javadoc_args}"
-		einfo "Complete command:"
-		einfo "javadoc ${javadoc_args} ${@}"
-	fi
-
-	ebegin "Generating JavaDoc"
-	javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
-}
-
-# @FUNCTION: java-pkg_filter-compiler
-# @USAGE: <compiler(s)_to_filter>
-# @DESCRIPTION:
-# Used to prevent the use of some compilers. Should be used in src_compile.
-# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
-java-pkg_filter-compiler() {
-	JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
-}
-
-# @FUNCTION: java-pkg_force-compiler
-# @USAGE: <compiler(s)_to_force>
-# @DESCRIPTION:
-# Used to force the use of particular compilers. Should be used in src_compile.
-# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
-# OutOfMemoryErrors that may come up.
-java-pkg_force-compiler() {
-	JAVA_PKG_FORCE_COMPILER="$@"
-}
-
-# @FUNCTION: use_doc
-# @DESCRIPTION:
-#
-# Helper function for getting ant to build javadocs. If the user has USE=doc,
-# then 'javadoc' or the argument are returned. Otherwise, there is no return.
-#
-# The output of this should be passed to ant.
-# @CODE
-# Parameters:
-# $@ - Option value to return. Defaults to 'javadoc'
-#
-# Examples:
-# build javadocs by calling 'javadoc' target
-#	eant $(use_doc)
-#
-# build javadocs by calling 'apidoc' target
-#	eant $(use_doc apidoc)
-# @CODE
-# @RETURN string - Name of the target to create javadocs
-use_doc() {
-	use doc && echo ${@:-javadoc}
-}
-
-
-# @FUNCTION: java-pkg_init
-# @INTERNAL
-# @DESCRIPTION:
-# The purpose of this function, as the name might imply, is to initialize the
-# Java environment. It ensures that that there aren't any environment variables
-# that'll muss things up. It initializes some variables, which are used
-# internally. And most importantly, it'll switch the VM if necessary.
-#
-# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
-# call it during each of the phases of the merge process.
-java-pkg_init() {
-	debug-print-function ${FUNCNAME} $*
-
-	# Don't set up build environment if installing from binary. #206024 #258423
-	[[ "${MERGE_TYPE}" == "binary" ]] && return
-	# Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
-	# work nothing is lost.
-	has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
-
-	unset JAVAC
-	unset JAVA_HOME
-
-	java-config --help >/dev/null || {
-		eerror ""
-		eerror "Can't run java-config --help"
-		eerror "Have you upgraded python recently but haven't"
-		eerror "run python-updater yet?"
-		die "Can't run java-config --help"
-	}
-
-	# People do all kinds of weird things.
-	# https://forums.gentoo.org/viewtopic-p-3943166.html
-	local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
-	local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
-	if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
-		ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
-		ewarn "sun-jdk vms and and as such break configure scripts that"
-		ewarn "use it (for example app-office/openoffice) so we filter it out."
-		ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
-		ewarn "make.conf for example) to silence this warning or"
-		ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
-	fi
-
-	if [[ -z ${accept} ]]; then
-		# export _JAVA_OPTIONS= doesn't work because it will show up in java
-		# -version output
-		unset _JAVA_OPTIONS
-		# phase hooks make this run many times without this
-		I_WANT_GLOBAL_JAVA_OPTIONS="true"
-	fi
-
-	if java-pkg_func-exists ant_src_unpack; then
-		java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
-	fi
-
-	java-pkg_switch-vm
-	PATH=${JAVA_HOME}/bin:${PATH}
-
-	# TODO we will probably want to set JAVAC and JAVACFLAGS
-
-	# Do some QA checks
-	java-pkg_check-jikes
-
-	# Can't use unset here because Portage does not save the unset
-	# see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
-
-	# When users have crazy classpaths some packages can fail to compile.
-	# and everything should work with empty CLASSPATH.
-	# This also helps prevent unexpected dependencies on random things
-	# from the CLASSPATH.
-	export CLASSPATH=
-
-	# Unset external ANT_ stuff
-	export ANT_TASKS=
-	export ANT_OPTS=
-	export ANT_RESPECT_JAVA_HOME=
-}
-
-# @FUNCTION: java-pkg-init-compiler_
-# @INTERNAL
-# @DESCRIPTION:
-# This function attempts to figure out what compiler should be used. It does
-# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
-# COMPILERS variable defined there.
-# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
-#
-# It will go through the list of compilers, and verify that it supports the
-# target and source that are needed. If it is not suitable, then the next
-# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
-# isn't done.
-#
-# Once the which compiler to use has been figured out, it is set to
-# GENTOO_COMPILER.
-#
-# If you hadn't guessed, JAVA_PKG_FORCE_COMPILER is for testing only.
-#
-# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
-# suitable compiler was found there, then the default is to use javac provided
-# by the current VM.
-#
-#
-# @RETURN name of the compiler to use
-java-pkg_init-compiler_() {
-	debug-print-function ${FUNCNAME} $*
-
-	if [[ -n ${GENTOO_COMPILER} ]]; then
-		debug-print "GENTOO_COMPILER already set"
-		return
-	fi
-
-	local compilers;
-	if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
-		compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo	${COMPILERS})"
-	else
-		compilers=${JAVA_PKG_FORCE_COMPILER}
-	fi
-
-	debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
-
-	# Figure out if we should announce what compiler we're using
-	local compiler
-	for compiler in ${compilers}; do
-		debug-print "Checking ${compiler}..."
-		# javac should always be alright
-		if [[ ${compiler} = "javac" ]]; then
-			debug-print "Found javac... breaking"
-			export GENTOO_COMPILER="javac"
-			break
-		fi
-
-		if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
-			if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
-				einfo "Filtering ${compiler}" >&2
-				continue
-			fi
-		fi
-
-		# for non-javac, we need to make sure it supports the right target and
-		# source
-		local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
-		if [[ -f ${compiler_env} ]]; then
-			local desired_target="$(java-pkg_get-target)"
-			local desired_source="$(java-pkg_get-source)"
-
-
-			# Verify that the compiler supports target
-			local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET})
-			if ! has ${desired_target} ${supported_target}; then
-				ewarn "${compiler} does not support -target ${desired_target},	skipping"
-				continue
-			fi
-
-			# Verify that the compiler supports source
-			local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
-			if ! has ${desired_source} ${supported_source}; then
-				ewarn "${compiler} does not support -source ${desired_source}, skipping"
-				continue
-			fi
-
-			# if you get here, then the compiler should be good to go
-			export GENTOO_COMPILER="${compiler}"
-			break
-		else
-			ewarn "Could not find configuration for ${compiler}, skipping"
-			ewarn "Perhaps it is not installed?"
-			continue
-		fi
-	done
-
-	# If it hasn't been defined already, default to javac
-	if [[ -z ${GENTOO_COMPILER} ]]; then
-		if [[ -n ${compilers} ]]; then
-			einfo "No suitable compiler found: defaulting to JDK default for compilation" >&2
-		else
-			# probably don't need to notify users about the default.
-			:;#einfo "Defaulting to javac for compilation" >&2
-		fi
-		if java-config -g GENTOO_COMPILER 2> /dev/null; then
-			export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
-		else
-			export GENTOO_COMPILER=javac
-		fi
-	else
-		einfo "Using ${GENTOO_COMPILER} for compilation" >&2
-	fi
-
-}
-
-# @FUNCTION: init_paths_
-# @INTERNAL
-# @DESCRIPTION:
-# Initializes some variables that will be used. These variables are mostly used
-# to determine where things will eventually get installed.
-java-pkg_init_paths_() {
-	debug-print-function ${FUNCNAME} $*
-
-	local pkg_name
-	if [[ "${SLOT%/*}" == "0" ]] ; then
-		JAVA_PKG_NAME="${PN}"
-	else
-		JAVA_PKG_NAME="${PN}-${SLOT%/*}"
-	fi
-
-	JAVA_PKG_SHAREPATH="/usr/share/${JAVA_PKG_NAME}"
-	JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
-	JAVA_PKG_ENV="${ED}${JAVA_PKG_SHAREPATH}/package.env"
-	JAVA_PKG_VIRTUALS_PATH="/usr/share/java-config-2/virtuals"
-	JAVA_PKG_VIRTUAL_PROVIDER="${ED}${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
-
-	[[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
-	[[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="/usr/$(get_libdir)/${JAVA_PKG_NAME}"
-	[[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
-
-	# TODO maybe only print once?
-	debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}"
-	debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}"
-	debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
-	debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
-	debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
-}
-
-# @FUNCTION: java-pkg_do_write_
-# @INTERNAL
-# @DESCRIPTION:
-# Writes the package.env out to disk.
-#
-# TODO change to do-write, to match everything else
-java-pkg_do_write_() {
-	debug-print-function ${FUNCNAME} $*
-	java-pkg_init_paths_
-	# Create directory for package.env
-	dodir "${JAVA_PKG_SHAREPATH}"
-
-	# Create package.env
-	(
-		echo "DESCRIPTION=\"${DESCRIPTION}\""
-		echo "GENERATION=\"2\""
-		echo "SLOT=\"${SLOT}\""
-		echo "CATEGORY=\"${CATEGORY}\""
-		echo "PVR=\"${PVR}\""
-
-		[[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
-		[[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
-		[[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
-		[[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
-			&& echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
-		[[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
-			&& echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
-		echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
-		[[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
-			&& echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
-	) > "${JAVA_PKG_ENV}"
-
-	# register target/source
-	local target="$(java-pkg_get-target)"
-	local source="$(java-pkg_get-source)"
-	[[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
-	[[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
-
-	# register javadoc info
-	[[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \
-		>> ${JAVA_PKG_ENV}
-	# register source archives
-	[[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \
-		>> ${JAVA_PKG_ENV}
-
-	echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
-	[[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
-
-	# extra env variables
-	if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
-		cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
-		# nested echo to remove leading/trailing spaces
-		echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
-			>> "${JAVA_PKG_ENV}" || die
-	fi
-
-	# Strip unnecessary leading and trailing colons
-	# TODO try to cleanup if possible
-	sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
-}
-
-# @FUNCTION: java-pkg_record-jar_
-# @INTERNAL
-# @DESCRIPTION:
-# Record an (optional) dependency to the package.env
-# @CODE
-# Parameters:
-# --optional - record dependency as optional
-# --build - record dependency as build_only
-# $1 - package to record
-# $2 - (optional) jar of package to record
-# @CODE
-JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
-JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
-JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
-
-java-pkg_record-jar_() {
-	debug-print-function ${FUNCNAME} $*
-
-	local depend_file="${JAVA_PKG_DEPEND_FILE}"
-	case "${1}" in
-		"--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
-		"--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
-	esac
-
-	local pkg=${1} jar=${2} append
-	if [[ -z "${jar}" ]]; then
-		append="${pkg}"
-	else
-		append="$(basename ${jar})@${pkg}"
-	fi
-
-	echo "${append}" >> "${depend_file}"
-}
-
-# @FUNCTION: java-pkg_append_
-# @INTERNAL
-# @DESCRIPTION:
-# Appends a value to a variable
-#
-# @CODE
-# Parameters:
-# $1 variable name to modify
-# $2 value to append
-#
-# Examples:
-#	java-pkg_append_ CLASSPATH foo.jar
-# @CODE
-java-pkg_append_() {
-	debug-print-function ${FUNCNAME} $*
-
-	local var="${1}" value="${2}"
-	if [[ -z "${!var}" ]] ; then
-		export ${var}="${value}"
-	else
-		local oldIFS=${IFS} cur haveit
-		IFS=':'
-		for cur in ${!var}; do
-			if [[ ${cur} == ${value} ]]; then
-				haveit="yes"
-				break
-			fi
-		done
-		[[ -z ${haveit} ]] && export ${var}="${!var}:${value}"
-		IFS=${oldIFS}
-	fi
-}
-
-# @FUNCTION: java-pkg_expand_dir_
-# @INTERNAL
-# @DESCRIPTION:
-# Gets the full path of the file/directory's parent.
-# @CODE
-# Parameters:
-# $1 - file/directory to find parent directory for
-# @CODE
-# @RETURN: path to $1's parent directory
-java-pkg_expand_dir_() {
-	pushd "$(dirname "${1}")" >/dev/null 2>&1 || die
-	pwd
-	popd >/dev/null 2>&1 || die
-}
-
-# @FUNCTION: java-pkg_func-exists
-# @INTERNAL
-# @DESCRIPTION:
-# Does the indicated function exist?
-# @RETURN: 0 - function is declared, 1 - function is undeclared
-java-pkg_func-exists() {
-	declare -F ${1} > /dev/null
-}
-
-# @FUNCTION: java-pkg_setup-vm
-# @INTERNAL
-# @DESCRIPTION:
-# Sets up the environment for a specific VM
-java-pkg_setup-vm() {
-	debug-print-function ${FUNCNAME} $*
-
-	local vendor="$(java-pkg_get-vm-vendor)"
-	if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
-		addpredict "/dev/random"
-	elif [[ "${vendor}" == "ibm" ]]; then
-		addpredict "/proc/self/maps"
-		addpredict "/proc/cpuinfo"
-		addpredict "/proc/self/coredump_filter"
-	elif [[ "${vendor}" == "oracle" ]]; then
-		addpredict "/dev/random"
-		addpredict "/proc/self/coredump_filter"
-	elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
-		addpredict "/dev/random"
-		addpredict "/proc/self/coredump_filter"
-	elif [[ "${vendor}" == "jrockit" ]]; then
-		addpredict "/proc/cpuinfo"
-	fi
-}
-
-# @FUNCTION: java-pkg_needs-vm
-# @INTERNAL
-# @DESCRIPTION:
-# Does the current package depend on virtual/jdk or does it set
-# JAVA_PKG_WANT_BUILD_VM?
-#
-# @RETURN: 0 - Package depends on virtual/jdk; 1 - Package does not depend on virtual/jdk
-java-pkg_needs-vm() {
-	debug-print-function ${FUNCNAME} $*
-
-	if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
-		return 0
-	fi
-
-	[[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
-
-	return 1
-}
-
-# @FUNCTION: java-pkg_get-current-vm
-# @INTERNAL
-# @RETURN - The current VM being used
-java-pkg_get-current-vm() {
-	java-config -f
-}
-
-# @FUNCTION: java-pkg_get-vm-vendor
-# @INTERNAL
-# @RETURN - The vendor of the current VM
-java-pkg_get-vm-vendor() {
-	debug-print-function ${FUNCNAME} $*
-
-	local vm="$(java-pkg_get-current-vm)"
-	vm="${vm/-*/}"
-	echo "${vm}"
-}
-
-# @FUNCTION: java-pkg_get-vm-version
-# @INTERNAL
-# @RETURN - The version of the current VM
-java-pkg_get-vm-version() {
-	debug-print-function ${FUNCNAME} $*
-
-	java-config -g PROVIDES_VERSION
-}
-
-# @FUNCTION: java-pkg_build-vm-from-handle
-# @INTERNAL
-# @DESCRIPTION:
-# Selects a build vm from a list of vm handles. First checks for the system-vm
-# beeing usable, then steps through the listed handles till a suitable vm is
-# found.
-#
-# @RETURN - VM handle of an available JDK
-java-pkg_build-vm-from-handle() {
-	debug-print-function ${FUNCNAME} "$*"
-
-	local vm
-	vm=$(java-pkg_get-current-vm 2>/dev/null)
-	if [[ $? -eq 0 ]]; then
-		if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
-			echo ${vm}
-			return 0
-		fi
-	fi
-
-	for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
-		if java-config-2 --select-vm=${vm} 2>/dev/null; then
-			echo ${vm}
-			return 0
-		fi
-	done
-
-	eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
-	return 1
-}
-
-# @FUNCTION: java-pkg_switch-vm
-# @INTERNAL
-# @DESCRIPTION:
-# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
-# verify that the current VM is sufficient.
-# Setup the environment for the VM being used.
-java-pkg_switch-vm() {
-	debug-print-function ${FUNCNAME} $*
-
-	if java-pkg_needs-vm; then
-		# Use the VM specified by JAVA_PKG_FORCE_VM
-		if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
-			# If you're forcing the VM, I hope you know what your doing...
-			debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
-			export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
-		# if we're allowed to switch the vm...
-		elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
-			# if there is an explicit list of handles to choose from
-			if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
-				debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
-				GENTOO_VM=$(java-pkg_build-vm-from-handle)
-				if [[ $? != 0 ]]; then
-					eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
-					die "${FUNCNAME}: Failed to determine VM for building"
-				fi
-				# JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
-				# they can't be deduced from handles.
-				if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
-					eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
-					die "Specify JAVA_PKG_WANT_SOURCE"
-				fi
-				if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
-					eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
-					die "Specify JAVA_PKG_WANT_TARGET"
-				fi
-			# otherwise determine a vm from dep string
-			else
-				debug-print "depend-java-query:  NV_DEPEND:	${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
-				GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
-				if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
-					eerror "Unable to determine VM for building from dependencies:"
-					echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
-					die "Failed to determine VM for building."
-				fi
-			fi
-			export GENTOO_VM
-		# otherwise just make sure the current VM is sufficient
-		else
-			java-pkg_ensure-vm-version-sufficient
-		fi
-		debug-print "Using: $(java-config -f)"
-
-		java-pkg_setup-vm
-
-		export JAVA=$(java-config --java)
-		export JAVAC=$(java-config --javac)
-		JAVACFLAGS="$(java-pkg_javac-args)"
-		[[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
-		export JAVACFLAGS
-
-		export JAVA_HOME="$(java-config -g JAVA_HOME)"
-		export JDK_HOME=${JAVA_HOME}
-
-		#TODO If you know a better solution let us know.
-		java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
-
-		local tann="${T}/announced-vm"
-		# With the hooks we should only get here once from pkg_setup but better safe than sorry
-		# if people have for example modified eclasses some where
-		if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
-			einfo "Using: $(java-config -f)"
-			[[ ! -f "${tann}" ]] && touch "${tann}"
-		fi
-
-	else
-		[[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
-	fi
-}
-
-# @FUNCTION: java-pkg_die
-# @INTERNAL
-# @DESCRIPTION:
-# Enhanced die for Java packages, which displays some information that may be
-# useful for debugging bugs on bugzilla.
-#register_die_hook java-pkg_die
-if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
-	EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
-fi
-
-java-pkg_die() {
-	echo "!!! When you file a bug report, please include the following information:" >&2
-	echo "GENTOO_VM=${GENTOO_VM}  CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
-	echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
-	echo "and of course, the output of emerge --info =${P}" >&2
-}
-
-
-# TODO document
-# List jars in the source directory, ${S}
-java-pkg_jar-list() {
-	if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
-		einfo "Linked Jars"
-		find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
-		einfo "Jars"
-		find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
-		einfo "Classes"
-		find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
-	fi
-}
-
-# @FUNCTION: java-pkg_verify-classes
-# @INTERNAL
-# @DESCRIPTION:
-# Verify that the classes were compiled for the right source / target. Dies if
-# not.
-# @CODE
-# $1 (optional) - the file to check, otherwise checks whole ${D}
-# @CODE
-java-pkg_verify-classes() {
-	#$(find ${ED} -type f -name '*.jar' -o -name '*.class')
-
-	local version_verify="/usr/bin/class-version-verify.py"
-
-	if [[ ! -x "${version_verify}" ]]; then
-		version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
-	fi
-
-	if [[ ! -x "${version_verify}" ]]; then
-		ewarn "Unable to perform class version checks as"
-		ewarn "class-version-verify.py is unavailable"
-		ewarn "Please install dev-java/javatoolkit."
-		return
-	fi
-
-	local target=$(java-pkg_get-target)
-	local result
-	local log="${T}/class-version-verify.log"
-	if [[ -n "${1}" ]]; then
-		${version_verify} -v -t ${target} "${1}" > "${log}"
-		result=$?
-	else
-		ebegin "Verifying java class versions (target: ${target})"
-		${version_verify} -v -t ${target} -r "${ED}" > "${log}"
-		result=$?
-		eend ${result}
-	fi
-	[[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
-	if [[ ${result} != 0 ]]; then
-		eerror "Incorrect bytecode version found"
-		[[ -n "${1}" ]] && eerror "in file: ${1}"
-		eerror "See ${log} for more details."
-		die "Incorrect bytecode found"
-	fi
-}
-
-# @FUNCTION: java-pkg_ensure-dep
-# @INTERNAL
-# @DESCRIPTION:
-# Check that a package being used in jarfrom, getjars and getjar is contained
-# within DEPEND or RDEPEND with the correct SLOT. See this mail for details:
-# https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e
-# @CODE
-# Parameters:
-# $1 - empty - check both vars; "runtime" or "build" - check only
-#	RDEPEND, resp. DEPEND
-# $2 - Package name and slot.
-# @CODE
-java-pkg_ensure-dep() {
-	debug-print-function ${FUNCNAME} $*
-
-	local limit_to="${1}"
-	local target_pkg="${2}"
-	local dev_error=""
-
-	# Transform into a regular expression to look for a matching package
-	# and SLOT. SLOTs don't have to be numeric so foo-bar could either
-	# mean foo-bar:0 or foo:bar. So you want to get your head around the
-	# line below?
-	#
-	# * The target package first has any dots escaped, e.g. foo-1.2
-	#   becomes foo-1\.2.
-	#
-	# * sed then looks at the component following the last - or :
-	#   character, or the whole string if there is no - or :
-	#   character. It uses this to build a new regexp with two
-	#   significant branches.
-	#
-	# * The first checks for the whole target package string, optionally
-	#   followed by a version number, and then :0.
-	#
-	# * The second checks for the first part of the target package
-	#   string, optionally followed by a version number, followed by the
-	#   aforementioned component, treating that as a SLOT.
-	#
-	local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b
-
-	debug-print "Matching against: ${stripped_pkg}"
-
-	# Uncomment the lines below once we've dealt with more of these
-	# otherwise we'll be tempted to turn JAVA_PKG_STRICT off while
-	# getting hit with a wave of bug reports. :(
-
-	if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
-		dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
-		dev_error+="declared with a SLOT in DEPEND."
-#		if is-java-strict; then
-#			die "${dev_error}"
-#		else
-			eqawarn "java-pkg_ensure-dep: ${dev_error}"
-#			eerror "Because you have ${target_pkg} installed,"
-#			eerror "the package will build without problems, but please"
-#			eerror "report this to https://bugs.gentoo.org."
-#		fi
-	elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
-		dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
-		dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given."
-#		if is-java-strict; then
-#			die "${dev_error}"
-#		else
-			eqawarn "java-pkg_ensure-dep: ${dev_error}"
-#			eerror "The package will build without problems, but may fail to run"
-#			eerror "if you don't have ${target_pkg} installed,"
-#			eerror "so please report this to https://bugs.gentoo.org."
-#		fi
-	fi
-}
-
-java-pkg_check-phase() {
-	local phase=${1}
-	local funcname=${FUNCNAME[1]}
-	if [[ ${EBUILD_PHASE} != ${phase} ]]; then
-		local msg="${funcname} used outside of src_${phase}"
-		java-pkg_announce-qa-violation "${msg}"
-	fi
-}
-
-java-pkg_check-versioned-jar() {
-	local jar=${1}
-
-	if [[ ${jar} =~ ${PV} ]]; then
-		java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
-	fi
-}
-
-java-pkg_check-jikes() {
-	if has jikes ${IUSE}; then
-		java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
-	fi
-}
-
-java-pkg_announce-qa-violation() {
-	local nodie
-	if [[ ${1} == "--nodie" ]]; then
-		nodie="true"
-		shift
-	fi
-	echo "Java QA Notice: $@" >&2
-	increment-qa-violations
-	[[ -z "${nodie}" ]] && is-java-strict && die "${@}"
-}
-
-increment-qa-violations() {
-	let "JAVA_PKG_QA_VIOLATIONS+=1"
-	export JAVA_PKG_QA_VIOLATIONS
-}
-
-is-java-strict() {
-	[[ -n ${JAVA_PKG_STRICT} ]]
-	return $?
-}
-
-# @FUNCTION: java-pkg_clean
-# @DESCRIPTION:
-# Java package cleaner function. This will remove all *.class and *.jar
-# files, removing any bundled dependencies.
-java-pkg_clean() {
-	if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then
-		find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die
-	fi
-}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2017-08-07  6:12 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2017-08-07  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     2ce0208d19c5417cc5ac001c265da5880147d4b2
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  7 06:12:17 2017 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Mon Aug  7 06:12:17 2017 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=2ce0208d

toolchain.eclass: merged to gentoo main.

 eclass/toolchain.eclass | 2382 -----------------------------------------------
 1 file changed, 2382 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
deleted file mode 100644
index ca64091..0000000
--- a/eclass/toolchain.eclass
+++ /dev/null
@@ -1,2382 +0,0 @@
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-
-DESCRIPTION="The GNU Compiler Collection"
-HOMEPAGE="https://gcc.gnu.org/"
-RESTRICT="strip" # cross-compilers need controlled stripping
-
-inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator prefix
-
-if [[ ${PV} == *_pre9999* ]] ; then
-	EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
-	# naming style:
-	# gcc-4.7.1_pre9999 -> gcc-4_7-branch
-	#  Note that the micro version is required or lots of stuff will break.
-	#  To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
-	#  inheriting this eclass.
-	EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
-	EGIT_BRANCH=${EGIT_BRANCH//./_}
-	inherit git-2
-fi
-
-FEATURES=${FEATURES/multilib-strict/}
-
-EXPORTED_FUNCTIONS="pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm"
-case ${EAPI:-0} in
-	0|1)    die "Need to upgrade to at least EAPI=2";;
-	2|3)    EXPORTED_FUNCTIONS+=" src_prepare src_configure" ;;
-	4*|5*)  EXPORTED_FUNCTIONS+=" pkg_pretend src_prepare src_configure" ;;
-	*)      die "I don't speak EAPI ${EAPI}."
-esac
-EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
-
-#---->> globals <<----
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
-	if [[ ${CATEGORY} == cross-* ]] ; then
-		export CTARGET=${CATEGORY#cross-}
-	fi
-fi
-: ${TARGET_ABI:=${ABI}}
-: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
-: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
-
-is_crosscompile() {
-	[[ ${CHOST} != ${CTARGET} ]]
-}
-
-if [[ ${EAPI:-0} == [012] ]] ; then
-		: ${ED:=${D}}
-		: ${EROOT:=${ROOT}}
-fi
-
-# General purpose version check.  Without a second arg matches up to minor version (x.x.x)
-tc_version_is_at_least() {
-	version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}"
-}
-
-# General purpose version range check
-# Note that it matches up to but NOT including the second version
-tc_version_is_between() {
-	tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
-}
-
-GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
-GCC_PVR=${GCC_PV}
-[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
-GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
-GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
-GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
-GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
-GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
-[[ ${BRANCH_UPDATE-notset} == "notset" ]] && \
-	BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
-
-# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
-# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
-GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
-
-# Pre-release support
-if [[ ${GCC_PV} == *_pre* ]] ; then
-	PRERELEASE=${GCC_PV/_pre/-}
-elif [[ ${GCC_PV} == *_alpha* ]] ; then
-	SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
-elif [[ ${GCC_PV} == *_beta* ]] ; then
-	SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
-elif [[ ${GCC_PV} == *_rc* ]] ; then
-	SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
-fi
-
-if [[ ${SNAPSHOT} == [56789].0-* ]] ; then
-	# The gcc-5+ releases have dropped the .0 for some reason.
-	SNAPSHOT=${SNAPSHOT/.0}
-fi
-
-export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
-
-PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
-
-if tc_version_is_at_least 3.4.0 ; then
-	LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
-else
-	LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
-fi
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
-
-if is_crosscompile ; then
-	BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-	HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
-else
-	BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-fi
-
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
-
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
-# We will handle /usr/include/g++-v3/ with gcc-config ...
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
-
-#---->> LICENSE+SLOT+IUSE logic <<----
-
-if tc_version_is_at_least 4.6 ; then
-	LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
-elif tc_version_is_at_least 4.4 ; then
-	LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.2+"
-elif tc_version_is_at_least 4.3 ; then
-	LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
-elif tc_version_is_at_least 4.2 ; then
-	LICENSE="GPL-3+ LGPL-2.1+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
-elif tc_version_is_at_least 3.3 ; then
-	LICENSE="GPL-2+ LGPL-2.1+ FDL-1.2+"
-else
-	LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
-fi
-
-IUSE="regression-test vanilla"
-IUSE_DEF=( nls nptl )
-
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
-	IUSE+=" altivec debug"
-	IUSE_DEF+=( cxx fortran )
-	[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
-	[[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
-	[[ -n ${D_VER}   ]] && IUSE+=" d"
-	[[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
-	tc_version_is_at_least 3 && IUSE+=" doc gcj awt hardened multilib objc"
-	tc_version_is_at_least 4.0 && IUSE+=" objc-gc"
-	tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
-	tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
-	tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp )
-	tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
-	tc_version_is_at_least 4.7 && IUSE+=" go"
-	# Note: while <=gcc-4.7 also supported graphite, it required forked ppl
-	# versions which we dropped.  Since graphite was also experimental in
-	# the older versions, we don't want to bother supporting it.  #448024
-	tc_version_is_at_least 4.8 && IUSE+=" graphite" IUSE_DEF+=( sanitize )
-	tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv"
-	tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
-	tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch"
-fi
-
-IUSE+=" ${IUSE_DEF[*]/#/+}"
-
-SLOT="${GCC_CONFIG_VER}"
-
-#---->> DEPEND <<----
-
-RDEPEND="sys-libs/zlib
-	nls? ( virtual/libintl )"
-
-tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
-
-if tc_version_is_at_least 4 ; then
-	GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0 >=dev-libs/mpfr-2.4.2:0"
-	if tc_version_is_at_least 4.3 ; then
-		RDEPEND+=" ${GMP_MPFR_DEPS}"
-	elif in_iuse fortran ; then
-		RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
-	fi
-fi
-
-tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0"
-
-if in_iuse graphite ; then
-	if tc_version_is_at_least 5.0 ; then
-		RDEPEND+=" graphite? ( >=dev-libs/isl-0.14 )"
-	elif tc_version_is_at_least 4.8 ; then
-		RDEPEND+="
-			graphite? (
-				>=dev-libs/cloog-0.18.0
-				>=dev-libs/isl-0.11.1
-			)"
-	fi
-fi
-
-DEPEND="${RDEPEND}
-	>=sys-devel/bison-1.875
-	>=sys-devel/flex-2.5.4
-	nls? ( sys-devel/gettext )
-	regression-test? (
-		>=dev-util/dejagnu-1.4.4
-		>=sys-devel/autogen-5.5.4
-	)"
-
-if in_iuse gcj ; then
-	GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
-	GCJ_GTK_DEPS="
-		x11-libs/libXt
-		x11-libs/libX11
-		x11-libs/libXtst
-		x11-proto/xproto
-		x11-proto/xextproto
-		=x11-libs/gtk+-2*
-		virtual/pkgconfig
-	"
-	tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
-	tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
-	DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
-fi
-
-PDEPEND=">=sys-devel/gcc-config-1.7"
-
-#---->> S + SRC_URI essentials <<----
-
-# Set the source directory depending on whether we're using
-# a prerelease, snapshot, or release tarball.
-S=$(
-	if [[ -n ${PRERELEASE} ]] ; then
-		echo ${WORKDIR}/gcc-${PRERELEASE}
-	elif [[ -n ${SNAPSHOT} ]] ; then
-		echo ${WORKDIR}/gcc-${SNAPSHOT}
-	else
-		echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
-	fi
-)
-
-gentoo_urls() {
-	local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
-	HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI"
-	devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
-	echo mirror://gentoo/$1 ${devspace//URI/$1}
-}
-
-# This function handles the basics of setting the SRC_URI for a gcc ebuild.
-# To use, set SRC_URI with:
-#
-#	SRC_URI="$(get_gcc_src_uri)"
-#
-# Other than the variables normally set by portage, this function's behavior
-# can be altered by setting the following:
-#
-#	SNAPSHOT
-#			If set, this variable signals that we should be using a snapshot of
-#			gcc. It is expected to be in the format "YYYY-MM-DD". Note that if
-#			the ebuild has a _pre suffix, this variable is ignored and the
-#			prerelease tarball is used instead.
-#
-#	BRANCH_UPDATE
-#			If set, this variable signals that we should be using the main
-#			release tarball (determined by ebuild version) and applying a
-#			CVS branch update patch against it. The location of this branch
-#			update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
-#			Just like with SNAPSHOT, this variable is ignored if the ebuild
-#			has a _pre suffix.
-#
-#	PATCH_VER
-#	PATCH_GCC_VER
-#			This should be set to the version of the gentoo patch tarball.
-#			The resulting filename of this tarball will be:
-#			gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
-#
-#	PIE_VER
-#	PIE_GCC_VER
-#			These variables control patching in various updates for the logic
-#			controlling Position Independant Executables. PIE_VER is expected
-#			to be the version of this patch, and PIE_GCC_VER the gcc version of
-#			the patch:
-#			An example:
-#					PIE_VER="8.7.6.5"
-#					PIE_GCC_VER="3.4.0"
-#			The resulting filename of this tarball will be:
-#			gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
-#
-#	SPECS_VER
-#	SPECS_GCC_VER
-#			This is for the minispecs files included in the hardened gcc-4.x
-#			The specs files for hardenedno*, vanilla and for building the "specs" file.
-#			SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
-#			the gcc version of the patch.
-#			An example:
-#					SPECS_VER="8.7.6.5"
-#					SPECS_GCC_VER="3.4.0"
-#			The resulting filename of this tarball will be:
-#			gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
-#
-#	HTB_VER
-#	HTB_GCC_VER
-#			These variables control whether or not an ebuild supports Herman
-#			ten Brugge's bounds-checking patches. If you want to use a patch
-#			for an older gcc version with a new gcc, make sure you set
-#			HTB_GCC_VER to that version of gcc.
-get_gcc_src_uri() {
-	export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
-	export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
-	export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
-	export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
-	export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
-
-	# Set where to download gcc itself depending on whether we're using a
-	# prerelease, snapshot, or release tarball.
-	if [[ ${PV} == *9999* ]] ; then
-		# Nothing to do w/git snapshots.
-		:
-	elif [[ -n ${PRERELEASE} ]] ; then
-		GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
-	elif [[ -n ${SNAPSHOT} ]] ; then
-		GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
-	else
-		GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
-		# we want all branch updates to be against the main release
-		[[ -n ${BRANCH_UPDATE} ]] && \
-			GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
-	fi
-
-	[[ -n ${UCLIBC_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
-	[[ -n ${PATCH_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
-
-	# strawberry pie, Cappuccino and a Gauloises (it's a good thing)
-	[[ -n ${PIE_VER} ]] && \
-		PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
-		GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
-
-	# gcc minispec for the hardened gcc 4 compiler
-	[[ -n ${SPECS_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
-
-	# gcc bounds checking patch
-	if [[ -n ${HTB_VER} ]] ; then
-		local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
-		GCC_SRC_URI+="
-			boundschecking? (
-				mirror://sourceforge/boundschecking/${HTBFILE}
-				$(gentoo_urls ${HTBFILE})
-			)"
-	fi
-
-	[[ -n ${D_VER} ]] && \
-		GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
-
-	if in_iuse gcj ; then
-		if tc_version_is_at_least 4.5 ; then
-			GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
-		elif tc_version_is_at_least 4.3 ; then
-			GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
-		fi
-	fi
-
-	echo "${GCC_SRC_URI}"
-}
-
-SRC_URI=$(get_gcc_src_uri)
-
-#---->> pkg_pretend <<----
-
-toolchain_pkg_pretend() {
-	if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
-	   [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then
-		die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it" \
-			"in your make.conf if you want to use this version."
-	fi
-
-	[[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && \
-		die "Sorry, this version does not support uClibc"
-
-	if ! use_if_iuse cxx ; then
-		use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
-		use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
-		use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
-	fi
-
-	want_minispecs
-}
-
-#---->> pkg_setup <<----
-
-toolchain_pkg_setup() {
-	case ${EAPI} in
-	2|3) toolchain_pkg_pretend ;;
-	esac
-
-	# we dont want to use the installed compiler's specs to build gcc
-	unset GCC_SPECS
-	unset LANGUAGES #265283
-}
-
-#---->> src_unpack <<----
-
-toolchain_src_unpack() {
-	if [[ ${PV} == *9999* ]]; then
-		git-2_src_unpack
-	else
-		gcc_quick_unpack
-	fi
-}
-
-gcc_quick_unpack() {
-	pushd "${WORKDIR}" > /dev/null
-	export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
-	export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
-	export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
-	export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
-	export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
-
-	if [[ -n ${GCC_A_FAKEIT} ]] ; then
-		unpack ${GCC_A_FAKEIT}
-	elif [[ -n ${PRERELEASE} ]] ; then
-		unpack gcc-${PRERELEASE}.tar.bz2
-	elif [[ -n ${SNAPSHOT} ]] ; then
-		unpack gcc-${SNAPSHOT}.tar.bz2
-	elif [[ ${PV} != *9999* ]] ; then
-		unpack gcc-${GCC_RELEASE_VER}.tar.bz2
-		# We want branch updates to be against a release tarball
-		if [[ -n ${BRANCH_UPDATE} ]] ; then
-			pushd "${S}" > /dev/null
-			epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
-			popd > /dev/null
-		fi
-	fi
-
-	if [[ -n ${D_VER} ]] && use d ; then
-		pushd "${S}"/gcc > /dev/null
-		unpack gdc-${D_VER}-src.tar.bz2
-		cd ..
-		ebegin "Adding support for the D language"
-		./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
-		if ! eend $? ; then
-			eerror "The D GCC package failed to apply"
-			eerror "Please include this log file when posting a bug report:"
-			eerror "  ${T}/dgcc.log"
-			die "failed to include the D language"
-		fi
-		popd > /dev/null
-	fi
-
-	[[ -n ${PATCH_VER} ]] && \
-		unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
-
-	[[ -n ${UCLIBC_VER} ]] && \
-		unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
-
-	if want_pie ; then
-		if [[ -n ${PIE_CORE} ]] ; then
-			unpack ${PIE_CORE}
-		else
-			unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
-		fi
-		[[ -n ${SPECS_VER} ]] && \
-			unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
-	fi
-
-	use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
-
-	popd > /dev/null
-}
-
-#---->> src_prepare <<----
-
-toolchain_src_prepare() {
-	export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
-	cd "${S}"
-
-	if ! use vanilla ; then
-		if [[ -n ${PATCH_VER} ]] ; then
-			guess_patch_type_in_dir "${WORKDIR}"/patch
-			EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
-			epatch "${WORKDIR}"/patch
-			BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
-		fi
-		if [[ -n ${UCLIBC_VER} ]] ; then
-			guess_patch_type_in_dir "${WORKDIR}"/uclibc
-			EPATCH_MULTI_MSG="Applying uClibc patches ..." \
-			epatch "${WORKDIR}"/uclibc
-		fi
-	fi
-	do_gcc_HTB_patches
-	do_gcc_PIE_patches
-	epatch_user
-
-	if ( tc_version_is_at_least 4.8.2 || use hardened ) && ! use vanilla ; then
-		make_gcc_hard
-	fi
-
-	# install the libstdc++ python into the right location
-	# http://gcc.gnu.org/PR51368
-	if tc_version_is_between 4.5 4.7 ; then
-		sed -i \
-			'/^pythondir =/s:=.*:= $(datadir)/python:' \
-			"${S}"/libstdc++-v3/python/Makefile.in || die
-	fi
-
-	# make sure the pkg config files install into multilib dirs.
-	# since we configure with just one --libdir, we can't use that
-	# (as gcc itself takes care of building multilibs).  #435728
-	find "${S}" -name Makefile.in \
-		-exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
-
-	# No idea when this first started being fixed, but let's go with 4.3.x for now
-	if ! tc_version_is_at_least 4.3 ; then
-		fix_files=""
-		for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
-			[[ -e ${x} ]] && fix_files="${fix_files} ${x}"
-		done
-		ht_fix_file ${fix_files} */configure *.sh */Makefile.in
-	fi
-
-	setup_multilib_osdirnames
-	gcc_version_patch
-
-	if tc_version_is_at_least 4.1 ; then
-		if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
-			# BASE-VER must be a three-digit version number
-			# followed by an optional -pre string
-			#   eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
-			# If BASE-VER differs from ${PV/_/-} then libraries get installed in
-			# the wrong directory.
-			echo ${PV/_/-} > "${S}"/gcc/BASE-VER
-		fi
-	fi
-
-	# >= gcc-4.3 doesn't bundle ecj.jar, so copy it
-	if tc_version_is_at_least 4.3 && use gcj ; then
-		if tc_version_is_at_least 4.5 ; then
-			einfo "Copying ecj-4.5.jar"
-			cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
-		else
-			einfo "Copying ecj-4.3.jar"
-			cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
-		fi
-	fi
-
-	# disable --as-needed from being compiled into gcc specs
-	# natively when using a gcc version < 3.4.4
-	# http://gcc.gnu.org/PR14992
-	if ! tc_version_is_at_least 3.4.4 ; then
-		sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
-	fi
-
-	# In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
-	# in line with gcc-4.
-	if tc_version_is_between 3.3 4.0 ; then
-		do_gcc_rename_java_bins
-	fi
-
-	# Prevent libffi from being installed
-	if tc_version_is_between 3.0 4.8 ; then
-		sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
-		sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
-	fi
-
-	# Fixup libtool to correctly generate .la files with portage
-	elibtoolize --portage --shallow --no-uclibc
-
-	gnuconfig_update
-
-	# update configure files
-	local f
-	einfo "Fixing misc issues in configure files"
-	for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
-		ebegin "  Updating ${f/${S}\/} [LANG]"
-		patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
-			|| eerror "Please file a bug about this"
-		eend $?
-	done
-	sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
-
-	# Prevent new texinfo from breaking old versions (see #198182, #464008)
-	tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
-
-	if [[ -x contrib/gcc_update ]] ; then
-		einfo "Touching generated files"
-		./contrib/gcc_update --touch | \
-			while read f ; do
-				einfo "  ${f%%...}"
-			done
-	fi
-}
-
-guess_patch_type_in_dir() {
-	[[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
-		&& EPATCH_SUFFIX="patch.bz2" \
-		|| EPATCH_SUFFIX="patch"
-}
-
-do_gcc_HTB_patches() {
-	use_if_iuse boundschecking || return 0
-
-	# modify the bounds checking patch with a regression patch
-	epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
-	BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
-}
-
-do_gcc_PIE_patches() {
-	want_pie || return 0
-	use vanilla && return 0
-
-	if tc_version_is_at_least 4.3.2 ; then
-		guess_patch_type_in_dir "${WORKDIR}"/piepatch/
-		EPATCH_MULTI_MSG="Applying pie patches ..." \
-		epatch "${WORKDIR}"/piepatch/
-	else
-		guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
-
-		# corrects startfile/endfile selection and shared/static/pie flag usage
-		EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
-		epatch "${WORKDIR}"/piepatch/upstream
-		# adds non-default pie support (rs6000)
-		EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
-		epatch "${WORKDIR}"/piepatch/nondef
-		# adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
-		EPATCH_MULTI_MSG="Applying default pie patches ..." \
-		epatch "${WORKDIR}"/piepatch/def
-	fi
-
-	BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
-}
-
-# configure to build with the hardened GCC specs as the default
-make_gcc_hard() {
-
-	local gcc_hard_flags=""
-	# Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
-	if tc_version_is_at_least 6.0 ; then
-		if use pie ; then
-			einfo "Updating gcc to use automatic PIE building ..."
-		fi
-		if use ssp ; then
-			einfo "Updating gcc to use automatic SSP building ..."
-		fi
-		if use hardened ; then
-			# Will add some optimatizion as default.
-			gcc_hard_flags+=" -DEXTRA_OPTIONS"
-			# rebrand to make bug reports easier
-			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
-		fi
-	else
-		if use hardened ; then
-			# rebrand to make bug reports easier
-			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
-			if hardened_gcc_works ; then
-				einfo "Updating gcc to use automatic PIE + SSP building ..."
-				gcc_hard_flags+=" -DEFAULT_PIE_SSP"
-			elif hardened_gcc_works pie ; then
-				einfo "Updating gcc to use automatic PIE building ..."
-				ewarn "SSP has not been enabled by default"
-				gcc_hard_flags+=" -DEFAULT_PIE"
-			elif hardened_gcc_works ssp ; then
-				einfo "Updating gcc to use automatic SSP building ..."
-				ewarn "PIE has not been enabled by default"
-				gcc_hard_flags+=" -DEFAULT_SSP"
-			else
-				# do nothing if hardened isn't supported, but don't die either
-				ewarn "hardened is not supported for this arch in this gcc version"
-				return 0
-			fi
-		else
-			if hardened_gcc_works ssp ; then
-				einfo "Updating gcc to use automatic SSP building ..."
-				gcc_hard_flags+=" -DEFAULT_SSP"
-			fi
-		fi
-	fi
-
-	# we want to be able to control the pie patch logic via something other
-	# than ALL_CFLAGS...
-	sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
-		-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
-		-i "${S}"/gcc/Makefile.in
-	# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
-	if tc_version_is_at_least 4.7 ; then
-		sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
-			-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-			-i "${S}"/gcc/Makefile.in
-	fi
-
-	sed -i \
-		-e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
-		"${S}"/gcc/Makefile.in || die
-
-}
-
-# This is a historical wart.  The original Gentoo/amd64 port used:
-#    lib32 - 32bit binaries (x86)
-#    lib64 - 64bit binaries (x86_64)
-#    lib   - "native" binaries (a symlink to lib64)
-# Most other distros use the logic (including mainline gcc):
-#    lib   - 32bit binaries (x86)
-#    lib64 - 64bit binaries (x86_64)
-# Over time, Gentoo is migrating to the latter form.
-#
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc
-# versions will dynamically detect whether to use lib or lib32 for its
-# 32bit multilib.  So, to keep the automagic from getting things wrong
-# while people are transitioning from the old style to the new style,
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
-setup_multilib_osdirnames() {
-	is_multilib || return 0
-
-	local config
-	local libdirs="../lib64 ../lib32"
-
-	# this only makes sense for some Linux targets
-	case ${CTARGET} in
-	x86_64*-linux*)    config="i386" ;;
-	powerpc64*-linux*) config="rs6000" ;;
-	sparc64*-linux*)   config="sparc" ;;
-	s390x*-linux*)     config="s390" ;;
-	*)	               return 0 ;;
-	esac
-	config+="/t-linux64"
-
-	local sed_args=()
-	if tc_version_is_at_least 4.6 ; then
-		sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
-	fi
-	if [[ ${SYMLINK_LIB} == "yes" ]] ; then
-		einfo "updating multilib directories to be: ${libdirs}"
-		if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
-			sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
-		else
-			sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
-		fi
-	else
-		einfo "using upstream multilib; disabling lib32 autodetection"
-		sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
-	fi
-	sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
-}
-
-gcc_version_patch() {
-	# gcc-4.3+ has configure flags (whoo!)
-	tc_version_is_at_least 4.3 && return 0
-
-	local version_string=${GCC_CONFIG_VER}
-	[[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
-
-	einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
-
-	local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
-	if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
-		gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
-	else
-		version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
-		gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
-	fi
-	sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
-}
-
-do_gcc_rename_java_bins() {
-	# bug #139918 - conflict between gcc and java-config-2 for ownership of
-	# /usr/bin/rmi{c,registry}.	 Done with mv & sed rather than a patch
-	# because patches would be large (thanks to the rename of man files),
-	# and it's clear from the sed invocations that all that changes is the
-	# rmi{c,registry} names to grmi{c,registry} names.
-	# Kevin F. Quinn 2006-07-12
-	einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
-	# 1) Move the man files if present (missing prior to gcc-3.4)
-	for manfile in rmic rmiregistry ; do
-		[[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
-		mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
-	done
-	# 2) Fixup references in the docs if present (mission prior to gcc-3.4)
-	for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do
-		[[ -f ${S}/${jfile} ]] || continue
-		sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
-			die "Failed to fixup file ${jfile} for rename to grmiregistry"
-		sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
-			die "Failed to fixup file ${jfile} for rename to grmic"
-	done
-	# 3) Fixup Makefiles to build the changed executable names
-	#	 These are present in all 3.x versions, and are the important bit
-	#	 to get gcc to build with the new names.
-	for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do
-		sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
-			die "Failed to fixup file ${jfile} for rename to grmiregistry"
-		# Careful with rmic on these files; it's also the name of a directory
-		# which should be left unchanged.  Replace occurrences of 'rmic$',
-		# 'rmic_' and 'rmic '.
-		sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
-			die "Failed to fixup file ${jfile} for rename to grmic"
-	done
-}
-
-#---->> src_configure <<----
-
-toolchain_src_configure() {
-	downgrade_arch_flags
-	gcc_do_filter_flags
-
-	einfo "CFLAGS=\"${CFLAGS}\""
-	einfo "CXXFLAGS=\"${CXXFLAGS}\""
-	einfo "LDFLAGS=\"${LDFLAGS}\""
-
-	# Force internal zip based jar script to avoid random
-	# issues with 3rd party jar implementations.  #384291
-	export JAR=no
-
-	# For hardened gcc 4.3 piepatchset to build the hardened specs
-	# file (build.specs) to use when building gcc.
-	if ! tc_version_is_at_least 4.4 && want_minispecs ; then
-		setup_minispecs_gcc_build_specs
-	fi
-
-	local confgcc=( --host=${CHOST} )
-
-	if is_crosscompile || tc-is-cross-compiler ; then
-		# Straight from the GCC install doc:
-		# "GCC has code to correctly determine the correct value for target
-		# for nearly all native systems. Therefore, we highly recommend you
-		# not provide a configure target when configuring a native compiler."
-		confgcc+=( --target=${CTARGET} )
-	fi
-	[[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
-
-	confgcc+=(
-		--prefix="${PREFIX}"
-		--bindir="${BINPATH}"
-		--includedir="${INCLUDEPATH}"
-		--datadir="${DATAPATH}"
-		--mandir="${DATAPATH}/man"
-		--infodir="${DATAPATH}/info"
-		--with-gxx-include-dir="${STDCXX_INCDIR}"
-	)
-
-	# Stick the python scripts in their own slotted directory (bug #279252)
-	#
-	#  --with-python-dir=DIR
-	#  Specifies where to install the Python modules used for aot-compile. DIR
-	#  should not include the prefix used in installation. For example, if the
-	#  Python modules are to be installed in /usr/lib/python2.5/site-packages,
-	#  then --with-python-dir=/lib/python2.5/site-packages should be passed.
-	#
-	# This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
-	if tc_version_is_at_least 4.4 ; then
-		confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
-	fi
-
-	### language options
-
-	local GCC_LANG="c"
-	is_cxx && GCC_LANG+=",c++"
-	is_d   && GCC_LANG+=",d"
-	is_gcj && GCC_LANG+=",java"
-	is_go  && GCC_LANG+=",go"
-	is_jit && GCC_LANG+=",jit"
-	if is_objc || is_objcxx ; then
-		GCC_LANG+=",objc"
-		if tc_version_is_at_least 4 ; then
-			use objc-gc && confgcc+=( --enable-objc-gc )
-		fi
-		is_objcxx && GCC_LANG+=",obj-c++"
-	fi
-
-	# fortran support just got sillier! the lang value can be f77 for
-	# fortran77, f95 for fortran95, or just plain old fortran for the
-	# currently supported standard depending on gcc version.
-	is_fortran && GCC_LANG+=",fortran"
-	is_f77 && GCC_LANG+=",f77"
-	is_f95 && GCC_LANG+=",f95"
-
-	# We do NOT want 'ADA support' in here!
-	# is_ada && GCC_LANG+=",ada"
-
-	confgcc+=( --enable-languages=${GCC_LANG} )
-
-	### general options
-
-	confgcc+=(
-		--enable-obsolete
-		--enable-secureplt
-		--disable-werror
-		--with-system-zlib
-	)
-
-	if use nls ; then
-		confgcc+=( --enable-nls --without-included-gettext )
-	else
-		confgcc+=( --disable-nls )
-	fi
-
-	tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
-
-	# Use the default ("release") checking because upstream usually neglects
-	# to test "disabled" so it has a history of breaking. #317217
-	if tc_version_is_at_least 3.4 ; then
-		# The "release" keyword is new to 4.0. #551636
-		local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
-		confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
-	fi
-
-	# Branding
-	tc_version_is_at_least 4.3 && confgcc+=(
-		--with-bugurl=https://bugs.gentoo.org/
-		--with-pkgversion="${BRANDING_GCC_PKGVERSION}"
-	)
-
-	# If we want hardened support with the newer piepatchset for >=gcc 4.4
-	if tc_version_is_at_least 4.4 && want_minispecs ; then
-		confgcc+=( $(use_enable hardened esp) )
-	fi
-
-	# allow gcc to search for clock funcs in the main C lib.
-	# if it can't find them, then tough cookies -- we aren't
-	# going to link in -lrt to all C++ apps.  #411681
-	if tc_version_is_at_least 4.4 && is_cxx ; then
-		confgcc+=( --enable-libstdcxx-time )
-	fi
-
-	# Support to disable pch when building libstdcxx
-	if tc_version_is_at_least 6.0 && ! use pch ; then
-		confgcc+=( --disable-libstdcxx-pch )
-	fi
-
-	# The jit language requires this.
-	is_jit && confgcc+=( --enable-host-shared )
-
-	# # Turn on the -Wl,--build-id flag by default for ELF targets. #525942
-	# # This helps with locating debug files.
-	# case ${CTARGET} in
-	# *-linux-*|*-elf|*-eabi)
-	# 	tc_version_is_at_least 4.5 && confgcc+=(
-	# 		--enable-linker-build-id
-	# 	)
-	# 	;;
-	# esac
-
-	# newer gcc versions like to bootstrap themselves with C++,
-	# so we need to manually disable it ourselves
-	if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
-		confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
-	fi
-
-	### Cross-compiler options
-	if is_crosscompile ; then
-		# Enable build warnings by default with cross-compilers when system
-		# paths are included (e.g. via -I flags).
-		confgcc+=( --enable-poison-system-directories )
-
-		# When building a stage1 cross-compiler (just C compiler), we have to
-		# disable a bunch of features or gcc goes boom
-		local needed_libc=""
-		case ${CTARGET} in
-		*-linux)		 needed_libc=no-fucking-clue;;
-		*-dietlibc)		 needed_libc=dietlibc;;
-		*-elf|*-eabi)	 needed_libc=newlib;;
-		*-freebsd*)		 needed_libc=freebsd-lib;;
-		*-gnu*)			 needed_libc=glibc;;
-		*-klibc)		 needed_libc=klibc;;
-		*-musl*)		 needed_libc=musl;;
-		*-uclibc*)
-			if ! echo '#include <features.h>' | \
-			   $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
-			   grep -q __HAVE_SHARED__
-			then #291870
-				confgcc+=( --disable-shared )
-			fi
-			needed_libc=uclibc
-			;;
-		*-cygwin)		 needed_libc=cygwin;;
-		x86_64-*-mingw*|\
-		*-w64-mingw*)	 needed_libc=mingw64-runtime;;
-		mingw*|*-mingw*) needed_libc=mingw-runtime;;
-		avr)			 confgcc+=( --enable-shared --disable-threads );;
-		esac
-		if [[ -n ${needed_libc} ]] ; then
-			local confgcc_no_libc=( --disable-shared )
-			tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
-			if ! has_version ${CATEGORY}/${needed_libc} ; then
-				confgcc+=(
-					"${confgcc_no_libc[@]}"
-					--disable-threads
-					--without-headers
-				)
-			elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
-				confgcc+=(
-					"${confgcc_no_libc[@]}"
-					--with-sysroot="${PREFIX}"/${CTARGET}
-				)
-			else
-				confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
-			fi
-		fi
-
-		tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
-	else
-		if tc-is-static-only ; then
-			confgcc+=( --disable-shared )
-		else
-			confgcc+=( --enable-shared )
-		fi
-		case ${CHOST} in
-		mingw*|*-mingw*|*-cygwin)
-			confgcc+=( --enable-threads=win32 ) ;;
-		*)
-			confgcc+=( --enable-threads=posix ) ;;
-		esac
-	fi
-
-	# __cxa_atexit is "essential for fully standards-compliant handling of
-	# destructors", but apparently requires glibc.
-	case ${CTARGET} in
-	*-uclibc*)
-		confgcc+=(
-			--disable-__cxa_atexit
-			$(use_enable nptl tls)
-		)
-		tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
-		if tc_version_is_between 3.4 4.3 ; then
-			confgcc+=( --enable-clocale=uclibc )
-		fi
-		;;
-	*-elf|*-eabi)
-		confgcc+=( --with-newlib )
-		;;
-	*-gnu*)
-		confgcc+=(
-			--enable-__cxa_atexit
-			--enable-clocale=gnu
-		)
-		;;
-	*-freebsd*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
-	*-solaris*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
-	esac
-
-	### arch options
-
-	gcc-multilib-configure
-
-	# ppc altivec support
-	confgcc+=( $(use_enable altivec) )
-
-	# gcc has fixed-point arithmetic support in 4.3 for mips targets that can
-	# significantly increase compile time by several hours.  This will allow
-	# users to control this feature in the event they need the support.
-	tc_version_is_at_least 4.3 && confgcc+=( $(use_enable fixed-point) )
-
-	case $(tc-is-softfloat) in
-	yes)    confgcc+=( --with-float=soft ) ;;
-	softfp) confgcc+=( --with-float=softfp ) ;;
-	*)
-		# If they've explicitly opt-ed in, do hardfloat,
-		# otherwise let the gcc default kick in.
-		case ${CTARGET//_/-} in
-		*-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
-		esac
-	esac
-
-	local with_abi_map=()
-	case $(tc-arch) in
-	arm)	#264534 #414395
-		local a arm_arch=${CTARGET%%-*}
-		# Remove trailing endian variations first: eb el be bl b l
-		for a in e{b,l} {b,l}e b l ; do
-			if [[ ${arm_arch} == *${a} ]] ; then
-				arm_arch=${arm_arch%${a}}
-				break
-			fi
-		done
-		# Convert armv7{a,r,m} to armv7-{a,r,m}
-		[[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
-		# See if this is a valid --with-arch flag
-		if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
-			. "${srcdir}"/config.gcc) &>/dev/null
-		then
-			confgcc+=( --with-arch=${arm_arch} )
-		fi
-
-		# Make default mode thumb for microcontroller classes #418209
-		[[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
-
-		# Enable hardvfp
-		if [[ $(tc-is-softfloat) == "no" ]] && \
-		   [[ ${CTARGET} == armv[67]* ]] && \
-		   tc_version_is_at_least 4.5
-		then
-			# Follow the new arm hardfp distro standard by default
-			confgcc+=( --with-float=hard )
-			case ${CTARGET} in
-			armv6*) confgcc+=( --with-fpu=vfp ) ;;
-			armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
-			esac
-		fi
-		;;
-	mips)
-		# Add --with-abi flags to set default ABI
-		confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
-		;;
-	amd64)
-		# drop the older/ABI checks once this get's merged into some
-		# version of gcc upstream
-		if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
-			confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
-		fi
-		;;
-	x86)
-		# Default arch for x86 is normally i386, lets give it a bump
-		# since glibc will do so based on CTARGET anyways
-		confgcc+=( --with-arch=${CTARGET%%-*} )
-		;;
-	hppa)
-		# Enable sjlj exceptions for backward compatibility on hppa
-		[[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
-		;;
-	ppc)
-		# Set up defaults based on current CFLAGS
-		is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
-		[[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
-		;;
-	esac
-
-	# if the target can do biarch (-m32/-m64), enable it.  overhead should
-	# be small, and should simplify building of 64bit kernels in a 32bit
-	# userland by not needing sys-devel/kgcc64.  #349405
-	case $(tc-arch) in
-	ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
-	sparc)     tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
-	amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
-	esac
-
-	# On Darwin we need libdir to be set in order to get correct install names
-	# for things like libobjc-gnu, libgcj and libfortran.  If we enable it on
-	# non-Darwin we screw up the behaviour this eclass relies on.  We in
-	# particular need this over --libdir for bug #255315.
-	[[ ${CTARGET} == *-darwin* ]] && \
-		confgcc+=( --enable-version-specific-runtime-libs )
-
-	### library options
-
-	if ! is_gcj ; then
-		confgcc+=( --disable-libgcj )
-	elif use awt ; then
-		confgcc+=( --enable-java-awt=gtk )
-	fi
-
-	if tc_version_is_at_least 4.2 ; then
-		if in_iuse openmp ; then
-			# Make sure target has pthreads support. #326757 #335883
-			# There shouldn't be a chicken & egg problem here as openmp won't
-			# build without a C library, and you can't build that w/out
-			# already having a compiler ...
-			if ! is_crosscompile || \
-			   $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
-			then
-				confgcc+=( $(use_enable openmp libgomp) )
-			else
-				# Force disable as the configure script can be dumb #359855
-				confgcc+=( --disable-libgomp )
-			fi
-		else
-			# For gcc variants where we don't want openmp (e.g. kgcc)
-			confgcc+=( --disable-libgomp )
-		fi
-	fi
-
-	if tc_version_is_at_least 4.0 ; then
-		if in_iuse mudflap ; then
-			confgcc+=( $(use_enable mudflap libmudflap) )
-		else
-			confgcc+=( --disable-libmudflap )
-		fi
-
-		if use_if_iuse libssp ; then
-			confgcc+=( --enable-libssp )
-		else
-			if hardened_gcc_is_stable ssp; then
-				export gcc_cv_libc_provides_ssp=yes
-			fi
-			confgcc+=( --disable-libssp )
-		fi
-	fi
-
-	if in_iuse cilk ; then
-		confgcc+=( $(use_enable cilk libcilkrts) )
-	fi
-
-	if in_iuse mpx ; then
-		confgcc+=( $(use_enable mpx libmpx) )
-	fi
-
-	if in_iuse vtv ; then
-		confgcc+=(
-			$(use_enable vtv vtable-verify)
-			$(use_enable vtv libvtv)
-		)
-	fi
-
-	# newer gcc's come with libquadmath, but only fortran uses
-	# it, so auto punt it when we don't care
-	if tc_version_is_at_least 4.6 && ! is_fortran ; then
-		confgcc+=( --disable-libquadmath )
-	fi
-
-	if tc_version_is_at_least 4.6 ; then
-		confgcc+=( --enable-lto )
-	elif tc_version_is_at_least 4.5 ; then
-		confgcc+=( --disable-lto )
-	fi
-
-	# graphite was added in 4.4 but we only support it in 4.8+ due to external
-	# library issues.  #448024
-	if tc_version_is_at_least 5.0 ; then
-		confgcc+=( $(use_with graphite isl) )
-		use graphite && confgcc+=( --disable-isl-version-check )
-	elif tc_version_is_at_least 4.8 ; then
-		confgcc+=( $(use_with graphite cloog) )
-		use graphite && confgcc+=( --disable-isl-version-check )
-	elif tc_version_is_at_least 4.4 ; then
-		confgcc+=( --without-{cloog,ppl} )
-	fi
-
-	if tc_version_is_at_least 4.8 ; then
-		confgcc+=( $(use_enable sanitize libsanitizer) )
-	fi
-
-	if tc_version_is_at_least 6.0 ; then
-		confgcc+=(
-			$(use_enable pie default-pie)
-			# This defaults to -fstack-protector-strong.
-			$(use_enable ssp default-ssp)
-		)
-	fi
-
-	# Disable gcc info regeneration -- it ships with generated info pages
-	# already.  Our custom version/urls/etc... trigger it.  #464008
-	export gcc_cv_prog_makeinfo_modern=no
-
-	# Do not let the X detection get in our way.  We know things can be found
-	# via system paths, so no need to hardcode things that'll break multilib.
-	# Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
-	# killing the 32bit builds which want /usr/lib.
-	export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
-
-	confgcc+=( "$@" ${EXTRA_ECONF} )
-
-	# Nothing wrong with a good dose of verbosity
-	echo
-	einfo "PREFIX:          ${PREFIX}"
-	einfo "BINPATH:         ${BINPATH}"
-	einfo "LIBPATH:         ${LIBPATH}"
-	einfo "DATAPATH:        ${DATAPATH}"
-	einfo "STDCXX_INCDIR:   ${STDCXX_INCDIR}"
-	echo
-	einfo "Languages:       ${GCC_LANG}"
-	echo
-	einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
-	echo
-
-	# Build in a separate build tree
-	mkdir -p "${WORKDIR}"/build
-	pushd "${WORKDIR}"/build > /dev/null
-
-	# and now to do the actual configuration
-	addwrite /dev/zero
-	echo "${S}"/configure "${confgcc[@]}"
-	# Older gcc versions did not detect bash and re-exec itself, so force the
-	# use of bash.  Newer ones will auto-detect, but this is not harmeful.
-	CONFIG_SHELL="${EPREFIX}/bin/bash" \
-	bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
-
-	# return to whatever directory we were in before
-	popd > /dev/null
-}
-
-# Replace -m flags unsupported by the version being built with the best
-# available equivalent
-downgrade_arch_flags() {
-	local arch bver i isa myarch mytune rep ver
-
-	bver=${1:-${GCC_BRANCH_VER}}
-	[[ $(gcc-version) < ${bver} ]] && return 0
-	[[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
-
-	myarch=$(get-flag march)
-	mytune=$(get-flag mtune)
-
-	# If -march=native isn't supported we have to tease out the actual arch
-	if [[ ${myarch} == native || ${mytune} == native ]] ; then
-		if [[ ${bver} < 4.2 ]] ; then
-			arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
-				| sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
-			replace-cpu-flags native ${arch}
-		fi
-	fi
-
-	# Handle special -mtune flags
-	[[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel generic
-	[[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
-	[[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
-	[[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
-
-	# "added" "arch" "replacement"
-	local archlist=(
-		4.9 bdver4 bdver3
-		4.9 bonnell atom
-		4.9 broadwell core-avx2
-		4.9 haswell core-avx2
-		4.9 ivybridge core-avx-i
-		4.9 nehalem corei7
-		4.9 sandybridge corei7-avx
-		4.9 silvermont corei7
-		4.9 westmere corei7
-		4.8 bdver3 bdver2
-		4.8 btver2 btver1
-		4.7 bdver2 bdver1
-		4.7 core-avx2 core-avx-i
-		4.6 bdver1 amdfam10
-		4.6 btver1 amdfam10
-		4.6 core-avx-i core2
-		4.6 corei7 core2
-		4.6 corei7-avx core2
-		4.5 atom core2
-		4.3 amdfam10 k8
-		4.3 athlon64-sse3 k8
-		4.3 barcelona k8
-		4.3 core2 nocona
-		4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
-		4.3 k8-sse3 k8
-		4.3 opteron-sse3 k8
-		3.4 athlon-fx x86-64
-		3.4 athlon64 x86-64
-		3.4 c3-2 c3
-		3.4 k8 x86-64
-		3.4 opteron x86-64
-		3.4 pentium-m pentium3
-		3.4 pentium3m pentium3
-		3.4 pentium4m pentium4
-	)
-
-	for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
-		myarch=$(get-flag march)
-		mytune=$(get-flag mtune)
-
-		ver=${archlist[i]}
-		arch=${archlist[i + 1]}
-		rep=${archlist[i + 2]}
-
-		[[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
-
-		if [[ ${ver} > ${bver} ]] ; then
-			einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..."
-			[[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep}
-			[[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep}
-			continue
-		else
-			break
-		fi
-	done
-
-	# we only check -mno* here since -m* get removed by strip-flags later on
-	local isalist=(
-		4.9 -mno-sha
-		4.9 -mno-avx512pf
-		4.9 -mno-avx512f
-		4.9 -mno-avx512er
-		4.9 -mno-avx512cd
-		4.8 -mno-xsaveopt
-		4.8 -mno-xsave
-		4.8 -mno-rtm
-		4.8 -mno-fxsr
-		4.7 -mno-lzcnt
-		4.7 -mno-bmi2
-		4.7 -mno-avx2
-		4.6 -mno-tbm
-		4.6 -mno-rdrnd
-		4.6 -mno-fsgsbase
-		4.6 -mno-f16c
-		4.6 -mno-bmi
-		4.5 -mno-xop
-		4.5 -mno-movbe
-		4.5 -mno-lwp
-		4.5 -mno-fma4
-		4.4 -mno-pclmul
-		4.4 -mno-fma
-		4.4 -mno-avx
-		4.4 -mno-aes
-		4.3 -mno-ssse3
-		4.3 -mno-sse4a
-		4.3 -mno-sse4
-		4.3 -mno-sse4.2
-		4.3 -mno-sse4.1
-		4.3 -mno-popcnt
-		4.3 -mno-abm
-	)
-
-	for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
-		ver=${isalist[i]}
-		isa=${isalist[i + 1]}
-		[[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-}
-	done
-}
-
-gcc_do_filter_flags() {
-	strip-flags
-	replace-flags -O? -O2
-
-	# dont want to funk ourselves
-	filter-flags '-mabi*' -m31 -m32 -m64
-
-	filter-flags -frecord-gcc-switches # 490738
-	filter-flags -mno-rtm -mno-htm # 506202
-
-	if tc_version_is_between 3.2 3.4 ; then
-		# XXX: this is so outdated it's barely useful, but it don't hurt...
-		replace-cpu-flags G3 750
-		replace-cpu-flags G4 7400
-		replace-cpu-flags G5 7400
-
-		# XXX: should add a sed or something to query all supported flags
-		#      from the gcc source and trim everything else ...
-		filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
-		filter-flags -f{no-,}stack-protector{,-all}
-		filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
-	fi
-
-	if tc_version_is_at_least 3.4 ; then
-		case $(tc-arch) in
-			amd64|x86)
-				filter-flags '-mcpu=*'
-
-				tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
-
-				if tc_version_is_between 4.6 4.7 ; then
-					# https://bugs.gentoo.org/411333
-					# https://bugs.gentoo.org/466454
-					replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
-				fi
-				;;
-			alpha)
-				# https://bugs.gentoo.org/454426
-				append-ldflags -Wl,--no-relax
-				;;
-			sparc)
-				# temporary workaround for random ICEs reproduced by multiple users
-				# https://bugs.gentoo.org/457062
-				tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
-				;;
-			*-macos)
-				# http://gcc.gnu.org/PR25127
-				tc_version_is_between 4.0 4.2 && \
-					filter-flags '-mcpu=*' '-march=*' '-mtune=*'
-				;;
-		esac
-	fi
-
-	strip-unsupported-flags
-
-	# these are set here so we have something sane at configure time
-	if is_crosscompile ; then
-		# Set this to something sane for both native and target
-		CFLAGS="-O2 -pipe"
-		FFLAGS=${CFLAGS}
-		FCFLAGS=${CFLAGS}
-
-		local VAR="CFLAGS_"${CTARGET//-/_}
-		CXXFLAGS=${!VAR}
-	fi
-
-	export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
-}
-
-setup_minispecs_gcc_build_specs() {
-	# Setup the "build.specs" file for gcc 4.3 to use when building.
-	if hardened_gcc_works pie ; then
-		cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
-	fi
-	if hardened_gcc_works ssp ; then
-		for s in ssp sspall ; do
-			cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
-		done
-	fi
-	for s in nostrict znow ; do
-		cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
-	done
-	export GCC_SPECS="${WORKDIR}"/build.specs
-}
-
-gcc-multilib-configure() {
-	if ! is_multilib ; then
-		confgcc+=( --disable-multilib )
-		# Fun times: if we are building for a target that has multiple
-		# possible ABI formats, and the user has told us to pick one
-		# that isn't the default, then not specifying it via the list
-		# below will break that on us.
-	else
-		confgcc+=( --enable-multilib )
-	fi
-
-	# translate our notion of multilibs into gcc's
-	local abi list
-	for abi in $(get_all_abis TARGET) ; do
-		local l=$(gcc-abi-map ${abi})
-		[[ -n ${l} ]] && list+=",${l}"
-	done
-	if [[ -n ${list} ]] ; then
-		case ${CTARGET} in
-		x86_64*)
-			tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
-			;;
-		esac
-	fi
-}
-
-gcc-abi-map() {
-	# Convert the ABI name we use in Gentoo to what gcc uses
-	local map=()
-	case ${CTARGET} in
-	mips*)   map=("o32 32" "n32 n32" "n64 64") ;;
-	x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
-	esac
-
-	local m
-	for m in "${map[@]}" ; do
-		l=( ${m} )
-		[[ $1 == ${l[0]} ]] && echo ${l[1]} && break
-	done
-}
-
-#----> src_compile <----
-
-toolchain_src_compile() {
-	touch "${S}"/gcc/c-gperf.h
-
-	# Do not make manpages if we do not have perl ...
-	[[ ! -x /usr/bin/perl ]] \
-		&& find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
-
-	gcc_do_make ${GCC_MAKE_TARGET}
-}
-
-gcc_do_make() {
-	# This function accepts one optional argument, the make target to be used.
-	# If omitted, gcc_do_make will try to guess whether it should use all,
-	# or bootstrap-lean depending on CTARGET and arch.
-	# An example of how to use this function:
-	#
-	#	gcc_do_make all-target-libstdc++-v3
-
-	[[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
-
-	# default target
-	if is_crosscompile || tc-is-cross-compiler ; then
-		# 3 stage bootstrapping doesnt quite work when you cant run the
-		# resulting binaries natively ^^;
-		GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
-	else
-		GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
-	fi
-
-	# Older versions of GCC could not do profiledbootstrap in parallel due to
-	# collisions with profiling info.
-	# boundschecking also seems to introduce parallel build issues.
-	if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || use_if_iuse boundschecking ; then
-		! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
-	fi
-
-	if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
-		STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
-	elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
-		# See bug #79852
-		STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
-	fi
-
-	if is_crosscompile; then
-		# In 3.4, BOOT_CFLAGS is never used on a crosscompile...
-		# but I'll leave this in anyways as someone might have had
-		# some reason for putting it in here... --eradicator
-		BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
-	else
-		# we only want to use the system's CFLAGS if not building a
-		# cross-compiler.
-		BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
-	fi
-
-	einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
-
-	pushd "${WORKDIR}"/build >/dev/null
-
-	emake \
-		LDFLAGS="${LDFLAGS}" \
-		STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
-		LIBPATH="${LIBPATH}" \
-		BOOT_CFLAGS="${BOOT_CFLAGS}" \
-		${GCC_MAKE_TARGET} \
-		|| die "emake failed with ${GCC_MAKE_TARGET}"
-
-	if ! is_crosscompile && use cxx && use_if_iuse doc ; then
-		if type -p doxygen > /dev/null ; then
-			if tc_version_is_at_least 4.3 ; then
-				cd "${CTARGET}"/libstdc++-v3/doc
-				emake doc-man-doxygen || ewarn "failed to make docs"
-			elif tc_version_is_at_least 3.0 ; then
-				cd "${CTARGET}"/libstdc++-v3
-				emake doxygen-man || ewarn "failed to make docs"
-			fi
-			# Clean bogus manpages.  #113902
-			find -name '*_build_*' -delete
-			# Blow away generated directory references.  Newer versions of gcc
-			# have gotten better at this, but not perfect.  This is easier than
-			# backporting all of the various doxygen patches.  #486754
-			find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
-				xargs rm -f
-		else
-			ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
-		fi
-	fi
-
-	popd >/dev/null
-}
-
-#---->> src_test <<----
-
-toolchain_src_test() {
-	if use regression-test ; then
-		cd "${WORKDIR}"/build
-		emake -k check
-	fi
-}
-
-#---->> src_install <<----
-
-toolchain_src_install() {
-	cd "${WORKDIR}"/build
-
-	# Do allow symlinks in private gcc include dir as this can break the build
-	find gcc/include*/ -type l -delete
-
-	# Copy over the info pages.  We disabled their generation earlier, but the
-	# build system only expects to install out of the build dir, not the source.  #464008
-	mkdir -p gcc/doc
-	local x=
-	for x in "${S}"/gcc/doc/*.info* ; do
-		if [[ -f ${x} ]] ; then
-			cp "${x}" gcc/doc/ || die
-		fi
-	done
-
-	# We remove the generated fixincludes, as they can cause things to break
-	# (ncurses, openssl, etc).  We do not prevent them from being built, as
-	# in the following commit which we revert:
-	# https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
-	# This is because bsd userland needs fixedincludes to build gcc, while
-	# linux does not.  Both can dispose of them afterwards.
-	while read x ; do
-		grep -q 'It has been auto-edited by fixincludes from' "${x}" \
-			&& rm -f "${x}"
-	done < <(find gcc/include*/ -name '*.h')
-
-	# Do the 'make install' from the build directory
-	S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
-
-	# Punt some tools which are really only useful while building gcc
-	find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
-	# This one comes with binutils
-	find "${D}" -name libiberty.a -delete
-
-	# Move the libraries to the proper location
-	gcc_movelibs
-
-	# Basic sanity check
-	if ! is_crosscompile ; then
-		local EXEEXT
-		eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
-		[[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
-	fi
-
-	dodir /etc/env.d/gcc
-	create_gcc_env_entry
-
-	# Setup the gcc_env_entry for hardened gcc 4 with minispecs
-	want_minispecs && copy_minispecs_gcc_specs
-
-	# Make sure we dont have stuff lying around that
-	# can nuke multiple versions of gcc
-	gcc_slot_java
-
-	dodir /usr/bin
-	cd "${D}"${BINPATH}
-	# Ugh: we really need to auto-detect this list.
-	#      It's constantly out of date.
-	for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
-		# For some reason, g77 gets made instead of ${CTARGET}-g77...
-		# this should take care of that
-		if [[ -f ${x} ]] ; then
-			# In case they're hardlinks, clear out the target first
-			# otherwise the mv below will complain.
-			rm -f ${CTARGET}-${x}
-			mv ${x} ${CTARGET}-${x}
-		fi
-
-		if [[ -f ${CTARGET}-${x} ]] ; then
-			if ! is_crosscompile ; then
-				ln -sf ${CTARGET}-${x} ${x}
-				dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
-					/usr/bin/${x}-${GCC_CONFIG_VER}
-			fi
-			# Create versioned symlinks
-			dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
-				/usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
-		fi
-
-		if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
-			rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
-			ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
-		fi
-	done
-	# Rename the main go binaries as we don't want to clobber dev-lang/go
-	# when gcc-config runs. #567806
-	if tc_version_is_at_least 5 && is_go ; then
-		for x in go gofmt; do
-			mv ${x} ${x}-${GCCMAJOR} || die
-		done
-	fi
-
-	# Now do the fun stripping stuff
-	env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
-	is_crosscompile && \
-		env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${HOSTLIBPATH}"
-	env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
-	# gcc used to install helper binaries in lib/ but then moved to libexec/
-	[[ -d ${D}${PREFIX}/libexec/gcc ]] && \
-		env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
-
-	cd "${S}"
-	if is_crosscompile; then
-		rm -rf "${ED}"usr/share/{man,info}
-		rm -rf "${D}"${DATAPATH}/{man,info}
-	else
-		if tc_version_is_at_least 3.0 ; then
-			local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
-			if [[ -d ${cxx_mandir} ]] ; then
-				cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
-			fi
-		fi
-		has noinfo ${FEATURES} \
-			&& rm -r "${D}${DATAPATH}"/info \
-			|| prepinfo "${DATAPATH#${EPREFIX}}"
-		has noman ${FEATURES} \
-			&& rm -r "${D}${DATAPATH}"/man \
-			|| prepman "${DATAPATH#${EPREFIX}}"
-	fi
-	# prune empty dirs left behind
-	find "${D}" -depth -type d -delete 2>/dev/null
-
-	# install testsuite results
-	if use regression-test; then
-		docinto testsuite
-		find "${WORKDIR}"/build -type f -name "*.sum" -exec dodoc {} +
-		find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -exec dodoc {} +
-	fi
-
-	# Rather install the script, else portage with changing $FILESDIR
-	# between binary and source package borks things ....
-	if ! is_crosscompile ; then
-		insinto "${DATAPATH#${EPREFIX}}"
-		newins "$(prefixify_ro "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
-		exeinto "${DATAPATH#${EPREFIX}}"
-		doexe "$(prefixify_ro "${GCC_FILESDIR}"/fix_libtool_files.sh)" || die
-		doexe "${GCC_FILESDIR}"/c{89,99} || die
-	fi
-
-	# libstdc++.la: Delete as it doesn't add anything useful: g++ itself
-	# handles linkage correctly in the dynamic & static case.  It also just
-	# causes us pain: any C++ progs/libs linking with libtool will gain a
-	# reference to the full libstdc++.la file which is gcc version specific.
-	# libstdc++fs.la: It doesn't link against anything useful.
-	# libsupc++.la: This has no dependencies.
-	# libcc1.la: There is no static library, only dynamic.
-	# libcc1plugin.la: Same as above, and it's loaded via dlopen.
-	# libgomp.la: gcc itself handles linkage (libgomp.spec).
-	# libgomp-plugin-*.la: Same as above, and it's an internal plugin only
-	# loaded via dlopen.
-	# libgfortran.la: gfortran itself handles linkage correctly in the
-	# dynamic & static case (libgfortran.spec). #573302
-	# libgfortranbegin.la: Same as above, and it's an internal lib.
-	# libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
-	# libmpxwrappers.la: See above.
-	# libitm.la: gcc itself handles linkage correctly (libitm.spec).
-	# libvtv.la: gcc itself handles linkage correctly.
-	# lib*san.la: Sanitizer linkage is handled internally by gcc, and they
-	# do not support static linking. #487550 #546700
-	find "${D}/${LIBPATH}" \
-		'(' \
-			-name libstdc++.la -o \
-			-name libstdc++fs.la -o \
-			-name libsupc++.la -o \
-			-name libcc1.la -o \
-			-name libcc1plugin.la -o \
-			-name 'libgomp.la' -o \
-			-name 'libgomp-plugin-*.la' -o \
-			-name libgfortran.la -o \
-			-name libgfortranbegin.la -o \
-			-name libmpx.la -o \
-			-name libmpxwrappers.la -o \
-			-name libitm.la -o \
-			-name libvtv.la -o \
-			-name 'lib*san.la' \
-		')' -type f -delete
-
-	# Use gid of 0 because some stupid ports don't have
-	# the group 'root' set to gid 0.  Send to /dev/null
-	# for people who are testing as non-root.
-	chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
-
-	# Move pretty-printers to gdb datadir to shut ldconfig up
-	local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
-	pushd "${D}${LIBPATH}" >/dev/null
-	for py in $(find . -name '*-gdb.py') ; do
-		local multidir=${py%/*}
-		insinto "${gdbdir}/${multidir}"
-		sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
-		doins "${py}" || die
-		rm "${py}" || die
-	done
-	popd >/dev/null
-
-	# Don't scan .gox files for executable stacks - false positives
-	export QA_EXECSTACK="usr/lib*/go/*/*.gox"
-	export QA_WX_LOAD="usr/lib*/go/*/*.gox"
-
-	# Disable RANDMMAP so PCH works. #301299
-	if tc_version_is_at_least 4.3 ; then
-		pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
-		pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
-	fi
-}
-
-# Move around the libs to the right location.  For some reason,
-# when installing gcc, it dumps internal libraries into /usr/lib
-# instead of the private gcc lib path
-gcc_movelibs() {
-	# older versions of gcc did not support --print-multi-os-directory
-	tc_version_is_at_least 3.2 || return 0
-
-	# For non-target libs which are for CHOST and not CTARGET, we want to
-	# move them to the compiler-specific CHOST internal dir.  This is stuff
-	# that you want to link against when building tools rather than building
-	# code to run on the target.
-	if tc_version_is_at_least 5 && is_crosscompile ; then
-		dodir "${HOSTLIBPATH#${EPREFIX}}"
-		mv "${ED}"usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
-	fi
-
-	# For all the libs that are built for CTARGET, move them into the
-	# compiler-specific CTARGET internal dir.
-	local x multiarg removedirs=""
-	for multiarg in $($(XGCC) -print-multi-lib) ; do
-		multiarg=${multiarg#*;}
-		multiarg=${multiarg//@/ -}
-
-		local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
-		local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
-		local TODIR="${D}${LIBPATH}"/${MULTIDIR}
-		local FROMDIR=
-
-		[[ -d ${TODIR} ]] || mkdir -p ${TODIR}
-
-		for FROMDIR in \
-			"${LIBPATH}"/${OS_MULTIDIR} \
-			"${LIBPATH}"/../${MULTIDIR} \
-			"${PREFIX}"/lib/${OS_MULTIDIR} \
-			"${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
-		do
-			removedirs="${removedirs} ${FROMDIR}"
-			FROMDIR=${D}${FROMDIR}
-			if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
-				local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
-				if [[ -n ${files} ]] ; then
-					mv ${files} "${TODIR}" || die
-				fi
-			fi
-		done
-		fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
-
-		# SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
-		FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
-		for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
-			[[ -f ${x} ]] || continue
-			sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
-			mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
-		done
-	done
-
-	# We remove directories separately to avoid this case:
-	#	mv SRC/lib/../lib/*.o DEST
-	#	rmdir SRC/lib/../lib/
-	#	mv SRC/lib/../lib32/*.o DEST  # Bork
-	for FROMDIR in ${removedirs} ; do
-		rmdir "${D}"${FROMDIR} >& /dev/null
-	done
-	find -depth "${D}" -type d -exec rmdir {} + >& /dev/null
-}
-
-# make sure the libtool archives have libdir set to where they actually
-# -are-, and not where they -used- to be.  also, any dependencies we have
-# on our own .la files need to be updated.
-fix_libtool_libdir_paths() {
-	local libpath="$1"
-
-	pushd "${D}" >/dev/null
-
-	pushd "./${libpath}" >/dev/null
-	local dir="${PWD#${D%/}}"
-	local allarchives=$(echo *.la)
-	allarchives="\(${allarchives// /\\|}\)"
-	popd >/dev/null
-
-	# The libdir might not have any .la files. #548782
-	find "./${dir}" -maxdepth 1 -name '*.la' \
-		-exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
-	# Would be nice to combine these, but -maxdepth can not be specified
-	# on sub-expressions.
-	find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
-		-exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
-	find "./${dir}/" -maxdepth 1 -name '*.la' \
-		-exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
-
-	popd >/dev/null
-}
-
-create_gcc_env_entry() {
-	dodir /etc/env.d/gcc
-	local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
-
-	local gcc_specs_file
-	local gcc_envd_file="${ED}${gcc_envd_base}"
-	if [[ -z $1 ]] ; then
-		# I'm leaving the following commented out to remind me that it
-		# was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
-		# on chroot or in non-toolchain.eclass gcc ebuilds!
-		#gcc_specs_file="${LIBPATH}/specs"
-		gcc_specs_file=""
-	else
-		gcc_envd_file+="-$1"
-		gcc_specs_file="${LIBPATH}/$1.specs"
-	fi
-
-	# We want to list the default ABI's LIBPATH first so libtool
-	# searches that directory first.  This is a temporary
-	# workaround for libtool being stupid and using .la's from
-	# conflicting ABIs by using the first one in the search path
-	local ldpaths mosdirs
-	if tc_version_is_at_least 3.2 ; then
-		local mdir mosdir abi ldpath
-		for abi in $(get_all_abis TARGET) ; do
-			mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
-			ldpath=${LIBPATH}
-			[[ ${mdir} != "." ]] && ldpath+="/${mdir}"
-			ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
-
-			mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
-			mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
-		done
-	else
-		# Older gcc's didn't do multilib, so logic is simple.
-		ldpaths=${LIBPATH}
-	fi
-
-	cat <<-EOF > ${gcc_envd_file}
-	PATH="${BINPATH}"
-	ROOTPATH="${BINPATH}"
-	GCC_PATH="${BINPATH}"
-	LDPATH="${ldpaths}"
-	MANPATH="${DATAPATH}/man"
-	INFOPATH="${DATAPATH}/info"
-	STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
-	CTARGET="${CTARGET}"
-	GCC_SPECS="${gcc_specs_file}"
-	MULTIOSDIRS="${mosdirs}"
-	EOF
-}
-
-copy_minispecs_gcc_specs() {
-	# on gcc 6 we don't need minispecs
-	if tc_version_is_at_least 6.0 ; then
-		return 0
-	fi
-
-	# setup the hardenedno* specs files and the vanilla specs file.
-	if hardened_gcc_works ; then
-		create_gcc_env_entry hardenednopiessp
-	fi
-	if hardened_gcc_works pie ; then
-		create_gcc_env_entry hardenednopie
-	fi
-	if hardened_gcc_works ssp ; then
-		create_gcc_env_entry hardenednossp
-	fi
-	create_gcc_env_entry vanilla
-	insinto ${LIBPATH#${EPREFIX}}
-	doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
-	# Build system specs file which, if it exists, must be a complete set of
-	# specs as it completely and unconditionally overrides the builtin specs.
-	if ! tc_version_is_at_least 4.4 ; then
-		$(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
-		cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
-		doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
-	fi
-}
-
-gcc_slot_java() {
-	local x
-
-	# Move Java headers to compiler-specific dir
-	for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
-		[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
-	done
-	for x in gcj gnu java javax org ; do
-		if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
-			dodir /${LIBPATH#${EPREFIX}}/include/${x}
-			mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
-			rm -rf "${D}${PREFIX}"/include/${x}
-		fi
-	done
-
-	if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
-		dodir /${LIBPATH#${EPREFIX}}/security
-		mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
-		rm -rf "${D}${PREFIX}"/lib*/security
-	fi
-
-	# Move random gcj files to compiler-specific directories
-	for x in libgcj.spec logging.properties ; do
-		x="${D}${PREFIX}/lib/${x}"
-		[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
-	done
-
-	# Rename jar because it could clash with Kaffe's jar if this gcc is
-	# primary compiler (aka don't have the -<version> extension)
-	cd "${D}${BINPATH}"
-	[[ -f jar ]] && mv -f jar gcj-jar
-}
-
-#---->> pkg_post* <<----
-
-toolchain_pkg_postinst() {
-	do_gcc_config
-
-	if ! is_crosscompile ; then
-		echo
-		ewarn "If you have issues with packages unable to locate libstdc++.la,"
-		ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
-		echo
-		ewarn "You might want to review the GCC upgrade guide when moving between"
-		ewarn "major versions (like 4.2 to 4.3):"
-		ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC"
-		echo
-
-		# Clean up old paths
-		rm -f "${EROOT}"*/rcscripts/awk/fixlafiles.awk "${EROOT}"sbin/fix_libtool_files.sh
-		rmdir "${EROOT}"*/rcscripts{/awk,} 2>/dev/null
-
-		mkdir -p "${EROOT}"usr/{share/gcc-data,sbin,bin}
-		# DATAPATH has EPREFIX already, use ROOT with it
-		cp "${ROOT}${DATAPATH}"/fixlafiles.awk "${EROOT}"usr/share/gcc-data/ || die
-		cp "${ROOT}${DATAPATH}"/fix_libtool_files.sh "${EROOT}"usr/sbin/ || die
-
-		# Since these aren't critical files and portage sucks with
-		# handling of binpkgs, don't require these to be found
-		cp "${ROOT}${DATAPATH}"/c{89,99} "${EROOT}"usr/bin/ 2>/dev/null
-	fi
-
-	if use regression-test ; then
-		elog "Testsuite results have been installed into /usr/share/doc/${PF}/testsuite"
-		echo
-	fi
-
-	if [[ -n ${PRERELEASE}${SNAPSHOT} ]] ; then
-		einfo "This GCC ebuild is provided for your convenience, and the use"
-		einfo "of this compiler is not supported by the Gentoo Developers."
-		einfo "Please report bugs to upstream at http://gcc.gnu.org/bugzilla/"
-	fi
-}
-
-toolchain_pkg_postrm() {
-	# to make our lives easier (and saner), we do the fix_libtool stuff here.
-	# rather than checking SLOT's and trying in upgrade paths, we just see if
-	# the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
-	# unmerging.  if it does, that means this was a simple re-emerge.
-
-	# clean up the cruft left behind by cross-compilers
-	if is_crosscompile ; then
-		if [[ -z $(ls "${EROOT}"etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
-			rm -f "${EROOT}"etc/env.d/gcc/config-${CTARGET}
-			rm -f "${EROOT}"etc/env.d/??gcc-${CTARGET}
-			rm -f "${EROOT}"usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
-		fi
-		return 0
-	fi
-
-	# ROOT isnt handled by the script
-	[[ ${ROOT} != "/" ]] && return 0
-
-	if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
-		# make sure the profile is sane during same-slot upgrade #289403
-		do_gcc_config
-
-		einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
-		fix_libtool_files.sh ${GCC_RELEASE_VER}
-		if [[ -n ${BRANCH_UPDATE} ]] ; then
-			einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
-			fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
-		fi
-	fi
-
-	return 0
-}
-
-do_gcc_config() {
-	if ! should_we_gcc_config ; then
-		env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config --use-old --force
-		return 0
-	fi
-
-	local current_gcc_config target
-
-	current_gcc_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
-	if [[ -n ${current_gcc_config} ]] ; then
-		local current_specs use_specs
-		# figure out which specs-specific config is active
-		current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
-		[[ -n ${current_specs} ]] && use_specs=-${current_specs}
-
-		if [[ -n ${use_specs} ]] && \
-		   [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
-		then
-			ewarn "The currently selected specs-specific gcc config,"
-			ewarn "${current_specs}, doesn't exist anymore. This is usually"
-			ewarn "due to enabling/disabling hardened or switching to a version"
-			ewarn "of gcc that doesnt create multiple specs files. The default"
-			ewarn "config will be used, and the previous preference forgotten."
-			use_specs=""
-		fi
-
-		target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
-	else
-		# The curent target is invalid.  Attempt to switch to a valid one.
-		# Blindly pick the latest version.  #529608
-		# TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
-		# doing a partial grep like this.
-		target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
-	fi
-
-	gcc-config "${target}"
-}
-
-should_we_gcc_config() {
-	# if the current config is invalid, we definitely want a new one
-	# Note: due to bash quirkiness, the following must not be 1 line
-	local curr_config
-	curr_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
-
-	# if the previously selected config has the same major.minor (branch) as
-	# the version we are installing, then it will probably be uninstalled
-	# for being in the same SLOT, make sure we run gcc-config.
-	local curr_config_ver=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
-
-	local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
-
-	if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
-		return 0
-	else
-		# if we're installing a genuinely different compiler version,
-		# we should probably tell the user -how- to switch to the new
-		# gcc version, since we're not going to do it for him/her.
-		# We don't want to switch from say gcc-3.3 to gcc-3.4 right in
-		# the middle of an emerge operation (like an 'emerge -e world'
-		# which could install multiple gcc versions).
-		# Only warn if we're installing a pkg as we might be called from
-		# the pkg_{pre,post}rm steps.  #446830
-		if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
-			einfo "The current gcc config appears valid, so it will not be"
-			einfo "automatically switched for you.  If you would like to"
-			einfo "switch to the newly installed gcc version, do the"
-			einfo "following:"
-			echo
-			einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
-			einfo "source /etc/profile"
-			echo
-		fi
-		return 1
-	fi
-}
-
-#---->> support and misc functions <<----
-
-# This is to make sure we don't accidentally try to enable support for a
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
-#
-# Also add a hook so special ebuilds (kgcc64) can control which languages
-# exactly get enabled
-gcc-lang-supported() {
-	grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
-	[[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
-	has $1 ${TOOLCHAIN_ALLOWED_LANGS}
-}
-
-is_ada() {
-	gcc-lang-supported ada || return 1
-	use ada
-}
-
-is_cxx() {
-	gcc-lang-supported 'c++' || return 1
-	! is_crosscompile && tc_version_is_at_least 4.8 && return 0
-	use cxx
-}
-
-is_d() {
-	gcc-lang-supported d || return 1
-	use_if_iuse d
-}
-
-is_f77() {
-	gcc-lang-supported f77 || return 1
-	use fortran
-}
-
-is_f95() {
-	gcc-lang-supported f95 || return 1
-	use fortran
-}
-
-is_fortran() {
-	gcc-lang-supported fortran || return 1
-	use fortran
-}
-
-is_gcj() {
-	gcc-lang-supported java || return 1
-	use cxx && use_if_iuse gcj
-}
-
-is_go() {
-	gcc-lang-supported go || return 1
-	use cxx && use_if_iuse go
-}
-
-is_jit() {
-	gcc-lang-supported jit || return 1
-	use_if_iuse jit
-}
-
-is_multilib() {
-	tc_version_is_at_least 3 || return 1
-	use multilib
-}
-
-is_objc() {
-	gcc-lang-supported objc || return 1
-	use_if_iuse objc
-}
-
-is_objcxx() {
-	gcc-lang-supported 'obj-c++' || return 1
-	use cxx && use_if_iuse objc++
-}
-
-# Grab a variable from the build system (taken from linux-info.eclass)
-get_make_var() {
-	local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
-	echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
-		r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
-}
-
-XGCC() { get_make_var GCC_FOR_TARGET ; }
-
-# The gentoo piessp patches allow for 3 configurations:
-# 1) PIE+SSP by default
-# 2) PIE by default
-# 3) SSP by default
-hardened_gcc_works() {
-	if [[ $1 == "pie" ]] ; then
-		# $gcc_cv_ld_pie is unreliable as it simply take the output of
-		# `ld --help | grep -- -pie`, that reports the option in all cases, also if
-		# the loader doesn't actually load the resulting executables.
-		# To avoid breakage, blacklist FreeBSD here at least
-		[[ ${CTARGET} == *-freebsd* ]] && return 1
-
-		want_pie || return 1
-		use_if_iuse nopie && return 1
-		hardened_gcc_is_stable pie
-		return $?
-	elif [[ $1 == "ssp" ]] ; then
-		[[ -n ${SPECS_VER} ]] || return 1
-		use_if_iuse nossp && return 1
-		hardened_gcc_is_stable ssp
-		return $?
-	else
-		# laziness ;)
-		hardened_gcc_works pie || return 1
-		hardened_gcc_works ssp || return 1
-		return 0
-	fi
-}
-
-hardened_gcc_is_stable() {
-	local tocheck
-	if [[ $1 == "pie" ]] ; then
-		if [[ ${CTARGET} == *-uclibc* ]] ; then
-			tocheck=${PIE_UCLIBC_STABLE}
-		else
-			tocheck=${PIE_GLIBC_STABLE}
-		fi
-	elif [[ $1 == "ssp" ]] ; then
-		if [[ ${CTARGET} == *-uclibc* ]] ; then
-			tocheck=${SSP_UCLIBC_STABLE}
-		elif  [[ ${CTARGET} == *-gnu* ]] ; then
-			tocheck=${SSP_STABLE}
-		fi
-	else
-		die "hardened_gcc_stable needs to be called with pie or ssp"
-	fi
-
-	has $(tc-arch) ${tocheck} && return 0
-	return 1
-}
-
-want_minispecs() {
-	# on gcc 6 we don't need minispecs
-	if tc_version_is_at_least 6.0 ; then
-		return 0
-	fi
-	if tc_version_is_at_least 4.3.2 && use hardened ; then
-		if ! want_pie ; then
-			ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
-		elif use vanilla ; then
-			ewarn "You will not get hardened features if you have the vanilla USE-flag."
-		elif use nopie && use nossp ; then
-			ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
-		elif ! hardened_gcc_works ; then
-			ewarn "Your $(tc-arch) arch is not supported."
-		else
-			return 0
-		fi
-		ewarn "Hope you know what you are doing. Hardened will not work."
-		return 0
-	fi
-	return 1
-}
-
-want_pie() {
-	! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
-	[[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
-	tc_version_is_at_least 4.3.2 && return 1
-	[[ -z ${PIE_VER} ]] && return 1
-	use !nopie && return 0
-	return 1
-}
-
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
-toolchain_death_notice() {
-	if [[ -e "${WORKDIR}"/build ]] ; then
-		pushd "${WORKDIR}"/build >/dev/null
-		(echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
-		[[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
-		tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
-			gccinfo.log build.log $(find -name config.log)
-		rm gccinfo.log build.log
-		eerror
-		eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
-		eerror
-		popd >/dev/null
-	fi
-}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2017-08-30  9:22 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2017-08-30  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     9ef840da9329237f76d336c7b490281714391429
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 24 08:06:40 2017 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Thu Aug 24 08:06:40 2017 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=9ef840da

eclass/R-packages.eclass: merged to R_Overlay.

 eclass/R-packages.eclass | 51 ------------------------------------------------
 1 file changed, 51 deletions(-)

diff --git a/eclass/R-packages.eclass b/eclass/R-packages.eclass
deleted file mode 100644
index cea7eba..0000000
--- a/eclass/R-packages.eclass
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: $
-
-inherit eutils
-
-EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst
-
-SLOT="0"
-KEYWORDS="~amd64 ~x86"
-IUSE="byte-compile"
-
-DEPEND="dev-lang/R"
-RDEPEND="${DEPEND}"
-
-S="${WORKDIR}"
-
-R-packages_src_unpack() {
-	unpack ${A}
-	mv ${PN//_/.} ${P}
-}
-
-R-packages_src_prepare() {
-	cd ${P}
-	epatch_user
-}
-
-R-packages_src_compile() {
-	einfo "R CMD INSTALL ${S}/${P} -l . $(use byte-compile && echo --byte-compile)"
-	MAKEFLAGS="CFLAGS=${CFLAGS// /\\ } CXXFLAGS=${CXXFLAGS// /\\ } FFLAGS=${FFLAGS// /\\ } FCFLAGS=${FCFLAGS// /\\ } LDFLAGS=${LDFLAGS// /\\ }" \
-		R CMD INSTALL ${S}/${P} -l . $(use byte-compile && echo --byte-compile)
-}
-
-R-packages_src_install() {
-	insinto /usr/$(get_libdir)/R/site-library
-	doins -r ${PN//_/.}
-}
-
-R-packages_pkg_postinst() {
-	if [[ "${_UNRESOLVABLE_PACKAGES:-}" ]]; then
-		# _UNRESOLVABLE_PACKAGES is only set if it has more than zero items
-		local _max=${#_UNRESOLVABLE_PACKAGES[*]} i=
-
-		einfo "Dependency(-ies):"
-		for (( i=0; i<${_max}; i++ )); do
-			einfo "- ${_UNRESOLVABLE_PACKAGES[$i]}"
-		done
-		einfo 'are (is) suggested by upstream but could not be found.'
-		einfo 'Please install it manually from the R interpreter if you need it.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/android:master commit in: eclass/
@ 2017-11-27  1:09 Benda XU
  0 siblings, 0 replies; 21+ messages in thread
From: Benda XU @ 2017-11-27  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     ebdd8464a4a6072da5f2fd6775ae062a080c3776
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 27 01:08:42 2017 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 01:08:42 2017 +0000
URL:        https://gitweb.gentoo.org/proj/android.git/commit/?id=ebdd8464

db.eclass, user.eclass: upstreamed.

 eclass/db.eclass   | 210 ------------------------
 eclass/user.eclass | 474 -----------------------------------------------------
 2 files changed, 684 deletions(-)

diff --git a/eclass/db.eclass b/eclass/db.eclass
deleted file mode 100644
index f7070d4..0000000
--- a/eclass/db.eclass
+++ /dev/null
@@ -1,210 +0,0 @@
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/db.eclass,v 1.49 2013/07/21 09:23:45 pacho Exp $
-# This is a common location for functions used in the sys-libs/db ebuilds
-#
-# Bugs: maintainer-needed@gentoo.org
-
-inherit eutils multilib
-
-IUSE="doc test examples"
-
-EXPORT_FUNCTIONS src_test
-
-DEPEND="test? ( >=dev-lang/tcl-8.4 )"
-
-RDEPEND=""
-
-db_fix_so() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
-	LIB="${EROOT}/usr/$(get_libdir)"
-
-	cd "${LIB}"
-
-	# first clean up old symlinks
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
-	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
-	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
-
-	# now rebuild all the correct ones
-	for ext in so a dylib sl; do
-		for name in libdb libdb_{cxx,tcl,java,sql,stl}; do
-			target=`find . -maxdepth 1 -type f -name "${name}-*.${ext}" |sort -n |tail -n 1`
-			[ -n "${target}" ] || continue;
-			case ${CHOST} in 
-			*-aix*)
-				aixdll --merge-runtime \
-					--keepdir=false \
-					--target="${name}.${ext}" \
-					--current="${target}" \
-					`find . -maxdepth 1 -type f -name "${name}-*.${ext}"`
-				;;
-			*)
-				ln -sf ${target//.\//} ${name}.${ext}
-				;;
-			esac;
-		done;
-	done;
-
-	# db[23] gets some extra-special stuff
-	if [ -f libdb1$(get_libname 2) ]; then
-		ln -sf libdb1$(get_libname 2) libdb$(get_libname 2)
-		ln -sf libdb1$(get_libname 2) libdb1$(get_libname)
-		ln -sf libdb1$(get_libname 2) libdb-1$(get_libame)
-	fi
-	# what do we do if we ever get 3.3 ?
-	for i in libdb libdb_{cxx,tcl,java,sql,stl}; do
-		if [ -f $i-3$(get_libname 2) ]; then
-			ln -sf $i-3$(get_libname 2) $i-3$(get_libname)
-			ln -sf $i-3$(get_libname 2) $i$(get_libname 3)
-		fi
-	done
-
-	# do the same for headers now
-	# but since there are only two of them, just overwrite them
-	cd "${EROOT}"/usr/include
-	target=`find . -maxdepth 1 -type d -name 'db[0-9]*' | sort -n |cut -d/ -f2- | tail -n1`
-	if [ -n "${target}" ] && [ -e "${target}/db.h" ] && ( ! [[ -e db.h ]] || [[ -h db.h ]] ); then
-		einfo "Creating db.h symlinks to ${target}"
-		ln -sf "${target}"/db.h .
-		ln -sf "${target}"/db_185.h .
-	elif [ ! -e "${target}/db.h" ]; then
-		if [ -n "${target}" ]; then
-			ewarn "Could not find ${target}/db.h"
-		elif [ -h db.h ]; then
-			einfo "Apparently you just removed the last instance of $PN. Removing the symlinks"
-			rm -f db.h db_185.h
-		fi
-	fi
-}
-
-db_src_install_doc() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-	# not everybody wants this wad of documentation as it is primarily API docs
-	if use doc; then
-		dodir /usr/share/doc/${PF}/html
-		mv "${ED}"/usr/docs/* "${ED}"/usr/share/doc/${PF}/html/
-		rm -rf "${ED}"/usr/docs
-	else
-		rm -rf "${ED}"/usr/docs
-	fi
-
-	db_src_install_examples
-}
-
-db_src_install_examples() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-	if use examples ; then
-		local langs="c cxx stl"
-		[[ "${IUSE/java}" != "${IUSE}" ]] \
-			&& use java \
-			&& langs="${langs} java"
-		for i in $langs ; do
-			destdir="/usr/share/doc/${PF}/"
-			src="${S}/../examples_${i}/"
-			if [ -f "${src}" ]; then
-				dodir "${destdir}"
-				cp -ra "${src}" "${ED}${destdir}/"
-			fi
-		done
-	fi
-}
-
-db_src_install_usrbinslot() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-	# slot all program names to avoid overwriting
-	for fname in "${ED}"/usr/bin/db*
-	do
-		dn="$(dirname "${fname}")"
-		bn="$(basename "${fname}")"
-		bn="${bn/db/db${SLOT}}"
-		mv "${fname}" "${dn}/${bn}" || \
-			die "Failed to rename ${fname} to ${dn}/${bn}"
-	done
-}
-
-db_src_install_headerslot() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-	# install all headers in a slotted location
-	dodir /usr/include/db${SLOT}
-	mv "${ED}"/usr/include/*.h "${ED}"/usr/include/db${SLOT}/
-}
-
-db_src_install_usrlibcleanup() {
-	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-	LIB="${ED}/usr/$(get_libdir)"
-	# Clean out the symlinks so that they will not be recorded in the
-	# contents (bug #60732)
-
-	if [ "${ED}" = "" ]; then
-		die "Calling clean_links while \$ED not defined"
-	fi
-
-	if [ -e "${LIB}"/libdb.a ] && [ ! -e "${LIB}"/libdb-${SLOT}.a ]; then
-		einfo "Moving libdb.a to a versioned name"
-		mv "${LIB}/libdb.a" "${LIB}/libdb-${SLOT}.a"
-	fi
-
-	if [ -e "${LIB}"/libdb_cxx.a ] && [ ! -e "${LIB}"/libdb_cxx-${SLOT}.a ]; then
-		einfo "Moving libdb_cxx.a to a versioned name"
-		mv "${LIB}/libdb_cxx.a" "${LIB}/libdb_cxx-${SLOT}.a"
-	fi
-
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" -delete
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname "[23]")" -delete
-	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete #519364
-	find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" -delete #519364
-	einfo "removing unversioned static archives"
-	find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
-
-	rm -f \
-		"${ED}"/usr/include/{db,db_185}.h \
-		"${LIB}"/libdb{,_{cxx,sql,stl,java,tcl}}.a
-}
-
-db_src_test() {
-	if [[ $UID -eq 0 ]]; then
-		M="You must run the testsuite as non-root, skipping"
-		ewarn "${M}"
-		elog "${M}"
-		return 0
-	fi
-
-	if use tcl; then
-		einfo "Running sys-libs/db testsuite"
-		ewarn "This can take 6+ hours on modern machines"
-		# Fix stuff that fails with relative paths, and upstream moving files
-		# around...
-		local test_parallel=''
-		for t in \
-			"${S}"/test/parallel.tcl \
-			"${S}"/../test/parallel.tcl \
-			"${S}"/test/tcl/parallel.tcl \
-			"${S}"/../test/tcl/parallel.tcl \
-			; do
-			[[ -f "${t}" ]] && test_parallel="${t}" && break
-		done
-
-		sed -ri \
-			-e '/regsub .test_path ./s,(regsub),#\1,g' \
-			-e '/regsub .src_root ./s,(regsub),#\1,g' \
-			-e '/regsub .tcl_utils ./s,(regsub),#\1,g' \
-			"${test_parallel}"
-		cd "${S}"
-		for t in \
-			../test/test.tcl \
-			../test/tcl/test.tcl \
-			; do
-			[[ -f "${t}" ]] && testbase="${t}" && break
-		done
-		echo "source ${t}" > testrunner.tcl
-		echo "run_parallel $(makeopts_jobs) run_std" >> testrunner.tcl
-
-		tclsh testrunner.tcl
-		egrep -qs '^FAIL' ALL.OUT* && die "Some tests failed, please see ${S}/ALL.OUT*"
-	else
-		eerror "You must have USE=tcl to run the sys-libs/db testsuite."
-	fi
-}

diff --git a/eclass/user.eclass b/eclass/user.eclass
deleted file mode 100644
index 9fddbbb..0000000
--- a/eclass/user.eclass
+++ /dev/null
@@ -1,474 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: user.eclass
-# @MAINTAINER:
-# base-system@gentoo.org (Linux)
-# Joe Jezak <josejx@gmail.com> (OS X)
-# usata@gentoo.org (OS X)
-# Aaron Walker <ka0ttic@gentoo.org> (FreeBSD)
-# @BLURB: user management in ebuilds
-# @DESCRIPTION:
-# The user eclass contains a suite of functions that allow ebuilds
-# to quickly make sure users in the installed system are sane.
-
-if [[ -z ${_USER_ECLASS} ]]; then
-_USER_ECLASS=1
-
-# @FUNCTION: _assert_pkg_ebuild_phase
-# @INTERNAL
-# @USAGE: <calling func name>
-_assert_pkg_ebuild_phase() {
-	case ${EBUILD_PHASE} in
-	setup|preinst|postinst) ;;
-	*)
-		eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:"
-		eerror "You may only call from pkg_{setup,preinst,postinst} functions."
-		eerror "Package fails at QA and at life.  Please file a bug."
-		die "Bad package!  $1 is only for use in some pkg_* functions!"
-	esac
-}
-
-# @FUNCTION: egetent
-# @USAGE: <database> <key>
-# @DESCRIPTION:
-# Small wrapper for getent (Linux), nidump (< Mac OS X 10.5),
-# dscl (Mac OS X 10.5), and pw (FreeBSD) used in enewuser()/enewgroup().
-#
-# Supported databases: group passwd
-egetent() {
-	local db=$1 key=$2
-
-	[[ $# -ge 3 ]] && die "usage: egetent <database> <key>"
-
-	case ${db} in
-	passwd|group) ;;
-	*) die "sorry, database '${db}' not yet supported; file a bug" ;;
-	esac
-
-	case ${CHOST} in
-	*-darwin[678])
-		case ${key} in
-		*[!0-9]*) # Non numeric
-			nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
-			;;
-		*)	# Numeric
-			nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
-			;;
-		esac
-		;;
-	*-darwin*)
-		local mykey
-		case ${db} in
-		passwd) db="Users"  mykey="UniqueID" ;;
-		group)  db="Groups" mykey="PrimaryGroupID" ;;
-		esac
-
-		case ${key} in
-		*[!0-9]*) # Non numeric
-			dscl . -read /${db}/${key} 2>/dev/null |grep RecordName
-			;;
-		*)	# Numeric
-			dscl . -search /${db} ${mykey} ${key} 2>/dev/null
-			;;
-		esac
-		;;
-	*-freebsd*|*-dragonfly*)
-		case ${db} in
-		passwd) db="user" ;;
-		*) ;;
-		esac
-
-		# lookup by uid/gid
-		local opts
-		if [[ ${key} == [[:digit:]]* ]] ; then
-			[[ ${db} == "user" ]] && opts="-u" || opts="-g"
-		fi
-
-		pw show ${db} ${opts} "${key}" -q
-		;;
-	*-netbsd*|*-openbsd*)
-		grep "${key}:\*:" /etc/${db}
-		;;
-	*)
-		# ignore output if nscd doesn't exist, or we're not running as root
-		nscd -i "${db}" 2>/dev/null
-		getent "${db}" "${key}"
-		;;
-	esac
-}
-
-# @FUNCTION: enewuser
-# @USAGE: <user> [uid] [shell] [homedir] [groups]
-# @DESCRIPTION:
-# Same as enewgroup, you are not required to understand how to properly add
-# a user to the system.  The only required parameter is the username.
-# Default uid is (pass -1 for this) next available, default shell is
-# /bin/false, default homedir is /dev/null, and there are no default groups.
-enewuser() {
-	if [[ ${EUID} != 0 ]] ; then
-		einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
-		return 0
-	fi
-	_assert_pkg_ebuild_phase ${FUNCNAME}
-
-	# get the username
-	local euser=$1; shift
-	if [[ -z ${euser} ]] ; then
-		eerror "No username specified !"
-		die "Cannot call enewuser without a username"
-	fi
-
-	# lets see if the username already exists
-	if [[ -n $(egetent passwd "${euser}") ]] ; then
-		return 0
-	fi
-	einfo "Adding user '${euser}' to your system ..."
-
-	# options to pass to useradd
-	local opts=()
-
-	# handle uid
-	local euid=$1; shift
-	if [[ -n ${euid} && ${euid} != -1 ]] ; then
-		if [[ ${euid} -gt 0 ]] ; then
-			if [[ -n $(egetent passwd ${euid}) ]] ; then
-				euid="next"
-			fi
-		else
-			eerror "Userid given but is not greater than 0 !"
-			die "${euid} is not a valid UID"
-		fi
-	else
-		euid="next"
-	fi
-	if [[ ${euid} == "next" ]] ; then
-		for ((euid = 101; euid <= 999; euid++)); do
-			[[ -z $(egetent passwd ${euid}) ]] && break
-		done
-	fi
-	opts+=( -u ${euid} )
-	einfo " - Userid: ${euid}"
-
-	# handle shell
-	local eshell=$1; shift
-	if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
-		if [[ ! -e ${ROOT}${eshell} ]] ; then
-			eerror "A shell was specified but it does not exist !"
-			die "${eshell} does not exist in ${ROOT}"
-		fi
-		if [[ ${eshell} == */false || ${eshell} == */nologin ]] ; then
-			eerror "Do not specify ${eshell} yourself, use -1"
-			die "Pass '-1' as the shell parameter"
-		fi
-	else
-		for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do
-			[[ -x ${ROOT}${eshell} ]] && break
-		done
-
-		if [[ ${eshell} == "/dev/null" ]] ; then
-			eerror "Unable to identify the shell to use, proceeding with userland default."
-			case ${USERLAND} in
-				GNU)    eshell="/bin/false" ;;
-				BSD)    eshell="/sbin/nologin" ;;
-				Darwin) eshell="/usr/sbin/nologin" ;;
-				*) die "Unable to identify the default shell for userland ${USERLAND}"
-			esac
-		fi
-	fi
-	einfo " - Shell: ${eshell}"
-	opts+=( -s "${eshell}" )
-
-	# handle homedir
-	local ehome=$1; shift
-	if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
-		ehome="/dev/null"
-	fi
-	einfo " - Home: ${ehome}"
-	opts+=( -d "${ehome}" )
-
-	# handle groups
-	local egroups=$1; shift
-	local g egroups_arr
-	IFS="," read -r -a egroups_arr <<<"${egroups}"
-	shift
-	if [[ ${#egroups_arr[@]} -gt 0 ]] ; then
-		local defgroup exgroups
-		for g in "${egroups_arr[@]}" ; do
-			if [[ -z $(egetent group "${g}") ]] ; then
-				eerror "You must add group ${g} to the system first"
-				die "${g} is not a valid GID"
-			fi
-			if [[ -z ${defgroup} ]] ; then
-				defgroup=${g}
-			else
-				exgroups+=",${g}"
-			fi
-		done
-		opts+=( -g "${defgroup}" )
-		if [[ ! -z ${exgroups} ]] ; then
-			opts+=( -G "${exgroups:1}" )
-		fi
-	fi
-	einfo " - Groups: ${egroups:-(none)}"
-
-	# handle extra args
-	if [[ $# -gt 0 ]] ; then
-		die "extra arguments no longer supported; please file a bug"
-	else
-		local comment="added by portage for ${PN}"
-		opts+=( -c "${comment}" )
-		einfo " - GECOS: ${comment}"
-	fi
-
-	# add the user
-	case ${CHOST} in
-	*-darwin*)
-		### Make the user
-		dscl . create "/users/${euser}" uid ${euid}
-		dscl . create "/users/${euser}" shell "${eshell}"
-		dscl . create "/users/${euser}" home "${ehome}"
-		dscl . create "/users/${euser}" realname "added by portage for ${PN}"
-		### Add the user to the groups specified
-		for g in "${egroups_arr[@]}" ; do
-			dscl . merge "/groups/${g}" users "${euser}"
-		done
-		;;
-
-	*-freebsd*|*-dragonfly*)
-		pw useradd "${euser}" "${opts[@]}" || die
-		;;
-
-	*-netbsd*)
-		useradd "${opts[@]}" "${euser}" || die
-		;;
-
-	*-openbsd*)
-		# all ops the same, except the -g vs -g/-G ...
-		useradd -u ${euid} -s "${eshell}" \
-			-d "${ehome}" -g "${egroups}" "${euser}" || die
-		;;
-
-	*)
-		useradd -r "${opts[@]}" "${euser}" || die
-		;;
-	esac
-
-	if [[ ! -e ${ROOT}/${ehome} ]] ; then
-		einfo " - Creating ${ehome} in ${ROOT}"
-		mkdir -p "${ROOT}/${ehome}"
-		chown "${euser}" "${ROOT}/${ehome}"
-		chmod 755 "${ROOT}/${ehome}"
-	fi
-}
-
-# @FUNCTION: enewgroup
-# @USAGE: <group> [gid]
-# @DESCRIPTION:
-# This function does not require you to understand how to properly add a
-# group to the system.  Just give it a group name to add and enewgroup will
-# do the rest.  You may specify the gid for the group or allow the group to
-# allocate the next available one.
-enewgroup() {
-	if [[ ${EUID} != 0 ]] ; then
-		einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
-		return 0
-	fi
-	_assert_pkg_ebuild_phase ${FUNCNAME}
-
-	# get the group
-	local egroup=$1; shift
-	if [[ -z ${egroup} ]] ; then
-		eerror "No group specified !"
-		die "Cannot call enewgroup without a group"
-	fi
-
-	# see if group already exists
-	if [[ -n $(egetent group "${egroup}") ]] ; then
-		return 0
-	fi
-	einfo "Adding group '${egroup}' to your system ..."
-
-	# handle gid
-	local egid=$1; shift
-	if [[ ! -z ${egid} ]] ; then
-		if [[ ${egid} -gt 0 ]] ; then
-			if [[ -n $(egetent group ${egid}) ]] ; then
-				egid="next available; requested gid taken"
-			fi
-		else
-			eerror "Groupid given but is not greater than 0 !"
-			die "${egid} is not a valid GID"
-		fi
-	else
-		egid="next available"
-	fi
-	einfo " - Groupid: ${egid}"
-
-	# handle extra
-	if [[ $# -gt 0 ]] ; then
-		die "extra arguments no longer supported; please file a bug"
-	fi
-
-	# Some targets need to find the next available GID manually
-	_enewgroup_next_gid() {
-		if [[ ${egid} == *[!0-9]* ]] ; then
-			# Non numeric
-			for ((egid = 101; egid <= 999; egid++)) ; do
-				[[ -z $(egetent group ${egid}) ]] && break
-			done
-		fi
-	}
-
-	# add the group
-	case ${CHOST} in
-	*-darwin*)
-		_enewgroup_next_gid
-		dscl . create "/groups/${egroup}" gid ${egid}
-		dscl . create "/groups/${egroup}" passwd '*'
-		;;
-
-	*-freebsd*|*-dragonfly*)
-		_enewgroup_next_gid
-		pw groupadd "${egroup}" -g ${egid} || die
-		;;
-
-	*-netbsd*)
-		_enewgroup_next_gid
-		groupadd -g ${egid} "${egroup}" || die
-		;;
-
-	*)
-		local opts
-		if [[ ${egid} == *[!0-9]* ]] ; then
-			# Non numeric; let groupadd figure out a GID for us
-			opts=""
-		else
-			opts="-g ${egid}"
-		fi
-		# We specify -r so that we get a GID in the system range from login.defs
-		groupadd -r ${opts} "${egroup}" || die
-		;;
-	esac
-}
-
-# @FUNCTION: egethome
-# @USAGE: <user>
-# @DESCRIPTION:
-# Gets the home directory for the specified user.
-egethome() {
-	local pos
-
-	[[ $# -eq 1 ]] || die "usage: egethome <user>"
-
-	case ${CHOST} in
-	*-darwin*|*-freebsd*|*-dragonfly*)
-		pos=9
-		;;
-	*)	# Linux, NetBSD, OpenBSD, etc...
-		pos=6
-		;;
-	esac
-
-	egetent passwd "$1" | cut -d: -f${pos}
-}
-
-# @FUNCTION: egetshell
-# @USAGE: <user>
-# @DESCRIPTION:
-# Gets the shell for the specified user.
-egetshell() {
-	local pos
-
-	[[ $# -eq 1 ]] || die "usage: egetshell <user>"
-
-	case ${CHOST} in
-	*-darwin*|*-freebsd*|*-dragonfly*)
-		pos=10
-		;;
-	*)	# Linux, NetBSD, OpenBSD, etc...
-		pos=7
-		;;
-	esac
-
-	egetent passwd "$1" | cut -d: -f${pos}
-}
-
-# @FUNCTION: esethome
-# @USAGE: <user> <homedir>
-# @DESCRIPTION:
-# Update the home directory in a platform-agnostic way.
-# Required parameters is the username and the new home directory.
-# Specify -1 if you want to set home to the enewuser default
-# of /dev/null.
-# If the new home directory does not exist, it is created.
-# Any previously existing home directory is NOT moved.
-esethome() {
-	_assert_pkg_ebuild_phase ${FUNCNAME}
-
-	# get the username
-	local euser=$1; shift
-	if [[ -z ${euser} ]] ; then
-		eerror "No username specified !"
-		die "Cannot call esethome without a username"
-	fi
-
-	# lets see if the username already exists
-	if [[ -z $(egetent passwd "${euser}") ]] ; then
-		ewarn "User does not exist, cannot set home dir -- skipping."
-		return 1
-	fi
-
-	# handle homedir
-	local ehome=$1; shift
-	if [[ -z ${ehome} ]] ; then
-		eerror "No home directory specified !"
-		die "Cannot call esethome without a home directory or '-1'"
-	fi
-
-	if [[ ${ehome} == "-1" ]] ; then
-		ehome="/dev/null"
-	fi
-
-	# exit with no message if home dir is up to date
-	if [[ $(egethome "${euser}") == ${ehome} ]]; then
-		return 0
-	fi
-
-	einfo "Updating home for user '${euser}' ..."
-	einfo " - Home: ${ehome}"
-
-	# ensure home directory exists, otherwise update will fail
-	if [[ ! -e ${ROOT}/${ehome} ]] ; then
-		einfo " - Creating ${ehome} in ${ROOT}"
-		mkdir -p "${ROOT}/${ehome}"
-		chown "${euser}" "${ROOT}/${ehome}"
-		chmod 755 "${ROOT}/${ehome}"
-	fi
-
-	# update the home directory
-	case ${CHOST} in
-	*-darwin*)
-		dscl . change "/users/${euser}" home "${ehome}"
-		;;
-
-	*-freebsd*|*-dragonfly*)
-		pw usermod "${euser}" -d "${ehome}" && return 0
-		[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
-		eerror "There was an error when attempting to update the home directory for ${euser}"
-		eerror "Please update it manually on your system:"
-		eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
-		;;
-
-	*)
-		usermod -d "${ehome}" "${euser}" && return 0
-		[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
-		eerror "There was an error when attempting to update the home directory for ${euser}"
-		eerror "Please update it manually on your system (as root):"
-		eerror "\t usermod -d \"${ehome}\" \"${euser}\""
-		;;
-	esac
-}
-
-fi


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-11-27  1:09 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-26  4:05 [gentoo-commits] proj/android:master commit in: eclass/ Benda XU
2016-05-26  4:04 ` [gentoo-commits] dev/heroxbd:master " Benda XU
  -- strict thread matches above, loose matches on Subject: below --
2017-11-27  1:09 [gentoo-commits] proj/android:master " Benda XU
2017-08-30  9:22 Benda XU
2017-08-07  6:12 Benda XU
2017-02-09  4:52 Benda XU
2017-01-07 14:29 Benda XU
2016-10-24 12:30 Benda XU
2016-07-21 12:38 Benda XU
2016-07-21  2:23 [gentoo-commits] dev/heroxbd:master " Benda XU
2016-07-21  2:19 ` [gentoo-commits] proj/android:master " Benda XU
2016-07-21  2:19 Benda XU
2016-06-24  3:07 Benda XU
2016-06-15 11:40 Benda XU
2016-06-15 10:56 Benda XU
2016-06-14  2:00 Benda XU
2016-06-07 10:48 Benda XU
2016-05-26  4:05 Benda XU
2016-05-26  4:05 Benda XU
2016-05-26  4:05 Benda XU
2016-05-23 16:15 [gentoo-commits] dev/heroxbd:master " Benda XU
2016-05-26  4:05 ` [gentoo-commits] proj/android:master " Benda XU
2016-05-23  6:18 [gentoo-commits] dev/heroxbd:master " Benda XU
2016-05-26  4:05 ` [gentoo-commits] proj/android:master " Benda XU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox