1 |
commit: eb30619181a56cdb24a40c7ee249b177ec53b6b9 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Mar 4 04:57:40 2023 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Mar 4 05:25:55 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=eb306191 |
7 |
|
8 |
repository: config: fix initial sync of (git) repositories |
9 |
|
10 |
After bd8f9f6c590dca750285e296a6c3d530f1053d89, we started to |
11 |
actually dereference the Path object on the (new) repository |
12 |
location. If it doesn't exist yet, it has no owner, and |
13 |
a FileNotFoundError is thrown: |
14 |
``` |
15 |
[...] |
16 |
File "/usr/lib/python3.10/site-packages/portage/repository/config.py", line 794, in _parse |
17 |
repo = RepoConfig(sname, optdict, local_config=local_config) |
18 |
File "/usr/lib/python3.10/site-packages/portage/repository/config.py", line 360, in __init__ |
19 |
elif Path(self.location).owner() not in ("root", "portage"): |
20 |
File "/usr/lib/python3.10/pathlib.py", line 1103, in owner |
21 |
return self._accessor.owner(self) |
22 |
File "/usr/lib/python3.10/pathlib.py", line 343, in owner |
23 |
return pwd.getpwuid(self.stat(path).st_uid).pw_name |
24 |
FileNotFoundError: [Errno 2] No such file or directory: '/var/db/repos/foo' |
25 |
``` |
26 |
|
27 |
It's fine if the repository doesn't exist yet, the intention in |
28 |
ef123a214708c85f9802f2a649b93137fd2ee3be was to default to non-volatile |
29 |
for such cases, so let's honour that by catching FileNotFoundError |
30 |
and PermissionError. |
31 |
|
32 |
Note that this was exposed by bd8f9f6c590dca750285e296a6c3d530f1053d89 and |
33 |
the real issue was in ef123a214708c85f9802f2a649b93137fd2ee3be, but it's |
34 |
worth having Fixes: tags for both as it becomes easier to understand |
35 |
when it was exposed and when it was actually an issue. |
36 |
|
37 |
Bug: https://bugs.gentoo.org/899208 |
38 |
Fixes: bd8f9f6c590dca750285e296a6c3d530f1053d89 ("repository: config: fix volatile detection, add missing () operator") |
39 |
Fixes: ef123a214708c85f9802f2a649b93137fd2ee3be ("config: Add 'volatile' configuration option") |
40 |
Closes: https://github.com/gentoo/portage/pull/1004 |
41 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
42 |
|
43 |
NEWS | 8 +++----- |
44 |
lib/portage/repository/config.py | 36 +++++++++++++++++++----------------- |
45 |
2 files changed, 22 insertions(+), 22 deletions(-) |
46 |
|
47 |
diff --git a/NEWS b/NEWS |
48 |
index a127798e3..ff52a70b7 100644 |
49 |
--- a/NEWS |
50 |
+++ b/NEWS |
51 |
@@ -1,11 +1,9 @@ |
52 |
-portage-3.0.46 (UNRELEASED) |
53 |
+portage-3.0.45.2 (2023-03-04) |
54 |
-------------- |
55 |
|
56 |
-Features: |
57 |
-* TODO |
58 |
- |
59 |
Bug fixes: |
60 |
-* TODO |
61 |
+* repository: config: Fix initial sync of repositories (bug #899208). Regression |
62 |
+ from portage-3.0.45, but the real bug is from portage-3.0.42. |
63 |
|
64 |
portage-3.0.45.1 (2023-02-27) |
65 |
-------------- |
66 |
|
67 |
diff --git a/lib/portage/repository/config.py b/lib/portage/repository/config.py |
68 |
index 8688c633d..3d887ffaa 100644 |
69 |
--- a/lib/portage/repository/config.py |
70 |
+++ b/lib/portage/repository/config.py |
71 |
@@ -343,24 +343,26 @@ class RepoConfig: |
72 |
# If it's unset, we default to no (i.e. the repository is not volatile), |
73 |
# but with a heuristic for when a repository is not likely to be suitable |
74 |
# (likely to contain custom user changes). |
75 |
- |
76 |
- # If the repository doesn't exist, we can't check its ownership, |
77 |
- # so err on the safe side. |
78 |
- if missing or not self.location: |
79 |
- self.volatile = True |
80 |
- # On Prefix, you can't rely on the ownership as a proxy for user |
81 |
- # owned because the user typically owns everything. |
82 |
- # But we can't access if we're on Prefix here, so use whether |
83 |
- # we're under /var/db/repos instead. |
84 |
- elif not self.location.startswith("/var/db/repos"): |
85 |
- self.volatile = True |
86 |
- # If the owner of the repository isn't root or Portage, it's |
87 |
- # an indication the user may expect to be able to safely make |
88 |
- # changes in the directory, so default to volatile. |
89 |
- elif Path(self.location).owner() not in ("root", "portage"): |
90 |
+ try: |
91 |
+ # If the repository doesn't exist, we can't check its ownership, |
92 |
+ # so err on the safe side. |
93 |
+ if missing or not self.location: |
94 |
+ self.volatile = True |
95 |
+ # On Prefix, you can't rely on the ownership as a proxy for user |
96 |
+ # owned because the user typically owns everything. |
97 |
+ # But we can't access if we're on Prefix here, so use whether |
98 |
+ # we're under /var/db/repos instead. |
99 |
+ elif not self.location.startswith("/var/db/repos"): |
100 |
+ self.volatile = True |
101 |
+ # If the owner of the repository isn't root or Portage, it's |
102 |
+ # an indication the user may expect to be able to safely make |
103 |
+ # changes in the directory, so default to volatile. |
104 |
+ elif Path(self.location).owner() not in ("root", "portage"): |
105 |
+ self.volatile = True |
106 |
+ else: |
107 |
+ self.volatile = False |
108 |
+ except (FileNotFoundError, PermissionError): |
109 |
self.volatile = True |
110 |
- else: |
111 |
- self.volatile = False |
112 |
|
113 |
self.eapi = None |
114 |
self.missing_repo_name = missing |