Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-apps/portage/, sys-apps/portage/files/
Date: Fri, 14 Jan 2022 12:28:23
Message-Id: 1642163296.c6c1c09765855d9a1984b358066b4cadfb3c92da.grobian@gentoo
1 commit: c6c1c09765855d9a1984b358066b4cadfb3c92da
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 14 12:28:16 2022 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 14 12:28:16 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=c6c1c097
7
8 sys-apps/portage-3.0.30: version bump
9
10 Package-Manager: Portage-3.0.30, Repoman-3.0.3
11 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
12
13 sys-apps/portage/Manifest | 1 +
14 .../portage/files/portage-3.0.30-ebuildshell.patch | 349 +++++++++++++++++++++
15 .../files/portage-3.0.30-prefix-stack.patch | 81 +++++
16 sys-apps/portage/portage-3.0.30.ebuild | 307 ++++++++++++++++++
17 4 files changed, 738 insertions(+)
18
19 diff --git a/sys-apps/portage/Manifest b/sys-apps/portage/Manifest
20 index 13a1d23d2a..59b77c8363 100644
21 --- a/sys-apps/portage/Manifest
22 +++ b/sys-apps/portage/Manifest
23 @@ -1 +1,2 @@
24 DIST prefix-portage-3.0.21.tar.bz2 1339211 BLAKE2B 019cf0f3d2d1c45e7849221fc40b49e2c84949b74c8a8c74fbd2ca451a2dd075fb7b8bfec121a173ca0848c57a5a57a62d465b2957c4eb4d87f6a180299da91e SHA512 0aff5004ae80e2cd9dce740c56c3c2643ef390510c3b3821d893e5c76733d3a8d4e7648963febb29479b9ee155868ec11526a393beb3b383e741451178f39e5a
25 +DIST prefix-portage-3.0.30.tar.bz2 1465506 BLAKE2B 5a575bc6c6c537518a1d4738f59d6f5eec467c834d434493e83cb0262c9c121b0e55906b9f1b877b6e68b4b78f69548df03d8901a619ce1c69d9ffe5f2623e55 SHA512 52bb91057c8c983f227f1d30dcda1bdf915aecc1de89375b2af648e7bfc5543a30f9b670b3d7720724f8277f3e65745a22dfe670038222d61e939fd75c9b7bfd
26
27 diff --git a/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch b/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch
28 new file mode 100644
29 index 0000000000..20f0aab813
30 --- /dev/null
31 +++ b/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch
32 @@ -0,0 +1,349 @@
33 +From 8c6b115fa0325b5bed2e1a9c4c8e8af45cdecc2e Mon Sep 17 00:00:00 2001
34 +From: Michael Haubenwallner <michael.haubenwallner@×××××××.at>
35 +Date: Wed, 6 Nov 2013 12:40:05 +0100
36 +Subject: [PATCH 1/2] Add ebuildshell feature, bug#155161.
37 +
38 +---
39 + bin/ebuild.sh | 146 ++++++++++++++++++++++++++++++++++-
40 + bin/filter-bash-environment.py | 55 +++++++++----
41 + bin/save-ebuild-env.sh | 2 +-
42 + man/make.conf.5 | 6 ++
43 + lib/_emerge/AbstractEbuildProcess.py | 1 +
44 + lib/portage/const.py | 1 +
45 + 6 files changed, 194 insertions(+), 17 deletions(-)
46 +
47 +diff --git a/bin/ebuild.sh b/bin/ebuild.sh
48 +index f76a48d8e..683a4e9c1 100755
49 +--- a/bin/ebuild.sh
50 ++++ b/bin/ebuild.sh
51 +@@ -121,7 +121,7 @@ __qa_source() {
52 + __qa_call() {
53 + local shopts=$(shopt) OLDIFS="$IFS"
54 + local retval
55 +- "$@"
56 ++ __call-ebuildshell "$@"
57 + retval=$?
58 + set +e
59 + [[ $shopts != $(shopt) ]] &&
60 +@@ -547,6 +547,150 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
61 + unset BIN_PATH BIN BODY FUNC_SRC
62 + fi
63 +
64 ++__call-ebuildshell() {
65 ++ if ! has ebuildshell ${FEATURES}; then
66 ++ "$@"
67 ++ return $?
68 ++ fi
69 ++ local __ebuildshell_args=( "$@" )
70 ++ # These are the variables I have seen 'bash -i' maintaining the values for:
71 ++ local __ebuildshell_bash_i_vars="__ebuildshell_.*
72 ++ _ BASH_ARGC BASH_ARGV BASH_COMMAND BASH_LINENO BASH_SOURCE
73 ++ BASH_VERSINFO BASH_SUBSHELL BASHOPTS BASHPID COMP_WORDBREAKS
74 ++ DIRSTACK EUID FUNCNAME GROUPS HISTCMD HISTFILE LINENO PIPESTATUS
75 ++ PPID PS1 PS2 PS3 PS4 PWD RANDOM SECONDS SHELLOPTS UID"
76 ++ # Allow recursive ebuildshell, for use in multibuild.eclass and similar:
77 ++ local __ebuildshell_pid=${BASHPID:-$(__bashpid)}
78 ++ local __ebuildshell_tmpf="${T}/ebuildshell.${__ebuildshell_pid}"
79 ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars}
80 ++ (
81 ++ cat <<-EOE
82 ++ # local variables of functions using recursive ebuildshell are
83 ++ # visible to the EXIT trap of that recursive ebuildshell. To
84 ++ # keep them local, we have to filter them from that recursive
85 ++ # ebuildshell's return-env. As 'declare -p' is unable to tell
86 ++ # local-ity of variables, we abuse the trace attribute for local
87 ++ # variables to filter them from the return-env. So we need the
88 ++ # local alias active before declaring any functions.
89 ++ # On a sidehand, this allows for copy&paste of function body
90 ++ # lines including the local keyword.
91 ++ alias local='declare -t'
92 ++ shopt -s expand_aliases
93 ++ EOE
94 ++ (
95 ++ declare -p
96 ++ declare -fp
97 ++ shopt -p
98 ++ [[ ${BASH_VERSINFO[0]} == 3 ]] && export
99 ++ ) |
100 ++ (
101 ++ # we need everything but the bash vars after 'env -i'
102 ++ 2>"${__ebuildshell_tmpf}.ebuild-rovars" \
103 ++ "${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}" \
104 ++ "${PORTAGE_BIN_PATH}"/filter-bash-environment.py \
105 ++ --report-readonly-variables \
106 ++ --preserve-readonly-attribute \
107 ++ "${__ebuildshell_bash_i_vars}" \
108 ++ || die "filter-bash-environment.py failed"
109 ++ )
110 ++ # 'declare -g' is available since bash-4.2,
111 ++ # https://bugs.gentoo.org/show_bug.cgi?id=155161#c35
112 ++ if (( ${BASH_VERSINFO[0]} > 4 )) ||
113 ++ (( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} >= 2 ))
114 ++ then
115 ++ __ebuildshell_bash42_true=
116 ++ __ebuildshell_bash42_false='#bash-4.2#'
117 ++ else
118 ++ __ebuildshell_bash42_true='#bash-4.2#'
119 ++ __ebuildshell_bash42_false=
120 ++ fi
121 ++ # The already readonly variables, without bash maintained ones:
122 ++ __ebuildshell_ro_ebuild_vars=$(<"${__ebuildshell_tmpf}.ebuild-rovars")
123 ++ cat <<-EOE
124 ++ # properly quote the function arguments
125 ++ $(declare -p __ebuildshell_args)
126 ++ set -- "\${__ebuildshell_args[@]}"
127 ++ unset __ebuildshell_args
128 ++ # be informative about what to do
129 ++ PS1="EBUILD ${PN} $1 \$ "
130 ++ type $1
131 ++ ${__ebuildshell_bash42_false}echo 'warning: preserving variables across phases requires bash-4.2'
132 ++ echo "WANTED: \$@"
133 ++ echo "or use: \"\\\$@\""
134 ++ # use bash history, but not the 'user's real one
135 ++ HISTFILE=~/.bash_history
136 ++ # but do not use history-expansion with '!',
137 ++ # for copy&paste of function body lines containing: !
138 ++ set +H
139 ++ # this is a debugging shell already
140 ++ shopt -u extdebug
141 ++ trap - DEBUG
142 ++ # at exit, dump the current environment
143 ++ trap "
144 ++ unalias local
145 ++ unset -f __call-ebuildshell
146 ++ rm -f '${__ebuildshell_tmpf}.return-'*
147 ++ (
148 ++ (
149 ++ # declare -p does not tell the -g flag,
150 ++ # so we add it by aliasing declare.
151 ++ ${__ebuildshell_bash42_true}echo \"alias declare='declare -g'\"
152 ++ declare -p
153 ++ ${__ebuildshell_bash42_true}echo \"unalias declare\"
154 ++ declare -fp
155 ++ shopt -p | grep -v '\\(expand_aliases\\|extdebug\\)$'
156 ++ $([[ ${BASH_VERSINFO[0]} == 3 ]] && echo export)
157 ++ ) |
158 ++ (
159 ++ # We may have more readonly variables now, yet we
160 ++ # need to filter variables that were readonly before.
161 ++ # And filter local variables by their trace attribute.
162 ++ 2>'${__ebuildshell_tmpf}.return-rovars' \\
163 ++ '${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}' \\
164 ++ '${PORTAGE_BIN_PATH}'/filter-bash-environment.py \\
165 ++ --report-readonly-variables \\
166 ++ --preserve-readonly-attribute \\
167 ++ --filter-traced-variables \\
168 ++ '${__ebuildshell_bash_i_vars} \
169 ++ ${__ebuildshell_ro_ebuild_vars}' \\
170 ++ || die 'filter-bash-environment.py failed'
171 ++ )
172 ++ ) > '${__ebuildshell_tmpf}.return-env'
173 ++ " EXIT
174 ++ # can do some cleanup right now
175 ++ rm -f '${__ebuildshell_tmpf}.ebuild-'*
176 ++ EOE
177 ++ ) > "${__ebuildshell_tmpf}.ebuild-env"
178 ++
179 ++ # pre-fill the history with "$@"
180 ++ echo '"$@"' >> ~/.bash_history
181 ++ chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} ~/.bash_history &>/dev/null
182 ++
183 ++ env -i HOME=~ ${BASH} --rcfile "${__ebuildshell_tmpf}.ebuild-env" -i
184 ++
185 ++ # The environment- and exit-status handling after leaving the ebuildshell
186 ++ # prompt is expected to be identical as without the ebuildshell prompt.
187 ++ local __ebuildshell_status=$?
188 ++
189 ++ # We might be in a recursive ebuildshell, but do not want
190 ++ # any aliases being active while sourcing the return-env.
191 ++ local __ebuildshell_orig_aliases=$(alias)
192 ++ unalias -a
193 ++ source "${__ebuildshell_tmpf}.return-env"
194 ++ unalias -a
195 ++ eval "${__ebuildshell_orig_aliases}"
196 ++
197 ++ # Portage has a whitelist of readonly variables: If an ebuild defines
198 ++ # additional readonly variables, their readonly attribute is removed
199 ++ # across ebuild phases. If we ever want to preserve the readonly
200 ++ # attribute of additional ebuild-defined variables across phases,
201 ++ # when returning from the ebuildshell their names are in
202 ++ # "${__ebuildshell_tmpf}.return-rovars"
203 ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars}
204 ++
205 ++ return ${__ebuildshell_status}
206 ++}
207 ++
208 + # Subshell/helper die support (must export for the die helper).
209 + export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
210 + trap 'exit 1' SIGTERM
211 +diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
212 +index 06cac7214..5590dbfc4 100755
213 +--- a/bin/filter-bash-environment.py
214 ++++ b/bin/filter-bash-environment.py
215 +@@ -14,7 +14,8 @@
216 + br'(^|^declare\s+-\S+\s+|^declare\s+|^export\s+)([^=\s]+)=("|\')?.*$'
217 + )
218 + close_quote_re = re.compile(br'(\\"|"|\')\s*$')
219 +-readonly_re = re.compile(br"^declare\s+-(\S*)r(\S*)\s+")
220 ++readonly_re = re.compile(br"^declare\s+-(\S*)r(\S*)\s+([^=\s]+)")
221 ++trace_re = re.compile(br"^declare\s+-\S*t\S*\s+")
222 + # declare without assignment
223 + var_declare_re = re.compile(br"^declare(\s+-\S+)?\s+([^=\s]+)\s*$")
224 +
225 +@@ -30,7 +31,7 @@
226 + return close_quote_match is not None and close_quote_match.group(1) == quote
227 +
228 +
229 +-def filter_declare_readonly_opt(line):
230 ++def filter_declare_readonly_opt(line, options):
231 + readonly_match = readonly_re.match(line)
232 + if readonly_match is not None:
233 + declare_opts = b""
234 +@@ -38,14 +39,19 @@
235 + group = readonly_match.group(i)
236 + if group is not None:
237 + declare_opts += group
238 ++ var = readonly_match.group(3)
239 ++ if '--report-readonly-variables' in options:
240 ++ getattr(sys.stderr, 'buffer', sys.stderr).write(var + b'\n')
241 ++ if '--preserve-readonly-attribute' in options:
242 ++ declare_opts += b'r'
243 + if declare_opts:
244 +- line = b"declare -" + declare_opts + b" " + line[readonly_match.end() :]
245 ++ line = b"declare -" + declare_opts + b" " + var + line[readonly_match.end() :]
246 + else:
247 +- line = b"declare " + line[readonly_match.end() :]
248 ++ line = b"declare " + var + line[readonly_match.end() :]
249 + return line
250 +
251 +
252 +-def filter_bash_environment(pattern, file_in, file_out):
253 ++def filter_bash_environment(pattern, file_in, file_out, options):
254 + # Filter out any instances of the \1 character from variable values
255 + # since this character multiplies each time that the environment
256 + # is saved (strange bash behavior). This can eventually result in
257 +@@ -68,6 +74,8 @@
258 + if var_assign_match is not None:
259 + quote = var_assign_match.group(3)
260 + filter_this = pattern.match(var_assign_match.group(2)) is not None
261 ++ if not filter_this and '--filter-traced-variables' in options:
262 ++ filter_this = trace_re.match(line) is not None
263 + # Exclude the start quote when searching for the end quote,
264 + # to ensure that the start quote is not misidentified as the
265 + # end quote (happens if there is a newline immediately after
266 +@@ -78,7 +86,7 @@
267 + multi_line_quote = quote
268 + multi_line_quote_filter = filter_this
269 + if not filter_this:
270 +- line = filter_declare_readonly_opt(line)
271 ++ line = filter_declare_readonly_opt(line, options)
272 + file_out.write(line.replace(b"\1", b""))
273 + continue
274 + else:
275 +@@ -86,8 +94,10 @@
276 + if declare_match is not None:
277 + # declare without assignment
278 + filter_this = pattern.match(declare_match.group(2)) is not None
279 ++ if not filter_this and '--filter-traced-variables' in options:
280 ++ filter_this = trace_re.match(line) is not None
281 + if not filter_this:
282 +- line = filter_declare_readonly_opt(line)
283 ++ line = filter_declare_readonly_opt(line, options)
284 + file_out.write(line)
285 + continue
286 +
287 +@@ -127,8 +137,28 @@
288 + + "intact. The PATTERN is a space separated list of variable names"
289 + + " and it supports python regular expression syntax."
290 + )
291 +- usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0])
292 +- args = sys.argv[1:]
293 ++ usage = "usage: %s [-h|OPTIONS] PATTERN" % os.path.basename(sys.argv[0])
294 ++ args = []
295 ++ known_options = {
296 ++ '--report-readonly-variables':
297 ++ "Write names of readonly variables to stderr.",
298 ++ '--preserve-readonly-attribute':
299 ++ "Preserve the '-r' flag in 'declare -r'.",
300 ++ '--filter-traced-variables':
301 ++ "Filter out variables declared with '-t' attribute."
302 ++ }
303 ++ options = {}
304 ++ for arg in sys.argv[1:]:
305 ++ if arg in known_options.keys():
306 ++ options[arg] = True
307 ++ continue
308 ++ if '-h' == arg or '--help' == arg:
309 ++ sys.stdout.write(usage + "\n\nKnown <options>:\n\n")
310 ++ for option, descr in known_options.items():
311 ++ sys.stdout.write(" " + option + "\t" + descr + "\n")
312 ++ sys.stdout.flush()
313 ++ sys.exit(os.EX_OK)
314 ++ args.append(arg)
315 +
316 + if "-h" in args or "--help" in args:
317 + sys.stdout.write(usage + "\n")
318 +@@ -150,5 +180,5 @@
319 + var_pattern.append(br".*\W.*")
320 +
321 + var_pattern = b"^(" + b"|".join(var_pattern) + b")$"
322 +- filter_bash_environment(re.compile(var_pattern), file_in, file_out)
323 ++ filter_bash_environment(re.compile(var_pattern), file_in, file_out, options)
324 + file_out.flush()
325 +diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
326 +index bb17382d4..af35a3327 100755
327 +--- a/bin/save-ebuild-env.sh
328 ++++ b/bin/save-ebuild-env.sh
329 +@@ -53,7 +53,7 @@
330 + einfo einfon ewarn eerror ebegin __eend eend KV_major \
331 + KV_minor KV_micro KV_to_int get_KV has \
332 + __has_phase_defined_up_to \
333 +- hasv hasq __qa_source __qa_call \
334 ++ hasv hasq __qa_source __qa_call __call-ebuildshell \
335 + addread addwrite adddeny addpredict __sb_append_var \
336 + use usev useq has_version portageq \
337 + best_version use_with use_enable register_die_hook \
338 +diff --git a/man/make.conf.5 b/man/make.conf.5
339 +index b0c1aa4f2..568f350a0 100644
340 +--- a/man/make.conf.5
341 ++++ b/man/make.conf.5
342 +@@ -408,6 +408,12 @@ exist). Also see the related \fIunmerge\-backup\fR feature.
343 + Use locks to ensure that unsandboxed ebuild phases never execute
344 + concurrently. Also see \fIparallel\-install\fR.
345 + .TP
346 ++.B ebuildshell
347 ++Drop into an interactive shell for each phase function, meant for
348 ++debugging. Because the shell would normally be used to execute the
349 ++phase function, commands like src_unpack or epatch are available in the
350 ++interactive shell. Use `die` to terminate the merge.
351 ++.TP
352 + .B fail\-clean
353 + Clean up temporary files after a build failure. This is particularly useful
354 + if you have \fBPORTAGE_TMPDIR\fR on tmpfs. If this feature is enabled, you
355 +diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py
356 +index 370cac529..a521596e5 100644
357 +--- a/lib/_emerge/AbstractEbuildProcess.py
358 ++++ b/lib/_emerge/AbstractEbuildProcess.py
359 +@@ -234,6 +234,7 @@
360 + null_fd = None
361 + if (
362 + 0 not in self.fd_pipes
363 ++ and "ebuildshell" not in self.settings.features
364 + and self.phase not in self._phases_interactive_whitelist
365 + and "interactive" not in self.settings.get("PROPERTIES", "").split()
366 + ):
367 +diff --git a/lib/portage/const.py b/lib/portage/const.py
368 +index 3c23c85ed..d9c57f300 100644
369 +--- a/lib/portage/const.py
370 ++++ b/lib/portage/const.py
371 +@@ -172,6 +172,7 @@
372 + "distlocks",
373 + "downgrade-backup",
374 + "ebuild-locks",
375 ++ "ebuildshell",
376 + "fail-clean",
377 + "fakeroot",
378 + "fixlafiles",
379 +--
380 +2.16.1
381 +
382
383 diff --git a/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch b/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch
384 new file mode 100644
385 index 0000000000..c49c473ea3
386 --- /dev/null
387 +++ b/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch
388 @@ -0,0 +1,81 @@
389 +From 1fe30e79c368ce71e024d70c3ec07a6aed3ef262 Mon Sep 17 00:00:00 2001
390 +From: Michael Haubenwallner <haubi@g.o>
391 +Date: Fri, 22 Mar 2019 17:52:05 +0100
392 +Subject: [PATCH] from FEATURES=stacked-prefix to USE=prefix-stack
393 +
394 +Rather than telling the base prefix' portage to support stacked prefix,
395 +be explicit in the stacked prefix about to USE that feature.
396 +Bug: https://bugs.gentoo.org/658572
397 +---
398 + bin/install-qa-check.d/05prefix | 10 +++-------
399 + bin/phase-helpers.sh | 12 ++++--------
400 + lib/portage/const.py | 1 -
401 + 3 files changed, 7 insertions(+), 16 deletions(-)
402 +
403 +diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix
404 +index 03da3bbce..4f48e4216 100644
405 +--- a/bin/install-qa-check.d/05prefix
406 ++++ b/bin/install-qa-check.d/05prefix
407 +@@ -36,16 +36,12 @@ install_qa_check_prefix() {
408 + local WHITELIST=" /usr/bin/env "
409 + # shebang can be an absolutised path, bug #342929
410 + local eprefix=$(canonicalize ${EPREFIX})
411 +- # Without the stacked-prefix feature, tests using BPREFIX
412 +- # are redundant to EPREFIX, but run only if we will fail.
413 ++ # Without USE=prefix-stack, tests using BPREFIX are
414 ++ # redundant to EPREFIX, but run only if we will fail.
415 + # Otherways, BPREFIX really is BROOT (the EAPI 7 one).
416 + local BPREFIX=${EPREFIX}
417 + local bprefix=${eprefix}
418 +- if has stacked-prefix ${FEATURES} &&
419 +- [[ -z ${ROOT%/} ]] &&
420 +- [[ ${CBUILD} == ${CHOST} ]] &&
421 +- [[ ${EPREFIX} != ${BROOT-${PORTAGE_OVERRIDE_EPREFIX}} ]] &&
422 +- :; then
423 ++ if has prefix-stack ${USE} ; then
424 + BPREFIX=${BROOT-${PORTAGE_OVERRIDE_EPREFIX}}
425 + bprefix=$(canonicalize ${BPREFIX})
426 + fi
427 +diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
428 +index 606b1cdfd..c64f1106b 100644
429 +--- a/bin/phase-helpers.sh
430 ++++ b/bin/phase-helpers.sh
431 +@@ -932,18 +932,14 @@ ___best_version_and_has_version_common() {
432 + fi ;;
433 + esac
434 +
435 +- # PREFIX LOCAL: stacked-prefix feature
436 ++ # PREFIX LOCAL: prefix-stack feature
437 + if ___eapi_has_prefix_variables &&
438 + has "${root_arg}" '--host-root' '-b' &&
439 +- has stacked-prefix ${FEATURES} &&
440 ++ has prefix-stack ${USE} &&
441 + [[ -z ${ROOT%/} ]] &&
442 +- [[ ${CBUILD} == ${CHOST} ]] &&
443 +- [[ ${EPREFIX} != ${BROOT-${PORTAGE_OVERRIDE_EPREFIX}} ]] &&
444 + :; then
445 +- # When we merge into another EPREFIX, but not into some ROOT,
446 +- # and CHOST is equal to CBUILD, build tools found in EPREFIX
447 +- # perfectly work for the current build environment.
448 +- # In a "stacked prefix" we explicitly utilize this situation.
449 ++ # When we merge into "stacked" EPREFIX, but not into some ROOT, build
450 ++ # tools found in EPREFIX perfectly work for current build environment.
451 + "${FUNCNAME[1]}" "${atom}" && return 0
452 + fi
453 + # END PREFIX LOCAL
454 +diff --git a/lib/portage/const.py b/lib/portage/const.py
455 +index eddce377d..db02cbc56 100644
456 +--- a/lib/portage/const.py
457 ++++ b/lib/portage/const.py
458 +@@ -207,8 +207,6 @@ SUPPORTED_FEATURES = frozenset([
459 + "usersync",
460 + "webrsync-gpg",
461 + "xattr",
462 +- # PREFIX LOCAL
463 +- "stacked-prefix",
464 + ]
465 + )
466 +
467 +--
468 +2.19.2
469 +
470
471 diff --git a/sys-apps/portage/portage-3.0.30.ebuild b/sys-apps/portage/portage-3.0.30.ebuild
472 new file mode 100644
473 index 0000000000..88a5cd8eac
474 --- /dev/null
475 +++ b/sys-apps/portage/portage-3.0.30.ebuild
476 @@ -0,0 +1,307 @@
477 +# Copyright 1999-2022 Gentoo Authors
478 +# Distributed under the terms of the GNU General Public License v2
479 +
480 +EAPI=7
481 +
482 +DISTUTILS_USE_SETUPTOOLS=no
483 +PYTHON_COMPAT=( pypy3 python3_{7..9} )
484 +PYTHON_REQ_USE='bzip2(+),threads(+)'
485 +
486 +inherit distutils-r1 linux-info systemd prefix
487 +
488 +DESCRIPTION="Portage package manager used in Gentoo Prefix"
489 +HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
490 +
491 +LICENSE="GPL-2"
492 +KEYWORDS="~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
493 +SLOT="0"
494 +IUSE="apidoc build doc gentoo-dev +ipc +native-extensions rsync-verify selinux test xattr"
495 +RESTRICT="!test? ( test )"
496 +
497 +BDEPEND="
498 + app-arch/xz-utils
499 + test? ( dev-vcs/git )"
500 +DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
501 + >=app-arch/tar-1.27
502 + dev-lang/python-exec:2
503 + >=sys-apps/sed-4.0.5 sys-devel/patch
504 + doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
505 + apidoc? (
506 + dev-python/sphinx
507 + dev-python/sphinx-epytext
508 + )"
509 +# Require sandbox-2.2 for bug #288863.
510 +# For whirlpool hash, require python[ssl] (bug #425046).
511 +# For compgen, require bash[readline] (bug #445576).
512 +# app-portage/gemato goes without PYTHON_USEDEP since we're calling
513 +# the executable.
514 +RDEPEND="
515 + !prefix? ( acct-user/portage )
516 + app-arch/zstd
517 + >=app-arch/tar-1.27
518 + dev-lang/python-exec:2
519 + >=sys-apps/findutils-4.4
520 + !build? (
521 + >=sys-apps/sed-4.0.5
522 + >=app-shells/bash-5.0:0[readline]
523 + >=app-admin/eselect-1.2
524 + rsync-verify? (
525 + >=app-portage/gemato-14.5[${PYTHON_USEDEP}]
526 + >=sec-keys/openpgp-keys-gentoo-release-20180706
527 + >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
528 + )
529 + )
530 + elibc_glibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) )
531 + elibc_musl? ( >=sys-apps/sandbox-2.2 )
532 + kernel_linux? ( sys-apps/util-linux )
533 + >=app-misc/pax-utils-0.1.18
534 + selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
535 + xattr? ( kernel_linux? (
536 + >=sys-apps/install-xattr-0.3
537 + ) )
538 + !<app-admin/logrotate-3.8.0
539 + !<app-portage/gentoolkit-0.4.6
540 + !<app-portage/repoman-2.3.10
541 + !~app-portage/repoman-3.0.0"
542 +PDEPEND="
543 + !build? (
544 + >=net-misc/rsync-2.6.4
545 + >=sys-apps/file-5.41
546 + >=sys-apps/coreutils-6.4
547 + )"
548 +# coreutils-6.4 rdep is for date format in emerge-webrsync #164532
549 +# NOTE: FEATURES=installsources requires debugedit and rsync
550 +
551 +SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives https://dev.gentoo.org/~grobian/distfiles"
552 +
553 +prefix_src_archives() {
554 + local x y
555 + for x in ${@}; do
556 + for y in ${SRC_ARCHIVES}; do
557 + echo ${y}/${x}
558 + done
559 + done
560 +}
561 +
562 +TARBALL_PV=${PV}
563 +SRC_URI="mirror://gentoo/prefix-${PN}-${TARBALL_PV}.tar.bz2
564 + $(prefix_src_archives prefix-${PN}-${TARBALL_PV}.tar.bz2)"
565 +
566 +S="${WORKDIR}"/prefix-${PN}-${TARBALL_PV}
567 +
568 +pkg_pretend() {
569 + local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS ~UTS_NS"
570 +
571 + check_extra_config
572 +}
573 +
574 +python_prepare_all() {
575 + distutils-r1_python_prepare_all
576 +
577 + eapply "${FILESDIR}"/${PN}-3.0.30-prefix-stack.patch # 658572
578 + eapply "${FILESDIR}"/${PN}-3.0.30-ebuildshell.patch # 155161
579 + if use gentoo-dev; then
580 + einfo "Disabling --dynamic-deps by default for gentoo-dev..."
581 + sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
582 + -i lib/_emerge/create_depgraph_params.py || \
583 + die "failed to patch create_depgraph_params.py"
584 +
585 + einfo "Enabling additional FEATURES for gentoo-dev..."
586 + echo 'FEATURES="${FEATURES} strict-keepdir"' \
587 + >> cnf/make.globals || die
588 + fi
589 +
590 + if use native-extensions; then
591 + printf "[build_ext]\nportage_ext_modules=true\n" >> \
592 + setup.cfg || die
593 + fi
594 +
595 + if ! use ipc ; then
596 + einfo "Disabling ipc..."
597 + sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
598 + -i lib/_emerge/AbstractEbuildProcess.py || \
599 + die "failed to patch AbstractEbuildProcess.py"
600 + fi
601 +
602 + if use xattr && use kernel_linux ; then
603 + einfo "Adding FEATURES=xattr to make.globals ..."
604 + echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
605 + || die "failed to append to make.globals"
606 + fi
607 +
608 + if use build || ! use rsync-verify; then
609 + sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
610 + -e '/^sync-webrsync-verify-signature/s|yes|no|' \
611 + -i cnf/repos.conf || die "sed failed"
612 + fi
613 +
614 + if [[ -n ${EPREFIX} ]] ; then
615 + # PREFIX LOCAL: only hack const_autotool
616 + local extrapath="/usr/sbin:/usr/bin:/sbin:/bin"
617 + # ok, we can't rely on PORTAGE_ROOT_USER being there yet, as people
618 + # tend not to update that often, as long as we are a separate ebuild
619 + # we can assume when unset, it's time for some older trick
620 + if [[ -z ${PORTAGE_ROOT_USER} ]] ; then
621 + PORTAGE_ROOT_USER=$(python -c 'from portage.const import rootuser; print rootuser')
622 + fi
623 + # We need to probe for bash in the Prefix, because it may not
624 + # exist, in which case we fall back to the currently in use
625 + # bash. This logic is necessary in particular during bootstrap,
626 + # where we pull ourselves out of a temporary place with tools
627 + local bash="${EPREFIX}/bin/bash"
628 + [[ ! -x ${bash} ]] && bash=${BASH}
629 +
630 + einfo "Adjusting sources for ${EPREFIX}"
631 + find . -type f -exec \
632 + sed -e "s|@PORTAGE_EPREFIX@|${EPREFIX}|" \
633 + -e "s|@PORTAGE_MV@|$(type -P mv)|" \
634 + -e "s|@PORTAGE_BASH@|${bash}|" \
635 + -e "s|@PREFIX_PORTAGE_PYTHON@|$(type -P python)|" \
636 + -e "s|@EXTRA_PATH@|${extrapath}|" \
637 + -e "s|@portagegroup@|${PORTAGE_GROUP:-portage}|" \
638 + -e "s|@portageuser@|${PORTAGE_USER:-portage}|" \
639 + -e "s|@rootuser@|${PORTAGE_ROOT_USER:-root}|" \
640 + -e "s|@rootuid@|$(id -u ${PORTAGE_ROOT_USER:-root})|" \
641 + -e "s|@rootgid@|$(id -g ${PORTAGE_ROOT_USER:-root})|" \
642 + -e "s|@sysconfdir@|${EPREFIX}/etc|" \
643 + -i '{}' + || \
644 + die "Failed to patch sources"
645 + # We don't need the below, since setup.py deals with this (and
646 + # more) so we don't have to make this correct
647 + # -e "s|@PORTAGE_BASE@|${EPREFIX}/usr/lib/portage/${EPYTHON}|" \
648 +
649 + # remove Makefiles, or else they will get installed
650 + find . -name "Makefile.*" -delete
651 +
652 + einfo "Prefixing shebangs ..."
653 + while read -r -d $'\0' ; do
654 + local shebang=$(head -n1 "$REPLY")
655 + if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
656 + sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
657 + die "sed failed"
658 + fi
659 + done < <(find . -type f ! -name etc-update -print0)
660 +
661 + einfo "Setting gentoo_prefix as reponame for emerge-webrsync"
662 + sed -i -e 's/repo_name=gentoo/repo_name=gentoo_prefix/' \
663 + bin/emerge-webrsync || die
664 +
665 + einfo "Making absent gemato non-fatal"
666 + sed -i -e '/exitcode = 127/d' \
667 + lib/portage/sync/modules/rsync/rsync.py || die
668 + # END PREFIX LOCAL
669 + fi
670 +
671 + # PREFIX LOCAL: make.conf is written by bootstrap-prefix.sh
672 + if use !prefix ; then
673 + cd "${S}/cnf" || die
674 + if [ -f "make.conf.example.${ARCH}".diff ]; then
675 + patch make.conf.example "make.conf.example.${ARCH}".diff || \
676 + die "Failed to patch make.conf.example"
677 + else
678 + eerror ""
679 + eerror "Portage does not have an arch-specific configuration for this arch."
680 + eerror "Please notify the arch maintainer about this issue. Using generic."
681 + eerror ""
682 + fi
683 + fi
684 +}
685 +
686 +python_compile_all() {
687 + local targets=()
688 + use doc && targets+=( docbook )
689 + use apidoc && targets+=( apidoc )
690 +
691 + if [[ ${targets[@]} ]]; then
692 + esetup.py "${targets[@]}"
693 + fi
694 +}
695 +
696 +python_test() {
697 + esetup.py test
698 +}
699 +
700 +python_install() {
701 + # Install sbin scripts to bindir for python-exec linking
702 + # they will be relocated in pkg_preinst()
703 + distutils-r1_python_install \
704 + --system-prefix="${EPREFIX}/usr" \
705 + --bindir="$(python_get_scriptdir)" \
706 + --docdir="${EPREFIX}/usr/share/doc/${PF}" \
707 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
708 + --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
709 + --sbindir="$(python_get_scriptdir)" \
710 + --sysconfdir="${EPREFIX}/etc" \
711 + "${@}"
712 +}
713 +
714 +python_install_all() {
715 + distutils-r1_python_install_all
716 +
717 + local targets=()
718 + use doc && targets+=(
719 + install_docbook
720 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
721 + )
722 + use apidoc && targets+=(
723 + install_apidoc
724 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
725 + )
726 +
727 + # install docs
728 + if [[ ${targets[@]} ]]; then
729 + esetup.py "${targets[@]}"
730 + fi
731 +
732 + dotmpfiles "${FILESDIR}"/portage-ccache.conf
733 +
734 + # Due to distutils/python-exec limitations
735 + # these must be installed to /usr/bin.
736 + local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
737 + einfo "Moving admin scripts to the correct directory"
738 + dodir /usr/sbin
739 + for target in ${sbin_relocations}; do
740 + einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
741 + mv "${ED}/usr/bin/${target}" "${ED}/usr/sbin/${target}" || die "sbin scripts move failed!"
742 + done
743 +}
744 +
745 +pkg_preinst() {
746 + python_setup
747 + local sitedir=$(python_get_sitedir)
748 + [[ -d ${D}${sitedir} ]] || die "${D}${sitedir}: No such directory"
749 + env -u DISTDIR \
750 + -u PORTAGE_OVERRIDE_EPREFIX \
751 + -u PORTAGE_REPOSITORIES \
752 + -u PORTDIR \
753 + -u PORTDIR_OVERLAY \
754 + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
755 + "${PYTHON}" -m portage._compat_upgrade.default_locations || die
756 +
757 + env -u BINPKG_COMPRESS -u PORTAGE_REPOSITORIES \
758 + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
759 + "${PYTHON}" -m portage._compat_upgrade.binpkg_compression || die
760 +
761 + env -u FEATURES -u PORTAGE_REPOSITORIES \
762 + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
763 + "${PYTHON}" -m portage._compat_upgrade.binpkg_multi_instance || die
764 +
765 + # elog dir must exist to avoid logrotate error for bug #415911.
766 + # This code runs in preinst in order to bypass the mapping of
767 + # portage:portage to root:root which happens after src_install.
768 + keepdir /var/log/portage/elog
769 + # This is allowed to fail if the user/group are invalid for prefix users.
770 + if chown ${PORTAGE_USER}:${PORTAGE_GROUP} "${ED}"/var/log/portage{,/elog} 2>/dev/null ; then
771 + chmod g+s,ug+rwx "${ED}"/var/log/portage{,/elog}
772 + fi
773 +
774 + if has_version "<${CATEGORY}/${PN}-2.3.77"; then
775 + elog "The emerge --autounmask option is now disabled by default, except for"
776 + elog "portions of behavior which are controlled by the --autounmask-use and"
777 + elog "--autounmask-license options. For backward compatibility, previous"
778 + elog "behavior of --autounmask=y and --autounmask=n is entirely preserved."
779 + elog "Users can get the old behavior simply by adding --autounmask to the"
780 + elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this"
781 + elog "change, see https://bugs.gentoo.org/658648."
782 + fi
783 +}