Schedule ebuild pkg_setup phases on the merge queue,
authorZac Medico <zmedico@gentoo.org>
Sun, 27 Jul 2008 02:23:40 +0000 (02:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 27 Jul 2008 02:23:40 +0000 (02:23 -0000)
in order to serialize unsandboxed access to the live
filesystem.

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

pym/_emerge/__init__.py

index cd59ce39b7a5091ebe318cb61f8bcf4841c24c0c..c4f6adb746cdb57ac2013140f603c12e7e9d75d8 100644 (file)
@@ -2557,19 +2557,16 @@ class EbuildBuild(CompositeTask):
 
 class EbuildExecuter(CompositeTask):
 
-       __slots__ = ("pkg", "scheduler", "settings")
+       __slots__ = ("pkg", "scheduler", "settings") + ("_tree",)
 
-       _phases = ("setup", "unpack", "compile", "test", "install")
+       _phases = ("unpack", "compile", "test", "install")
 
        def _start(self):
+               self._tree = "porttree"
                pkg = self.pkg
-               scheduler = self.scheduler
-               tree = "porttree"
-               settings = self.settings
-
                phase = "clean"
                clean_phase = EbuildPhase(background=self.background, pkg=pkg, phase=phase,
-                       scheduler=scheduler, settings=settings, tree=tree)
+                       scheduler=self.scheduler, settings=self.settings, tree=self._tree)
                self._start_task(clean_phase, self._clean_phase_exit)
 
        def _clean_phase_exit(self, clean_phase):
@@ -2580,19 +2577,32 @@ class EbuildExecuter(CompositeTask):
 
                pkg = self.pkg
                scheduler = self.scheduler
-               tree = "porttree"
                settings = self.settings
                cleanup = 1
 
                # This initializes PORTAGE_LOG_FILE.
                portage.prepare_build_dirs(pkg.root, settings, cleanup)
 
-               ebuild_phases = TaskSequence(scheduler=scheduler)
+               setup_phase = EbuildPhase(background=self.background,
+                       pkg=pkg, phase="setup", scheduler=scheduler,
+                       settings=settings, tree=self._tree)
+
+               setup_phase.addExitListener(self._setup_exit)
+               self._current_task = setup_phase
+               self.scheduler.scheduleSetup(setup_phase)
+
+       def _setup_exit(self, setup_phase):
+
+               if self._default_exit(setup_phase) != os.EX_OK:
+                       self.wait()
+                       return
+
+               ebuild_phases = TaskSequence(scheduler=self.scheduler)
 
                for phase in self._phases:
                        ebuild_phases.add(EbuildPhase(background=self.background,
-                               pkg=pkg, phase=phase, scheduler=scheduler,
-                               settings=settings, tree=tree))
+                               pkg=self.pkg, phase=phase, scheduler=self.scheduler,
+                               settings=self.settings, tree=self._tree))
 
                self._start_task(ebuild_phases, self._default_final_exit)
 
@@ -3125,11 +3135,13 @@ class Binpkg(CompositeTask):
                settings.backup_changes("PORTAGE_BINPKG_FILE")
 
                phase = "setup"
-               ebuild_phase = EbuildPhase(background=self.background,
+               setup_phase = EbuildPhase(background=self.background,
                        pkg=self.pkg, phase=phase, scheduler=self.scheduler,
                        settings=settings, tree=self._tree)
 
-               self._start_task(ebuild_phase, self._setup_exit)
+               setup_phase.addExitListener(self._setup_exit)
+               self._current_task = setup_phase
+               self.scheduler.scheduleSetup(setup_phase)
 
        def _setup_exit(self, setup_phase):
                if self._default_exit(setup_phase) != os.EX_OK:
@@ -8693,7 +8705,7 @@ class Scheduler(PollScheduler):
        class _iface_class(SlotObject):
                __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge",
                        "dblinkElog", "fetch", "register", "schedule",
-                       "scheduleYield", "unregister")
+                       "scheduleSetup", "scheduleYield", "unregister")
 
        class _fetch_iface_class(SlotObject):
                __slots__ = ("log_file", "schedule")
@@ -8765,7 +8777,9 @@ class Scheduler(PollScheduler):
                        dblinkDisplayMerge=self._dblink_display_merge,
                        dblinkElog=self._dblink_elog,
                        fetch=fetch_iface, register=self._register,
-                       schedule=self._schedule_wait, scheduleYield=self._schedule_yield,
+                       schedule=self._schedule_wait,
+                       scheduleSetup=self._schedule_setup,
+                       scheduleYield=self._schedule_yield,
                        unregister=self._unregister)
 
                self._task_queues = self._task_queues_class()
@@ -8944,6 +8958,14 @@ class Scheduler(PollScheduler):
                """
                self._task_queues.fetch.addFront(fetcher)
 
+       def _schedule_setup(self, setup_phase):
+               """
+               Schedule a setup phase on the merge queue, in order to
+               serialize unsandboxed access to the live filesystem.
+               """
+               self._task_queues.merge.addFront(setup_phase)
+               self._schedule()
+
        def _find_blockers(self, new_pkg):
                """
                Returns a callable which should be called only when