public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/_compat_upgrade/
@ 2021-02-27  1:20 Zac Medico
  0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2021-02-27  1:20 UTC (permalink / raw
  To: gentoo-commits

commit:     cb354edf61a133798e81e7059bdfcaeb25c13982
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 26 23:15:09 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 27 01:16:11 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cb354edf

make.globals: make FEATURES=-binpkg-multi-instance sticky for existing installs

Add a _compat_upgrade.binpkg_multi_instance script that the ebuild
can call in pkg_preinst in order to maintain a backward-compatible
FEATURES=-binpkg-multi-instance default on existing installs where
enabling binpkg-multi-instance could cause disruption.

Bug: https://bugs.gentoo.org/772785
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 .../_compat_upgrade/binpkg_multi_instance.py       | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lib/portage/_compat_upgrade/binpkg_multi_instance.py b/lib/portage/_compat_upgrade/binpkg_multi_instance.py
new file mode 100644
index 000000000..b4aabe8b2
--- /dev/null
+++ b/lib/portage/_compat_upgrade/binpkg_multi_instance.py
@@ -0,0 +1,33 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+import portage
+from portage import os
+from portage.const import GLOBAL_CONFIG_PATH
+
+COMPAT_FEATURES = 'FEATURES="${FEATURES} -binpkg-multi-instance"'
+
+
+def main():
+	"""
+	If the current installation is still has binpkg-multi-instance
+	disabled, then patch make.globals inside ${ED} to maintain backward
+	compatibility. This is intended to be called from the ebuild as
+	follows:
+
+	pkg_preinst() {
+		python_setup
+		env -u FEATURES -u PORTAGE_REPOSITORIES \
+			PYTHONPATH="${D}$(python_get_sitedir)${PYTHONPATH:+:${PYTHONPATH}}" \
+			"${PYTHON}" -m portage._compat_upgrade.binpkg_multi_instance || die
+	}
+	"""
+	if 'binpkg-multi-instance' not in portage.settings.features:
+		portage.output.EOutput().einfo('Setting make.globals default {} for backward compatibility'.format(COMPAT_FEATURES))
+		config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'make.globals')
+		with open(config_path, 'at') as f:
+			f.write("{}\n".format(COMPAT_FEATURES))
+
+
+if __name__ == '__main__':
+	main()


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/_compat_upgrade/
@ 2023-12-10 22:59 Sam James
  0 siblings, 0 replies; 3+ messages in thread
From: Sam James @ 2023-12-10 22:59 UTC (permalink / raw
  To: gentoo-commits

commit:     b0037e6d973f57de0745dc59aa6d265f410649c0
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 26 22:57:41 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> 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 <dilfridge <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1102
Signed-off-by: Sam James <sam <AT> 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',


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/_compat_upgrade/
@ 2023-12-10 22:59 Sam James
  0 siblings, 0 replies; 3+ messages in thread
From: Sam James @ 2023-12-10 22:59 UTC (permalink / raw
  To: gentoo-commits

commit:     6283b8667ddc8d428751f5a385a96374b1f837d2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 10 22:59:42 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 10 22:59:42 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6283b866

Fix indentation

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/_compat_upgrade/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/_compat_upgrade/meson.build b/lib/portage/_compat_upgrade/meson.build
index e99b33c152..6db0981b9c 100644
--- a/lib/portage/_compat_upgrade/meson.build
+++ b/lib/portage/_compat_upgrade/meson.build
@@ -1,7 +1,7 @@
 py.install_sources(
     [
         'binpkg_compression.py',
-	'binpkg_format.py',
+        'binpkg_format.py',
         'binpkg_multi_instance.py',
         'default_locations.py',
         '__init__.py',


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-10 22:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-10 22:59 [gentoo-commits] proj/portage:master commit in: lib/portage/_compat_upgrade/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2023-12-10 22:59 Sam James
2021-02-27  1:20 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox