Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/
Date: Fri, 04 May 2018 17:01:02
Message-Id: 1525452692.17604fd598d799c6af24b66fc2c240f90dddd420.zmedico@gentoo
1 commit: 17604fd598d799c6af24b66fc2c240f90dddd420
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 4 16:47:49 2018 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Fri May 4 16:51:32 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=17604fd5
7
8 EbuildMerge: wait build dir to unlock (bug 654812)
9
10 Wait for the build dir to unlock, in order to ensure that
11 the category directory is removed when appropriate.
12
13 Fixes: 720fef408d07 ("Binpkg: use async_unlock (bug 614108)")
14 Fixes: 5ca8ef781952 ("EbuildBuild: use async_unlock (bug 614108)")
15 Bug: https://bugs.gentoo.org/654812
16
17 pym/_emerge/Binpkg.py | 12 +++++++++++-
18 pym/_emerge/EbuildBuild.py | 12 +++++++++++-
19 pym/_emerge/EbuildMerge.py | 26 +++++++++++++++++++++-----
20 3 files changed, 43 insertions(+), 7 deletions(-)
21
22 diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
23 index e9c5ef568..2b67816e8 100644
24 --- a/pym/_emerge/Binpkg.py
25 +++ b/pym/_emerge/Binpkg.py
26 @@ -1,4 +1,4 @@
27 -# Copyright 1999-2013 Gentoo Foundation
28 +# Copyright 1999-2018 Gentoo Foundation
29 # Distributed under the terms of the GNU General Public License v2
30
31 import functools
32 @@ -428,6 +428,10 @@ class Binpkg(CompositeTask):
33 return task
34
35 def _install_exit(self, task):
36 + """
37 + @returns: Future, result is the returncode from an
38 + EbuildBuildDir.async_unlock() task
39 + """
40 self.settings.pop("PORTAGE_BINPKG_FILE", None)
41 if task.returncode == os.EX_OK and \
42 'binpkg-logs' not in self.settings.features and \
43 @@ -437,3 +441,9 @@ class Binpkg(CompositeTask):
44 except OSError:
45 pass
46 self._async_unlock_builddir()
47 + if self._current_task is None:
48 + result = self.scheduler.create_future()
49 + self.scheduler.call_soon(result.set_result, os.EX_OK)
50 + else:
51 + result = self._current_task.async_wait()
52 + return result
53
54 diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
55 index e5b96691a..00d4680f5 100644
56 --- a/pym/_emerge/EbuildBuild.py
57 +++ b/pym/_emerge/EbuildBuild.py
58 @@ -1,4 +1,4 @@
59 -# Copyright 1999-2014 Gentoo Foundation
60 +# Copyright 1999-2018 Gentoo Foundation
61 # Distributed under the terms of the GNU General Public License v2
62
63 from __future__ import unicode_literals
64 @@ -494,4 +494,14 @@ class EbuildBuild(CompositeTask):
65 return task
66
67 def _install_exit(self, task):
68 + """
69 + @returns: Future, result is the returncode from an
70 + EbuildBuildDir.async_unlock() task
71 + """
72 self._async_unlock_builddir()
73 + if self._current_task is None:
74 + result = self.scheduler.create_future()
75 + self.scheduler.call_soon(result.set_result, os.EX_OK)
76 + else:
77 + result = self._current_task.async_wait()
78 + return result
79
80 diff --git a/pym/_emerge/EbuildMerge.py b/pym/_emerge/EbuildMerge.py
81 index 07d9134c3..bedea902d 100644
82 --- a/pym/_emerge/EbuildMerge.py
83 +++ b/pym/_emerge/EbuildMerge.py
84 @@ -1,9 +1,12 @@
85 -# Copyright 1999-2011 Gentoo Foundation
86 +# Copyright 1999-2018 Gentoo Foundation
87 # Distributed under the terms of the GNU General Public License v2
88
89 +import functools
90 +
91 from _emerge.CompositeTask import CompositeTask
92 from portage import os
93 from portage.dbapi._MergeProcess import MergeProcess
94 +from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
95
96 class EbuildMerge(CompositeTask):
97
98 @@ -35,8 +38,7 @@ class EbuildMerge(CompositeTask):
99
100 def _merge_exit(self, merge_task):
101 if self._final_exit(merge_task) != os.EX_OK:
102 - self.exit_hook(self)
103 - self.wait()
104 + self._start_exit_hook(self.returncode)
105 return
106
107 self.postinst_failure = merge_task.postinst_failure
108 @@ -55,5 +57,19 @@ class EbuildMerge(CompositeTask):
109 logger.log(" ::: completed emerge (%s of %s) %s to %s" % \
110 (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg.root))
111
112 - self.exit_hook(self)
113 - self.wait()
114 + self._start_exit_hook(self.returncode)
115 +
116 + def _start_exit_hook(self, returncode):
117 + """
118 + Start the exit hook, and set returncode after it completes.
119 + """
120 + # The returncode will be set after exit hook is complete.
121 + self.returncode = None
122 + self._start_task(
123 + AsyncTaskFuture(future=self.exit_hook(self)),
124 + functools.partial(self._exit_hook_exit, returncode))
125 +
126 + def _exit_hook_exit(self, returncode, task):
127 + self._assert_current(task)
128 + self.returncode = returncode
129 + self._async_wait()