Scheduler is now able to clean world set when removing a package.
authorMounir Lamouri <volkmar@gentoo.org>
Sat, 15 Aug 2009 19:28:53 +0000 (19:28 -0000)
committerMounir Lamouri <volkmar@gentoo.org>
Sat, 15 Aug 2009 19:28:53 +0000 (19:28 -0000)
world_atom function has been updated
and PackageUninstall is calling it after unmerge.

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

pym/_emerge/MergeListItem.py
pym/_emerge/PackageUninstall.py
pym/_emerge/Scheduler.py

index 7e4556ec2fc3aecbaf1aa6273f2cebd4232cee1f..0205e659528d9b634dac7d61afce85dd660fcf9e 100644 (file)
@@ -132,7 +132,8 @@ class MergeListItem(CompositeTask):
 
                                uninstall = PackageUninstall(background=self.background,
                                        ldpath_mtimes=ldpath_mtimes, opts=self.emerge_opts,
-                                       pkg=pkg, scheduler=scheduler, settings=settings)
+                                       pkg=pkg, scheduler=scheduler, settings=settings,
+                                       world_atom=world_atom)
 
                                uninstall.start()
                                retval = uninstall.wait()
index ff1b5e189ef4a32558c4f8c7ff992b99be8fc9df..d86947c4aa7be09dae9b76d33c8b639e19638876 100644 (file)
@@ -12,11 +12,12 @@ from _emerge.UninstallFailure import UninstallFailure
 
 class PackageUninstall(AsynchronousTask):
 
-       __slots__ = ("ldpath_mtimes", "opts", "pkg", "scheduler", "settings")
+       __slots__ = ("world_atom", "ldpath_mtimes", "opts",
+                       "pkg", "scheduler", "settings")
 
        def _start(self):
                try:
-                       unmerge(self.pkg.root_config, self.opts, "unmerge",
+                       retval = unmerge(self.pkg.root_config, self.opts, "unmerge",
                                [self.pkg.cpv], self.ldpath_mtimes, clean_world=0,
                                clean_delay=0, raise_on_error=1, scheduler=self.scheduler,
                                writemsg_level=self._writemsg_level)
@@ -24,6 +25,10 @@ class PackageUninstall(AsynchronousTask):
                        self.returncode = e.status
                else:
                        self.returncode = os.EX_OK
+
+               if retval == 1:
+                       self.world_atom(self.pkg)
+
                self.wait()
 
        def _writemsg_level(self, msg, level=0, noiselevel=0):
index cef4ee6ca05115769d5bb3c9b294926e367362ad..1e05aac0ffcd952a475502b0aacfae013cb83531 100644 (file)
@@ -1566,8 +1566,8 @@ class Scheduler(PollScheduler):
 
        def _world_atom(self, pkg):
                """
-               Add the package to the world file, but only if
-               it's supposed to be added. Otherwise, do nothing.
+               Add or remove the package to the world file, but only if
+               it's supposed to be added or removed. Otherwise, do nothing.
                """
 
                if set(("--buildpkgonly", "--fetchonly",
@@ -1596,17 +1596,25 @@ class Scheduler(PollScheduler):
                        if hasattr(world_set, "load"):
                                world_set.load() # maybe it's changed on disk
 
-                       atom = create_world_atom(pkg, args_set, root_config)
-                       if atom:
-                               if hasattr(world_set, "add"):
-                                       self._status_msg(('Recording %s in "world" ' + \
-                                               'favorites file...') % atom)
-                                       logger.log(" === (%s of %s) Updating world file (%s)" % \
-                                               (pkg_count.curval, pkg_count.maxval, pkg.cpv))
-                                       world_set.add(atom)
-                               else:
-                                       writemsg_level('\n!!! Unable to record %s in "world"\n' % \
-                                               (atom,), level=logging.WARN, noiselevel=-1)
+                       if pkg.operation == "uninstall":
+                               if hasattr(world_set, "cleanPackage"):
+                                       world_set.cleanPackage(pkg.root_config.trees["vartree"].dbapi,
+                                                       pkg.cpv)
+                               if hasattr(world_set, "remove"):
+                                       for s in pkg.root_config.setconfig.active:
+                                               world_set.remove(SETPREFIX+s)
+                       else:
+                               atom = create_world_atom(pkg, args_set, root_config)
+                               if atom:
+                                       if hasattr(world_set, "add"):
+                                               self._status_msg(('Recording %s in "world" ' + \
+                                                       'favorites file...') % atom)
+                                               logger.log(" === (%s of %s) Updating world file (%s)" % \
+                                                       (pkg_count.curval, pkg_count.maxval, pkg.cpv))
+                                               world_set.add(atom)
+                                       else:
+                                               writemsg_level('\n!!! Unable to record %s in "world"\n' % \
+                                                       (atom,), level=logging.WARN, noiselevel=-1)
                finally:
                        if world_locked:
                                world_set.unlock()