Gentoo Archives: gentoo-commits

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