Move environment sanity check to the Scheduler and do it if there
authorZac Medico <zmedico@gentoo.org>
Wed, 18 Aug 2010 22:31:29 +0000 (15:31 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 18 Aug 2010 22:31:29 +0000 (15:31 -0700)
are any source packages in the merge list.

pym/_emerge/Scheduler.py
pym/portage/package/ebuild/doebuild.py

index 43fa68a7787294c104198446b966f9829cf67e21..2a052af4cf3f06e13819f904bbeafab8c8a613ca 100644 (file)
@@ -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()
index 32cec8d11bcc9abf4e8ddabc60a7a7d915f55367..10c8e0684f051cdf2af51de4deb4f31c7aa58243 100644 (file)
@@ -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