app-portage/gentoolkit{,-dev}: import from upstream Gentoo

This grabs the latest stable versions from upstream so we can punt
the versions in the cros overlay.

BUG=None
TEST=`emerge gentoolkit{,-dev}` installs the latest versions
TEST=`python cros_portage_upgrade_unittest.py` passes
TEST=`cbuildbot x86-generic-full` works
TEST=build_packages+build_image for x86-alex boots

Change-Id: I11f75280082c4482b2a1108847f92e56a74dc4d5
Reviewed-on: https://gerrit.chromium.org/gerrit/10977
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
diff --git a/app-portage/gentoolkit-dev/files/gentoolkit-dev-0.2.8-tests.patch b/app-portage/gentoolkit-dev/files/gentoolkit-dev-0.2.8-tests.patch
new file mode 100644
index 0000000..eff0ed6
--- /dev/null
+++ b/app-portage/gentoolkit-dev/files/gentoolkit-dev-0.2.8-tests.patch
@@ -0,0 +1,26 @@
+From 2dd3de9b4e41f64567c4f04c4d03ef9af89e4d49 Mon Sep 17 00:00:00 2001
+From: Nathan Phillip Brink <binki@gentoo.org>
+Date: Tue, 28 Jun 2011 21:33:02 -0400
+Subject: [PATCH] Fix bug 373421 by ignoring GENTOO_AUTHOR_NAME, GENTOO_AUTHOR_EMAIL, GENTOO_COMMITTER_NAME, and GENTOO_COMMITTER_EMAIL during tests.
+
+---
+ src/echangelog/test/test.sh |    3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/src/echangelog/test/test.sh b/src/echangelog/test/test.sh
+index 0c6d40a..8ec5943 100755
+--- a/src/echangelog/test/test.sh
++++ b/src/echangelog/test/test.sh
+@@ -7,6 +7,9 @@ SUPPORTED_VCS="cvs svn git"
+ VCSTEST="echangelog-test/vcstest"
+ _ROOT=$(pwd)
+ 
++# bug 373421
++unset GENTOO_AUTHOR_NAME GENTOO_AUTHOR_EMAIL \
++    GENTOO_COMMITTER_NAME GENTOO_COMMITTER_EMAIL
+ export ECHANGELOG_USER="Just a test <echangelogtest@gentoo.org>"
+ 
+ MD5_INIT="21ac109c53cf02378593a4f613b2bb55"
+-- 
+1.7.3.4
+
diff --git a/app-portage/gentoolkit-dev/gentoolkit-dev-0.2.8.ebuild b/app-portage/gentoolkit-dev/gentoolkit-dev-0.2.8.ebuild
new file mode 100644
index 0000000..56edfdf
--- /dev/null
+++ b/app-portage/gentoolkit-dev/gentoolkit-dev-0.2.8.ebuild
@@ -0,0 +1,43 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-portage/gentoolkit-dev/gentoolkit-dev-0.2.8.ebuild,v 1.8 2011/07/17 10:26:32 xarthisius Exp $
+
+EAPI="3"
+
+PYTHON_DEPEND="*:2.6"
+PYTHON_USE_WITH="xml"
+
+inherit python eutils
+
+DESCRIPTION="Collection of developer scripts for Gentoo"
+HOMEPAGE="http://www.gentoo.org/proj/en/portage/tools/index.xml"
+SRC_URI="mirror://gentoo/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE=""
+
+DEPEND=""
+RDEPEND="sys-apps/portage
+	dev-lang/perl
+	sys-apps/diffutils"
+
+src_prepare() {
+	epatch "${FILESDIR}/${P}-tests.patch"
+}
+
+src_test() {
+	# echangelog test is not able to run as root
+	# the EUID check may not work for everybody
+	if [[ ${EUID} -ne 0 ]];
+	then
+		emake test || die
+	else
+		ewarn "test skipped, please re-run as non-root if you wish to test ${PN}"
+	fi
+}
+
+src_install() {
+	emake DESTDIR="${ED}" install || die
+}
diff --git a/app-portage/gentoolkit/files/0.3.0.4-equery-380573.patch b/app-portage/gentoolkit/files/0.3.0.4-equery-380573.patch
new file mode 100644
index 0000000..f7aa743
--- /dev/null
+++ b/app-portage/gentoolkit/files/0.3.0.4-equery-380573.patch
@@ -0,0 +1,34 @@
+From 92e6be628307b0643307202ba9994cab9a4dd439 Mon Sep 17 00:00:00 2001
+From: dol-sen <brian.dolbec@gmail.com>
+Date: Thu, 25 Aug 2011 00:04:47 -0700
+Subject: [PATCH] fix bug 380573.
+
+---
+ pym/gentoolkit/equery/meta.py |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
+index 01e090a..f617cfa 100644
+--- a/pym/gentoolkit/equery/meta.py
++++ b/pym/gentoolkit/equery/meta.py
+@@ -22,7 +22,7 @@ from functools import partial
+ 
+ import gentoolkit.pprinter as pp
+ from gentoolkit import errors
+-from gentoolkit import keyword
++from gentoolkit.keyword import Keyword
+ from gentoolkit.equery import format_options, mod_usage, CONFIG
+ from gentoolkit.helpers import print_sequence, print_file
+ from gentoolkit.textwrap_ import TextWrapper
+@@ -217,7 +217,7 @@ def format_keywords(keywords):
+ 
+ 	result = []
+ 
+-	for kw in sorted(keywords, keyword.compare_strs):
++	for kw in sorted(keywords, key=Keyword):
+ 		if kw.startswith('-'):
+ 			# arch masked
+ 			kw = pp.keyword(kw, stable=False, hard_masked=True)
+-- 
+1.7.3.4
+
diff --git a/app-portage/gentoolkit/files/0.3.0.4-euse-376393.patch b/app-portage/gentoolkit/files/0.3.0.4-euse-376393.patch
new file mode 100644
index 0000000..17dc804
--- /dev/null
+++ b/app-portage/gentoolkit/files/0.3.0.4-euse-376393.patch
@@ -0,0 +1,21 @@
+From: Paul Varner <fuzzyray@gentoo.org>
+Date: Wed, 27 Jul 2011 19:01:34 +0000 (-0500)
+Subject: Fix missing parenthises in euse.  Bug 376393
+X-Git-Url: http://git.overlays.gentoo.org/gitweb/?p=proj%2Fgentoolkit.git;a=commitdiff_plain;h=9ad547e5f33fce1dfb378809252d871265a82c58;hp=af81292035e8d3559b11ab16fc54ccd921cb3587
+
+Fix missing parenthises in euse.  Bug 376393
+---
+
+diff --git a/bin/euse b/bin/euse
+index 65fb119..be47cc9 100755
+--- a/bin/euse
++++ b/bin/euse
+@@ -508,7 +508,7 @@ get_flagstatus_helper_pkg() {
+ 			atoms=($(
+ 				echo "${atoms[@]}" | python -c "
+ from __future__ import print_function;import portage.dep as dep, sys
+-print(' '.join(dep.match_to_list('$5-$6',sys.stdin.read().split()))"))
++print(' '.join(dep.match_to_list('$5-$6',sys.stdin.read().split())))"))
+ 		fi
+ 		flags=$(for atom in ${atoms[@]}; do
+ 			[[ -z $atom ]] && continue
diff --git a/app-portage/gentoolkit/files/0.3.0.4-euse-379599.patch b/app-portage/gentoolkit/files/0.3.0.4-euse-379599.patch
new file mode 100644
index 0000000..dc43784
--- /dev/null
+++ b/app-portage/gentoolkit/files/0.3.0.4-euse-379599.patch
@@ -0,0 +1,37 @@
+From 6edc15a5690a3c26a3c530669a922e01f50ab830 Mon Sep 17 00:00:00 2001
+From: Paul Varner <fuzzyray@gentoo.org>
+Date: Wed, 24 Aug 2011 12:28:06 -0500
+Subject: [PATCH] Fix traversal of cascading profiles by euse (Bug 379559).
+ Thanks to Ian Abbot for the patch!
+
+---
+ bin/euse |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/bin/euse b/bin/euse
+index be47cc9..bedba35 100755
+--- a/bin/euse
++++ b/bin/euse
+@@ -439,7 +439,6 @@ traverse_profile() {
+ 	
+ 	curdir="${2:-$(get_real_path ${MAKE_PROFILE_PATH})}"
+ 	
+-	[[ -f "${curdir}/${1}" ]] && rvalue="${curdir}/${1} ${rvalue}"
+ 	if [[ -f "${curdir}/parent" ]]; then
+ 		for parent in $(egrep -v '(^#|^ *$)' ${curdir}/parent); do
+ 			# Bug 231394, handle parent path being absolute
+@@ -448,9 +447,10 @@ traverse_profile() {
+ 			else
+ 				pdir="$(get_real_path ${curdir}/${parent})"
+ 			fi
+-			rvalue="$(traverse_profile ${1} ${pdir}) ${rvalue}"
++			rvalue="${rvalue} $(traverse_profile ${1} ${pdir})"
+ 		done
+ 	fi
++	[[ -f "${curdir}/${1}" ]] && rvalue="${rvalue} ${curdir}/${1}"
+ 
+ 	echo "${rvalue}"
+ } # }}}
+-- 
+1.7.3.4
+
diff --git a/app-portage/gentoolkit/files/0.3.0.4-euse-382219.patch b/app-portage/gentoolkit/files/0.3.0.4-euse-382219.patch
new file mode 100644
index 0000000..168ca3d
--- /dev/null
+++ b/app-portage/gentoolkit/files/0.3.0.4-euse-382219.patch
@@ -0,0 +1,42 @@
+From 4a1fe09bfdff516e28aab23eea102984fedb429a Mon Sep 17 00:00:00 2001
+From: Christian Ruppert <idl0r@gentoo.org>
+Date: Wed, 7 Sep 2011 14:39:10 +0200
+Subject: [PATCH] Add missing quotes
+
+---
+ bin/euse |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/bin/euse b/bin/euse
+index bedba35..febe732 100755
+--- a/bin/euse
++++ b/bin/euse
+@@ -275,21 +275,21 @@ get_useflags() {
+ 	# backup portdir so get_portdir() doesn't give false results later
+ 	portdir_backup="${PORTDIR}"
+ 	
+-	ACTIVE_FLAGS[0]="$(reduce_incrementals ${USE})"
++	ACTIVE_FLAGS[0]="$(reduce_incrementals "${USE}")"
+ 	USE=""
+ 	for x in $(get_all_make_conf); do
+ 		source "${x}"
+-		ACTIVE_FLAGS[1]="$(reduce_incrementals ${ACTIVE_FLAGS[1]} ${USE})"
++		ACTIVE_FLAGS[1]="$(reduce_incrementals "${ACTIVE_FLAGS[1]}" "${USE}")"
+ 	done
+ 	USE=""
+ 	for x in $(get_all_make_defaults); do
+ 		source "${x}"
+ 		ACTIVE_FLAGS[2]="${ACTIVE_FLAGS[2]} ${USE}"
+ 	done
+-	ACTIVE_FLAGS[2]="$(reduce_incrementals ${ACTIVE_FLAGS[2]})"
++	ACTIVE_FLAGS[2]="$(reduce_incrementals "${ACTIVE_FLAGS[2]}")"
+ 	USE=""
+ 	source "${MAKE_GLOBALS_PATH}"
+-	ACTIVE_FLAGS[3]="$(reduce_incrementals ${USE})"
++	ACTIVE_FLAGS[3]="$(reduce_incrementals "${USE}")"
+ 
+ 	# restore saved env variables
+ 	USE="${ACTIVE_FLAGS[0]}"
+-- 
+1.7.3.4
+
diff --git a/app-portage/gentoolkit/files/0.3.0.4-gentoolkit-375293.patch b/app-portage/gentoolkit/files/0.3.0.4-gentoolkit-375293.patch
new file mode 100644
index 0000000..bc0bad5
--- /dev/null
+++ b/app-portage/gentoolkit/files/0.3.0.4-gentoolkit-375293.patch
@@ -0,0 +1,25 @@
+From 0382df255affced93b59322611a58bf98aec6c64 Mon Sep 17 00:00:00 2001
+From: Paul Varner <fuzzyray@gentoo.org>
+Date: Fri, 15 Jul 2011 14:59:23 -0500
+Subject: [PATCH] Do not index ChangeLog entries with an invalid CPV. (Bug 375293)
+
+---
+ pym/gentoolkit/helpers.py |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
+index 225a198..a0b29ab 100644
+--- a/pym/gentoolkit/helpers.py
++++ b/pym/gentoolkit/helpers.py
+@@ -175,7 +175,7 @@ class ChangeLog(object):
+ 			if not pkg_name.strip():
+ 				continue
+ 			try:
+-				entry_ver = CPV(pkg_name)
++				entry_ver = CPV(pkg_name, validate=True)
+ 			except errors.GentoolkitInvalidCPV:
+ 				if self.invalid_entry_is_fatal:
+ 					raise ValueError(entry_ver)
+-- 
+1.7.3.4
+
diff --git a/app-portage/gentoolkit/gentoolkit-0.3.0.4-r4.ebuild b/app-portage/gentoolkit/gentoolkit-0.3.0.4-r4.ebuild
new file mode 100644
index 0000000..64f3204
--- /dev/null
+++ b/app-portage/gentoolkit/gentoolkit-0.3.0.4-r4.ebuild
@@ -0,0 +1,85 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-portage/gentoolkit/gentoolkit-0.3.0.4-r4.ebuild,v 1.5 2011/10/18 21:05:47 jer Exp $
+
+EAPI="3"
+SUPPORT_PYTHON_ABIS="1"
+RESTRICT_PYTHON_ABIS="2.[45]"
+PYTHON_USE_WITH="xml"
+PYTHON_NONVERSIONED_EXECUTABLES=(".*")
+
+inherit distutils python eutils
+
+DESCRIPTION="Collection of administration scripts for Gentoo"
+HOMEPAGE="http://www.gentoo.org/proj/en/portage/tools/index.xml"
+SRC_URI="mirror://gentoo/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE=""
+
+# Drop "~m68k ~s390 ~sh ~sparc-fbsd ~x86-fbsd" due to dev-python/argparse dependency
+# Note: argparse is provided in python 2.7 and 3.2 (Bug 346005)
+KEYWORDS="~alpha amd64 arm hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc x86 ~ppc-aix ~x86-fbsd ~x64-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+
+DEPEND="sys-apps/portage"
+RDEPEND="${DEPEND}
+	!<=app-portage/gentoolkit-dev-0.2.7
+	dev-python/argparse
+	|| ( app-misc/realpath sys-freebsd/freebsd-bin )
+	sys-apps/gawk
+	sys-apps/grep"
+
+distutils_src_compile_pre_hook() {
+	echo VERSION="${PVR}" "$(PYTHON)" setup.py set_version
+	VERSION="${PVR}" "$(PYTHON)" setup.py set_version \
+		|| die "setup.py set_version failed"
+}
+
+src_prepare() {
+	epatch "${FILESDIR}/${PV}-euse-376393.patch"
+	epatch "${FILESDIR}/${PV}-euse-379599.patch"
+	epatch "${FILESDIR}/${PV}-gentoolkit-375293.patch"
+	epatch "${FILESDIR}/${PV}-equery-380573.patch"
+	epatch "${FILESDIR}/${PV}-euse-382219.patch"
+}
+
+src_install() {
+	python_convert_shebangs -r "" build-*/scripts-*
+	distutils_src_install
+
+	# Create cache directory for revdep-rebuild
+	dodir /var/cache/revdep-rebuild
+	keepdir /var/cache/revdep-rebuild
+	use prefix || fowners root:root /var/cache/revdep-rebuild
+	fperms 0700 /var/cache/revdep-rebuild
+
+	# remove on Gentoo Prefix platforms where it's broken anyway
+	if use prefix; then
+		elog "The revdep-rebuild command is removed, the preserve-libs"
+		elog "feature of portage will handle issues."
+		rm "${ED}"/usr/bin/revdep-rebuild
+		rm "${ED}"/usr/share/man/man1/revdep-rebuild.1
+		rm -rf "${ED}"/etc/revdep-rebuild
+		rm -rf "${ED}"/var
+	fi
+
+	# Can distutils handle this?
+	dosym eclean /usr/bin/eclean-dist
+	dosym eclean /usr/bin/eclean-pkg
+}
+
+pkg_postinst() {
+	distutils_pkg_postinst
+
+	einfo
+	einfo "For further information on gentoolkit, please read the gentoolkit"
+	einfo "guide: http://www.gentoo.org/doc/en/gentoolkit.xml"
+	einfo
+	einfo "Another alternative to equery is app-portage/portage-utils"
+	ewarn
+	ewarn "glsa-check since gentoolkit 0.3 has modified some output,"
+	ewarn "options and default behavior. The list of injected GLSAs"
+	ewarn "has moved to /var/lib/portage/glsa_injected, please"
+	ewarn "run 'glsa-check -p affected' before copying the existing checkfile."
+}