1 |
commit: 230595cf600cae6beb6ebf6f817d08ace433c3ea |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 11 01:23:41 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun May 24 22:26:29 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=230595cf |
7 |
|
8 |
Default BINPKG_COMPRESSION to zstd (bug 715108) |
9 |
|
10 |
This includes a _compat_upgrade.binpkg_compression script that the |
11 |
ebuild can call in pkg_preinst in order to maintain a backward-compatible |
12 |
bzip2 default when appropriate, ensuring that binary package consumers |
13 |
are not caught off guard. |
14 |
|
15 |
Bug: https://bugs.gentoo.org/715108 |
16 |
Reviewed-by: Brian Dolbec <dolsen <AT> gentoo.org> |
17 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
18 |
|
19 |
.travis.yml | 4 +++ |
20 |
cnf/make.globals | 5 +-- |
21 |
lib/portage/_compat_upgrade/binpkg_compression.py | 40 +++++++++++++++++++++++ |
22 |
lib/portage/tests/resolver/ResolverPlayground.py | 1 + |
23 |
man/make.conf.5 | 4 +-- |
24 |
5 files changed, 50 insertions(+), 4 deletions(-) |
25 |
|
26 |
diff --git a/.travis.yml b/.travis.yml |
27 |
index 9269d4034..2132c8c87 100644 |
28 |
--- a/.travis.yml |
29 |
+++ b/.travis.yml |
30 |
@@ -1,3 +1,4 @@ |
31 |
+dist: bionic |
32 |
language: python |
33 |
python: |
34 |
- 2.7 |
35 |
@@ -8,6 +9,9 @@ python: |
36 |
- pypy3 |
37 |
|
38 |
# command to install dependencies |
39 |
+before_install: |
40 |
+ # Use "dist: bionic" to get a zstd with --long support. |
41 |
+ - sudo apt-get -y install zstd |
42 |
install: |
43 |
- pip install tox |
44 |
|
45 |
|
46 |
diff --git a/cnf/make.globals b/cnf/make.globals |
47 |
index 4a59dbe3c..dd3f28f70 100644 |
48 |
--- a/cnf/make.globals |
49 |
+++ b/cnf/make.globals |
50 |
@@ -34,8 +34,9 @@ RPMDIR="/var/cache/rpm" |
51 |
# Temporary build directory |
52 |
PORTAGE_TMPDIR="/var/tmp" |
53 |
|
54 |
-# The compression used for binary packages. Defaults to zstd when USE=zstd is enabled. |
55 |
-BINPKG_COMPRESS="bzip2" |
56 |
+# The compression used for binary packages. Defaults to zstd except for |
57 |
+# existing installs where bzip2 is used for backward compatibility. |
58 |
+BINPKG_COMPRESS="zstd" |
59 |
|
60 |
# Fetching command (3 tries, passive ftp for firewall compatibility) |
61 |
FETCHCOMMAND="wget -t 3 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" |
62 |
|
63 |
diff --git a/lib/portage/_compat_upgrade/binpkg_compression.py b/lib/portage/_compat_upgrade/binpkg_compression.py |
64 |
new file mode 100644 |
65 |
index 000000000..0f5704733 |
66 |
--- /dev/null |
67 |
+++ b/lib/portage/_compat_upgrade/binpkg_compression.py |
68 |
@@ -0,0 +1,40 @@ |
69 |
+# Copyright 2020 Gentoo Authors |
70 |
+# Distributed under the terms of the GNU General Public License v2 |
71 |
+ |
72 |
+import re |
73 |
+ |
74 |
+import portage |
75 |
+from portage import os |
76 |
+from portage.const import GLOBAL_CONFIG_PATH |
77 |
+ |
78 |
+COMPAT_BINPKG_COMPRESS = 'bzip2' |
79 |
+ |
80 |
+ |
81 |
+def main(): |
82 |
+ """ |
83 |
+ If the current installation is still configured to use the old |
84 |
+ default BINPKG_COMPRESS=bzip2 setting, then patch make.globals |
85 |
+ inside ${ED} to maintain backward compatibility, ensuring that |
86 |
+ binary package consumers are not caught off guard. This is |
87 |
+ intended to be called from the ebuild as follows: |
88 |
+ |
89 |
+ pkg_preinst() { |
90 |
+ python_setup |
91 |
+ env -u BINPKG_COMPRESS |
92 |
+ PYTHONPATH="${D%/}$(python_get_sitedir)${PYTHONPATH:+:${PYTHONPATH}}" \ |
93 |
+ "${PYTHON}" -m portage._compat_upgrade.binpkg_compression || die |
94 |
+ } |
95 |
+ """ |
96 |
+ if portage.settings.get('BINPKG_COMPRESS', COMPAT_BINPKG_COMPRESS) == COMPAT_BINPKG_COMPRESS: |
97 |
+ config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'make.globals') |
98 |
+ with open(config_path) as f: |
99 |
+ content = f.read() |
100 |
+ compat_setting = 'BINPKG_COMPRESS="{}"'.format(COMPAT_BINPKG_COMPRESS) |
101 |
+ portage.output.EOutput().einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting)) |
102 |
+ content = re.sub('^BINPKG_COMPRESS=.*$', compat_setting, content, flags=re.MULTILINE) |
103 |
+ with open(config_path, 'wt') as f: |
104 |
+ f.write(content) |
105 |
+ |
106 |
+ |
107 |
+if __name__ == '__main__': |
108 |
+ main() |
109 |
|
110 |
diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py |
111 |
index 98831e000..de80a0cc1 100644 |
112 |
--- a/lib/portage/tests/resolver/ResolverPlayground.py |
113 |
+++ b/lib/portage/tests/resolver/ResolverPlayground.py |
114 |
@@ -112,6 +112,7 @@ class ResolverPlayground(object): |
115 |
"uname", |
116 |
"uniq", |
117 |
"xargs", |
118 |
+ "zstd", |
119 |
) |
120 |
# Exclude internal wrappers from PATH lookup. |
121 |
orig_path = os.environ['PATH'] |
122 |
|
123 |
diff --git a/man/make.conf.5 b/man/make.conf.5 |
124 |
index f82fed65a..a3bd662ae 100644 |
125 |
--- a/man/make.conf.5 |
126 |
+++ b/man/make.conf.5 |
127 |
@@ -1,4 +1,4 @@ |
128 |
-.TH "MAKE.CONF" "5" "Nov 2019" "Portage VERSION" "Portage" |
129 |
+.TH "MAKE.CONF" "5" "May 2020" "Portage VERSION" "Portage" |
130 |
.SH "NAME" |
131 |
make.conf \- custom settings for Portage |
132 |
.SH "SYNOPSIS" |
133 |
@@ -115,7 +115,7 @@ This variable is used to determine the compression used for \fIbinary |
134 |
packages\fR. Supported settings and compression algorithms are: bzip2, gzip, |
135 |
lz4, lzip, lzop, xz, zstd. |
136 |
.br |
137 |
-Defaults to "bzip2". |
138 |
+Defaults to "zstd". |
139 |
.br |
140 |
.I Example: |
141 |
.nf |