Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 888543 - sys-apps/portage - PATH mangling breaks dev-util/cmake module lookup on merged-usr
Summary: sys-apps/portage - PATH mangling breaks dev-util/cmake module lookup on merge...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 890833 (view as bug list)
Depends on: 889328
Blocks: usrmerge, usrmerge-fixes
  Show dependency tree
 
Reported: 2022-12-26 19:54 UTC by Jimmy Kloss
Modified: 2023-03-31 18:22 UTC (History)
7 users (show)

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


Attachments
build.log (media-libs:sdl2-ttf-2.20.0:20221222-175747.log,3.90 KB, text/x-log)
2022-12-26 19:54 UTC, Jimmy Kloss
Details
emerge --info (emerge-info.txt,27.93 KB, text/plain)
2022-12-26 19:56 UTC, Jimmy Kloss
Details
CMakeOutput.log (CMakeOutput.log,21.71 KB, text/x-log)
2022-12-27 14:57 UTC, Jimmy Kloss
Details
media-libs/libsdl2 cmake merged-usr fix using REALPATH (libsdl2-cmake-merged-usr.patch,489 bytes, patch)
2023-01-14 22:04 UTC, Jon Daniel
Details | Diff
[New Ebuild] media-libs/libsdl2-2.26.2-r1.ebuild (libsdl2-2.26.2-r1.ebuild,6.35 KB, text/plain)
2023-01-14 22:22 UTC, Jon Daniel
Details
dev-util/cmake-3.25.1 add GetRealPath to CollapseFullPath (cmake-3.25.1-realpath.patch,1.54 KB, patch)
2023-01-15 06:55 UTC, Jon Daniel
Details | Diff
[New Ebuild] dev-util/cmake-3.25.1-r1.ebuild (cmake-3.25.1-r1.ebuild,8.65 KB, text/plain)
2023-01-15 06:57 UTC, Jon Daniel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jimmy Kloss 2022-12-26 19:54:22 UTC
When emerging sdl2-ttf it fails with:

CMake Error at /lib64/cmake/SDL2/sdl2-config.cmake:13 (message):
  File or directory //include/SDL2 referenced by variable SDL2_INCLUDE_DIR
  does not exist !

When trying to build in manually it works fine though.

Reproducible: Always

Steps to Reproduce:
1. emerge -1avq media-libs/sdl2-ttf
2.
3.
Comment 1 Jimmy Kloss 2022-12-26 19:54:59 UTC
Created attachment 844941 [details]
build.log
Comment 2 Jimmy Kloss 2022-12-26 19:56:02 UTC
Created attachment 844943 [details]
emerge --info
Comment 3 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-12-26 20:18:34 UTC
Please also share /var/tmp/portage/media-libs/sdl2-ttf-2.20.0/work/SDL2_ttf-2.20.0_build-abi_x86_64.amd64/CMakeFiles/CMakeOutput.log.
Comment 4 Ionen Wolkens gentoo-dev 2022-12-26 23:26:11 UTC
I wonder what's getting it the idea to use /lib64/cmake/SDL2 before /usr/lib64/cmake/SDL2? The same is happening with the gcc check:
    -- Check for working C compiler: /sbin/x86_64-pc-linux-gnu-gcc - skipped
While (also on merged-usr) me I get:
    -- Check for working C compiler: /usr/sbin/x86_64-pc-linux-gnu-gcc - skipped

The //include bit is not so strange given:
    get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
    set(includedir "${prefix}/include")
