from portage.cache.mappings import slot_dict_class
from portage.const import LIBC_PACKAGE_ATOM
from portage.elog.messages import eerror
+from portage.localization import _
from portage.output import colorize, create_color_func, red
bad = create_color_func("BAD")
from portage.sets import SETPREFIX
return os.EX_OK
+ def _env_sanity_check(self):
+ """
+ Verify a sane environment before trying to build anything from source.
+ """
+ have_src_pkg = False
+ for x in self._mergelist:
+ if isinstance(x, Package) and not x.built:
+ have_src_pkg = True
+ break
+
+ if not have_src_pkg:
+ return os.EX_OK
+
+ for settings in self.pkgsettings.values():
+ for var in ("ARCH", ):
+ value = settings.get(var)
+ if value and value.strip():
+ continue
+ msg = _("%(var)s is not set... "
+ "Are you missing the '%(configroot)setc/make.profile' symlink? "
+ "Is the symlink correct? "
+ "Is your portage tree complete?") % \
+ {"var": var, "configroot": settings["PORTAGE_CONFIGROOT"]}
+
+ out = portage.output.EOutput()
+ for line in textwrap.wrap(msg, 70):
+ out.eerror(line)
+ return 1
+
+ return os.EX_OK
+
def _check_manifests(self):
# Verify all the manifests now so that the user is notified of failure
# as soon as possible.
if rval != os.EX_OK:
return rval
+ rval = self._env_sanity_check()
+ if rval != os.EX_OK:
+ return rval
+
# TODO: Immediately recalculate deps here if --keep-going
# is enabled and corrupt manifests are detected.
rval = self._check_manifests()
if e.errno != errno.ENOENT:
raise
env_stat = None
- if env_stat is not None:
- pass
- else:
- for var in ("ARCH", ):
- value = settings.get(var)
- if value and value.strip():
- continue
- msg = _("%(var)s is not set... "
- "Are you missing the '%(configroot)setc/make.profile' symlink? "
- "Is the symlink correct? "
- "Is your portage tree complete?") % \
- {"var": var, "configroot": settings["PORTAGE_CONFIGROOT"]}
- for line in wrap(msg, 70):
- eerror(line, phase="setup", key=settings.mycpv)
- elog_process(settings.mycpv, settings)
- return 1
return os.EX_OK