Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 899208 - sys-apps/portage-3.0.45.1-r2 fails initial sync via git sync submodule
Summary: sys-apps/portage-3.0.45.1-r2 fails initial sync via git sync submodule
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: PullRequest
Depends on: 898022
Blocks:
  Show dependency tree
 
Reported: 2023-03-03 21:36 UTC by Matthew Marchese
Modified: 2023-03-19 19:14 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emaint sync traceback (eselect-repository-sync-issue.txt,2.05 KB, text/plain)
2023-03-03 21:36 UTC, Matthew Marchese
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Marchese Gentoo Infrastructure gentoo-dev 2023-03-03 21:36:26 UTC
Created attachment 855998 [details]
emaint sync traceback

The latest (unstable) Portage version 3.0.45.1 refuses to sync when adding a git-based repo, then attempting to sync. I have not tested other sync types, only git. Appears to be an issue with Portage itself, and not eselect repository.

To reproduce:

* Be on sys-apps/portage-3.0.45.1
* Add a git-based overlay: eselect repository enable mva
* Attempt to sync using one of:
** emaint sync -r mva
** emerge --sync

See the attachment for traceback. Thank you!
Comment 1 Matthew Marchese Gentoo Infrastructure gentoo-dev 2023-03-03 21:37:08 UTC
Forgot to mention it works as expected after rolling back to the previous stable version: sys-apps/portage-3.0.44.
Comment 2 Matthew Marchese Gentoo Infrastructure gentoo-dev 2023-03-03 22:02:57 UTC
Also should mention a bit more context: this issue only effects the *initial sync*, since the repository directory under /var/db/repos/<dir> is not being created.

In this instance, manually creating it and running emaint again fixes it:

# mkdir mkdir /var/db/repos/mva
# emaint sync -r mva
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-04 04:57:31 UTC
Exposed by

commit bd8f9f6c590dca750285e296a6c3d530f1053d89
Author: Florian Schmaus <flow@gentoo.org>
Date:   Sun Feb 26 20:47:01 2023 +0100

    repository: config: fix volatile detection, add missing () operator
    
    Path(self.location).owner was missing the function-call operator.
    
    Closes: https://bugs.gentoo.org/895526
    Fixes: ef123a214708 ("config: Add 'volatile' configuration option")
    Signed-off-by: Florian Schmaus <flow@gentoo.org>
    Closes: https://github.com/gentoo/portage/pull/997
    Signed-off-by: Sam James <sam@gentoo.org>

... but it was latent, the real issue was introduced by

commit ef123a214708c85f9802f2a649b93137fd2ee3be
Author: Sam James <sam@gentoo.org>
Date:   Sat Dec 17 05:12:46 2022 +0000

    config: Add 'volatile' configuration option
    
    This introduces a 'volatile' configuration option for repos.conf.
    
    * If a repository is marked as volatile (volatile=true), then Portage
      will assume the repository may be changed at any time, and that
      it may contain e.g. local changes.
    
      Portage will not perform optimizations based on assuming its integrity.
    
      It will also not perform destructive operations if it is a git repository
      (it will not prioritise being able to continue to sync).
    
    * If a repository is marked as non-volatile (volatile=false), then Portage
      will assume that only Portage changes the repository and that it will not
      be modified otherwise.
    
      Portage will perform optimizations based on assuming this, like not
      needing to verify the metadata cache for ebuilds & eclasses.
    
      Portage will prioritise the repository continuing to work and may
      e.g. 'git reset --hard' or 'git clean -fdx' in order to keep git repositories
      working for sync purposes. (If you do not like this, please set 'volatile=true').
    
    Bug: https://bugs.gentoo.org/528394
    Bug: https://bugs.gentoo.org/887025
    See: https://github.com/gentoo/portage/pull/801
    See: https://github.com/gentoo/portage/pull/931
    See: https://github.com/gentoo/portage/pull/939
    See: https://github.com/gentoo/portage/pull/960
    Signed-off-by: Sam James <sam@gentoo.org>
Comment 4 Larry the Git Cow gentoo-dev 2023-03-04 05:26:31 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=eb30619181a56cdb24a40c7ee249b177ec53b6b9

commit eb30619181a56cdb24a40c7ee249b177ec53b6b9
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-03-04 04:57:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-03-04 05:25:55 +0000

    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>

 NEWS                             |  8 +++-----
 lib/portage/repository/config.py | 36 +++++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 22 deletions(-)
Comment 5 Larry the Git Cow gentoo-dev 2023-03-04 05:33:39 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e2c509b07d318bc46595088bd0c316a768d742b8

commit e2c509b07d318bc46595088bd0c316a768d742b8
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-03-04 05:32:55 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-03-04 05:33:22 +0000

    sys-apps/portage: add 3.0.45.2
    
    Closes: https://bugs.gentoo.org/898022
    Closes: https://bugs.gentoo.org/899208
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest                |   1 +
 sys-apps/portage/portage-3.0.45.2.ebuild | 284 +++++++++++++++++++++++++++++++
 2 files changed, 285 insertions(+)
Comment 6 Larry the Git Cow gentoo-dev 2023-03-19 19:14:34 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=08cdac85ffaf9b9915c40d9ffcd0ed3cf0e434d3

commit 08cdac85ffaf9b9915c40d9ffcd0ed3cf0e434d3
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-03-10 14:56:04 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-03-19 19:14:29 +0000

    repository: config: absorb all exceptions when determining volatility
    
    Not ideal, but we don't have much else of a choice. It's a very
    small section and trying to granularly specify the relevant exceptions
    here is clearly a waste of time (see ref'd bugs).
    
    Besides, the consequence is just failing-safe and assuming the repo
    is volatile anyway.
    
    Bug: https://bugs.gentoo.org/899208
    Bug: https://bugs.gentoo.org/900683
    Signed-off-by: Sam James <sam@gentoo.org>
    Closes: https://github.com/gentoo/portage/pull/1005
    Signed-off-by: Sam James <sam@gentoo.org>

 NEWS                             | 12 ++++++++++--
 lib/portage/repository/config.py |  9 ++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)