repoman: check for deprecated EAPIs, bug #470670

This adds support for repo.eapi.banned (fatal) and repo.eapi.deprecated
(warning) checks which are controlled by eapis-banned and
eapis-deprecated settings in a repository's metadata/layout.conf.
diff --git a/bin/repoman b/bin/repoman
index 20832ec..c4a5a22 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -380,6 +380,8 @@
 	"metadata.bad": "Bad metadata.xml files",
 	"metadata.warning": "Warnings in metadata.xml files",
 	"portage.internal": "The ebuild uses an internal Portage function or variable",
+	"repo.eapi.banned": "The ebuild uses an EAPI which is banned by the repository's metadata/layout.conf settings",
+	"repo.eapi.deprecated": "The ebuild uses an EAPI which is deprecated by the repository's metadata/layout.conf settings",
 	"virtual.oldstyle": "The ebuild PROVIDEs an old-style virtual (see GLEP 37)",
 	"virtual.suspect": "Ebuild contains a package that usually should be pulled via virtual/, not directly.",
 	"usage.obsolete": "The ebuild makes use of an obsolete construct",
@@ -424,6 +426,7 @@
 "wxwidgets.eclassnotused",
 "metadata.warning",
 "portage.internal",
+"repo.eapi.deprecated",
 "usage.obsolete",
 "upstream.workaround",
 "LIVEVCS.stable",
@@ -1815,6 +1818,16 @@
 		inherited = pkg.inherited
 		live_ebuild = live_eclasses.intersection(inherited)
 
+		if repo_config.eapi_is_banned(eapi):
+			stats["repo.eapi.banned"] += 1
+			fails["repo.eapi.banned"].append(
+				"%s: %s" % (relative_path, eapi))
+
+		elif repo_config.eapi_is_deprecated(eapi):
+			stats["repo.eapi.deprecated"] += 1
+			fails["repo.eapi.deprecated"].append(
+				"%s: %s" % (relative_path, eapi))
+
 		for k, v in myaux.items():
 			if not isinstance(v, basestring):
 				continue
diff --git a/man/portage.5 b/man/portage.5
index 46a64f1..e462266 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -1,4 +1,4 @@
-.TH "PORTAGE" "5" "Nov 2012" "Portage VERSION" "Portage"
+.TH "PORTAGE" "5" "May 2013" "Portage VERSION" "Portage"
 .SH NAME
 portage \- the heart of Gentoo
 .SH "DESCRIPTION"
@@ -875,6 +875,12 @@
 # indicate that this repo can be used as a substitute for foo-overlay
 aliases = foo-overlay
 
+# indicate that ebuilds with the specified EAPIs are banned
+eapis\-banned = 0 1
+
+# indicate that ebuilds with the specified EAPIs are deprecated
+eapis\-deprecated = 2 3
+
 # sign commits in this repo, which requires Git >=1.7.9, and
 # key configured by `git config user.signingkey key_id`
 sign\-commits = true
diff --git a/man/repoman.1 b/man/repoman.1
index 912ba65..bf498d4 100644
--- a/man/repoman.1
+++ b/man/repoman.1
@@ -1,4 +1,4 @@
-.TH "REPOMAN" "1" "Oct 2012" "Portage VERSION" "Portage"
+.TH "REPOMAN" "1" "May 2013" "Portage VERSION" "Portage"
 .SH NAME
 repoman \- Gentoo's program to enforce a minimal level of quality assurance in packages added to the portage tree
 .SH SYNOPSIS
@@ -326,6 +326,14 @@
 .B metadata.warning
 Warnings in metadata.xml files
 .TP
+.B repo.eapi.banned
+The ebuild uses an EAPI which is banned by the repository's
+metadata/layout.conf settings.
+.TP
+.B repo.eapi.deprecated
+The ebuild uses an EAPI which is deprecated by the repository's
+metadata/layout.conf settings.
+.TP
 .B portage.internal
 The ebuild uses an internal Portage function or variable
 .TP
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 969fce4..da8c365 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -80,7 +80,8 @@
 		'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
 		'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority',
 		'profile_formats', 'sign_commit', 'sign_manifest', 'sync',
-		'thin_manifest', 'update_changelog', 'user_location')
+		'thin_manifest', 'update_changelog', 'user_location',
+		'_eapis_banned', '_eapis_deprecated')
 
 	def __init__(self, name, repo_opts):
 		"""Build a RepoConfig with options in repo_opts
@@ -198,6 +199,15 @@
 			self.portage1_profiles_compat = not eapi_allows_directories_on_profile_level_and_repository_level(eapi) and \
 				layout_data['profile-formats'] == ('portage-1-compat',)
 
+			self._eapis_banned = frozenset(layout_data['eapis-banned'])
+			self._eapis_deprecated = frozenset(layout_data['eapis-deprecated'])
+
+	def eapi_is_banned(self, eapi):
+		return eapi in self._eapis_banned
+
+	def eapi_is_deprecated(self, eapi):
+		return eapi in self._eapis_deprecated
+
 	def iter_pregenerated_caches(self, auxdbkeys, readonly=True, force=False):
 		"""
 		Reads layout.conf cache-formats from left to right and yields cache
@@ -745,6 +755,9 @@
 	data['allow-provide-virtual'] = \
 		layout_data.get('allow-provide-virtuals', 'false').lower() == 'true'
 
+	data['eapis-banned'] = tuple(layout_data.get('eapis-banned', '').split())
+	data['eapis-deprecated'] = tuple(layout_data.get('eapis-deprecated', '').split())
+
 	data['sign-commit'] = layout_data.get('sign-commits', 'false').lower() \
 		== 'true'