summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/__init__.py45
-rw-r--r--pym/portage/dbapi/vartree.py1
2 files changed, 23 insertions, 23 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 334736e5e..c4399f6e4 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1771,16 +1771,18 @@ class config(object):
def load_infodir(self,infodir):
self.modifying()
backup_pkg_metadata = dict(self.configdict["pkg"].iteritems())
- if "pkg" in self.configdict:
+ if "pkg" in self.configdict and \
+ "CATEGORY" in self.configdict["pkg"]:
self.configdict["pkg"].clear()
+ self.configdict["pkg"]["CATEGORY"] = \
+ backup_pkg_metadata["CATEGORY"]
else:
- writemsg("No pkg setup for settings instance?\n",
- noiselevel=-1)
- sys.exit(17)
+ raise portage.exception.PortageException(
+ "No pkg setup for settings instance?")
retval = 0
- category_corrupt = False
- if os.path.exists(infodir):
+ found_category_file = False
+ if os.path.isdir(infodir):
if os.path.exists(infodir+"/environment"):
self.configdict["pkg"]["PORT_ENV_FILE"] = infodir+"/environment"
@@ -1791,6 +1793,9 @@ class config(object):
# FEATURES from the build host shouldn't be interpreted as
# FEATURES on the client system.
continue
+ if filename == "CATEGORY":
+ found_category_file = True
+ continue
if myre.match(filename):
try:
file_path = os.path.join(infodir, filename)
@@ -1807,29 +1812,22 @@ class config(object):
else:
self.configdict["pkg"][filename] = mydata
self.configdict["env"][filename] = mydata
- # CATEGORY is important because it's used in doebuild
- # to infer the cpv. If it's corrupted, it leads to
- # strange errors later on, so we'll validate it and
- # print a warning if necessary.
- if filename == "CATEGORY":
- matchobj = re.match(r'^[-\w_.+]+', mydata)
- if not matchobj:
- writemsg("!!! CATEGORY file is corrupt: %s\n" % \
- os.path.join(infodir, filename), noiselevel=-1)
- self.configdict["pkg"].pop(filename, None)
- self.configdict["env"].pop(filename, None)
- category_corrupt = True
except (OSError, IOError):
writemsg("!!! Unable to read file: %s\n" % infodir+"/"+filename,
noiselevel=-1)
pass
retval = 1
- if "CATEGORY" not in self.configdict["pkg"]:
- if not category_corrupt:
- writemsg("!!! CATEGORY file is missing: %s\n" % \
- os.path.join(infodir, "CATEGORY"), noiselevel=-1)
+
+ # Missing or corrupt CATEGORY will cause problems for
+ # doebuild(), which uses it to infer the cpv. We already
+ # know the category, so there's no need to trust this
+ # file. Show a warning if the file is missing though,
+ # because it's required (especially for binary packages).
+ if not found_category_file:
+ writemsg("!!! CATEGORY file is missing: %s\n" % \
+ os.path.join(infodir, "CATEGORY"), noiselevel=-1)
self.configdict["pkg"].update(backup_pkg_metadata)
- retval = 0
+ retval = 0
return retval
def setcpv(self, mycpv, use_cache=1, mydb=None):
@@ -5771,6 +5769,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes
gid=portage_gid, mode=0755)
writemsg_stdout(">>> Extracting info\n")
xptbz2.unpackinfo(infloc)
+ mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi)
mysettings.load_infodir(infloc)
# Store the md5sum in the vdb.
fp = open(os.path.join(infloc, "BINPKGMD5"), "w")
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 54b8d135e..4974a04af 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1083,6 +1083,7 @@ class dblink(object):
write_atomic(os.path.join(self.dbdir, "PF"), self.pkg+"\n")
break
+ self.settings.setcpv(self.mycpv, mydb=self.vartree.dbapi)
self.settings.load_infodir(self.dbdir)
if myebuildpath:
try: