From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: /, lib/portage/repository/
Date: Sat, 4 Mar 2023 05:26:31 +0000 (UTC) [thread overview]
Message-ID: <1677907555.eb30619181a56cdb24a40c7ee249b177ec53b6b9.sam@gentoo> (raw)
commit: eb30619181a56cdb24a40c7ee249b177ec53b6b9
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 4 04:57:40 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Mar 4 05:25:55 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=eb306191
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 <AT> gentoo.org>
NEWS | 8 +++-----
lib/portage/repository/config.py | 36 +++++++++++++++++++-----------------
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
reply other threads:[~2023-03-04 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1677907555.eb30619181a56cdb24a40c7ee249b177ec53b6b9.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox