econf() {
local x
- ! hasq "$EAPI" 0 1 && [[ $EBUILD_PHASE = compile && \
- $(type -t src_configure) = function ]] && \
- eqawarn "econf called in src_compile instead of src_configure"
+ local phase_func=$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
+ if [[ -n $phase_func ]] ; then
+ if hasq "$EAPI" 0 1 ; then
+ [[ $phase_func != src_compile ]] && \
+ eqawarn "QA Notice: econf called in" \
+ "$phase_func instead of src_compile"
+ else
+ [[ $phase_func != src_configure ]] && \
+ eqawarn "QA Notice: econf called in" \
+ "$phase_func instead of src_configure"
+ fi
+ fi
: ${ECONF_SOURCE:=.}
if [ -x "${ECONF_SOURCE}/configure" ]; then
# like it's supposed to here.
! hasq test ${USE} && export USE="${USE} test"
fi
- ebuild_phase pre_src_test
if [[ -e $PORTAGE_BUILDDIR/.tested ]] ; then
vecho ">>> It appears that ${PN} has already been tested; skipping."
return
vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
else
addpredict /
+ ebuild_phase pre_src_test
ebuild_phase src_test
+ touch "$PORTAGE_BUILDDIR/.tested" || \
+ die "Failed to 'touch .tested' in $PORTAGE_BUILDDIR"
+ ebuild_phase post_src_test
SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
fi
- touch "$PORTAGE_BUILDDIR/.tested" || \
- die "Failed to 'touch .tested' in $PORTAGE_BUILDDIR"
- ebuild_phase post_src_test
trap - SIGINT SIGQUIT
}
except ParseError, e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
+ except SystemExit:
+ raise
+ except Exception:
+ # If an unexpected exception occurs then we don't want the mod_echo
+ # output to obscure the traceback, so dump the mod_echo output before
+ # showing the traceback.
+ import traceback
+ tb_str = traceback.format_exc()
+ try:
+ from portage.elog import mod_echo
+ except ImportError:
+ pass
+ else:
+ mod_echo.finalize()
+ sys.stderr.write(tb_str)
+ sys.exit(1)
sys.exit(retval)
secpass >= 2:
try:
f = portage.util.atomic_ofstream(self._cache_filename, mode='wb')
- pickle.dump(self._cache_data, f, -1)
+ pickle.dump(self._cache_data, f, protocol=2)
f.close()
portage.util.apply_secpass_permissions(
self._cache_filename, gid=portage.portage_gid, mode=0644)
def __init__(self, clone=None, mycpv=None, config_profile_path=None,
config_incrementals=None, config_root=None, target_root=None,
- local_config=True):
+ local_config=True, env=None):
"""
@param clone: If provided, init will use deepcopy to copy by value the instance.
@type clone: Instance of config class.
@type mycpv: String
@param config_profile_path: Configurable path to the profile (usually PROFILE_PATH from portage.const)
@type config_profile_path: String
- @param config_incrementals: List of incremental variables (usually portage.const.INCREMENTALS)
+ @param config_incrementals: List of incremental variables
+ (defaults to portage.const.INCREMENTALS)
@type config_incrementals: List
@param config_root: path to read local config from (defaults to "/", see PORTAGE_CONFIGROOT)
@type config_root: String
@param local_config: Enables loading of local config (/etc/portage); used most by repoman to
ignore local config (keywording and unmasking)
@type local_config: Boolean
+ @param env: The calling environment which is used to override settings.
+ Defaults to os.environ if unspecified.
+ @type env: dict
"""
# When initializing the global portage.settings instance, avoid
else:
self.profile_path = config_profile_path[:]
- if not config_incrementals:
- writemsg("incrementals not specified to class config\n")
+ if config_incrementals is None:
self.incrementals = copy.deepcopy(portage.const.INCREMENTALS)
else:
self.incrementals = copy.deepcopy(config_incrementals)
expand_map.update(env_d)
# backupenv is used for calculating incremental variables.
- self.backupenv = os.environ.copy()
+ if env is None:
+ env = os.environ
+ self.backupenv = env.copy()
if env_d:
# Remove duplicate values so they don't override updated
d.update(mydict)
try:
f = atomic_ofstream(filename, mode='wb')
- pickle.dump(d, f, -1)
+ pickle.dump(d, f, protocol=2)
f.close()
portage.util.apply_secpass_permissions(filename,
uid=uid, gid=portage_gid, mode=0644)
myroots = [(settings["ROOT"], settings)]
if settings["ROOT"] != "/":
- settings = config(config_root=None, target_root="/",
- config_incrementals=portage.const.INCREMENTALS)
+
# When ROOT != "/" we only want overrides from the calling
# environment to apply to the config that's associated
- # with ROOT != "/", so we wipe out the "backupenv" for the
- # config that is associated with ROOT == "/" and regenerate
- # it's incrementals.
- # Preserve backupenv values that are initialized in the config
- # constructor. Also, preserve XARGS since it is set by the
- # portage.data module.
-
- backupenv_whitelist = settings._environ_whitelist
- backupenv = settings.configdict["backupenv"]
- env_d = settings.configdict["env.d"]
- for k, v in os.environ.iteritems():
- if k in backupenv_whitelist:
- continue
- if k in env_d or \
- v == backupenv.get(k):
- backupenv.pop(k, None)
- settings.regenerate()
+ # with ROOT != "/", so pass an empty dict for the env parameter.
+ settings = config(config_root=None, target_root="/", env={})
settings.lock()
myroots.append((settings["ROOT"], settings))
def __init__(self, *args, **kwargs):
+ self.data = {}
+
if len(args) > 1:
raise TypeError(
"expected at most 1 positional argument, got " + \
'portage.locks:unlockfile',
'portage.output:colorize',
'portage.util:cmp_sort_key,writemsg',
- 'portage.versions:catpkgsplit,pkgcmp',
+ 'portage.versions:catpkgsplit,vercmp',
)
from portage import auxdbkeys, dep_expand
# If the cpv includes explicit -r0, it has to be preserved
# for consistency in findname and aux_get calls, so use a
# dict to map strings back to their original values.
- str_map = {}
- for i, cpv in enumerate(cpv_list):
- mysplit = tuple(catpkgsplit(cpv)[1:])
- str_map[mysplit] = cpv
- cpv_list[i] = mysplit
- cpv_list.sort(key=cmp_sort_key(pkgcmp))
- for i, mysplit in enumerate(cpv_list):
- cpv_list[i] = str_map[mysplit]
+ ver_map = {}
+ for cpv in cpv_list:
+ ver_map[cpv] = '-'.join(catpkgsplit(cpv)[2:])
+ def cmp_cpv(cpv1, cpv2):
+ return vercmp(ver_map[cpv1], ver_map[cpv2])
+ cpv_list.sort(key=cmp_sort_key(cmp_cpv))
def cpv_all(self):
"""Return all CPVs in the db
uri = None
_src_uri_validate(cpv, eapi, x)
continue
- if x[:-1] == "?":
+ if x == '||':
+ raise portage.exception.InvalidDependString(
+ ("getFetchMap(): '%s' SRC_URI contains invalid " + \
+ "|| operator") % (cpv,))
+
+ if x[-1:] == "?":
if operator is not None:
raise portage.exception.InvalidDependString(
("getFetchMap(): '%s' SRC_URI arrow missing " + \
if operator is None:
uri = x
continue
- if operator is not None:
- if "/" in x:
- raise portage.exception.InvalidDependString(
- ("getFetchMap(): '%s' SRC_URI '/' character in " + \
- "file name: '%s'") % (cpv, x))
- if x[-1] == "?":
- raise portage.exception.InvalidDependString(
- ("getFetchMap(): '%s' SRC_URI arrow missing " + \
- "right operand") % (cpv,))
+
+ # This should be the right operand of an arrow operator.
+ if "/" in x:
+ raise portage.exception.InvalidDependString(
+ ("getFetchMap(): '%s' SRC_URI '/' character in " + \
+ "file name: '%s'") % (cpv, x))
+
+ if x[-1:] == "?":
+ raise portage.exception.InvalidDependString(
+ ("getFetchMap(): '%s' SRC_URI arrow missing " + \
+ "right operand") % (cpv,))
+
+ # Found the right operand, so reset state.
uri = None
operator = None
def load(self):
""" Reload the registry data from file """
+ self._data = None
try:
self._data = pickle.load(open(self._filename, 'rb'))
+ except (ValueError, pickle.UnpicklingError), e:
+ writemsg_level("!!! Error loading '%s': %s\n" % \
+ (self._filename, e), level=logging.ERROR, noiselevel=-1)
except (EOFError, IOError), e:
if isinstance(e, EOFError) or e.errno == errno.ENOENT:
- self._data = {}
+ pass
elif e.errno == PermissionDenied.errno:
raise PermissionDenied(self._filename)
else:
- raise e
+ raise
+ if self._data is None:
+ self._data = {}
self._data_orig = self._data.copy()
def store(self):
""" Store the registry data to file. No need to call this if autocommit
return
try:
f = atomic_ofstream(self._filename, 'wb')
- pickle.dump(self._data, f)
+ pickle.dump(self._data, f, protocol=2)
f.close()
except EnvironmentError, e:
if e.errno != PermissionDenied.errno:
del self._aux_cache["modified"]
try:
f = atomic_ofstream(self._aux_cache_filename, 'wb')
- pickle.dump(self._aux_cache, f, -1)
+ pickle.dump(self._aux_cache, f, protocol=2)
f.close()
apply_secpass_permissions(
self._aux_cache_filename, gid=portage_gid, mode=0644)
return 1
+ def _eqawarn(self, phase, lines):
+ from portage.elog.messages import eqawarn as _eqawarn
+ if self._scheduler is None:
+ for l in lines:
+ _eqawarn(l, phase=phase, key=self.settings.mycpv)
+ else:
+ self._scheduler.dblinkElog(self,
+ phase, _eqawarn, lines)
+
def _eerror(self, phase, lines):
from portage.elog.messages import eerror as _eerror
if self._scheduler is None:
level=logging.ERROR, noiselevel=-1)
return 1
- inforoot_slot_file = os.path.join(inforoot, "SLOT")
- slot = None
- try:
- f = open(inforoot_slot_file)
+ slot = ''
+ for var_name in ('CHOST', 'SLOT'):
try:
- slot = f.read().strip()
- finally:
- f.close()
- except EnvironmentError, e:
- if e.errno != errno.ENOENT:
- raise
- del e
+ val = open(os.path.join(inforoot, var_name)).readline().strip()
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ val = ''
- if slot is None:
- slot = ""
+ if var_name == 'SLOT':
+ slot = val
+
+ if val != self.settings.get(var_name, ''):
+ self._eqawarn('preinst',
+ ["QA Notice: Expected %s='%s', got '%s'\n" % \
+ (var_name, self.settings.get(var_name, ''), val)])
def eerror(lines):
self._eerror("preinst", lines)
- if slot != self.settings["SLOT"]:
- showMessage("!!! WARNING: Expected SLOT='%s', got '%s'\n" % \
- (self.settings["SLOT"], slot), level=logging.WARN)
-
if not os.path.exists(self.dbcatdir):
os.makedirs(self.dbcatdir)
sys.stderr.flush()
try:
metadatafile = open(metadatafilename, 'wb')
- pickle.dump(metadata,metadatafile)
+ pickle.dump(metadata, metadatafile, protocol=2)
metadatafile.close()
except SystemExit, e:
raise
if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
metadata[baseurl]["timestamp"] = int(time.time())
metadatafile = open(metadatafilename, 'wb')
- pickle.dump(metadata,metadatafile)
+ pickle.dump(metadata, metadatafile, protocol=2)
metadatafile.close()
if makepickle:
metadatafile = open(makepickle, 'wb')
- pickle.dump(metadata[baseurl]["data"],metadatafile)
+ pickle.dump(metadata[baseurl]["data"], metadatafile, protocol=2)
metadatafile.close()
except SystemExit, e:
raise
if "CVS" in mysplit:
return False
for x in mysplit:
- if x.startswith("."):
+ if x[:1] == '.':
return False
- return not filename.startswith("digest-")
+ return not filename[:7] == 'digest-'
def manifest2MiscfileFilter(filename):
filename = filename.strip(os.sep)
tests = [
( "0", "http://foo/bar -> blah.tbz2" , False ),
( "1", "http://foo/bar -> blah.tbz2" , False ),
+ ( "2", "|| ( http://foo/bar -> blah.tbz2 )" , False ),
( "2", "http://foo/bar -> blah.tbz2" , True ),
( "2", "foo? ( http://foo/bar -> blah.tbz2 )" , True ),
( "2", "http://foo/bar -> foo? ( ftp://foo/a )" , False ),
( "2", "http://foo/bar blah.tbz2 ->" , False ),
( "2", "-> http://foo/bar blah.tbz2 )" , False ),
( "2", "http://foo/bar ->" , False ),
+ ( "2", "http://foo/bar -> foo? ( http://foo.com/foo )" , False ),
( "2", "foo? ( http://foo/bar -> ) blah.tbz2" , False ),
( "2", "http://foo/bar -> foo/blah.tbz2" , False ),
( "2", "http://foo.com/foo http://foo/bar -> blah.tbz2" , True ),
self._obj = obj
def __lt__(self, other):
- if not isinstance(other, self.__class__):
+ if other.__class__ is not self.__class__:
raise TypeError("Expected type %s, got %s" % \
(self.__class__, other.__class__))
- if self._cmp_func(self._obj, other._obj) < 0:
- return True
- return False
+ return self._cmp_func(self._obj, other._obj) < 0
def unique_array(s):
"""lifted from python cookbook, credit: Tim Peters