1 |
On 11/01/2018 02:50 AM, Michał Górny wrote: |
2 |
> Add FEATURES=binpkg-docompress that can be used whether docompress |
3 |
> compression is performed before or after creating binary packages. With |
4 |
> the feature enabled (the default), the current behavior of storing |
5 |
> compressed files in binpkg is preserved. With it disabled, uncompressed |
6 |
> files are stored inside binary package and are compressed when |
7 |
> installing. |
8 |
> |
9 |
> Storing uncompressed files in binary packages has two advantages: |
10 |
> |
11 |
> 1. Avoids the double-compression penalty, effectively improving binary |
12 |
> package compression speed and compression ratio. |
13 |
> |
14 |
> 2. Allows the same packages to be reused on systems with different |
15 |
> docompress configurations. |
16 |
> |
17 |
> The option is roughly backwards compatible. Old Portage versions will |
18 |
> install packages created with FEATURES=-binpkg-docompress correctly, |
19 |
> albeit without compression. Portage with FEATURES=binpkg-docompress |
20 |
> should install old binpackages semi-correctly, potentially recompressing |
21 |
> them (and throwing already-compressed warnings on format mismatch). |
22 |
> The new behavior is left off by default to avoid those problems. |
23 |
> |
24 |
> Signed-off-by: Michał Górny <mgorny@g.o> |
25 |
> --- |
26 |
> bin/misc-functions.sh | 34 +++++++++++++++++++++++--- |
27 |
> cnf/make.globals | 2 +- |
28 |
> lib/portage/const.py | 1 + |
29 |
> lib/portage/dbapi/vartree.py | 12 +++++++++ |
30 |
> lib/portage/package/ebuild/doebuild.py | 3 ++- |
31 |
> man/make.conf.5 | 6 +++++ |
32 |
> 6 files changed, 52 insertions(+), 6 deletions(-) |
33 |
> |
34 |
> diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh |
35 |
> index db7aaed5a..96aa66611 100755 |
36 |
> --- a/bin/misc-functions.sh |
37 |
> +++ b/bin/misc-functions.sh |
38 |
> @@ -109,10 +109,13 @@ install_qa_check() { |
39 |
> |
40 |
> [[ -d ${ED%/}/usr/share/info ]] && prepinfo |
41 |
> |
42 |
> - # Apply compression. |
43 |
> - "${PORTAGE_BIN_PATH}"/ecompress --queue "${PORTAGE_DOCOMPRESS[@]}" |
44 |
> - "${PORTAGE_BIN_PATH}"/ecompress --ignore "${PORTAGE_DOCOMPRESS_SKIP[@]}" |
45 |
> - "${PORTAGE_BIN_PATH}"/ecompress --dequeue |
46 |
> + # If binpkg-docompress is enabled, apply compression before creating |
47 |
> + # the binary package. |
48 |
> + if has binpkg-docompress ${FEATURES}; then |
49 |
> + "${PORTAGE_BIN_PATH}"/ecompress --queue "${PORTAGE_DOCOMPRESS[@]}" |
50 |
> + "${PORTAGE_BIN_PATH}"/ecompress --ignore "${PORTAGE_DOCOMPRESS_SKIP[@]}" |
51 |
> + "${PORTAGE_BIN_PATH}"/ecompress --dequeue |
52 |
> + fi |
53 |
> |
54 |
> export STRIP_MASK |
55 |
> if ___eapi_has_dostrip; then |
56 |
> @@ -160,6 +163,29 @@ install_qa_check() { |
57 |
> rm -f "${ED%/}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!" |
58 |
> } |
59 |
> |
60 |
> +__dyn_instprep() { |
61 |
> + if has chflags ${FEATURES}; then |
62 |
> + # Save all the file flags for restoration afterwards. |
63 |
> + mtree -c -p "${ED}" -k flags > "${T}/bsdflags.mtree" |
64 |
> + # Remove all the file flags so that we can do anything necessary. |
65 |
> + chflags -R noschg,nouchg,nosappnd,nouappnd "${ED}" |
66 |
> + chflags -R nosunlnk,nouunlnk "${ED}" 2>/dev/null |
67 |
> + fi |
68 |
> + |
69 |
> + # If binpkg-docompress is disabled, we need to apply compression |
70 |
> + # before installing. |
71 |
> + if ! has binpkg-docompress ${FEATURES}; then |
72 |
> + "${PORTAGE_BIN_PATH}"/ecompress --queue "${PORTAGE_DOCOMPRESS[@]}" |
73 |
> + "${PORTAGE_BIN_PATH}"/ecompress --ignore "${PORTAGE_DOCOMPRESS_SKIP[@]}" |
74 |
> + "${PORTAGE_BIN_PATH}"/ecompress --dequeue |
75 |
> + fi |
76 |
> + |
77 |
> + if has chflags ${FEATURES}; then |
78 |
> + # Restore all the file flags that were saved earlier on. |
79 |
> + mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null |
80 |
> + fi |
81 |
> +} |
82 |
> + |
83 |
> preinst_qa_check() { |
84 |
> postinst_qa_check preinst |
85 |
> } |
86 |
> diff --git a/cnf/make.globals b/cnf/make.globals |
87 |
> index 04a708af8..72b567e98 100644 |
88 |
> --- a/cnf/make.globals |
89 |
> +++ b/cnf/make.globals |
90 |
> @@ -50,7 +50,7 @@ RESUMECOMMAND_SSH=${FETCHCOMMAND_SSH} |
91 |
> FETCHCOMMAND_SFTP="bash -c \"x=\\\${2#sftp://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; eval \\\"declare -a ssh_opts=(\\\${3})\\\" ; exec sftp \\\${port:+-P \\\${port}} \\\"\\\${ssh_opts[@]}\\\" \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" sftp \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\"" |
92 |
> |
93 |
> # Default user options |
94 |
> -FEATURES="assume-digests binpkg-logs |
95 |
> +FEATURES="assume-digests binpkg-docompress binpkg-logs |
96 |
> config-protect-if-modified distlocks ebuild-locks |
97 |
> fixlafiles merge-sync multilib-strict news |
98 |
> parallel-fetch preserve-libs protect-owned |
99 |
> diff --git a/lib/portage/const.py b/lib/portage/const.py |
100 |
> index 7f84bf0e9..a343fc040 100644 |
101 |
> --- a/lib/portage/const.py |
102 |
> +++ b/lib/portage/const.py |
103 |
> @@ -122,6 +122,7 @@ EBUILD_PHASES = ( |
104 |
> ) |
105 |
> SUPPORTED_FEATURES = frozenset([ |
106 |
> "assume-digests", |
107 |
> + "binpkg-docompress", |
108 |
> "binpkg-logs", |
109 |
> "binpkg-multi-instance", |
110 |
> "buildpkg", |
111 |
> diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py |
112 |
> index c16fdfe88..fd8aaeb8e 100644 |
113 |
> --- a/lib/portage/dbapi/vartree.py |
114 |
> +++ b/lib/portage/dbapi/vartree.py |
115 |
> @@ -3719,6 +3719,7 @@ class dblink(object): |
116 |
> |
117 |
> This function does the following: |
118 |
> |
119 |
> + calls doebuild(mydo=instprep) |
120 |
> calls get_ro_checker to retrieve a function for checking whether Portage |
121 |
> will write to a read-only filesystem, then runs it against the directory list |
122 |
> calls self._preserve_libs if FEATURES=preserve-libs |
123 |
> @@ -3768,6 +3769,17 @@ class dblink(object): |
124 |
> level=logging.ERROR, noiselevel=-1) |
125 |
> return 1 |
126 |
> |
127 |
> + # run instprep internal phase |
128 |
> + doebuild_environment(myebuild, "instprep", |
129 |
> + settings=self.settings, db=mydbapi) |
130 |
> + phase = EbuildPhase(background=False, phase="instprep", |
131 |
> + scheduler=self._scheduler, settings=self.settings) |
132 |
> + phase.start() |
133 |
> + if phase.wait() != os.EX_OK: |
134 |
> + showMessage(_("!!! instprep failed\n"), |
135 |
> + level=logging.ERROR, noiselevel=-1) |
136 |
> + return 1 |
137 |
> + |
138 |
> is_binpkg = self.settings.get("EMERGE_FROM") == "binary" |
139 |
> slot = '' |
140 |
> for var_name in ('CHOST', 'SLOT'): |
141 |
> diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py |
142 |
> index 9706de422..d7b535698 100644 |
143 |
> --- a/lib/portage/package/ebuild/doebuild.py |
144 |
> +++ b/lib/portage/package/ebuild/doebuild.py |
145 |
> @@ -674,7 +674,7 @@ def doebuild(myebuild, mydo, _unused=DeprecationWarning, settings=None, debug=0, |
146 |
> "config", "info", "setup", "depend", "pretend", |
147 |
> "fetch", "fetchall", "digest", |
148 |
> "unpack", "prepare", "configure", "compile", "test", |
149 |
> - "install", "rpm", "qmerge", "merge", |
150 |
> + "install", "instprep", "rpm", "qmerge", "merge", |
151 |
> "package", "unmerge", "manifest", "nofetch"] |
152 |
> |
153 |
> if mydo not in validcommands: |
154 |
> @@ -1402,6 +1402,7 @@ def _spawn_actionmap(settings): |
155 |
> "compile": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}}, |
156 |
> "test": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}}, |
157 |
> "install": {"cmd":ebuild_sh, "args":{"droppriv":0, "free":0, "sesandbox":sesandbox, "fakeroot":fakeroot}}, |
158 |
> +"instprep": {"cmd":misc_sh, "args":{"droppriv":0, "free":0, "sesandbox":sesandbox, "fakeroot":fakeroot}}, |
159 |
> "rpm": {"cmd":misc_sh, "args":{"droppriv":0, "free":0, "sesandbox":0, "fakeroot":fakeroot}}, |
160 |
> "package": {"cmd":misc_sh, "args":{"droppriv":0, "free":0, "sesandbox":0, "fakeroot":fakeroot}}, |
161 |
> } |
162 |
|
163 |
The feature seems find but the instprep phase is not needed if we use |
164 |
MiscFunctionsProcess instead of EbuildPhase. Here's a list of odd things |
165 |
about the instprep ebuild phase implementation as it is: |
166 |
|
167 |
1) You can call instprep explicitly via the ebuild(1) command, but I |
168 |
doubt that we really want or need to allow that. |
169 |
|
170 |
2) Unlinke other ebuild phases, the doebuild function doesn't created a |
171 |
.instpreped file to indicate when the instprep phase has executed. |
172 |
|
173 |
3) Currently instprep executes when FEATURES=binpkg-docompress is |
174 |
enabled, even though it does nothing of value. I think we should instead |
175 |
generate a relevant list of MiscFunctionsProcess commands for the |
176 |
enabled FEATURES, and only start a MiscFunctionsProcess instance if the |
177 |
list of commands is non-empty. |
178 |
-- |
179 |
Thanks, |
180 |
Zac |