Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 889418 - sys-apps/portage: incomplete cleanup with directories outside ${WORKDIR}
Summary: sys-apps/portage: incomplete cleanup with directories outside ${WORKDIR}
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-02 22:15 UTC by David Seifert
Modified: 2023-09-16 15:04 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Seifert gentoo-dev 2023-01-02 22:15:11 UTC
1. ebuild antlr-cpp-4.11.1.ebuild install
2. ebuild antlr-cpp-4.11.1.ebuild clean

$ tree -d /var/tmp/portage/dev-cpp/
/var/tmp/portage/dev-cpp/
└── antlr-cpp-4.11.1
    └── work_build
        ├── CMakeFiles
        │   ├── 3.25.1
        │   │   ├── CompilerIdC
        │   │   │   └── tmp
        │   │   └── CompilerIdCXX
        │   │       └── tmp
        │   ├── CMakeScratch
        │   └── pkgRedirects
        └── runtime
            └── CMakeFiles
                └── antlr4_shared.dir
                    └── src
                        ├── atn
                        ├── dfa
                        ├── internal
                        ├── misc
                        ├── support
                        └── tree
                            ├── pattern
                            └── xpath

This happens due to a weird interaction in cmake.eclass with EAPI 8. When ${S} == ${WORKDIR}, the eclass creates a build dir that is not nested within ${WORKDIR}:

>>> Compiling source in /var/tmp/portage/dev-cpp/antlr-cpp-4.11.1/work ...
debug: cmake_src_compile: entering function, parameters: 
debug: cmake_build: entering function, parameters: 
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/dev-cpp/antlr-cpp-4.11.1/work"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/dev-cpp/antlr-cpp-4.11.1/work_build"

which then causes issues with a subsequent compile, since we have stale old files lying around, breaking the build. Clearly, cmake.eclass is at fault, but portage should be robust enough to remove files outside ${WORKDIR}.
Comment 1 David Seifert gentoo-dev 2023-01-02 22:33:34 UTC
cmake.eclass bug: https://bugs.gentoo.org/889420
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-01-03 05:34:32 UTC
We should probably report unexpected files as a bug too.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-01-03 05:34:43 UTC
(I mean, emit error in Portage)
Comment 4 Larry the Git Cow gentoo-dev 2023-07-02 13:24:00 UTC
The bug has been referenced in the following commit(s):

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

commit b6e2235a3982cad4d74bb7eb49e858835344c3ba
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-26 09:54:06 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-07-02 13:23:39 +0000

    cmake.eclass: workaround S=${WORKDIR} creating builddir above ${WORKDIR}
    
    When S=${WORKDIR}, cmake.eclass would create its build directory (if CMAKE_USE_DIR
    is unset) above WORKDIR(!) as ${WORKDIR}_build. Creating directories above
    WORKDIR is not legal.
    
    Portage has its own bug (bug #889418) in that it doesn't clean up unknown directories
    above WORKDIR in PORTAGE_TMPDIR, so combined, you get a problem where "ebuild ... clean" doesn't
    actually clean things up at all, and you get very confusing issues if e.g. changing
    CC between runs.
    
    The explicit S=WORKDIR check isn't truly needed but it makes explicit our
    intent here.
    
    Bug: https://bugs.gentoo.org/889418
    Closes: https://bugs.gentoo.org/889420
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/cmake.eclass | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2023-09-16 15:04:10 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/kde.git/commit/?id=2b32cb0d67222da271e2ae25b19479f0374648da

commit 2b32cb0d67222da271e2ae25b19479f0374648da
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-26 09:54:06 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2023-09-16 15:03:30 +0000

    cmake.eclass: workaround S=${WORKDIR} creating builddir above ${WORKDIR}
    
    When S=${WORKDIR}, cmake.eclass would create its build directory (if CMAKE_USE_DIR
    is unset) above WORKDIR(!) as ${WORKDIR}_build. Creating directories above
    WORKDIR is not legal.
    
    Portage has its own bug (bug #889418) in that it doesn't clean up unknown directories
    above WORKDIR in PORTAGE_TMPDIR, so combined, you get a problem where "ebuild ... clean" doesn't
    actually clean things up at all, and you get very confusing issues if e.g. changing
    CC between runs.
    
    The explicit S=WORKDIR check isn't truly needed but it makes explicit our
    intent here.
    
    Bug: https://bugs.gentoo.org/889418
    Closes: https://bugs.gentoo.org/889420
    Signed-off-by: Sam James <sam@gentoo.org>
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 eclass/cmake.eclass | 9 +++++++++
 1 file changed, 9 insertions(+)