summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/_MergeProcess.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-26 23:09:27 -0700
committerZac Medico <zmedico@gentoo.org>2011-03-26 23:09:27 -0700
commitcdf04882ce380579814b9cfe63ee593dbfba5ef9 (patch)
treea95aac78d8903d9533b549f8e3fc575be4073d36 /pym/portage/dbapi/_MergeProcess.py
parentdfc5e174bdbcb21a16c5d5bb464ea4fc43b456a5 (diff)
downloadportage-cdf04882ce380579814b9cfe63ee593dbfba5ef9.tar.gz
portage-cdf04882ce380579814b9cfe63ee593dbfba5ef9.tar.bz2
portage-cdf04882ce380579814b9cfe63ee593dbfba5ef9.zip
MergeProcess: add fallback setcpv call
It's important that this metadata access happens in the parent process, since closing of file descriptors in the subprocess can prevent access to open database connections such as that used by the sqlite metadata cache module.
Diffstat (limited to 'pym/portage/dbapi/_MergeProcess.py')
-rw-r--r--pym/portage/dbapi/_MergeProcess.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
index ea7c3e6d6..afb2e084d 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -30,6 +30,21 @@ class MergeProcess(SpawnProcess):
'_buf', '_elog_keys')
def _start(self):
+ # Portage should always call setcpv prior to this
+ # point, but here we have a fallback as a convenience
+ # for external API consumers. It's important that
+ # this metadata access happens in the parent process,
+ # since closing of file descriptors in the subprocess
+ # can prevent access to open database connections such
+ # as that used by the sqlite metadata cache module.
+ cpv = "%s/%s" % (self.mycat, self.mypkg)
+ settings = self.settings
+ if cpv != settings.mycpv or \
+ "IUSE" not in settings.configdict["pkg"]:
+ settings.reload()
+ settings.reset()
+ settings.setcpv(cpv, mydb=self.mydbapi)
+
self._handle_self_reinstall()
super(MergeProcess, self)._start()
@@ -116,9 +131,10 @@ class MergeProcess(SpawnProcess):
fcntl.fcntl(elog_reader_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
blockers = None
if self.blockers is not None:
- # Query blockers in the main process, since metadata cache
- # queries may not work for some databases from within a
- # subprocess. For example, sqlite is known to misbehave.
+ # Query blockers in the main process, since closing
+ # of file descriptors in the subprocess can prevent
+ # access to open database connections such as that
+ # used by the sqlite metadata cache module.
blockers = self.blockers()
mylink = self.dblink(self.mycat, self.mypkg, settings=self.settings,
treetype=self.treetype, vartree=self.vartree,