1 |
Add a _compat_upgrade.binpkg_multi_instance script that the ebuild |
2 |
can call in pkg_preinst in order to maintain a backward-compatible |
3 |
FEATURES=-binpkg-multi-instance default on existing installs where |
4 |
enabling binpkg-multi-instance could cause disruption. |
5 |
|
6 |
Bug: https://bugs.gentoo.org/772785 |
7 |
Signed-off-by: Zac Medico <zmedico@g.o> |
8 |
--- |
9 |
.../_compat_upgrade/binpkg_multi_instance.py | 33 +++++++++++++++++++ |
10 |
1 file changed, 33 insertions(+) |
11 |
create mode 100644 lib/portage/_compat_upgrade/binpkg_multi_instance.py |
12 |
|
13 |
diff --git a/lib/portage/_compat_upgrade/binpkg_multi_instance.py b/lib/portage/_compat_upgrade/binpkg_multi_instance.py |
14 |
new file mode 100644 |
15 |
index 000000000..bfeb72baa |
16 |
--- /dev/null |
17 |
+++ b/lib/portage/_compat_upgrade/binpkg_multi_instance.py |
18 |
@@ -0,0 +1,33 @@ |
19 |
+# Copyright 2021 Gentoo Authors |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+ |
22 |
+import portage |
23 |
+from portage import os |
24 |
+from portage.const import GLOBAL_CONFIG_PATH |
25 |
+ |
26 |
+COMPAT_FEATURES = 'FEATURES="${FEATURES} -binpkg-multi-instance"' |
27 |
+ |
28 |
+ |
29 |
+def main(): |
30 |
+ """ |
31 |
+ If the current installation is still has binpkg-multi-instance |
32 |
+ disabled, then patch make.globals inside ${ED} to maintain backward |
33 |
+ compatibility. This is intended to be called from the ebuild as |
34 |
+ follows: |
35 |
+ |
36 |
+ pkg_preinst() { |
37 |
+ python_setup |
38 |
+ env -u FEATURES |
39 |
+ PYTHONPATH="${D%/}$(python_get_sitedir)${PYTHONPATH:+:${PYTHONPATH}}" \ |
40 |
+ "${PYTHON}" -m portage._compat_upgrade.binpkg_multi_instance || die |
41 |
+ } |
42 |
+ """ |
43 |
+ if 'binpkg-multi-instance' not in portage.settings.features: |
44 |
+ portage.output.EOutput().einfo('Setting make.globals default {} for backward compatibility'.format(COMPAT_FEATURES)) |
45 |
+ config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'make.globals') |
46 |
+ with open(config_path, 'at') as f: |
47 |
+ f.write("{}\n".format(COMPAT_FEATURES)) |
48 |
+ |
49 |
+ |
50 |
+if __name__ == '__main__': |
51 |
+ main() |
52 |
-- |
53 |
2.26.2 |