from portage.output import ConsoleStyleFile, StyleWriter
from portage.util import cmp_sort_key, writemsg_level
from portage.package.ebuild.digestgen import digestgen
+from portage.eapi import *
if sys.hexversion >= 0x3000000:
basestring = str
# Check that URIs don't reference a server from thirdpartymirrors.
for uri in portage.flatten(portage.dep.use_reduce( \
myaux["SRC_URI"], matchall=True, is_src_uri=True, \
- allow_src_uri_file_renames=(eapi not in ("0", "1")))):
+ allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi))):
contains_mirror = False
for mirror in thirdpartymirrors:
if uri.startswith(mirror):
stats[mytype + '.suspect'] += 1
fails[mytype + '.suspect'].append(
relative_path + ": '%s'" % atom)
- if eapi == "0":
+ if not eapi_has_slot_deps(eapi):
if portage.dep.dep_getslot(atom):
stats['EAPI.incompatible'] += 1
fails['EAPI.incompatible'].append(
(relative_path + ": %s slot dependency" + \
" not supported with EAPI='%s':" + \
" '%s'") % (mytype, eapi, atom))
- if atom.use and eapi in ("0", "1"):
+ if atom.use and not eapi_has_use_deps(eapi):
stats['EAPI.incompatible'] += 1
fails['EAPI.incompatible'].append(
(relative_path + ": %s use dependency" + \
" not supported with EAPI='%s':" + \
" '%s'") % (mytype, eapi, atom))
if atom.blocker and atom.blocker.overlap.forbid \
- and eapi in ("0", "1"):
+ and not eapi_has_strong_blocks(eapi):
stats['EAPI.incompatible'] += 1
fails['EAPI.incompatible'].append(
(relative_path + ": %s new blocker syntax" + \
if myuse[mypos] and (myuse[mypos] in muselist):
del myuse[mypos]
- if default_use and eapi == "0":
+ if default_use and not eapi_has_iuse_defaults(eapi):
for myflag in default_use:
stats['EAPI.incompatible'] += 1
fails['EAPI.incompatible'].append(
from _emerge.CompositeTask import CompositeTask
import portage
from portage import os
+from portage.eapi import eapi_has_src_prepare_and_src_configure
class EbuildExecuter(CompositeTask):
pkg = self.pkg
phases = self._phases
eapi = pkg.metadata["EAPI"]
- if eapi in ("0", "1"):
+ if not eapi_has_src_prepare_and_src_configure(eapi):
# skip src_prepare and src_configure
phases = phases[2:]
from portage.dbapi import dbapi
from portage.dbapi.dep_expand import dep_expand
from portage.dep import Atom
+from portage.eapi import eapi_has_strong_blocks
from portage.output import bold, blue, colorize, create_color_func, darkblue, \
darkgreen, green, nc_len, red, teal, turquoise, yellow
bad = create_color_func("BAD")
forbid_overlap = False
heuristic_overlap = False
for blocker in myblocker_uninstalls.parent_nodes(task):
- if blocker.eapi in ("0", "1"):
+ if not eapi_has_strong_blocks(blocker.eapi):
heuristic_overlap = True
elif blocker.atom.blocker.overlap.forbid:
forbid_overlap = True
from portage.cache.mappings import Mapping
from portage.const import REPO_NAME_LOC
from portage.dbapi import dbapi
+from portage.eapi import eapi_has_src_uri_arrows
from portage.exception import PortageException, \
FileNotFound, InvalidDependString, InvalidPackageName
from portage.localization import _
(mypkg, eapi.lstrip("-")))
myuris = use_reduce(myuris, uselist=useflags, matchall=(useflags is None), \
- is_src_uri=True, allow_src_uri_file_renames=(eapi not in ("0", "1")))
+ is_src_uri=True, allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi))
myuris = flatten(myuris)
uri_map = OrderedDict()
import portage
from portage.dep import Atom, dep_opconvert, match_from_list, \
remove_slot, use_reduce
+from portage.eapi import eapi_has_strong_blocks, eapi_has_use_deps
from portage.exception import InvalidAtom, InvalidDependString, ParseError
from portage.localization import _
from portage.util import writemsg, writemsg_level
_("invalid atom: '%s'") % x)
else:
if x.blocker and x.blocker.overlap.forbid and \
- eapi in ("0", "1"):
+ not eapi_has_strong_blocks(eapi):
raise ParseError(
_("invalid atom: '%s'") % (x,))
- if x.use and eapi in ("0", "1"):
+ if x.use and not eapi_has_use_deps(eapi):
raise ParseError(
_("invalid atom: '%s'") % (x,))
--- /dev/null
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+def eapi_has_iuse_defaults(eapi):
+ return eapi != "0"
+
+def eapi_has_slot_deps(eapi):
+ return eapi != "0"
+
+def eapi_has_src_uri_arrows(eapi):
+ return eapi not in ("0", "1")
+
+def eapi_has_use_deps(eapi):
+ return eapi not in ("0", "1")
+
+def eapi_has_strong_blocks(eapi):
+ return eapi not in ("0", "1")
+
+def eapi_has_src_prepare_and_src_configure(eapi):
+ return eapi not in ("0", "1")
+
+def eapi_supports_prefix(eapi):
+ return eapi not in ("0", "1", "2")
+
+def eapi_exports_AA(eapi):
+ return eapi in ("0", "1", "2", "3")
+
+def eapi_exports_KV(eapi):
+ return eapi in ("0", "1", "2", "3")
+
+def eapi_exports_replace_vars(eapi):
+ return eapi not in ("0", "1", "2", "3")
+
+def eapi_has_pkg_pretend(eapi):
+ return eapi not in ("0", "1", "2", "3")
+
+def eapi_has_implicit_rdepend(eapi):
+ return eapi in ("0", "1", "2", "3")
+
+def eapi_has_dosed_dohard(eapi):
+ return eapi in ("0", "1", "2", "3")
from portage.dep import Atom, best_match_to_list, dep_opconvert, \
flatten, isvalidatom, match_from_list, match_to_list, \
remove_slot, use_reduce
+from portage.eapi import eapi_exports_AA, eapi_supports_prefix, eapi_exports_replace_vars
from portage.env.loaders import KeyValuePairFileLoader
from portage.exception import DirectoryNotFound, InvalidAtom, \
InvalidDependString, ParseError, PortageException
mydict["USE"] = self.get("PORTAGE_USE", "")
# Don't export AA to the ebuild environment in EAPIs that forbid it
- if eapi not in ("0", "1", "2", "3", "3_pre2"):
+ if not eapi_exports_AA(eapi):
mydict.pop("AA", None)
# Prefix variables are supported starting with EAPI 3.
- if phase == 'depend' or eapi in (None, "0", "1", "2"):
+ if phase == 'depend' or eapi is None or eapi_supports_prefix(eapi):
mydict.pop("ED", None)
mydict.pop("EPREFIX", None)
mydict.pop("EROOT", None)
mydict.pop('FILESDIR', None)
if phase not in ("pretend", "setup", "preinst", "postinst") or \
- eapi in ("0", "1", "2", "3"):
+ not eapi_exports_replace_vars(eapi):
mydict.pop("REPLACING_VERSIONS", None)
if phase not in ("prerm", "postrm") or \
- eapi in ("0", "1", "2", "3"):
+ not eapi_exports_replace_vars(eapi):
mydict.pop("REPLACED_BY_VERSION", None)
return mydict
uid, userpriv_groups
from portage.dbapi.virtual import fakedbapi
from portage.dep import Atom, paren_enclose, use_reduce
+from portage.eapi import eapi_exports_KV, eapi_has_src_uri_arrows, \
+ eapi_has_src_prepare_and_src_configure, eapi_has_pkg_pretend
from portage.elog import elog_process
from portage.elog.messages import eerror, eqawarn
from portage.exception import DigestException, FileNotFound, \
mysettings["PORTAGE_BUILDDIR"], ".exit_status")
#set up KV variable -- DEP SPEEDUP :: Don't waste time. Keep var persistent.
- if eapi not in ('0', '1', '2', '3', '3_pre2'):
+ if not eapi_exports_KV(eapi):
# Discard KV for EAPIs that don't support it. Cache KV is restored
# from the backupenv whenever config.reset() is called.
mysettings.pop('KV', None)
for k in misc_keys:
try:
use_reduce(metadata[k], matchall=True, is_src_uri=(k=="SRC_URI"), \
- allow_src_uri_file_renames=(eapi not in ("0", "1")))
+ allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi))
except InvalidDependString as e:
msgs.append(" %s: %s\n %s\n" % (
k, metadata[k], str(e)))
eapi = mysettings["EAPI"]
- if mydo == "configure" and eapi in ("0", "1"):
+ if mydo in ("configure", "prepare") and not eapi_has_src_prepare_and_src_configure(eapi):
return os.EX_OK
- if mydo == "prepare" and eapi in ("0", "1"):
- return os.EX_OK
-
- if mydo == "pretend" and eapi in ("0", "1", "2", "3", "3_pre2"):
+ if mydo == "pretend" and not eapi_has_pkg_pretend(eapi):
return os.EX_OK
kwargs = actionmap[mydo]["args"]
# repoman: Checks
-# Copyright 2007 Gentoo Foundation
+# Copyright 2007, 2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
"""This module contains functions used in Repoman to ascertain the quality
import re
import time
import repoman.errors as errors
+from portage.eapi import *
class LineCheck(object):
"""Run a check on a line of an ebuild."""
readonly_assignment = re.compile(r'\s*(export\s+)?(ED|EPREFIX|EROOT)=')
def check_eapi(self, eapi):
- return eapi not in ('0', '1', '2')
+ return eapi_supports_prefix(eapi)
class EbuildNestedDie(LineCheck):
"""Check ebuild for nested die statements (die statements in subshells"""
# Beginning with EAPI 4, there is no
# implicit RDEPEND=$DEPEND assignment
# to be concerned with.
- return eapi in ('0', '1', '2', '3')
+ return eapi_has_implicit_rdepend(eapi)
def check(self, num, line):
if not self._rdepend:
configure_re = re.compile(r'\s(econf|./configure)')
def check_eapi(self, eapi):
- return eapi not in ('0', '1')
+ return eapi_has_src_prepare_and_src_configure(eapi)
def phase_check(self, num, line):
if self.in_phase == 'src_compile':
src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s')
def check_eapi(self, eapi):
- return eapi not in ('0', '1')
+ return eapi_has_src_prepare_and_src_configure(eapi)
def phase_check(self, num, line):
if self.in_phase == 'src_unpack':
banned_commands_re = re.compile(r'^\s*(dosed|dohard)')
def check_eapi(self, eapi):
- return eapi not in ('0', '1', '2', '3', '3_pre2')
+ return not eapi_has_dosed_dohard(eapi)
def check(self, num, line):
m = self.banned_commands_re.match(line)
undefined_vars_re = re.compile(r'.*\$(\{(AA|KV)\}|(AA|KV))')
def check_eapi(self, eapi):
- return eapi not in ('0', '1', '2', '3', '3_pre2')
+ return not eapi_exports_AA(eapi) or not eapi_exports_KV(eapi)
def check(self, num, line):
m = self.undefined_vars_re.match(line)