summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-18 15:31:29 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-18 15:31:29 -0700
commitdf2c91cfdfbb827b61d4d3b7de6817a9ccd31a5d (patch)
treead2567792cf7de77ac5ca72dbd29c23fbdcd321b
parent11a8128ab1b2f2efc95b7a9ef72843f165fd94ae (diff)
downloadportage-df2c91cfdfbb827b61d4d3b7de6817a9ccd31a5d.tar.gz
portage-df2c91cfdfbb827b61d4d3b7de6817a9ccd31a5d.tar.bz2
portage-df2c91cfdfbb827b61d4d3b7de6817a9ccd31a5d.zip
Move environment sanity check to the Scheduler and do it if there
are any source packages in the merge list.
-rw-r--r--pym/_emerge/Scheduler.py36
-rw-r--r--pym/portage/package/ebuild/doebuild.py16
2 files changed, 36 insertions, 16 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 43fa68a77..2a052af4c 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -21,6 +21,7 @@ from portage import _unicode_encode
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
@@ -676,6 +677,37 @@ class Scheduler(PollScheduler):
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.
@@ -990,6 +1022,10 @@ class Scheduler(PollScheduler):
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()
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 32cec8d11..10c8e0684 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -879,22 +879,6 @@ def _prepare_env_file(settings):
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