Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903917 - emerge --sync broken with "Package basename mismatched"
Summary: emerge --sync broken with "Package basename mismatched"
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Binary packages support (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on: 902189
Blocks:
  Show dependency tree
 
Reported: 2023-04-06 14:45 UTC by Rick Farina (Zero_Chaos)
Modified: 2023-05-18 14:03 UTC (History)
1 user (show)

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


Attachments
broken binpkg by request of dol-son (jupyter-server-2.4.0-1.gpkg.tar,470.00 KB, application/x-tar)
2023-04-06 19:31 UTC, Rick Farina (Zero_Chaos)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Farina (Zero_Chaos) gentoo-dev 2023-04-06 14:45:34 UTC
after the main rsync completes I get this:

Performing Global Updates
(Could take a couple of minutes if you have a lot of binary packages.)
  .='update pass'  *='binary update'  #='/var/db update'  @='/var/db move'
  s='/var/db SLOT move'  %='binary move'  S='binary SLOT move'
  p='update /etc/portage/package.*'
/usr/portage/profiles/updates/2Q-2023.
Package basename mismatched, using jupyter-server-2.4.0Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/emerge", line 59, in <module>
    retval = emerge_main()
  File "/usr/lib/python3.10/site-packages/_emerge/main.py", line 1299, in emerge_main
    return run_action(emerge_config)
  File "/usr/lib/python3.10/site-packages/_emerge/actions.py", line 3862, in run_action
    return action_sync(emerge_config)
  File "/usr/lib/python3.10/site-packages/_emerge/actions.py", line 2426, in action_sync
    success, msgs = syncer.auto_sync(options=options)
  File "/usr/lib/python3.10/site-packages/portage/emaint/modules/sync/sync.py", line 89, in auto_sync
    return self._sync(repos, return_messages, emaint_opts=options)
  File "/usr/lib/python3.10/site-packages/portage/emaint/modules/sync/sync.py", line 261, in _sync
    self._do_pkg_moves()
  File "/usr/lib/python3.10/site-packages/portage/emaint/modules/sync/sync.py", line 272, in _do_pkg_moves
    if self.emerge_config.opts.get("--package-moves") != "n" and _global_updates(
  File "/usr/lib/python3.10/site-packages/portage/_global_updates.py", line 41, in _global_updates
    return _do_global_updates(
  File "/usr/lib/python3.10/site-packages/portage/_global_updates.py", line 257, in _do_global_updates
    bindb.update_ents(repo_map, onUpdate=onUpdate)
  File "/usr/lib/python3.10/site-packages/portage/dbapi/__init__.py", line 413, in update_ents
    aux_update(cpv, metadata_updates)
  File "/usr/lib/python3.10/site-packages/portage/dbapi/bintree.py", line 295, in aux_update
    mybinpkg.update_metadata(mydata)
  File "/usr/lib/python3.10/site-packages/portage/gpkg.py", line 1155, in update_metadata
    raise InvalidBinaryPackageFormat(
portage.exception.InvalidBinaryPackageFormat: gpkg file structure mismatch in /usr/portage/packages/dev-python/jupyter-server/jupyter-server-2.4.0-1.gpkg.tar; files: ['jupyter-server-2.4.0/gpkg-1', 'jupyter-server-2.4.0-1/metadata.tar.zst', 'jupyter-server-2.4.0/image.tar.zst', 'jupyter-server-2.4.0-1/Manifest']


I understand that if there is something wrong with a binpkg portage may ignore it or I'd even be fine with deleting it, but I feel exploding is likely the wrong way to handle it.
Comment 1 Rick Farina (Zero_Chaos) gentoo-dev 2023-04-06 15:09:39 UTC
I hit this error with portage 3.0.45.3-r2, I removed the portage line from my package.accept_keywords file, but attempting to downgrade immediately breaks in the same way

Nu ~ # emerge -1 portage -a                                                                                                                                              

Performing Global Updates
(Could take a couple of minutes if you have a lot of binary packages.)
  .='update pass'  *='binary update'  #='/var/db update'  @='/var/db move'
  s='/var/db SLOT move'  %='binary move'  S='binary SLOT move'
  p='update /etc/portage/package.*'
/usr/portage/profiles/updates/2Q-2023.
Package basename mismatched, using jupyter-server-2.4.0Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/emerge", line 59, in <module>
    retval = emerge_main()
  File "/usr/lib/python3.10/site-packages/_emerge/main.py", line 1299, in emerge_main
    return run_action(emerge_config)
  File "/usr/lib/python3.10/site-packages/_emerge/actions.py", line 3418, in run_action
    and _global_updates(
  File "/usr/lib/python3.10/site-packages/portage/_global_updates.py", line 41, in _global_updates
    return _do_global_updates(
  File "/usr/lib/python3.10/site-packages/portage/_global_updates.py", line 257, in _do_global_updates
    bindb.update_ents(repo_map, onUpdate=onUpdate)
  File "/usr/lib/python3.10/site-packages/portage/dbapi/__init__.py", line 413, in update_ents
    aux_update(cpv, metadata_updates)
  File "/usr/lib/python3.10/site-packages/portage/dbapi/bintree.py", line 295, in aux_update
    mybinpkg.update_metadata(mydata)
  File "/usr/lib/python3.10/site-packages/portage/gpkg.py", line 1155, in update_metadata
    raise InvalidBinaryPackageFormat(
portage.exception.InvalidBinaryPackageFormat: gpkg file structure mismatch in /usr/portage/packages/dev-python/jupyter-server/jupyter-server-2.4.0-1.gpkg.tar; files: ['jupyter-server-2.4.0/gpkg-1', 'jupyter-server-2.4.0-1/metadata.tar.zst', 'jupyter-server-2.4.0/image.tar.zst', 'jupyter-server-2.4.0-1/Manifest']
Comment 2 Brian Dolbec (RETIRED) gentoo-dev 2023-04-06 15:15:00 UTC
I agree, it shouldn't puke.  I'm thinking either _do_global_updates() or _do_pkg_moves() needs to handle the InvalidBinaryPackageFormat exception.



eclean-pkg & portage is being modified for cleaning invalid binpkgs already

work in progress: https://github.com/gentoo/gentoolkit/pull/28
                  https://github.com/gentoo/portage/pull/1016
Comment 3 Mike Gilbert gentoo-dev 2023-04-06 15:19:58 UTC
Regarding the error itself, I think this is another manifestation of bug 877271.
Comment 4 Sheng Yu 2023-04-06 15:32:31 UTC
Yes, it should catch that and give a warning, not dead. Should be a quick fix.
Comment 5 Brian Dolbec (RETIRED) gentoo-dev 2023-04-06 16:30:28 UTC
_do_global_updates() could with the invalid_paths varialbe addition to bindbapi, could use the filepath to nuke it, complete the update.
Comment 6 Brian Dolbec (RETIRED) gentoo-dev 2023-04-06 17:28:12 UTC
ok, looks like this is the location to fix it.  This is only an untested code patch to confirm a good place to make the change.

diff --git a/lib/portage/dbapi/__init__.py b/lib/portage/dbapi/__init__.py
index 366a6c170..9cfd7c492 100644
--- a/lib/portage/dbapi/__init__.py
+++ b/lib/portage/dbapi/__init__.py
@@ -410,7 +410,10 @@ class dbapi:
                 updates_list, metadata, parent=pkg
             )
             if metadata_updates:
-                aux_update(cpv, metadata_updates)
+                try:
+                    aux_update(cpv, metadata_updates)
+                except InvalidBinaryPackageFormat:
+                    print("!!!!!!!!!! found invalid binpkg")
                 if onUpdate:
                     onUpdate(maxval, i + 1)
             if onProgress:


either print out the info properly or nuke the offending binpkg directly.
Comment 7 Rick Farina (Zero_Chaos) gentoo-dev 2023-04-06 19:26:04 UTC
(In reply to Brian Dolbec from comment #6)

> either print out the info properly or nuke the offending binpkg directly.

When I hit invalid binpkgs using xpak format, portage basically told me it was ignoring them and then kept right on going with whatever I asked it to do.  I'm okay with that behavior.  It makes sense that eclean nukes invalid binary packages but portage just ignores them.  That said, since invalid binary packages will be ignored at best, I'd be fine with portage just deleting them as well.
Comment 8 Rick Farina (Zero_Chaos) gentoo-dev 2023-04-06 19:31:44 UTC
Created attachment 859637 [details]
broken binpkg by request of dol-son
Comment 9 Larry the Git Cow gentoo-dev 2023-04-07 09:52:39 UTC
The bug has been referenced in the following commit(s):

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

commit 2569a1a1d889a76af80ce24a005d54269df7d2e2
Author:     Sheng Yu <syu.os@protonmail.com>
AuthorDate: 2023-04-07 04:50:49 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-07 09:49:11 +0000

    dbapi: Catch invalid binpkg error during pkgmove
    
    Bug: https://bugs.gentoo.org/877271
    Bug: https://bugs.gentoo.org/903917
    Bug: https://bugs.gentoo.org/903926
    Signed-off-by: Sheng Yu <syu.os@protonmail.com>
    Closes: https://github.com/gentoo/portage/pull/1022
    Signed-off-by: Sam James <sam@gentoo.org>

 NEWS                          | 3 +++
 lib/portage/dbapi/__init__.py | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
Comment 10 Larry the Git Cow gentoo-dev 2023-04-07 10:06:59 UTC
The bug has been closed via the following commit(s):

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

commit 05f0b3b184011060c86787f93e16a29002bdc54a
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-04-07 09:59:46 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-07 09:59:55 +0000

    sys-apps/portage: add 3.0.46
    
    Closes: https://bugs.gentoo.org/861659
    Closes: https://bugs.gentoo.org/877271
    Closes: https://bugs.gentoo.org/898224
    Closes: https://bugs.gentoo.org/899898
    Closes: https://bugs.gentoo.org/902189
    Closes: https://bugs.gentoo.org/903917
    Closes: https://bugs.gentoo.org/903926
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.46.ebuild | 285 +++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+)