Move the world file update code out of update_config_files() since it should
authorZac Medico <zmedico@gentoo.org>
Sat, 13 Sep 2008 05:53:18 +0000 (05:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 13 Sep 2008 05:53:18 +0000 (05:53 -0000)
not be relative to PORTAGE_CONFIGROOT. Thanks to grobian for reporting.

svn path=/main/trunk/; revision=11508

pym/portage/__init__.py
pym/portage/update.py

index 3bcb0b06c0b5288a439d5942ebc5a4f074ae6a4a..199317c28ef7debc1a5fd41ad7454cbdb01f128b 100644 (file)
@@ -117,7 +117,7 @@ try:
        import portage.eclass_cache
        from portage.localization import _
        from portage.update import dep_transform, fixdbentries, grab_updates, \
-               parse_updates, update_config_files, update_dbentries
+               parse_updates, update_config_files, update_dbentries, update_dbentry
 
        # Need these functions directly in portage namespace to not break every external tool in existence
        from portage.versions import best, catpkgsplit, catsplit, pkgcmp, \
@@ -7069,6 +7069,7 @@ def _global_updates(trees, prev_mtimes):
        global secpass
        if secpass < 2 or "SANDBOX_ACTIVE" in os.environ:
                return
+       root = "/"
        mysettings = trees["/"]["vartree"].settings
        updpath = os.path.join(mysettings["PORTDIR"], "profiles", "updates")
 
@@ -7102,6 +7103,20 @@ def _global_updates(trees, prev_mtimes):
                                for msg in errors:
                                        writemsg("%s\n" % msg, noiselevel=-1)
 
+               world_file = os.path.join(root, WORLD_FILE)
+               world_list = grabfile(world_file)
+               world_modified = False
+               for update_cmd in myupd:
+                       for pos, atom in enumerate(world_list):
+                               new_atom = update_dbentry(update_cmd, atom)
+                               if atom != new_atom:
+                                       world_list[pos] = new_atom
+                                       world_modified = True
+               if world_modified:
+                       world_list.sort()
+                       write_atomic(world_file,
+                               "".join("%s\n" % (x,) for x in world_list))
+
                update_config_files("/",
                        mysettings.get("CONFIG_PROTECT","").split(),
                        mysettings.get("CONFIG_PROTECT_MASK","").split(),
index 36108dd22b5392ad5a36cb9bb13cf8d71f4ddba9..85d07f5a39795a4f8ab9db0af87e5ca811aeb6b8 100644 (file)
@@ -177,19 +177,6 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
                                del file_contents[x]
                        continue
 
-       worldlist = grabfile(os.path.join(config_root, WORLD_FILE))
-       modified = False
-       for update_cmd in update_iter:
-               for pos, atom in enumerate(worldlist):
-                       new_atom = update_dbentry(update_cmd, atom)
-                       if atom != new_atom:
-                               worldlist[pos] = new_atom
-                               modified = True
-       if modified:
-               worldlist.sort()
-               write_atomic(os.path.join(config_root, WORLD_FILE),
-                       "\n".join(worldlist)+"\n")
-
        # update /etc/portage/packages.*
        ignore_line_re = re.compile(r'^#|^\s*$')
        for update_cmd in update_iter: