diff options
author | Zac Medico <zmedico@gentoo.org> | 2024-03-01 09:09:56 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2024-03-01 10:08:51 -0800 |
commit | fe510e099bc9a8055c3ee50fced47fc3dc7ba166 (patch) | |
tree | ff275c35d3b881398b9feb64bd2b1bab0f26fed2 | |
parent | Improve whitespace handling when parsing /proc/self/mountinfo (diff) | |
download | portage-fe510e099bc9a8055c3ee50fced47fc3dc7ba166.tar.gz portage-fe510e099bc9a8055c3ee50fced47fc3dc7ba166.tar.bz2 portage-fe510e099bc9a8055c3ee50fced47fc3dc7ba166.zip |
doebuild: Call _setup_locale
Call _setup_locale in order to prevent an AssertionError from
config.environ() for the config phase (or any other phase for
that matter).
For returnproc or returnpid assume that the event loop is running
so we can't run the event loop to call _setup_locale in this case
and we have to assume the caller took care of it (otherwise
config.environ() will raise AssertionError).
Update DoebuildFdPipesTestCase to use EAPI 8 and test the
pkg_config function with an ebuild located in /var/db/pkg just
like emerge --config does. Set LC_ALL=C just before doebuild
calls in order to try and trigger the config.environ()
split_LC_ALL assertion.
Bug: https://bugs.gentoo.org/925863
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r-- | lib/portage/package/ebuild/doebuild.py | 8 | ||||
-rw-r--r-- | lib/portage/tests/ebuild/test_doebuild_fd_pipes.py | 77 |
2 files changed, 52 insertions, 33 deletions
diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index bc51fdff2..942fa9010 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -43,6 +43,7 @@ portage.proxy.lazyimport.lazyimport( "portage.util._async.SchedulerInterface:SchedulerInterface", "portage.util._eventloop.global_event_loop:global_event_loop", "portage.util.ExtractKernelVersion:ExtractKernelVersion", + "_emerge.EbuildPhase:_setup_locale", ) from portage import ( @@ -1034,6 +1035,13 @@ def doebuild( myebuild, mydo, myroot, mysettings, debug, use_cache, mydbapi ) + # For returnproc or returnpid assume that the event loop is running + # so we can't run the event loop to call _setup_locale in this case + # and we have to assume the caller took care of it (otherwise + # config.environ() will raise AssertionError). + if not (returnproc or returnpid): + asyncio.run(_setup_locale(mysettings)) + if mydo in clean_phases: builddir_lock = None if not returnpid and "PORTAGE_BUILDDIR_LOCKED" not in mysettings: diff --git a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py index 678486ed1..b38605bb9 100644 --- a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py +++ b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 Gentoo Authors +# Copyright 2013-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import multiprocessing @@ -27,20 +27,22 @@ class DoebuildFdPipesTestCase(TestCase): output_fd = self.output_fd ebuild_body = ["S=${WORKDIR}"] - for phase_func in ( - "pkg_info", - "pkg_nofetch", - "pkg_pretend", - "pkg_setup", - "src_unpack", - "src_prepare", - "src_configure", - "src_compile", - "src_test", - "src_install", + for phase_func, default in ( + ("pkg_info", False), + ("pkg_nofetch", False), + ("pkg_pretend", False), + ("pkg_setup", False), + ("pkg_config", False), + ("src_unpack", False), + ("src_prepare", True), + ("src_configure", False), + ("src_compile", False), + ("src_test", False), + ("src_install", False), ): ebuild_body.append( - ("%s() { echo ${EBUILD_PHASE}" " 1>&%s; }") % (phase_func, output_fd) + ("%s() { %secho ${EBUILD_PHASE}" " 1>&%s; }") + % (phase_func, "default; " if default else "", output_fd) ) ebuild_body.append("") @@ -48,7 +50,7 @@ class DoebuildFdPipesTestCase(TestCase): ebuilds = { "app-misct/foo-1": { - "EAPI": "5", + "EAPI": "8", "MISC_CONTENT": ebuild_body, } } @@ -103,24 +105,33 @@ class DoebuildFdPipesTestCase(TestCase): type_name="ebuild", ) settings.setcpv(pkg) - ebuildpath = portdb.findname(cpv) - self.assertNotEqual(ebuildpath, None) - - for phase in ( - "info", - "nofetch", - "pretend", - "setup", - "unpack", - "prepare", - "configure", - "compile", - "test", - "install", - "qmerge", - "clean", - "merge", + + # Try to trigger the config.environ() split_LC_ALL assertion for bug 925863. + settings["LC_ALL"] = "C" + + source_ebuildpath = portdb.findname(cpv) + self.assertNotEqual(source_ebuildpath, None) + + for phase, tree, ebuildpath in ( + ("info", "porttree", source_ebuildpath), + ("nofetch", "porttree", source_ebuildpath), + ("pretend", "porttree", source_ebuildpath), + ("setup", "porttree", source_ebuildpath), + ("unpack", "porttree", source_ebuildpath), + ("prepare", "porttree", source_ebuildpath), + ("configure", "porttree", source_ebuildpath), + ("compile", "porttree", source_ebuildpath), + ("test", "porttree", source_ebuildpath), + ("install", "porttree", source_ebuildpath), + ("qmerge", "porttree", source_ebuildpath), + ("clean", "porttree", source_ebuildpath), + ("merge", "porttree", source_ebuildpath), + ("clean", "porttree", source_ebuildpath), + ("config", "vartree", root_config.trees["vartree"].dbapi.findname(cpv)), ): + if ebuildpath is not source_ebuildpath: + self.assertNotEqual(ebuildpath, None) + pr, pw = multiprocessing.Pipe(duplex=False) producer = ForkProcess( @@ -131,8 +142,8 @@ class DoebuildFdPipesTestCase(TestCase): args=(QueryCommand._db, pw, ebuildpath, phase), kwargs={ "settings": settings, - "mydbapi": portdb, - "tree": "porttree", + "mydbapi": root_config.trees[tree].dbapi, + "tree": tree, "vartree": root_config.trees["vartree"], "prev_mtimes": {}, }, |