1 |
commit: ddbe8bd019552573b3f9c1ef2e5701df2edb4dd6 |
2 |
Author: Frédéric Pierret (fepitre) <frederic.pierret <AT> qubes-os <DOT> org> |
3 |
AuthorDate: Tue Aug 18 15:00:16 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 7 23:31:06 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ddbe8bd0 |
7 |
|
8 |
syncbase: update with newer Gemato proxy parameter in openpgp env |
9 |
|
10 |
- Handle global proxy setting which is overrided by the one provided |
11 |
in Portage configuration (if exists). |
12 |
|
13 |
Bug: https://bugs.gentoo.org/740904 |
14 |
Closes: https://github.com/gentoo/portage/pull/607 |
15 |
See: https://github.com/mgorny/gemato/commit/9980de271de4f8f5e993e2b634d0e8d7753e382f |
16 |
Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret <AT> qubes-os.org> |
17 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
18 |
|
19 |
lib/portage/sync/modules/git/git.py | 14 ++++++-------- |
20 |
lib/portage/sync/modules/rsync/rsync.py | 7 ++----- |
21 |
lib/portage/sync/modules/webrsync/webrsync.py | 4 ++-- |
22 |
lib/portage/sync/syncbase.py | 21 +++++++++++++++++++++ |
23 |
4 files changed, 31 insertions(+), 15 deletions(-) |
24 |
|
25 |
diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py |
26 |
index d87f1a601..8065fff33 100644 |
27 |
--- a/lib/portage/sync/modules/git/git.py |
28 |
+++ b/lib/portage/sync/modules/git/git.py |
29 |
@@ -207,19 +207,17 @@ class GitSync(NewBase): |
30 |
'sync-git-verify-commit-signature', 'false').lower() not in ('true', 'yes')): |
31 |
return True |
32 |
|
33 |
- if self.repo.sync_openpgp_key_path is not None: |
34 |
- if gemato is None: |
35 |
- writemsg_level("!!! Verifying against specified key requires gemato-11.0+ installed\n", |
36 |
+ if self.repo.sync_openpgp_key_path is not None and gemato is None: |
37 |
+ writemsg_level("!!! Verifying against specified key requires gemato-14.5+ installed\n", |
38 |
level=logging.ERROR, noiselevel=-1) |
39 |
- return False |
40 |
- openpgp_env = gemato.openpgp.OpenPGPEnvironment() |
41 |
- else: |
42 |
- openpgp_env = None |
43 |
+ return False |
44 |
+ |
45 |
+ openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path) |
46 |
|
47 |
try: |
48 |
out = EOutput() |
49 |
env = None |
50 |
- if openpgp_env is not None: |
51 |
+ if openpgp_env is not None and self.repo.sync_openpgp_key_path is not None: |
52 |
try: |
53 |
out.einfo('Using keys from %s' % (self.repo.sync_openpgp_key_path,)) |
54 |
with io.open(self.repo.sync_openpgp_key_path, 'rb') as f: |
55 |
|
56 |
diff --git a/lib/portage/sync/modules/rsync/rsync.py b/lib/portage/sync/modules/rsync/rsync.py |
57 |
index 35d1461e4..54e285d88 100644 |
58 |
--- a/lib/portage/sync/modules/rsync/rsync.py |
59 |
+++ b/lib/portage/sync/modules/rsync/rsync.py |
60 |
@@ -133,10 +133,7 @@ class RsyncSync(NewBase): |
61 |
if self.verify_metamanifest and gemato is not None: |
62 |
# Use isolated environment if key is specified, |
63 |
# system environment otherwise |
64 |
- if self.repo.sync_openpgp_key_path is not None: |
65 |
- openpgp_env = gemato.openpgp.OpenPGPEnvironment() |
66 |
- else: |
67 |
- openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment() |
68 |
+ openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path) |
69 |
|
70 |
try: |
71 |
# Load and update the keyring early. If it fails, then verification |
72 |
@@ -361,7 +358,7 @@ class RsyncSync(NewBase): |
73 |
# if synced successfully, verify now |
74 |
if exitcode == 0 and self.verify_metamanifest: |
75 |
if gemato is None: |
76 |
- writemsg_level("!!! Unable to verify: gemato-11.0+ is required\n", |
77 |
+ writemsg_level("!!! Unable to verify: gemato-14.5+ is required\n", |
78 |
level=logging.ERROR, noiselevel=-1) |
79 |
exitcode = 127 |
80 |
else: |
81 |
|
82 |
diff --git a/lib/portage/sync/modules/webrsync/webrsync.py b/lib/portage/sync/modules/webrsync/webrsync.py |
83 |
index 20cc25a2c..cc0dbc4a9 100644 |
84 |
--- a/lib/portage/sync/modules/webrsync/webrsync.py |
85 |
+++ b/lib/portage/sync/modules/webrsync/webrsync.py |
86 |
@@ -75,11 +75,11 @@ class WebRsync(SyncBase): |
87 |
return (1, False) |
88 |
|
89 |
if gemato is None: |
90 |
- writemsg_level("!!! Verifying against specified key requires gemato-11.0+ installed\n", |
91 |
+ writemsg_level("!!! Verifying against specified key requires gemato-14.5+ installed\n", |
92 |
level=logging.ERROR, noiselevel=-1) |
93 |
return (1, False) |
94 |
|
95 |
- openpgp_env = gemato.openpgp.OpenPGPEnvironment() |
96 |
+ openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path) |
97 |
|
98 |
out = portage.output.EOutput(quiet=quiet) |
99 |
try: |
100 |
|
101 |
diff --git a/lib/portage/sync/syncbase.py b/lib/portage/sync/syncbase.py |
102 |
index 8e83b94fb..6493741c2 100644 |
103 |
--- a/lib/portage/sync/syncbase.py |
104 |
+++ b/lib/portage/sync/syncbase.py |
105 |
@@ -20,6 +20,12 @@ from portage.util.futures.retry import retry |
106 |
from portage.util.futures.executor.fork import ForkExecutor |
107 |
from . import _SUBMODULE_PATH_MAP |
108 |
|
109 |
+try: |
110 |
+ import gemato.openpgp |
111 |
+except ImportError: |
112 |
+ gemato = None |
113 |
+ |
114 |
+ |
115 |
class SyncBase: |
116 |
'''Base Sync class for subclassing''' |
117 |
|
118 |
@@ -294,6 +300,21 @@ class SyncBase: |
119 |
loop.run_until_complete(decorated_func()) |
120 |
out.eend(0) |
121 |
|
122 |
+ def _get_openpgp_env(self, openpgp_key_path=None): |
123 |
+ if gemato is not None: |
124 |
+ # Override global proxy setting with one provided in emerge configuration |
125 |
+ if 'http_proxy' in self.spawn_kwargs['env']: |
126 |
+ proxy = self.spawn_kwargs['env']['http_proxy'] |
127 |
+ else: |
128 |
+ proxy = None |
129 |
+ |
130 |
+ if openpgp_key_path: |
131 |
+ openpgp_env = gemato.openpgp.OpenPGPEnvironment(proxy=proxy) |
132 |
+ else: |
133 |
+ openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment(proxy=proxy) |
134 |
+ |
135 |
+ return openpgp_env |
136 |
+ |
137 |
|
138 |
class NewBase(SyncBase): |
139 |
'''Subclasses Syncbase adding a new() and runs it |