(so, if it's using /lib64 then prefix=/ leading to //include which is not found, so it fails)

Can't seem to reproduce, not that I experimented much.
Comment 5 Jimmy Kloss 2022-12-27 14:57:39 UTC
Created attachment 845231 [details]
CMakeOutput.log
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-27 15:02:15 UTC
FIND=kfind, FILE=dolpihn, etc in environment could be it. If you try in a fresh, clean shell (env -i) as root, does it happen?
Comment 7 Jimmy Kloss 2022-12-27 15:35:52 UTC
(In reply to Sam James from comment #6)
> FIND=kfind, FILE=dolpihn, etc in environment could be it. If you try in a
> fresh, clean shell (env -i) as root, does it happen?

magnesium ~ # env -i emerge -1avq media-libs/sdl2-ttf
PORTAGE_BZIP2_COMMAND setting is invalid: 'bzip2'
PORTAGE_BZIP2_COMMAND setting from make.globals is invalid: 'bzip2'
!!! BINPKG_COMPRESS unsupported zstd. Missing package: app-arch/zstd[ebuild   R   ] media-libs/sdl2-ttf-2.20.0  USE="ha
rfbuzz -X -static-libs" ABI_X86="(64) -32 (-x32)"

Would you like to merge these packages? [Yes/No]
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) media-libs/sdl2-ttf-2.20.0::gentoo
>>> Failed to emerge media-libs/sdl2-ttf-2.20.0, Log file:
>>>  '/var/log/portage/elog/media-libs:sdl2-ttf-2.20.0:20221227-153413.log'
>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 0.13, 0.11, 0.20

Same error.
Comment 8 Mike Gilbert gentoo-dev 2022-12-27 21:34:41 UTC
Please show the output of the following:

ls -ld /bin /sbin /usr/bin /usr/sbin /lib64 /usr/lib64
Comment 9 Jimmy Kloss 2022-12-27 23:14:32 UTC
(In reply to Mike Gilbert from comment #8)

❯ ls -ld /bin /sbin /usr/bin /usr/sbin /lib64 /usr/lib64
lrwxrwxrwx 1 root root      7 Sep 14  2019 /bin -> usr/bin
lrwxrwxrwx 1 root root      9 Sep 14  2019 /lib64 -> usr/lib64
lrwxrwxrwx 1 root root      8 Sep 14  2019 /sbin -> usr/sbin
drwxr-xr-x 1 root root  78500 Dez 27 17:57 /usr/bin
drwxr-xr-x 1 root root 145500 Dez 27 17:45 /usr/lib64
lrwxrwxrwx 1 root root      3 Dez  9 19:37 /usr/sbin -> bin
Comment 10 Mike Gilbert gentoo-dev 2022-12-30 03:35:46 UTC
I can reproduce the failure if I set ROOTPATH="/usr/bin:/usr/sbin" in the environment before calling emerge/ebuild.

Portage seems to mangle PATH based on the ROOTPATH variable, and always moves those directories to the end. It also forcibly adds /sbin and /bin to to PATH before ROOTPATH if the latter does not contain them.

For example:

> % sudo ROOTPATH=/usr/bin:/usr/sbin ebuild foo-0.ebuild clean setup
>  * ROOTPATH=/usr/bin:/usr/sbin
>  * PATH=/usr/lib/ccache/bin:/home/floppym/src/portage/bin/ebuild-helpers/xattr:/home/floppym/src/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/bin:/usr/sbin

It appears that cmake searches for modules based on where it finds itself in PATH, and so it thinks it is installed in /sbin with prefix="".
Comment 11 Larry the Git Cow gentoo-dev 2023-01-02 20:45:57 UTC
The bug has been referenced in the following commit(s):

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

commit 69f2221413852630b2c231774e1f811f350fa3e6
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2022-12-31 22:01:08 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-01-02 20:35:27 +0000

    _doebuild_path: simplify logic used to set PATH
    
    Remove logic to incoporate PREROOTPATH and ROOTPATH. I'm not sure where
    PREROOTPATH was ever used, and ROOTPATH has been deprecated in
    baselayout for a while.
    
    Remove logic to add hard-coded directories like
    ${EPREFIX}/{,usr{,/local}/{sbin,bin}. Adding these paths is unnecessary
    if env.d or the calling environment have a valid PATH setting.
    
    Add logic to ignore PATH from the calling environment if PATH is set in
    env.d. This ensures that packages can update PATH by installing files in
    /etc/env.d and this will work without having to restart Portage with an
    updated environment.
    
    Bug: https://bugs.gentoo.org/607696
    Bug: https://bugs.gentoo.org/693308
    Bug: https://bugs.gentoo.org/888543
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 lib/portage/package/ebuild/doebuild.py | 44 +++++++++++-----------------------
 1 file changed, 14 insertions(+), 30 deletions(-)
Comment 12 Jon Daniel 2023-01-14 22:04:17 UTC
Created attachment 848479 [details, diff]
media-libs/libsdl2 cmake merged-usr fix using REALPATH
Comment 13 Jon Daniel 2023-01-14 22:22:00 UTC
Created attachment 848489 [details]
[New Ebuild] media-libs/libsdl2-2.26.2-r1.ebuild
Comment 14 Mike Gilbert gentoo-dev 2023-01-15 00:24:44 UTC
*** Bug 890833 has been marked as a duplicate of this bug. ***
Comment 15 Jon Daniel 2023-01-15 06:54:24 UTC
The bug is in dev-util/cmake-2.25.1.ebuild

Adding GetRealPath to CollapseFullPath the problem is resolved
 
See Also: https://bugs.gentoo.org/889822
Comment 16 Jon Daniel 2023-01-15 06:55:55 UTC
Created attachment 848545 [details, diff]
dev-util/cmake-3.25.1 add GetRealPath to CollapseFullPath
Comment 17 Jon Daniel 2023-01-15 06:57:52 UTC
Created attachment 848547 [details]
[New Ebuild] dev-util/cmake-3.25.1-r1.ebuild
Comment 18 Jon Daniel 2023-01-15 07:05:11 UTC
See Also: https://bugs.gentoo.org/889822
Comment 19 Mike Gilbert gentoo-dev 2023-01-15 14:51:12 UTC
(In reply to Jon Daniel from comment #15)
> The bug is in dev-util/cmake-2.25.1.ebuild

Please stop posting your patch(es) to every bug report you can find.
Comment 20 Larry the Git Cow gentoo-dev 2023-01-15 22:13:58 UTC
The bug has been closed via the following commit(s):

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

commit e342b1cae0ba19e35d27fe523ce0331e1412e295
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-15 22:13:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-15 22:13:26 +0000

    sys-apps/portage: add 3.0.44
    
    Closes: https://bugs.gentoo.org/889328
    Closes: https://bugs.gentoo.org/607696
    Closes: https://bugs.gentoo.org/867031
    Closes: https://bugs.gentoo.org/873202
    Closes: https://bugs.gentoo.org/888543
    Closes: https://bugs.gentoo.org/834038
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.44.ebuild | 288 +++++++++++++++++++++++++++++++++
 2 files changed, 289 insertions(+)