summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-28 22:29:06 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-28 22:29:06 +0000
commit5ba3d0a039ef9c56b63d15075bdf27a43d2883c2 (patch)
tree929de6e86f3d87d6367185a9086c26546c23c6bb /pym
parentea39352213cc363039952c47751ae089b984ae40 (diff)
downloadportage-5ba3d0a039ef9c56b63d15075bdf27a43d2883c2.tar.gz
portage-5ba3d0a039ef9c56b63d15075bdf27a43d2883c2.tar.bz2
portage-5ba3d0a039ef9c56b63d15075bdf27a43d2883c2.zip
If portage is reinstalling itself, create a temporary
copy of PORTAGE_BIN_PATH in order to avoid relying on on the new versions which may be incompatible. svn path=/main/trunk/; revision=8731
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 5bca2f8e2..5b64fd76a 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -2004,8 +2004,18 @@ class dblink(object):
outfile.flush()
outfile.close()
+ # If portage is reinstalling itself, remove the old
+ # version now since we want to use the temporary
+ # PORTAGE_BIN_PATH that will be removed when we return.
+ reinstall_self = False
+ if self.myroot == "/" and \
+ "sys-apps" == self.cat and \
+ "portage" == pkgsplit(self.pkg)[0]:
+ reinstall_self = True
+
for dblnk in others_in_slot:
- if dblnk.mycpv != self.mycpv:
+ if dblnk.mycpv != self.mycpv and \
+ not reinstall_self:
continue
writemsg_stdout(">>> Safely unmerging already-installed instance...\n")
# These caches are populated during collision-protect and the data
@@ -2337,6 +2347,41 @@ class dblink(object):
def merge(self, mergeroot, inforoot, myroot, myebuild=None, cleanup=0,
mydbapi=None, prev_mtimes=None):
+
+ # If portage is reinstalling itself, create a temporary
+ # copy of PORTAGE_BIN_PATH in order to avoid relying on
+ # on the new versions which may be incompatible.
+ bin_path_tmp = None
+ bin_path_orig = None
+ if self.myroot == "/" and \
+ "sys-apps" == self.cat and \
+ "portage" == pkgsplit(self.pkg)[0]:
+ bin_path_orig = self.settings["PORTAGE_BIN_PATH"]
+ from tempfile import mkdtemp
+ import shutil
+ bin_path_tmp = mkdtemp()
+ for x in os.listdir(bin_path_orig):
+ path = os.path.join(bin_path_orig, x)
+ if not os.path.isfile(path):
+ continue
+ shutil.copy(path, os.path.join(bin_path_tmp, x))
+ os.chmod(bin_path_tmp, 0755)
+ try:
+ if bin_path_tmp:
+ self.settings["PORTAGE_BIN_PATH"] = bin_path_tmp
+ self.settings.backup_changes("PORTAGE_BIN_PATH")
+ return self._merge(mergeroot, inforoot,
+ myroot, myebuild=myebuild, cleanup=cleanup,
+ mydbapi=mydbapi, prev_mtimes=prev_mtimes)
+ finally:
+ if bin_path_tmp:
+ bin_path_orig = self.settings["PORTAGE_BIN_PATH"]
+ self.settings.backup_changes("PORTAGE_BIN_PATH")
+ from shutil import rmtree
+ rmtree(bin_path_tmp)
+
+ def _merge(self, mergeroot, inforoot, myroot, myebuild=None, cleanup=0,
+ mydbapi=None, prev_mtimes=None):
retval = -1
self.lockdb()
try: