Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set gpkg as BINPKG_FORMAT default #1102

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions cnf/make.globals
Expand Up @@ -38,9 +38,9 @@ PORTAGE_TMPDIR="/var/tmp"
# existing installs where bzip2 is used for backward compatibility.
BINPKG_COMPRESS="zstd"

# The format used for binary packages. The default is use old "xpak" format.
# Set to "gpkg" to use new gentoo binary package format.
BINPKG_FORMAT="xpak"
# The format used for binary packages. The default is to use the new "gpkg" format.
# Set to "xpak" to use the old gentoo binary package format.
BINPKG_FORMAT="gpkg"

# The binary package default GPG signing command.
# flock is used to avoid a racing condition of gnupg
Expand Down
51 changes: 51 additions & 0 deletions 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()
1 change: 1 addition & 0 deletions lib/portage/_compat_upgrade/meson.build
@@ -1,6 +1,7 @@
py.install_sources(
[
'binpkg_compression.py',
'binpkg_format.py',
thesamesam marked this conversation as resolved.
Show resolved Hide resolved
'binpkg_multi_instance.py',
'default_locations.py',
'__init__.py',
Expand Down