move locking into env_update itself
authorBrian Harring <ferringb@chromium.org>
Thu, 15 Sep 2011 22:06:44 +0000 (15:06 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 15 Sep 2011 22:32:31 +0000 (15:32 -0700)
pym/portage/dbapi/vartree.py
pym/portage/util/env_update.py

index 4d0a6dd4cb3ebbe931446afa1b6da1ef5a148257..f146adecd96923379d08e36a3a750fa86aed2db5 100644 (file)
@@ -1842,16 +1842,10 @@ class dblink(object):
                else:
                        self.settings.pop("PORTAGE_LOG_FILE", None)
 
-               # Lock the config memory file to prevent symlink creation
-               # in merge_contents from overlapping with env-update.
-               self.vartree.dbapi._fs_lock()
-               try:
-                       env_update(target_root=self.settings['ROOT'],
-                               prev_mtimes=ldpath_mtimes,
-                               contents=contents, env=self.settings,
-                               writemsg_level=self._display_merge)
-               finally:
-                       self.vartree.dbapi._fs_unlock()
+               env_update(target_root=self.settings['ROOT'],
+                       prev_mtimes=ldpath_mtimes,
+                       contents=contents, env=self.settings,
+                       writemsg_level=self._display_merge, vardbapi=self.vartree.dbapi)
 
                return os.EX_OK
 
@@ -3811,17 +3805,11 @@ class dblink(object):
                        showMessage(_("!!! FAILED postinst: ")+str(a)+"\n",
                                level=logging.ERROR, noiselevel=-1)
 
-               # Lock the config memory file to prevent symlink creation
-               # in merge_contents from overlapping with env-update.
-               self.vartree.dbapi._fs_lock()
-               try:
-                       #update environment settings, library paths. DO NOT change symlinks.
-                       env_update(
-                               target_root=self.settings['ROOT'], prev_mtimes=prev_mtimes,
-                               contents=contents, env=self.settings,
-                               writemsg_level=self._display_merge)
-               finally:
-                       self.vartree.dbapi._fs_unlock()
+               #update environment settings, library paths. DO NOT change symlinks.
+               env_update(
+                       target_root=self.settings['ROOT'], prev_mtimes=prev_mtimes,
+                       contents=contents, env=self.settings,
+                       writemsg_level=self._display_merge, vardbapi=self.vartree.dbapi)
 
                # For gcc upgrades, preserved libs have to be removed after the
                # the library path has been updated.
index 19c7666b99539afda555b2bfcc8a46163d2f114d..71dcf376a60fdf52e6d595da5ea4ec1519b04f31 100644 (file)
@@ -19,12 +19,13 @@ from portage.process import find_binary
 from portage.util import atomic_ofstream, ensure_dirs, getconfig, \
        normalize_path, writemsg
 from portage.util.listdir import listdir
+from portage.dbapi.vartree import vartree
 
 if sys.hexversion >= 0x3000000:
        long = int
 
 def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
-       env=None, writemsg_level=None):
+       env=None, writemsg_level=None, vardbapi=None):
        """
        Parse /etc/env.d and use it to generate /etc/profile.env, csh.env,
        ld.so.conf, and prelink.conf. Finally, run ldconfig. When ldconfig is
@@ -39,6 +40,20 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
                defaults to portage.settings["ROOT"].
        @type target_root: String (Path)
        """
+       if vardbapi is None:
+               vardbapi = vartree(settings=portage.settings).dbapi
+
+       # Lock the config memory file to prevent symlink creation
+       # in merge_contents from overlapping with env-update.
+       vardbapi._fs_lock()
+       try:
+               return _env_update(makelinks, target_root, prev_mtimes, contents,
+                       env, writemsg_level)
+       finally:
+               vardbapi._fs_unlock()
+
+def _env_update(makelinks, target_root, prev_mtimes, contents, env,
+       writemsg_level):
        if writemsg_level is None:
                writemsg_level = portage.util.writemsg_level
        if target_root is None: