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