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)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7F9E8158013 for ; Sun, 10 Dec 2023 22:01:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 595E32BC01C; Sun, 10 Dec 2023 22:01:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 3F6A82BC016 for ; Sun, 10 Dec 2023 22:01:58 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5848034092E for ; Sun, 10 Dec 2023 22:01:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BADD314AC for ; Sun, 10 Dec 2023 22:01:55 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1702245708.3b975f9b28d1aa6e40c93431086669ad23f6f460.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/package/ebuild/doebuild.py X-VCS-Directories: lib/portage/package/ebuild/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 3b975f9b28d1aa6e40c93431086669ad23f6f460 X-VCS-Branch: master Date: Sun, 10 Dec 2023 22:01:55 +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: 6eacad3f-5350-4fce-a88b-02badddd6e0f X-Archives-Hash: 2df468057b6c0d165350962a8ff9b9be commit: 3b975f9b28d1aa6e40c93431086669ad23f6f460 Author: Sam James gentoo org> AuthorDate: Mon Sep 4 15:37:24 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Dec 10 22:01:48 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3b975f9b ebuild: refactor flushing vdb keys Refactor how we flush these VDB keys in build-info/ to make it easier to implement bug #913628: it was a pain with the forced-append of a newline even if we might tamper with the contents later on, so just postpone flushing to disk until the end. It saves some repetition too, so double win. Bug: https://bugs.gentoo.org/913628 Signed-off-by: Sam James gentoo.org> lib/portage/package/ebuild/doebuild.py | 42 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 8c7a06b3e2..346c989acc 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -2487,8 +2487,8 @@ def _post_src_install_write_metadata(settings): """ eapi_attrs = _get_eapi_attrs(settings.configdict["pkg"]["EAPI"]) - build_info_dir = os.path.join(settings["PORTAGE_BUILDDIR"], "build-info") + metadata_buffer = {} metadata_keys = ["IUSE"] if eapi_attrs.iuse_effective: @@ -2497,12 +2497,12 @@ def _post_src_install_write_metadata(settings): for k in metadata_keys: v = settings.configdict["pkg"].get(k) if v is not None: - write_atomic(os.path.join(build_info_dir, k), v + "\n") + metadata_buffer[k] = v for k in ("CHOST",): v = settings.get(k) if v is not None: - write_atomic(os.path.join(build_info_dir, k), v + "\n") + metadata_buffer[k] = v with open( _unicode_encode( @@ -2542,17 +2542,7 @@ def _post_src_install_write_metadata(settings): except OSError: pass continue - with open( - _unicode_encode( - os.path.join(build_info_dir, k), - encoding=_encodings["fs"], - errors="strict", - ), - mode="w", - encoding=_encodings["repo.content"], - errors="strict", - ) as f: - f.write(f"{v}\n") + metadata_buffer[k] = v if eapi_attrs.slot_operator: deps = evaluate_slot_operator_equal_deps(settings, use, QueryCommand.get_db()) @@ -2564,18 +2554,20 @@ def _post_src_install_write_metadata(settings): except OSError: pass continue - with open( - _unicode_encode( - os.path.join(build_info_dir, k), - encoding=_encodings["fs"], - errors="strict", - ), - mode="w", - encoding=_encodings["repo.content"], - errors="strict", - ) as f: - f.write(f"{v}\n") + metadata_buffer[k] = v + + for k, v in metadata_buffer.items(): + with open( + _unicode_encode( + os.path.join(build_info_dir, k), + encoding=_encodings["fs"], + errors="strict", + ), + mode="w", + encoding=_encodings["repo.content"], + ) as f: + f.write(f"{v}\n") def _preinst_bsdflags(mysettings): if bsd_chflags: