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 0EA02158004 for ; Sun, 10 Dec 2023 22:59:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43F8A2BC01C; Sun, 10 Dec 2023 22:59:56 +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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 277382BC01C for ; Sun, 10 Dec 2023 22:59:56 +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 DF26D33BE19 for ; Sun, 10 Dec 2023 22:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 796D0135D for ; Sun, 10 Dec 2023 22:59:53 +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: <1702249163.b0037e6d973f57de0745dc59aa6d265f410649c0.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/_compat_upgrade/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/_compat_upgrade/binpkg_format.py lib/portage/_compat_upgrade/meson.build X-VCS-Directories: lib/portage/_compat_upgrade/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b0037e6d973f57de0745dc59aa6d265f410649c0 X-VCS-Branch: master Date: Sun, 10 Dec 2023 22:59:53 +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: 8be94797-608f-44d1-b183-fadc0f8dd70d X-Archives-Hash: 97c4dd7e2778ff0c807f9047248a4279 commit: b0037e6d973f57de0745dc59aa6d265f410649c0 Author: Andreas K. Hüttel gentoo org> AuthorDate: Tue Sep 26 22:57:41 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Dec 10 22:59:23 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b0037e6d Add BINPKG_FORMAT to the compat_upgrade mechanism Signed-off-by: Andreas K. Hüttel gentoo.org> Closes: https://github.com/gentoo/portage/pull/1102 Signed-off-by: Sam James gentoo.org> lib/portage/_compat_upgrade/binpkg_format.py | 51 ++++++++++++++++++++++++++++ lib/portage/_compat_upgrade/meson.build | 1 + 2 files changed, 52 insertions(+) diff --git a/lib/portage/_compat_upgrade/binpkg_format.py b/lib/portage/_compat_upgrade/binpkg_format.py new file mode 100644 index 0000000000..6ad24799c5 --- /dev/null +++ b/lib/portage/_compat_upgrade/binpkg_format.py @@ -0,0 +1,51 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +import re + +import portage +from portage import os +from portage.const import GLOBAL_CONFIG_PATH + +COMPAT_BINPKG_FORMAT = "xpak" + + +def main(): + """ + If the current installation is still configured to use the old + default BINPKG_FORMAT=xpak setting, then patch make.globals + inside ${ED} to maintain backward compatibility, ensuring that + binary package consumers are not caught off guard. This is + intended to be called from the ebuild as follows: + + pkg_preinst() { + python_setup + env -u BINPKG_FORMAT + PYTHONPATH="${D%/}$(python_get_sitedir)${PYTHONPATH:+:${PYTHONPATH}}" \ + "${PYTHON}" -m portage._compat_upgrade.binpkg_format || die + } + """ + if ( + portage.settings.get("BINPKG_FORMAT", COMPAT_BINPKG_FORMAT) + == COMPAT_BINPKG_FORMAT + ): + config_path = os.path.join( + os.environ["ED"], GLOBAL_CONFIG_PATH.lstrip(os.sep), "make.globals" + ) + with open(config_path) as f: + content = f.read() + compat_setting = f'BINPKG_FORMAT="{COMPAT_BINPKG_FORMAT}"' + portage.output.EOutput().einfo( + "Setting make.globals default {} for backward compatibility".format( + compat_setting + ) + ) + content = re.sub( + "^BINPKG_FORMAT=.*$", compat_setting, content, flags=re.MULTILINE + ) + with open(config_path, "w") as f: + f.write(content) + + +if __name__ == "__main__": + main() diff --git a/lib/portage/_compat_upgrade/meson.build b/lib/portage/_compat_upgrade/meson.build index 365bd49ff4..e99b33c152 100644 --- a/lib/portage/_compat_upgrade/meson.build +++ b/lib/portage/_compat_upgrade/meson.build @@ -1,6 +1,7 @@ py.install_sources( [ 'binpkg_compression.py', + 'binpkg_format.py', 'binpkg_multi_instance.py', 'default_locations.py', '__init__.py',