summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-29 06:30:55 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-29 06:30:55 +0000
commit2d8d34c09770f315582e09935d14c5b42cfaa8a9 (patch)
tree0434325daa9e84e26c9d6765df53fa14fccbffa5 /pym
parent24bf0167dcce019bcc73f9da221878bfb119829f (diff)
downloadportage-2d8d34c09770f315582e09935d14c5b42cfaa8a9.tar.gz
portage-2d8d34c09770f315582e09935d14c5b42cfaa8a9.tar.bz2
portage-2d8d34c09770f315582e09935d14c5b42cfaa8a9.zip
When portage reinstalls itself, copy both the bin and pym
directories to a temp dir. Insert the temporary PORTAGE_PYM_PATH as the first element of sys.path and register an atexit hook to clean up the temporary directories. (trunk r8743) svn path=/main/branches/2.1.2/; revision=8744
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 76df20e70..5d0ea8f8f 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -9051,38 +9051,39 @@ class dblink:
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 portage is reinstalling itself, create temporary
+ copies of PORTAGE_BIN_PATH and PORTAGE_PYM_PATH in order
+ to avoid relying on the new versions which may be
+ incompatible. Insert the temporary PORTAGE_PYM_PATH
+ as the first element of sys.path and register an atexit
+ hook to clean up the temporary directories.
+ """
if self.myroot == "/" and \
"sys-apps" == self.cat and \
"portage" == pkgsplit(self.pkg)[0]:
- bin_path_orig = self.settings["PORTAGE_BIN_PATH"]
+ settings = self.settings
+ base_path_orig = os.path.dirname(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,
+ base_path_tmp = mkdtemp()
+ from portage_exec import atexit_register
+ atexit_register(shutil.rmtree, base_path_tmp)
+ dir_perms = 0755
+ for subdir in "bin", "pym":
+ var_name = "PORTAGE_%s_PATH" % subdir.upper()
+ var_orig = settings[var_name]
+ var_new = os.path.join(base_path_tmp, subdir)
+ settings[var_name] = var_new
+ settings.backup_changes(var_name)
+ shutil.copytree(var_orig, var_new, symlinks=True)
+ os.chmod(var_new, dir_perms)
+ os.chmod(base_path_tmp, dir_perms)
+ sys.path.insert(0, settings["PORTAGE_PYM_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):