aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-03-04 04:57:40 +0000
committerSam James <sam@gentoo.org>2023-03-04 05:25:55 +0000
commiteb30619181a56cdb24a40c7ee249b177ec53b6b9 (patch)
tree10f0947aa895417d1cbf842f48625b1420fc25cf
parentportage: news: further type annotations (diff)
downloadportage-eb306191.tar.gz
portage-eb306191.tar.bz2
portage-eb306191.zip
repository: config: fix initial sync of (git) repositories
After bd8f9f6c590dca750285e296a6c3d530f1053d89, we started to actually dereference the Path object on the (new) repository location. If it doesn't exist yet, it has no owner, and a FileNotFoundError is thrown: ``` [...] File "/usr/lib/python3.10/site-packages/portage/repository/config.py", line 794, in _parse repo = RepoConfig(sname, optdict, local_config=local_config) File "/usr/lib/python3.10/site-packages/portage/repository/config.py", line 360, in __init__ elif Path(self.location).owner() not in ("root", "portage"): File "/usr/lib/python3.10/pathlib.py", line 1103, in owner return self._accessor.owner(self) File "/usr/lib/python3.10/pathlib.py", line 343, in owner return pwd.getpwuid(self.stat(path).st_uid).pw_name FileNotFoundError: [Errno 2] No such file or directory: '/var/db/repos/foo' ``` It's fine if the repository doesn't exist yet, the intention in ef123a214708c85f9802f2a649b93137fd2ee3be was to default to non-volatile for such cases, so let's honour that by catching FileNotFoundError and PermissionError. Note that this was exposed by bd8f9f6c590dca750285e296a6c3d530f1053d89 and the real issue was in ef123a214708c85f9802f2a649b93137fd2ee3be, but it's worth having Fixes: tags for both as it becomes easier to understand when it was exposed and when it was actually an issue. Bug: https://bugs.gentoo.org/899208 Fixes: bd8f9f6c590dca750285e296a6c3d530f1053d89 ("repository: config: fix volatile detection, add missing () operator") Fixes: ef123a214708c85f9802f2a649b93137fd2ee3be ("config: Add 'volatile' configuration option") Closes: https://github.com/gentoo/portage/pull/1004 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--NEWS8
-rw-r--r--lib/portage/repository/config.py36
2 files changed, 22 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index a127798e3..ff52a70b7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,9 @@
-portage-3.0.46 (UNRELEASED)
+portage-3.0.45.2 (2023-03-04)
--------------
-Features:
-* TODO
-
Bug fixes:
-* TODO
+* repository: config: Fix initial sync of repositories (bug #899208). Regression
+ from portage-3.0.45, but the real bug is from portage-3.0.42.
portage-3.0.45.1 (2023-02-27)
--------------
diff --git a/lib/portage/repository/config.py b/lib/portage/repository/config.py
index 8688c633d..3d887ffaa 100644
--- a/lib/portage/repository/config.py
+++ b/lib/portage/repository/config.py
@@ -343,24 +343,26 @@ class RepoConfig:
# If it's unset, we default to no (i.e. the repository is not volatile),
# but with a heuristic for when a repository is not likely to be suitable
# (likely to contain custom user changes).
-
- # If the repository doesn't exist, we can't check its ownership,
- # so err on the safe side.
- if missing or not self.location:
- self.volatile = True
- # On Prefix, you can't rely on the ownership as a proxy for user
- # owned because the user typically owns everything.
- # But we can't access if we're on Prefix here, so use whether
- # we're under /var/db/repos instead.
- elif not self.location.startswith("/var/db/repos"):
- self.volatile = True
- # If the owner of the repository isn't root or Portage, it's
- # an indication the user may expect to be able to safely make
- # changes in the directory, so default to volatile.
- elif Path(self.location).owner() not in ("root", "portage"):
+ try:
+ # If the repository doesn't exist, we can't check its ownership,
+ # so err on the safe side.
+ if missing or not self.location:
+ self.volatile = True
+ # On Prefix, you can't rely on the ownership as a proxy for user
+ # owned because the user typically owns everything.
+ # But we can't access if we're on Prefix here, so use whether
+ # we're under /var/db/repos instead.
+ elif not self.location.startswith("/var/db/repos"):
+ self.volatile = True
+ # If the owner of the repository isn't root or Portage, it's
+ # an indication the user may expect to be able to safely make
+ # changes in the directory, so default to volatile.
+ elif Path(self.location).owner() not in ("root", "portage"):
+ self.volatile = True
+ else:
+ self.volatile = False
+ except (FileNotFoundError, PermissionError):
self.volatile = True
- else:
- self.volatile = False
self.eapi = None
self.missing_repo_name = missing