From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EED71158041 for ; Sat, 2 Mar 2024 04:09:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F01BDE29BF; Sat, 2 Mar 2024 04:09:10 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C2757E29BF for ; Sat, 2 Mar 2024 04:09:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 74D763430F4 for ; Sat, 2 Mar 2024 04:09:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D97287E7 for ; Sat, 2 Mar 2024 04:09:07 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1709316531.fe510e099bc9a8055c3ee50fced47fc3dc7ba166.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/ebuild/, lib/portage/package/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/package/ebuild/doebuild.py lib/portage/tests/ebuild/test_doebuild_fd_pipes.py X-VCS-Directories: lib/portage/tests/ebuild/ lib/portage/package/ebuild/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: fe510e099bc9a8055c3ee50fced47fc3dc7ba166 X-VCS-Branch: master Date: Sat, 2 Mar 2024 04:09:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 94764755-0780-4a64-9eaf-6d9a71b3a370 X-Archives-Hash: af4240f0cb2955336f126e3c3024af5c commit: fe510e099bc9a8055c3ee50fced47fc3dc7ba166 Author: Zac Medico gentoo org> AuthorDate: Fri Mar 1 17:09:56 2024 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Mar 1 18:08:51 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fe510e09 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 gentoo.org> lib/portage/package/ebuild/doebuild.py | 8 +++ 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 bc51fdff2d..942fa90101 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 678486ed16..b38605bb90 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": {}, },