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: Thu, 06 Dec 2018 13:49:38
Message-Id: 1544104163.f88f91600be7bd6772d19885d117b29096110001.grobian@gentoo
1 commit: f88f91600be7bd6772d19885d117b29096110001
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 6 13:49:23 2018 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 6 13:49:23 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=f88f9160
7
8 sys-apps/portage: small version bump to allow newer repoman
9
10 Package-Manager: Portage-2.3.45-prefix, Repoman-2.3.12
11 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
12
13 sys-apps/portage/Manifest | 1 +
14 .../portage/files/portage-2.3.45-ebuildshell.patch | 354 +++++++++++++++++++++
15 sys-apps/portage/portage-2.3.45.ebuild | 274 ++++++++++++++++
16 3 files changed, 629 insertions(+)
17
18 diff --git a/sys-apps/portage/Manifest b/sys-apps/portage/Manifest
19 index 61a3d79f0d..f2ff336e7c 100644
20 --- a/sys-apps/portage/Manifest
21 +++ b/sys-apps/portage/Manifest
22 @@ -2,3 +2,4 @@ DIST prefix-portage-2.2.28.tar.bz2 1187416 BLAKE2B 1ec27def0b427f60b38dc60178461
23 DIST prefix-portage-2.3.13.tar.bz2 1205509 BLAKE2B 851492dc1d3bd55721dfc1662af98a193c8071d87b6b64a09a736864031fa6482fe59a1662789ce8320b156241470688a9a815d79f7367b79500e590a41604f5 SHA512 4d59d04b9d6a896a545a40e04973a1c29f421b5d90f08012cb00a27ba1081eb914ddb625f543c26c93c8c75ba690f6ec72e4d9301f4f8e01a5fc68a3438cf46c
24 DIST prefix-portage-2.3.18.tar.bz2 1230290 BLAKE2B 9a7a290493293f166520931aab32a720519ebec15f4c74fe0b0dcd7cc930d591c24e3c87cae4722da119d57826b020b37092ec492bb4e12b774e51334eccf156 SHA512 508a5891fc28297e68baf031f4e99674a58c6268b16d50e094adc6676fb42f81bb81bd6f3dc70c24636be64ae015db51df86c49267c8c5a98129fe5e006310d7
25 DIST prefix-portage-2.3.40.3.tar.bz2 1253190 BLAKE2B 53e60b561e1f9b2a5367a1a23a74ba315358b8e7eb05eead2a46078198b92786745dbd07ab1bf69587866f462955a5dd6c0bc3eb51dbe507bfbff31d899c5f45 SHA512 67c2d7554c9236748b25a8b9f0f60736beda535298395ba2eb86dd5634b6520d645df193914f079d2c61cfa0d8f263f67c3476828319e2395dec2e45cf4b9b14
26 +DIST prefix-portage-2.3.45.tar.bz2 1255719 BLAKE2B 2a53b526418747edc02ab4cc8127425b92e8ae0f7fdc27af730f991f7cb6074aac51cdfd0ca75f7e6376c8059df1e02817963a0386cf1b1986eb798f21b8cf8c SHA512 dfea0774b5d801b3ca02fdd570c89c08b78f4e02e57c1b897a50af0056d4ed4522c6d236dcaf98ea3f1c446b0164abd1b45fd2cae12ed5ef6c34c83668894b5b
27
28 diff --git a/sys-apps/portage/files/portage-2.3.45-ebuildshell.patch b/sys-apps/portage/files/portage-2.3.45-ebuildshell.patch
29 new file mode 100644
30 index 0000000000..e495ee4c24
31 --- /dev/null
32 +++ b/sys-apps/portage/files/portage-2.3.45-ebuildshell.patch
33 @@ -0,0 +1,354 @@
34 +From 8c6b115fa0325b5bed2e1a9c4c8e8af45cdecc2e Mon Sep 17 00:00:00 2001
35 +From: Michael Haubenwallner <michael.haubenwallner@×××××××.at>
36 +Date: Wed, 6 Nov 2013 12:40:05 +0100
37 +Subject: [PATCH 1/2] Add ebuildshell feature, bug#155161.
38 +
39 +---
40 + bin/ebuild.sh | 146 ++++++++++++++++++++++++++++++++++-
41 + bin/filter-bash-environment.py | 55 +++++++++----
42 + bin/save-ebuild-env.sh | 2 +-
43 + man/make.conf.5 | 6 ++
44 + lib/_emerge/AbstractEbuildProcess.py | 1 +
45 + lib/portage/const.py | 1 +
46 + 6 files changed, 194 insertions(+), 17 deletions(-)
47 +
48 +diff --git a/bin/ebuild.sh b/bin/ebuild.sh
49 +index f76a48d8e..683a4e9c1 100755
50 +--- a/bin/ebuild.sh
51 ++++ b/bin/ebuild.sh
52 +@@ -121,7 +121,7 @@ __qa_source() {
53 + __qa_call() {
54 + local shopts=$(shopt) OLDIFS="$IFS"
55 + local retval
56 +- "$@"
57 ++ __call-ebuildshell "$@"
58 + retval=$?
59 + set +e
60 + [[ $shopts != $(shopt) ]] &&
61 +@@ -547,6 +547,150 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
62 + unset BIN_PATH BIN BODY FUNC_SRC
63 + fi
64 +
65 ++__call-ebuildshell() {
66 ++ if ! has ebuildshell ${FEATURES}; then
67 ++ "$@"
68 ++ return $?
69 ++ fi
70 ++ local __ebuildshell_args=( "$@" )
71 ++ # These are the variables I have seen 'bash -i' maintaining the values for:
72 ++ local __ebuildshell_bash_i_vars="__ebuildshell_.*
73 ++ _ BASH_ARGC BASH_ARGV BASH_COMMAND BASH_LINENO BASH_SOURCE
74 ++ BASH_VERSINFO BASH_SUBSHELL BASHOPTS BASHPID COMP_WORDBREAKS
75 ++ DIRSTACK EUID FUNCNAME GROUPS HISTCMD HISTFILE LINENO PIPESTATUS
76 ++ PPID PS1 PS2 PS3 PS4 PWD RANDOM SECONDS SHELLOPTS UID"
77 ++ # Allow recursive ebuildshell, for use in multibuild.eclass and similar:
78 ++ local __ebuildshell_pid=${BASHPID:-$(__bashpid)}
79 ++ local __ebuildshell_tmpf="${T}/ebuildshell.${__ebuildshell_pid}"
80 ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars}
81 ++ (
82 ++ cat <<-EOE
83 ++ # local variables of functions using recursive ebuildshell are
84 ++ # visible to the EXIT trap of that recursive ebuildshell. To
85 ++ # keep them local, we have to filter them from that recursive
86 ++ # ebuildshell's return-env. As 'declare -p' is unable to tell
87 ++ # local-ity of variables, we abuse the trace attribute for local
88 ++ # variables to filter them from the return-env. So we need the
89 ++ # local alias active before declaring any functions.
90 ++ # On a sidehand, this allows for copy&paste of function body
91 ++ # lines including the local keyword.
92 ++ alias local='declare -t'
93 ++ shopt -s expand_aliases
94 ++ EOE
95 ++ (
96 ++ declare -p
97 ++ declare -fp
98 ++ shopt -p
99 ++ [[ ${BASH_VERSINFO[0]} == 3 ]] && export
100 ++ ) |
101 ++ (
102 ++ # we need everything but the bash vars after 'env -i'
103 ++ 2>"${__ebuildshell_tmpf}.ebuild-rovars" \
104 ++ "${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}" \
105 ++ "${PORTAGE_BIN_PATH}"/filter-bash-environment.py \
106 ++ --report-readonly-variables \
107 ++ --preserve-readonly-attribute \
108 ++ "${__ebuildshell_bash_i_vars}" \
109 ++ || die "filter-bash-environment.py failed"
110 ++ )
111 ++ # 'declare -g' is available since bash-4.2,
112 ++ # https://bugs.gentoo.org/show_bug.cgi?id=155161#c35
113 ++ if (( ${BASH_VERSINFO[0]} > 4 )) ||
114 ++ (( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} >= 2 ))
115 ++ then
116 ++ __ebuildshell_bash42_true=
117 ++ __ebuildshell_bash42_false='#bash-4.2#'
118 ++ else
119 ++ __ebuildshell_bash42_true='#bash-4.2#'
120 ++ __ebuildshell_bash42_false=
121 ++ fi
122 ++ # The already readonly variables, without bash maintained ones:
123 ++ __ebuildshell_ro_ebuild_vars=$(<"${__ebuildshell_tmpf}.ebuild-rovars")
124 ++ cat <<-EOE
125 ++ # properly quote the function arguments
126 ++ $(declare -p __ebuildshell_args)
127 ++ set -- "\${__ebuildshell_args[@]}"
128 ++ unset __ebuildshell_args
129 ++ # be informative about what to do
130 ++ PS1="EBUILD ${PN} $1 \$ "
131 ++ type $1
132 ++ ${__ebuildshell_bash42_false}echo 'warning: preserving variables across phases requires bash-4.2'
133 ++ echo "WANTED: \$@"
134 ++ echo "or use: \"\\\$@\""
135 ++ # use bash history, but not the 'user's real one
136 ++ HISTFILE=~/.bash_history
137 ++ # but do not use history-expansion with '!',
138 ++ # for copy&paste of function body lines containing: !
139 ++ set +H
140 ++ # this is a debugging shell already
141 ++ shopt -u extdebug
142 ++ trap - DEBUG
143 ++ # at exit, dump the current environment
144 ++ trap "
145 ++ unalias local
146 ++ unset -f __call-ebuildshell
147 ++ rm -f '${__ebuildshell_tmpf}.return-'*
148 ++ (
149 ++ (
150 ++ # declare -p does not tell the -g flag,
151 ++ # so we add it by aliasing declare.
152 ++ ${__ebuildshell_bash42_true}echo \"alias declare='declare -g'\"
153 ++ declare -p
154 ++ ${__ebuildshell_bash42_true}echo \"unalias declare\"
155 ++ declare -fp
156 ++ shopt -p | grep -v '\\(expand_aliases\\|extdebug\\)$'
157 ++ $([[ ${BASH_VERSINFO[0]} == 3 ]] && echo export)
158 ++ ) |
159 ++ (
160 ++ # We may have more readonly variables now, yet we
161 ++ # need to filter variables that were readonly before.
162 ++ # And filter local variables by their trace attribute.
163 ++ 2>'${__ebuildshell_tmpf}.return-rovars' \\
164 ++ '${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}' \\
165 ++ '${PORTAGE_BIN_PATH}'/filter-bash-environment.py \\
166 ++ --report-readonly-variables \\
167 ++ --preserve-readonly-attribute \\
168 ++ --filter-traced-variables \\
169 ++ '${__ebuildshell_bash_i_vars} \
170 ++ ${__ebuildshell_ro_ebuild_vars}' \\
171 ++ || die 'filter-bash-environment.py failed'
172 ++ )
173 ++ ) > '${__ebuildshell_tmpf}.return-env'
174 ++ " EXIT
175 ++ # can do some cleanup right now
176 ++ rm -f '${__ebuildshell_tmpf}.ebuild-'*
177 ++ EOE
178 ++ ) > "${__ebuildshell_tmpf}.ebuild-env"
179 ++
180 ++ # pre-fill the history with "$@"
181 ++ echo '"$@"' >> ~/.bash_history
182 ++ chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} ~/.bash_history &>/dev/null
183 ++
184 ++ env -i HOME=~ ${BASH} --rcfile "${__ebuildshell_tmpf}.ebuild-env" -i
185 ++
186 ++ # The environment- and exit-status handling after leaving the ebuildshell
187 ++ # prompt is expected to be identical as without the ebuildshell prompt.
188 ++ local __ebuildshell_status=$?
189 ++
190 ++ # We might be in a recursive ebuildshell, but do not want
191 ++ # any aliases being active while sourcing the return-env.
192 ++ local __ebuildshell_orig_aliases=$(alias)
193 ++ unalias -a
194 ++ source "${__ebuildshell_tmpf}.return-env"
195 ++ unalias -a
196 ++ eval "${__ebuildshell_orig_aliases}"
197 ++
198 ++ # Portage has a whitelist of readonly variables: If an ebuild defines
199 ++ # additional readonly variables, their readonly attribute is removed
200 ++ # across ebuild phases. If we ever want to preserve the readonly
201 ++ # attribute of additional ebuild-defined variables across phases,
202 ++ # when returning from the ebuildshell their names are in
203 ++ # "${__ebuildshell_tmpf}.return-rovars"
204 ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars}
205 ++
206 ++ return ${__ebuildshell_status}
207 ++}
208 ++
209 + # Subshell/helper die support (must export for the die helper).
210 + export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
211 + trap 'exit 1' SIGTERM
212 +diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
213 +index 06cac7214..5590dbfc4 100755
214 +--- a/bin/filter-bash-environment.py
215 ++++ b/bin/filter-bash-environment.py
216 +@@ -12,7 +12,8 @@ func_end_re = re.compile(br'^\}$')
217 +
218 + var_assign_re = re.compile(br'(^|^declare\s+-\S+\s+|^declare\s+|^export\s+)([^=\s]+)=("|\')?.*$')
219 + close_quote_re = re.compile(br'(\\"|"|\')\s*$')
220 +-readonly_re = re.compile(br'^declare\s+-(\S*)r(\S*)\s+')
221 ++readonly_re = re.compile(br'^declare\s+-(\S*)r(\S*)\s+([^=\s]+)')
222 ++trace_re = re.compile(br'^declare\s+-\S*t\S*\s+')
223 + # declare without assignment
224 + var_declare_re = re.compile(br'^declare(\s+-\S+)?\s+([^=\s]+)\s*$')
225 +
226 +@@ -27,7 +28,7 @@ def have_end_quote(quote, line):
227 + return close_quote_match is not None and \
228 + close_quote_match.group(1) == quote
229 +
230 +-def filter_declare_readonly_opt(line):
231 ++def filter_declare_readonly_opt(line, options):
232 + readonly_match = readonly_re.match(line)
233 + if readonly_match is not None:
234 + declare_opts = b''
235 +@@ -35,14 +36,19 @@ def filter_declare_readonly_opt(line):
236 + group = readonly_match.group(i)
237 + if group is not None:
238 + declare_opts += group
239 ++ var = readonly_match.group(3)
240 ++ if '--report-readonly-variables' in options:
241 ++ getattr(sys.stderr, 'buffer', sys.stderr).write(var + b'\n')
242 ++ if '--preserve-readonly-attribute' in options:
243 ++ declare_opts += b'r'
244 + if declare_opts:
245 + line = b'declare -' + declare_opts + \
246 +- b' ' + line[readonly_match.end():]
247 ++ b' ' + var + line[readonly_match.end():]
248 + else:
249 +- line = b'declare ' + line[readonly_match.end():]
250 ++ line = b'declare ' + var + line[readonly_match.end():]
251 + return line
252 +
253 +-def filter_bash_environment(pattern, file_in, file_out):
254 ++def filter_bash_environment(pattern, file_in, file_out, options):
255 + # Filter out any instances of the \1 character from variable values
256 + # since this character multiplies each time that the environment
257 + # is saved (strange bash behavior). This can eventually result in
258 +@@ -66,6 +72,8 @@ def filter_bash_environment(pattern, file_in, file_out):
259 + quote = var_assign_match.group(3)
260 + filter_this = pattern.match(var_assign_match.group(2)) \
261 + is not None
262 ++ if not filter_this and '--filter-traced-variables' in options:
263 ++ filter_this = trace_re.match(line) is not None
264 + # Exclude the start quote when searching for the end quote,
265 + # to ensure that the start quote is not misidentified as the
266 + # end quote (happens if there is a newline immediately after
267 +@@ -75,7 +83,7 @@ def filter_bash_environment(pattern, file_in, file_out):
268 + multi_line_quote = quote
269 + multi_line_quote_filter = filter_this
270 + if not filter_this:
271 +- line = filter_declare_readonly_opt(line)
272 ++ line = filter_declare_readonly_opt(line, options)
273 + file_out.write(line.replace(b"\1", b""))
274 + continue
275 + else:
276 +@@ -84,8 +92,10 @@ def filter_bash_environment(pattern, file_in, file_out):
277 + # declare without assignment
278 + filter_this = pattern.match(declare_match.group(2)) \
279 + is not None
280 ++ if not filter_this and '--filter-traced-variables' in options:
281 ++ filter_this = trace_re.match(line) is not None
282 + if not filter_this:
283 +- line = filter_declare_readonly_opt(line)
284 ++ line = filter_declare_readonly_opt(line, options)
285 + file_out.write(line)
286 + continue
287 +
288 +@@ -122,13 +132,28 @@ if __name__ == "__main__":
289 + "while leaving bash function definitions and here-documents " + \
290 + "intact. The PATTERN is a space separated list of variable names" + \
291 + " and it supports python regular expression syntax."
292 +- usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0])
293 +- args = sys.argv[1:]
294 +-
295 +- if '-h' in args or '--help' in args:
296 +- sys.stdout.write(usage + "\n")
297 +- sys.stdout.flush()
298 +- sys.exit(os.EX_OK)
299 ++ usage = "usage: %s [-h|<options>] PATTERN" % os.path.basename(sys.argv[0])
300 ++ args = []
301 ++ known_options = {
302 ++ '--report-readonly-variables':
303 ++ "Write names of readonly variables to stderr.",
304 ++ '--preserve-readonly-attribute':
305 ++ "Preserve the '-r' flag in 'declare -r'.",
306 ++ '--filter-traced-variables':
307 ++ "Filter out variables declared with '-t' attribute."
308 ++ }
309 ++ options = {}
310 ++ for arg in sys.argv[1:]:
311 ++ if arg in known_options.keys():
312 ++ options[arg] = True
313 ++ continue
314 ++ if '-h' == arg or '--help' == arg:
315 ++ sys.stdout.write(usage + "\n\nKnown <options>:\n\n")
316 ++ for option, descr in known_options.items():
317 ++ sys.stdout.write(" " + option + "\t" + descr + "\n")
318 ++ sys.stdout.flush()
319 ++ sys.exit(os.EX_OK)
320 ++ args.append(arg)
321 +
322 + if len(args) != 1:
323 + sys.stderr.write(usage + "\n")
324 +@@ -151,5 +176,5 @@ if __name__ == "__main__":
325 +
326 + var_pattern = b'^(' + b'|'.join(var_pattern) + b')$'
327 + filter_bash_environment(
328 +- re.compile(var_pattern), file_in, file_out)
329 ++ re.compile(var_pattern), file_in, file_out, options)
330 + file_out.flush()
331 +diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
332 +index bb17382d4..af35a3327 100755
333 +--- a/bin/save-ebuild-env.sh
334 ++++ b/bin/save-ebuild-env.sh
335 +@@ -53,7 +53,7 @@ __save_ebuild_env() {
336 + einfo einfon ewarn eerror ebegin __eend eend KV_major \
337 + KV_minor KV_micro KV_to_int get_KV has \
338 + __has_phase_defined_up_to \
339 +- hasv hasq __qa_source __qa_call \
340 ++ hasv hasq __qa_source __qa_call __call-ebuildshell \
341 + addread addwrite adddeny addpredict __sb_append_var \
342 + use usev useq has_version portageq \
343 + best_version use_with use_enable register_die_hook \
344 +diff --git a/man/make.conf.5 b/man/make.conf.5
345 +index b0c1aa4f2..568f350a0 100644
346 +--- a/man/make.conf.5
347 ++++ b/man/make.conf.5
348 +@@ -408,6 +408,12 @@ exist). Also see the related \fIunmerge\-backup\fR feature.
349 + Use locks to ensure that unsandboxed ebuild phases never execute
350 + concurrently. Also see \fIparallel\-install\fR.
351 + .TP
352 ++.B ebuildshell
353 ++Drop into an interactive shell for each phase function, meant for
354 ++debugging. Because the shell would normally be used to execute the
355 ++phase function, commands like src_unpack or epatch are available in the
356 ++interactive shell. Use `die` to terminate the merge.
357 ++.TP
358 + .B fail\-clean
359 + Clean up temporary files after a build failure. This is particularly useful
360 + if you have \fBPORTAGE_TMPDIR\fR on tmpfs. If this feature is enabled, you
361 +diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py
362 +index 370cac529..a521596e5 100644
363 +--- a/lib/_emerge/AbstractEbuildProcess.py
364 ++++ b/lib/_emerge/AbstractEbuildProcess.py
365 +@@ -181,6 +181,7 @@ class AbstractEbuildProcess(SpawnProcess):
366 + self.fd_pipes = {}
367 + null_fd = None
368 + if 0 not in self.fd_pipes and \
369 ++ "ebuildshell" not in self.settings.features and \
370 + self.phase not in self._phases_interactive_whitelist and \
371 + "interactive" not in self.settings.get("PROPERTIES", "").split():
372 + null_fd = os.open('/dev/null', os.O_RDONLY)
373 +diff --git a/lib/portage/const.py b/lib/portage/const.py
374 +index 3c23c85ed..d9c57f300 100644
375 +--- a/lib/portage/const.py
376 ++++ b/lib/portage/const.py
377 +@@ -161,6 +161,7 @@ SUPPORTED_FEATURES = frozenset([
378 + "distlocks",
379 + "downgrade-backup",
380 + "ebuild-locks",
381 ++ "ebuildshell",
382 + "fail-clean",
383 + "fakeroot",
384 + "fixlafiles",
385 +--
386 +2.16.1
387 +
388
389 diff --git a/sys-apps/portage/portage-2.3.45.ebuild b/sys-apps/portage/portage-2.3.45.ebuild
390 new file mode 100644
391 index 0000000000..ee4c5d27f7
392 --- /dev/null
393 +++ b/sys-apps/portage/portage-2.3.45.ebuild
394 @@ -0,0 +1,274 @@
395 +# Copyright 1999-2018 Gentoo Authors
396 +# Distributed under the terms of the GNU General Public License v2
397 +
398 +EAPI=5
399 +
400 +PYTHON_COMPAT=(
401 + pypy
402 + python3_4 python3_5 python3_6 python3_7
403 + python2_7
404 +)
405 +PYTHON_REQ_USE='bzip2(+),threads(+)'
406 +
407 +inherit eutils distutils-r1 multilib
408 +
409 +DESCRIPTION="Portage package manager used in Gentoo Prefix"
410 +HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
411 +LICENSE="GPL-2"
412 +KEYWORDS="~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
413 +SLOT="0"
414 +IUSE="build doc epydoc +ipc +native-extensions selinux xattr prefix-chaining"
415 +
416 +DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
417 + >=app-arch/tar-1.27
418 + dev-lang/python-exec:2
419 + >=sys-apps/sed-4.0.5 sys-devel/patch
420 + doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
421 + epydoc? ( >=dev-python/epydoc-2.0[$(python_gen_usedep 'python2*')] )"
422 +# Require sandbox-2.2 for bug #288863.
423 +# For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
424 +# quite slow, so it's not considered in the dependencies as an alternative to
425 +# to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
426 +# for now, don't pull in xattr deps for other kernels.
427 +# For whirlpool hash, require python[ssl] (bug #425046).
428 +# For compgen, require bash[readline] (bug #445576).
429 +RDEPEND="
430 + >=app-arch/tar-1.27
431 + dev-lang/python-exec:2
432 + !build? (
433 + >=sys-apps/sed-4.0.5
434 + app-shells/bash:0[readline]
435 + >=app-admin/eselect-1.2
436 + $(python_gen_cond_dep 'dev-python/pyblake2[${PYTHON_USEDEP}]' \
437 + python{2_7,3_4,3_5} pypy)
438 + )
439 + elibc_FreeBSD? ( !prefix? ( sys-freebsd/freebsd-bin ) )
440 + elibc_glibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) )
441 + elibc_uclibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) )
442 + kernel_linux? ( >=app-misc/pax-utils-0.1.17 )
443 + kernel_SunOS? ( >=app-misc/pax-utils-0.1.17 )
444 + kernel_FreeBSD? ( >=app-misc/pax-utils-0.1.17 )
445 + kernel_Darwin? ( >=app-misc/pax-utils-0.1.18 )
446 + kernel_AIX? ( >=sys-apps/aix-miscutils-0.1.1634 )
447 + selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
448 + xattr? ( kernel_linux? (
449 + >=sys-apps/install-xattr-0.3
450 + $(python_gen_cond_dep 'dev-python/pyxattr[${PYTHON_USEDEP}]' \
451 + python2_7 pypy)
452 + ) )
453 + !<app-admin/logrotate-3.8.0"
454 +PDEPEND="
455 + !build? (
456 + >=net-misc/rsync-2.6.4
457 + userland_GNU? ( >=sys-apps/coreutils-6.4 )
458 + )"
459 +# coreutils-6.4 rdep is for date format in emerge-webrsync #164532
460 +# NOTE: FEATURES=installsources requires debugedit and rsync
461 +
462 +REQUIRED_USE="epydoc? ( $(python_gen_useflags 'python2*') )"
463 +
464 +SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives https://dev.gentoo.org/~grobian/distfiles"
465 +
466 +prefix_src_archives() {
467 + local x y
468 + for x in ${@}; do
469 + for y in ${SRC_ARCHIVES}; do
470 + echo ${y}/${x}
471 + done
472 + done
473 +}
474 +
475 +TARBALL_PV=${PV}
476 +SRC_URI="mirror://gentoo/prefix-${PN}-${TARBALL_PV}.tar.bz2
477 + $(prefix_src_archives prefix-${PN}-${TARBALL_PV}.tar.bz2)"
478 +
479 +S="${WORKDIR}"/prefix-${PN}-${TARBALL_PV}
480 +
481 +pkg_setup() {
482 + use epydoc && DISTUTILS_ALL_SUBPHASE_IMPLS=( python2.7 )
483 +}
484 +
485 +python_prepare_all() {
486 + distutils-r1_python_prepare_all
487 +
488 + epatch "${FILESDIR}"/${PN}-2.3.45-ebuildshell.patch # 155161
489 + use prefix-chaining && # maybe useful even with stacked-prefix
490 + epatch "${FILESDIR}"/${PN}-2.3.40-prefix-chaining.patch
491 +
492 + if use native-extensions; then
493 + printf "[build_ext]\nportage-ext-modules=true\n" >> \
494 + setup.cfg || die
495 + fi
496 +
497 + if ! use ipc ; then
498 + einfo "Disabling ipc..."
499 + sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
500 + -i lib/_emerge/AbstractEbuildProcess.py || \
501 + die "failed to patch AbstractEbuildProcess.py"
502 + fi
503 +
504 + if use xattr && use kernel_linux ; then
505 + einfo "Adding FEATURES=xattr to make.globals ..."
506 + echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
507 + || die "failed to append to make.globals"
508 + fi
509 +
510 + if [[ -n ${EPREFIX} ]] ; then
511 + # PREFIX LOCAL: only hack const_autotool
512 + local extrapath="/usr/sbin:/usr/bin:/sbin:/bin"
513 + # ok, we can't rely on PORTAGE_ROOT_USER being there yet, as people
514 + # tend not to update that often, as long as we are a separate ebuild
515 + # we can assume when unset, it's time for some older trick
516 + if [[ -z ${PORTAGE_ROOT_USER} ]] ; then
517 + PORTAGE_ROOT_USER=$(python -c 'from portage.const import rootuser; print rootuser')
518 + fi
519 + local defaultpath="${EPREFIX}/usr/sbin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/bin"
520 + # We need to probe for bash in the Prefix, because it may not
521 + # exist, in which case we fall back to the currently in use
522 + # bash. This logic is necessary in particular during bootstrap,
523 + # where we pull ourselves out of a temporary place with tools
524 + local bash="${EPREFIX}/bin/bash"
525 + [[ ! -x ${bash} ]] && bash=${BASH}
526 +
527 + einfo "Adjusting sources for ${EPREFIX}"
528 + find . -type f -exec \
529 + sed -e "s|@PORTAGE_EPREFIX@|${EPREFIX}|" \
530 + -e "s|@PORTAGE_MV@|$(type -P mv)|" \
531 + -e "s|@PORTAGE_BASH@|${bash}|" \
532 + -e "s|@PREFIX_PORTAGE_PYTHON@|$(type -P python)|" \
533 + -e "s|@DEFAULT_PATH@|${defaultpath}|" \
534 + -e "s|@EXTRA_PATH@|${extrapath}|" \
535 + -e "s|@portagegroup@|${PORTAGE_GROUP:-portage}|" \
536 + -e "s|@portageuser@|${PORTAGE_USER:-portage}|" \
537 + -e "s|@rootuser@|${PORTAGE_ROOT_USER:-root}|" \
538 + -e "s|@rootuid@|$(id -u ${PORTAGE_ROOT_USER:-root})|" \
539 + -e "s|@rootgid@|$(id -g ${PORTAGE_ROOT_USER:-root})|" \
540 + -e "s|@sysconfdir@|${EPREFIX}/etc|" \
541 + -i '{}' + || \
542 + die "Failed to patch sources"
543 + # We don't need the below, since setup.py deals with this (and
544 + # more) so we don't have to make this correct
545 + # -e "s|@PORTAGE_BASE@|${EPREFIX}/usr/lib/portage/${EPYTHON}|" \
546 +
547 + # remove Makefiles, or else they will get installed
548 + find . -name "Makefile.*" -delete
549 +
550 + einfo "Prefixing shebangs ..."
551 + while read -r -d $'\0' ; do
552 + local shebang=$(head -n1 "$REPLY")
553 + if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
554 + sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
555 + die "sed failed"
556 + fi
557 + done < <(find . -type f -print0)
558 +
559 + einfo "Setting gentoo_prefix as reponame for emerge-webrsync"
560 + sed -i -e 's/repo_name=gentoo/repo_name=gentoo_prefix/' \
561 + bin/emerge-webrsync || die
562 +
563 + einfo "Making absent gemato non-fatal"
564 + sed -i -e '/exitcode = 127/d' \
565 + lib/portage/sync/modules/rsync/rsync.py || die
566 +
567 + if [[ ${CHOST} == powerpc*-darwin* ]] ; then
568 + # asyncio triggers some python bug, not worth fixing on
569 + # ppc-macos, bug #656830
570 + sed -i -e '/^_asyncio_enabled/s/=.*$/= False/' \
571 + lib/portage/util/_eventloop/global_event_loop.py || die
572 + fi
573 + # END PREFIX LOCAL
574 + fi
575 +
576 + # PREFIX LOCAL: make.conf is written by bootstrap-prefix.sh
577 + if use !prefix ; then
578 + cd "${S}/cnf" || die
579 + if [ -f "make.conf.example.${ARCH}".diff ]; then
580 + patch make.conf.example "make.conf.example.${ARCH}".diff || \
581 + die "Failed to patch make.conf.example"
582 + else
583 + eerror ""
584 + eerror "Portage does not have an arch-specific configuration for this arch."
585 + eerror "Please notify the arch maintainer about this issue. Using generic."
586 + eerror ""
587 + fi
588 + fi
589 +}
590 +
591 +python_compile_all() {
592 + local targets=()
593 + use doc && targets+=( docbook )
594 + use epydoc && targets+=( epydoc )
595 +
596 + if [[ ${targets[@]} ]]; then
597 + esetup.py "${targets[@]}"
598 + fi
599 +}
600 +
601 +python_test() {
602 + esetup.py test
603 +}
604 +
605 +python_install() {
606 + # Install sbin scripts to bindir for python-exec linking
607 + # they will be relocated in pkg_preinst()
608 + distutils-r1_python_install \
609 + --system-prefix="${EPREFIX}/usr" \
610 + --bindir="$(python_get_scriptdir)" \
611 + --docdir="${EPREFIX}/usr/share/doc/${PF}" \
612 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
613 + --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
614 + --sbindir="$(python_get_scriptdir)" \
615 + --sysconfdir="${EPREFIX}/etc" \
616 + "${@}"
617 +}
618 +
619 +python_install_all() {
620 + distutils-r1_python_install_all
621 +
622 + local targets=()
623 + use doc && targets+=(
624 + install_docbook
625 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
626 + )
627 + use epydoc && targets+=(
628 + install_epydoc
629 + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
630 + )
631 +
632 + # install docs
633 + if [[ ${targets[@]} ]]; then
634 + esetup.py "${targets[@]}"
635 + fi
636 +
637 + # Due to distutils/python-exec limitations
638 + # these must be installed to /usr/bin.
639 + local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
640 + einfo "Moving admin scripts to the correct directory"
641 + dodir /usr/sbin
642 + for target in ${sbin_relocations}; do
643 + einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
644 + mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
645 + done
646 +}
647 +
648 +pkg_preinst() {
649 + # comment out sanity test until it is fixed to work
650 + # with the new PORTAGE_PYM_PATH
651 + #if [[ $ROOT == / ]] ; then
652 + ## Run some minimal tests as a sanity check.
653 + #local test_runner=$(find "${ED}" -name runTests)
654 + #if [[ -n $test_runner && -x $test_runner ]] ; then
655 + #einfo "Running preinst sanity tests..."
656 + #"$test_runner" || die "preinst sanity tests failed"
657 + #fi
658 + #fi
659 +
660 + # elog dir must exist to avoid logrotate error for bug #415911.
661 + # This code runs in preinst in order to bypass the mapping of
662 + # portage:portage to root:root which happens after src_install.
663 + keepdir /var/log/portage/elog
664 + # This is allowed to fail if the user/group are invalid for prefix users.
665 + if chown ${PORTAGE_USER}:${PORTAGE_GROUP} "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
666 + chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
667 + fi
668 +}