1 |
commit: 345256c2d439c5ab580e4226f227db2819883d40 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jun 4 23:32:46 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jun 4 23:44:15 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=345256c2 |
7 |
|
8 |
emerge -pf: spawn pkg_nofetch asynchronously (bug 657360) |
9 |
|
10 |
For pretend mode, fix doebuild to skip the spawn_nofetch call |
11 |
that would trigger event loop recursion, and spawn pkg_nofetch |
12 |
asynchronously. |
13 |
|
14 |
Bug: https://bugs.gentoo.org/657360 |
15 |
|
16 |
pym/_emerge/EbuildBuild.py | 16 ++++++++++++++-- |
17 |
pym/_emerge/EbuildFetchonly.py | 5 ++++- |
18 |
pym/portage/package/ebuild/doebuild.py | 15 +++++++-------- |
19 |
3 files changed, 25 insertions(+), 11 deletions(-) |
20 |
|
21 |
diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py |
22 |
index 00d4680f5..d9f7f6da7 100644 |
23 |
--- a/pym/_emerge/EbuildBuild.py |
24 |
+++ b/pym/_emerge/EbuildBuild.py |
25 |
@@ -142,8 +142,20 @@ class EbuildBuild(CompositeTask): |
26 |
pkg=pkg, pretend=opts.pretend, |
27 |
settings=settings) |
28 |
retval = fetcher.execute() |
29 |
- self.returncode = retval |
30 |
- self.wait() |
31 |
+ if retval == os.EX_OK: |
32 |
+ self._current_task = None |
33 |
+ self.returncode = os.EX_OK |
34 |
+ self._async_wait() |
35 |
+ else: |
36 |
+ # For pretend mode, the convention it to execute |
37 |
+ # pkg_nofetch and return a successful exitcode. |
38 |
+ self._start_task(SpawnNofetchWithoutBuilddir( |
39 |
+ background=self.background, |
40 |
+ portdb=self.pkg.root_config.trees[self._tree].dbapi, |
41 |
+ ebuild_path=self._ebuild_path, |
42 |
+ scheduler=self.scheduler, |
43 |
+ settings=self.settings), |
44 |
+ self._default_final_exit) |
45 |
return |
46 |
else: |
47 |
fetcher = EbuildFetcher( |
48 |
|
49 |
diff --git a/pym/_emerge/EbuildFetchonly.py b/pym/_emerge/EbuildFetchonly.py |
50 |
index f88ea96ef..eec2ad208 100644 |
51 |
--- a/pym/_emerge/EbuildFetchonly.py |
52 |
+++ b/pym/_emerge/EbuildFetchonly.py |
53 |
@@ -25,7 +25,10 @@ class EbuildFetchonly(SlotObject): |
54 |
listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all, |
55 |
mydbapi=portdb, tree="porttree") |
56 |
|
57 |
- if rval != os.EX_OK: |
58 |
+ # For pretend mode, this error message is suppressed, |
59 |
+ # and the unsuccessful return value is used to trigger |
60 |
+ # a call to the pkg_nofetch phase. |
61 |
+ if rval != os.EX_OK and not self.pretend: |
62 |
msg = "Fetch failed for '%s'" % (pkg.cpv,) |
63 |
eerror(msg, phase="unpack", key=pkg.cpv) |
64 |
|
65 |
|
66 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
67 |
index dc443df00..0e94de805 100644 |
68 |
--- a/pym/portage/package/ebuild/doebuild.py |
69 |
+++ b/pym/portage/package/ebuild/doebuild.py |
70 |
@@ -1079,14 +1079,13 @@ def doebuild(myebuild, mydo, _unused=DeprecationWarning, settings=None, debug=0, |
71 |
if not fetch(fetchme, mysettings, listonly=listonly, |
72 |
fetchonly=fetchonly, allow_missing_digests=False, |
73 |
digests=dist_digests): |
74 |
- spawn_nofetch(mydbapi, myebuild, settings=mysettings, |
75 |
- fd_pipes=fd_pipes) |
76 |
- if listonly: |
77 |
- # The convention for listonly mode is to report |
78 |
- # success in any case, even though fetch() may |
79 |
- # return unsuccessfully in order to trigger the |
80 |
- # nofetch phase. |
81 |
- return 0 |
82 |
+ # Since listonly mode is called by emerge --pretend in an |
83 |
+ # asynchronous context, spawn_nofetch would trigger event loop |
84 |
+ # recursion here, therefore delegate execution of pkg_nofetch |
85 |
+ # to the caller (bug 657360). |
86 |
+ if not listonly: |
87 |
+ spawn_nofetch(mydbapi, myebuild, settings=mysettings, |
88 |
+ fd_pipes=fd_pipes) |
89 |
return 1 |
90 |
|
91 |
if need_distfiles: |