Make some adjustments so that it's possible to install binary
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 05:16:44 +0000 (05:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 05:16:44 +0000 (05:16 -0000)
packages without having a portage tree:

* Make portdbapi.aux_get() return early by raising a KeyError
  if it detects that there is no portage tree.

* Move the ARCH and USERLAND sanity check to the last moment
  in doebuild() and only require these variables if an
  existing environment (such as environment.bz2) is
  unavailable.

* Make the NewsManager constructor cope with a broken
  make.profile symlink.

svn path=/main/trunk/; revision=8973

pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/porttree.py
pym/portage/news.py

index 85b0566b6e8adb7cf70543e1c1b8af985fc3b133..36c3234a99795627b9f2ae9bada6de688c35dd33 100644 (file)
@@ -6671,18 +6671,7 @@ def parse_opts(tmpcmdline, silent=False):
        return myaction, myopts, myfiles
 
 def validate_ebuild_environment(trees):
-       for myroot in trees:
-               mysettings = trees[myroot]["vartree"].settings
-               for var in "ARCH", "USERLAND":
-                       if mysettings.get(var):
-                               continue
-                       print >> sys.stderr, bad(("\a!!! %s is not set... " % var) + \
-                               "Are you missing the '%setc/make.profile' symlink?" % \
-                               mysettings["PORTAGE_CONFIGROOT"])
-                       print >> sys.stderr, bad("\a!!! Is the symlink correct? " + \
-                               "Is your portage tree complete?\n")
-                       sys.exit(9)
-               del myroot, mysettings
+       pass
 
 def load_emerge_config(trees=None):
        kwargs = {}
index 1c995633644ae2b5c767bd409005bd357361c8c6..3bcba4d6fdb15c578e0167bca3b090eca1e324dd 100644 (file)
@@ -4512,6 +4512,22 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                        env_stat = None
                        if env_stat:
                                mysettings._filter_calling_env = True
+                       else:
+                               for var in "ARCH", "USERLAND":
+                                       if mysettings.get(var):
+                                               continue
+                                       msg = ("%s is not set... " % var) + \
+                                               ("Are you missing the '%setc/make.profile' symlink? " % \
+                                               mysettings["PORTAGE_CONFIGROOT"]) + \
+                                               "Is the symlink correct? " + \
+                                               "Is your portage tree complete?"
+                                       from portage.elog.messages import eerror
+                                       from textwrap import wrap
+                                       for line in wrap(msg, 70):
+                                               eerror(line, phase=mydo, key=mysettings.mycpv)
+                                       from portage.elog import elog_process
+                                       elog_process(mysettings.mycpv, mysettings)
+                                       return 1
                        del env_file, env_stat, saved_env
                        _doebuild_exit_status_unlink(
                                mysettings.get("EBUILD_EXIT_STATUS_FILE"))
index 0ed55fba858fe55474f713fbf821b91ee2d1c6eb..be201562801321e926e5a3d17c9b80a10d85c8bc 100644 (file)
@@ -68,6 +68,13 @@ class portdbapi(dbapi):
                self.eclassdb = eclass_cache.cache(self.porttree_root,
                        overlays=self.mysettings["PORTDIR_OVERLAY"].split())
 
+               # This is used as sanity check for aux_get(). If there is no
+               # root eclass dir, we assume that PORTDIR is invalid or
+               # missing. This check allows aux_get() to detect a missing
+               # portage tree and return early by raising a KeyError.
+               self._have_root_eclass_dir = os.path.isdir(
+                       os.path.join(self.porttree_root, "eclasses"))
+
                self.metadbmodule = self.mysettings.load_best_module("portdbapi.metadbmodule")
 
                #if the portdbapi is "frozen", then we assume that we can cache everything (that no updates to it are happening)
@@ -303,6 +310,8 @@ class portdbapi(dbapi):
                if doregen:
                        if myebuild in self._broken_ebuilds:
                                raise KeyError(mycpv)
+                       if not self._have_root_eclass_dir:
+                               raise KeyError(mycpv)
                        writemsg("doregen: %s %s\n" % (doregen, mycpv), 2)
                        writemsg("Generating cache entry(0) for: "+str(myebuild)+"\n", 1)
 
index 540372e104f626a2da08b6e8de9fa34d739b0316..da7e159af2f593833ece45cf9a92987a196167e9 100644 (file)
@@ -36,10 +36,12 @@ class NewsManager(object):
 
                portdir = portdb.porttree_root
                profiles_base = os.path.join(portdir, 'profiles') + os.path.sep
-               profile_path = normalize_path(
-                       os.path.realpath(portdb.mysettings.profile_path))
-               if profile_path.startswith(profiles_base):
-                       profile_path = profile_path[len(profiles_base):]
+               profile_path = None
+               if portdb.mysettings.profile_path:
+                       profile_path = normalize_path(
+                               os.path.realpath(portdb.mysettings.profile_path))
+                       if profile_path.startswith(profiles_base):
+                               profile_path = profile_path[len(profiles_base):]
                self._profile_path = profile_path
 
                # Ensure that the unread path exists and is writable.