diff options
author | Zac Medico <zmedico@gentoo.org> | 2020-05-10 18:23:41 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2020-05-24 15:26:29 -0700 |
commit | 230595cf600cae6beb6ebf6f817d08ace433c3ea (patch) | |
tree | 3e4cedd56db0416944dd842e8a8380045ec4c3c9 /lib/portage/_compat_upgrade | |
parent | NeededEntry: don't use scanelf -q (bug 721336) (diff) | |
download | portage-230595cf600cae6beb6ebf6f817d08ace433c3ea.tar.gz portage-230595cf600cae6beb6ebf6f817d08ace433c3ea.tar.bz2 portage-230595cf600cae6beb6ebf6f817d08ace433c3ea.zip |
Default BINPKG_COMPRESSION to zstd (bug 715108)
This includes a _compat_upgrade.binpkg_compression script that the
ebuild can call in pkg_preinst in order to maintain a backward-compatible
bzip2 default when appropriate, ensuring that binary package consumers
are not caught off guard.
Bug: https://bugs.gentoo.org/715108
Reviewed-by: Brian Dolbec <dolsen@gentoo.org>
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/portage/_compat_upgrade')
-rw-r--r-- | lib/portage/_compat_upgrade/binpkg_compression.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/portage/_compat_upgrade/binpkg_compression.py b/lib/portage/_compat_upgrade/binpkg_compression.py new file mode 100644 index 000000000..0f5704733 --- /dev/null +++ b/lib/portage/_compat_upgrade/binpkg_compression.py @@ -0,0 +1,40 @@ +# 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_COMPRESS = 'bzip2' + + +def main(): + """ + If the current installation is still configured to use the old + default BINPKG_COMPRESS=bzip2 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_COMPRESS + PYTHONPATH="${D%/}$(python_get_sitedir)${PYTHONPATH:+:${PYTHONPATH}}" \ + "${PYTHON}" -m portage._compat_upgrade.binpkg_compression || die + } + """ + if portage.settings.get('BINPKG_COMPRESS', COMPAT_BINPKG_COMPRESS) == COMPAT_BINPKG_COMPRESS: + 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 = 'BINPKG_COMPRESS="{}"'.format(COMPAT_BINPKG_COMPRESS) + portage.output.EOutput().einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting)) + content = re.sub('^BINPKG_COMPRESS=.*$', compat_setting, content, flags=re.MULTILINE) + with open(config_path, 'wt') as f: + f.write(content) + + +if __name__ == '__main__': + main() |