Gentoo Archives: gentoo-commits

From: Michael Haubenwallner <haubi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-portage/prefix-toolkit/
Date: Wed, 04 Sep 2019 10:31:35
Message-Id: 1567593045.54b026b7d865a5936b16d099da8fabc372d5bd10.haubi@gentoo
1 commit: 54b026b7d865a5936b16d099da8fabc372d5bd10
2 Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 4 10:27:33 2019 +0000
4 Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 4 10:30:45 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54b026b7
7
8 app-portage/prefix-toolkit: revbump
9
10 startprefix:
11 * On Cygwin (assumed when /proc/registry/ is available), also preserve
12 SYSTEMDRIVE, COMSPEC and TEMP env vars, for native Windows programs.
13
14 prefix-stack-setup:
15 * Give the child prefix a private PORTAGE_TMPDIR, to not lock
16 PORTAGE_TMPDIR in base prefix when merging in multiple childs.
17 * Define clean CFLAGS/CXXFLAGS for the child prefix, it may use a
18 different compiler. Instead, preserve the base prefix' CFLAGS/CXXFLAGS
19 via package.env only for packages using the base prefix compiler.
20
21 Package-Manager: Portage-2.3.69, Repoman-2.3.16
22 Signed-off-by: Michael Haubenwallner <haubi <AT> gentoo.org>
23
24 app-portage/prefix-toolkit/prefix-toolkit-5.ebuild | 665 +++++++++++++++++++++
25 1 file changed, 665 insertions(+)
26
27 diff --git a/app-portage/prefix-toolkit/prefix-toolkit-5.ebuild b/app-portage/prefix-toolkit/prefix-toolkit-5.ebuild
28 new file mode 100644
29 index 00000000000..88068a06a24
30 --- /dev/null
31 +++ b/app-portage/prefix-toolkit/prefix-toolkit-5.ebuild
32 @@ -0,0 +1,665 @@
33 +# Copyright 1999-2019 Gentoo Authors
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=7
37 +
38 +DESCRIPTION="Utilities for users of Gentoo Prefix"
39 +HOMEPAGE="https://prefix.gentoo.org/"
40 +SRC_URI=""
41 +
42 +LICENSE="GPL-3"
43 +SLOT="0"
44 +
45 +[[ ${PV} == 9999 ]] ||
46 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
47 +
48 +DEPEND="
49 + !app-portage/prefix-chain-setup
50 + !sys-apps/prefix-chain-utils
51 +"
52 +BDEPEND="${DEPEND}
53 + >sys-apps/portage-2.3.62
54 +"
55 +# In prefix-stack, these dependencies actually are the @system set,
56 +# as we rely on the base prefix anyway for package management,
57 +# which should have a proper @system set.
58 +# See als: pkg_preinst
59 +RDEPEND="${DEPEND}
60 + prefix-stack? (
61 + >=sys-apps/baselayout-prefix-2.6
62 + sys-apps/gentoo-functions
63 + app-portage/elt-patches
64 + sys-devel/gnuconfig
65 + sys-devel/gcc-config
66 + )
67 +"
68 +
69 +S="${WORKDIR}"
70 +
71 +my_unpack() {
72 + local infile=$1
73 + local outfile=${2:-${infile}}
74 + ebegin "extracting ${outfile}"
75 + sed -ne "/^: ${infile} /,/EOIN/{/EOIN/d;p}" "${EBUILD}" \
76 + > "${outfile}" || die "Failed to unpack ${outfile}"
77 + eend $?
78 +}
79 +
80 +src_unpack() {
81 + if use prefix-stack ; then
82 + my_unpack prefix-stack.bash_login
83 + my_unpack prefix-stack.bashrc
84 + my_unpack prefix-stack.envd.99stack
85 + my_unpack prefix-stack-ccwrap
86 + local editor pager
87 + for editor in "${EDITOR}" {"${EPREFIX}","${BROOT}"}/bin/nano
88 + do
89 + [[ -x ${editor} ]] || continue
90 + done
91 + for pager in "${PAGER}" {"${EPREFIX}","${BROOT}"}/usr/bin/less
92 + do
93 + [[ -x ${pager} ]] || continue
94 + done
95 + printf '%s\n' "EDITOR=\"${editor}\"" "PAGER=\"${pager}\"" > 000fallback
96 + else
97 + my_unpack prefix-stack-setup
98 + fi
99 + my_unpack startprefix
100 +}
101 +
102 +my_prefixify() {
103 + local ebash eenv
104 + if use prefix-stack ; then
105 + ebash="${BROOT}/bin/bash"
106 + eenv="${BROOT}/usr/bin/env"
107 + else
108 + ebash="${EPREFIX}/bin/bash"
109 + eenv="${EPREFIX}/usr/bin/env"
110 + fi
111 +
112 + # the @=@ prevents repoman from believing we set readonly vars
113 + sed -e "s,@GENTOO_PORTAGE_BPREFIX@,${BROOT},g" \
114 + -e "s,@GENTOO_PORTAGE_EPREFIX@,${EPREFIX},g" \
115 + -e "s,@GENTOO_PORTAGE_CHOST@,${CHOST},g" \
116 + -e "s,@GENTOO_PORTAGE_EBASH@,${ebash},g" \
117 + -e "s,@GENTOO_PORTAGE_EENV@,${eenv},g" \
118 + -e "s,@=@,=,g" \
119 + -i "$@" || die
120 +}
121 +
122 +src_configure() {
123 + # do not eprefixify during unpack, to allow userpatches to apply
124 + my_prefixify *
125 +}
126 +
127 +src_install-prefix-stack-ccwrap() {
128 + # install toolchain wrapper.
129 + local wrapperdir=/usr/${CHOST}/gcc-bin/${CHOST}-${PN}/${PV}
130 + local wrappercfg=${CHOST}-${P}
131 +
132 + exeinto $wrapperdir
133 + doexe prefix-stack-ccwrap
134 +
135 + local cc
136 + for cc in \
137 + gcc \
138 + g++ \
139 + cpp \
140 + c++ \
141 + windres \
142 + ; do
143 + dosym prefix-stack-ccwrap $wrapperdir/${CHOST}-${cc}
144 + dosym ${CHOST}-${cc} $wrapperdir/${cc}
145 + done
146 +
147 + # LDPATH is required to keep gcc-config happy :(
148 + cat > ./${wrappercfg} <<-EOF
149 + GCC_PATH="${EPREFIX}$wrapperdir"
150 + LDPATH="${EPREFIX}$wrapperdir"
151 + EOF
152 +
153 + insinto /etc/env.d/gcc
154 + doins ./${wrappercfg}
155 +}
156 +
157 +src_install() {
158 + if use prefix-stack; then
159 + src_install-prefix-stack-ccwrap
160 + insinto /etc
161 + doins prefix-stack.bash_login
162 + insinto /etc/bash
163 + newins prefix-stack.bashrc bashrc
164 + newenvd prefix-stack.envd.99stack 99stack
165 + doenvd 000fallback
166 + else
167 + dobin prefix-stack-setup
168 + fi
169 + exeinto /
170 + doexe startprefix
171 +}
172 +
173 +pkg_preinst() {
174 + use prefix-stack || return 0
175 + ebegin "Purging @system package set for prefix stack"
176 + # In prefix stack we empty out the @system set defined via make.profile,
177 + # as we may be using some normal profile, but that @system set applies
178 + # to the base prefix only.
179 + # Instead, we only put ourselve into the @system set, and have additional
180 + # @system packages in our RDEPEND.
181 + my_lsprofile() {
182 + (
183 + cd -P "${1:-.}" || exit 1
184 + [[ -r ./parent ]] &&
185 + for p in $(<parent)
186 + do
187 + my_lsprofile "${p}" || exit 1
188 + done
189 + pwd -P
190 + )
191 + }
192 + local systemset="/etc/portage/profile/packages"
193 + dodir "${systemset%/*}"
194 + [[ -s ${EROOT}${systemset} ]] &&
195 + grep -v "# maintained by ${PN}" \
196 + "${EROOT}${systemset}" \
197 + > "${ED}${systemset}"
198 + local p
199 + for p in $(my_lsprofile "${EPREFIX}"/etc/portage/make.profile)
200 + do
201 + [[ -s ${p}/${systemset##*/} ]] || continue
202 + awk '/^[ \t]*[^-#]/{print "-" $1 " # maintained by '"${PN}-${PVR}"'"}' \
203 + < "${p}"/packages || die
204 + done | sort -u >> "${ED}${systemset}"
205 + [[ ${PIPESTATUS[@]} == "0 0" ]] || die "failed to collect for ${systemset}"
206 + echo "*${CATEGORY}/${PN} # maintained by ${PN}-${PVR}" >> "${ED}${systemset}" || die
207 + eend $?
208 +}
209 +
210 +return 0
211 +
212 +: startprefix <<'EOIN'
213 +#!@GENTOO_PORTAGE_EBASH@
214 +# Copyright 1999-2019 Gentoo Authors
215 +# Distributed under the terms of the GNU General Public License v2
216 +
217 +# Fabian Groffen <grobian@g.o> -- 2007-03-10
218 +# Enters the prefix environment by starting a login shell from the
219 +# prefix. The SHELL environment variable is elevated in order to make
220 +# applications that start login shells to work, such as `screen`.
221 +
222 +# if you come from a substantially polluted environment (another
223 +# Prefix), a cleanup as follows resolves most oddities I've ever seen:
224 +# env -i HOME=$HOME TERM=$TERM USER=$USER $SHELL -l
225 +# hence this script starts the Prefix shell like this
226 +
227 +if [[ ${SHELL#@GENTOO_PORTAGE_EPREFIX@} != ${SHELL} ]]
228 +then
229 + echo "You appear to be in prefix already (SHELL=${SHELL})" > /dev/stderr
230 + exit -1
231 +elif [[ ${SHELL#@GENTOO_PORTAGE_BPREFIX@} != ${SHELL} ]] &&
232 + [[ ${EPREFIX-unset} == '@GENTOO_PORTAGE_EPREFIX@' ]]
233 +then
234 + echo "You appear to be in stacked prefix already (EPREFIX=${EPREFIX})" > /dev/stderr
235 + exit -1
236 +fi
237 +
238 +# What is our prefix?
239 +EPREFIX@=@'@GENTOO_PORTAGE_EPREFIX@'
240 +BPREFIX@=@'@GENTOO_PORTAGE_BPREFIX@'
241 +
242 +# not all systems have the same location for shells, however what it
243 +# boils down to, is that we need to know what the shell is, and then we
244 +# can find it in the bin dir of our prefix
245 +for SHELL in \
246 + "${EPREFIX}/bin/${SHELL##*/}" \
247 + "${BPREFIX}/bin/${SHELL##*/}" \
248 + ${SHELL##*/}
249 +do
250 + [[ ${SHELL} == */* && -x ${SHELL} ]] && break
251 +done
252 +
253 +# check if the shell exists
254 +if [[ ${SHELL} != */* ]]
255 +then
256 + echo "Failed to find the Prefix shell, this is probably" > /dev/stderr
257 + echo "because you didn't emerge the shell ${SHELL}" > /dev/stderr
258 + exit 1
259 +fi
260 +
261 +# set the prefix shell in the environment
262 +export SHELL
263 +
264 +# give a small notice
265 +echo "Entering Gentoo Prefix ${EPREFIX}"
266 +# start the login shell, clean the entire environment but what's needed
267 +RETAIN="HOME=$HOME TERM=$TERM USER=$USER SHELL=$SHELL"
268 +# PROFILEREAD is necessary on SUSE not to wipe the env on shell start
269 +[[ -n ${PROFILEREAD} ]] && RETAIN+=" PROFILEREAD=$PROFILEREAD"
270 +# ssh-agent is handy to keep, of if set, inherit it
271 +[[ -n ${SSH_AUTH_SOCK} ]] && RETAIN+=" SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
272 +# if we're on some X terminal, makes sense to inherit that too
273 +[[ -n ${DISPLAY} ]] && RETAIN+=" DISPLAY=$DISPLAY"
274 +if [[ -d /proc/registry ]]; then # we're on Cygwin
275 + # crucial to Windows but cannot be restored, see
276 + # https://cygwin.com/ml/cygwin/2019-08/msg00072.html
277 + [[ -n ${SYSTEMDRIVE} ]] && RETAIN+=" SYSTEMDRIVE=$SYSTEMDRIVE"
278 + # COMSPEC is to native Windows what SHELL is to *nix
279 + [[ -n ${COMSPEC} ]] && RETAIN+=" COMSPEC=$COMSPEC"
280 + # some Windows programs (e.g. devenv.exe) need TMP or TEMP
281 + [[ -n ${TEMP} ]] && RETAIN+=" TEMP=$TEMP"
282 +fi
283 +# do it!
284 +if [[ ${SHELL#${EPREFIX}} != ${SHELL} ]] ; then
285 + '@GENTOO_PORTAGE_EENV@' -i $RETAIN $SHELL -l
286 +elif [[ ' bash ' == *" ${SHELL##*/} "* ]] ; then
287 + # shell coming from different prefix would load it's own
288 + # etc/profile upon -l, so we have to override
289 + '@GENTOO_PORTAGE_EENV@' -i ${RETAIN} "${SHELL}" --rcfile "${EPREFIX}"/etc/prefix-stack.bash_login -i
290 +else
291 + echo "Only bash is supported with stacked Prefix (you have ${SHELL##*/}), sorry!" > /dev/stderr
292 + exit 1
293 +fi
294 +# and leave a message when we exit... the shell might return non-zero
295 +# without having real problems, so don't send alarming messages about
296 +# that
297 +echo "Leaving Gentoo Prefix with exit status $?"
298 +EOIN
299 +
300 +: prefix-stack.bashrc <<'EOIN'
301 +# Copyright 1999-2019 Gentoo Authors
302 +# Distributed under the terms of the GNU General Public License v2
303 +#
304 +# In stacked Prefix there is no bash installed, yet
305 +# etc/bash/bashrc from base Prefix still is useful.
306 +#
307 +
308 +if [[ $- != *i* ]] ; then
309 + # Shell is non-interactive, bashrc does not apply
310 + return
311 +fi
312 +
313 +if [[ -r @GENTOO_PORTAGE_BPREFIX@/etc/bash/bashrc ]] ; then
314 + source '@GENTOO_PORTAGE_BPREFIX@/etc/bash/bashrc'
315 + # only if base Prefix does have an etc/bash/bashrc, we also
316 + # run bashrc snippets provided by packages in stacked Prefix
317 + for sh in '@GENTOO_PORTAGE_EPREFIX@'/etc/bash/bashrc.d/* ; do
318 + [[ -r ${sh} ]] && source "${sh}"
319 + done
320 + unset sh
321 +else
322 + # etc/profile does expect etc/bash/bashrc to set PS1
323 + PS1='\u@\h \w \$ '
324 +fi
325 +EOIN
326 +
327 +: prefix-stack.bash_login <<'EOIN'
328 +# Copyright 1999-2019 Gentoo Authors
329 +# Distributed under the terms of the GNU General Public License v2
330 +#
331 +# In stacked Prefix there is no bash installed, so there is
332 +# no bash able to load this Prefix' profile as login shell.
333 +# Instead, you can specify this one as bash rcfile to mimic
334 +# a bash login shell using this stacked Prefix profile.
335 +#
336 +
337 +if [[ -s '@GENTOO_PORTAGE_EPREFIX@/etc/profile' ]] ; then
338 + . '@GENTOO_PORTAGE_EPREFIX@/etc/profile'
339 +fi
340 +if [[ -s ~/.bash_profile ]] ; then
341 + . ~/.bash_profile
342 +elif [[ -s ~/.bash_login ]] ; then
343 + . ~/.bash_login
344 +elif [[ -s ~/.profile ]] ; then
345 + . ~/.profile
346 +fi
347 +EOIN
348 +
349 +: prefix-stack.envd.99stack <<'EOIN'
350 +PKG_CONFIG_PATH@=@"@GENTOO_PORTAGE_EPREFIX@/usr/lib/pkgconfig:@GENTOO_PORTAGE_EPREFIX@/usr/share/pkgconfig"
351 +PORTAGE_CONFIGROOT@=@"@GENTOO_PORTAGE_EPREFIX@"
352 +EPREFIX@=@"@GENTOO_PORTAGE_EPREFIX@"
353 +EOIN
354 +
355 +: prefix-stack-setup <<'EOIN'
356 +#!@GENTOO_PORTAGE_EPREFIX@/bin/bash
357 +# Copyright 1999-2019 Gentoo Authors
358 +# Distributed under the terms of the GNU General Public License v2
359 +
360 +PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
361 +PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
362 +CHILD_EPREFIX=
363 +CHILD_PROFILE=
364 +CHILD_CHOST=
365 +
366 +#
367 +# get ourselfs the functions.sh script for ebegin/eend/etc.
368 +#
369 +for f in \
370 + /lib/gentoo/functions.sh \
371 + /etc/init.d/functions.sh \
372 + /sbin/functions.sh \
373 +; do
374 + if [[ -r ${PARENT_EPREFIX}${f} ]] ; then
375 + . "${PARENT_EPREFIX}${f}"
376 + f=found
377 + break
378 + fi
379 +done
380 +
381 +if [[ ${f} != found ]] ; then
382 + echo "Cannot find Gentoo functions, aborting." >&2
383 + exit 1
384 +fi
385 +
386 +for arg in "$@"; do
387 + case "${arg}" in
388 + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
389 + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
390 + --chost=*) CHILD_CHOST="${arg#--chost=}" ;;
391 +
392 + --help)
393 + einfo "$0 usage:"
394 + einfo " --eprefix=[PATH] Path to new EPREFIX to create stacked to the prefix"
395 + einfo " where this script is installed (${PARENT_EPREFIX})"
396 + einfo " --profile=[PATH] The absolute path to the profile to use. This path"
397 + einfo " must point to a directory within ${PARENT_EPREFIX}"
398 + einfo " --chost=[CHOST] The CHOST to use for the new EPREFIX, required if"
399 + einfo " the profile does not set CHOST, or to override."
400 + exit 0
401 + ;;
402 + esac
403 +done
404 +
405 +#
406 +# sanity check of given values
407 +#
408 +
409 +test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
410 +test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
411 +test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
412 +test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
413 +
414 +if [[ -z ${CHILD_CHOST} ]]
415 +then
416 + my_lsprofile() {
417 + (
418 + cd -P "${1:-.}" || exit 1
419 + [[ -r ./parent ]] &&
420 + for p in $(<parent)
421 + do
422 + my_lsprofile "${p}" || exit 1
423 + done
424 + pwd -P
425 + )
426 + }
427 +
428 + for profile in $(my_lsprofile "${CHILD_PROFILE}") missing
429 + do
430 + if [[ ${profile} == missing ]]
431 + then
432 + eerror "profile does not set CHOST, need --chost argument"
433 + exit 1
434 + fi
435 + [[ -s "${profile}/make.defaults" ]] || continue
436 + grep -q '^[ ]*CHOST@=@' "${profile}/make.defaults" && break
437 + done
438 +fi
439 +
440 +einfo "creating stacked prefix ${CHILD_EPREFIX}"
441 +
442 +#
443 +# functions needed below.
444 +#
445 +eend_exit() {
446 + eend $1
447 + [[ $1 != 0 ]] && exit 1
448 +}
449 +
450 +#
451 +# create the directories required to bootstrap the least.
452 +#
453 +ebegin "creating directory structure"
454 +(
455 + set -e
456 + mkdir -p "${CHILD_EPREFIX}"/var/tmp/portage
457 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.mask
458 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.force
459 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/env
460 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/package.env
461 + ln -s "${PARENT_EPREFIX}"/etc/portage/repos.conf "${CHILD_EPREFIX}"/etc/portage/repos.conf
462 +)
463 +eend_exit $?
464 +
465 +#
466 +# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
467 +#
468 +ebegin "creating make.conf"
469 +(
470 + set -e
471 + echo "#"
472 + echo "# These are sane default compiler flags, feel free to adopt them as you like."
473 + echo "# Extending the flags is done to respect flags probably set by some profile."
474 + echo "#"
475 + echo "CFLAGS=\"\${CFLAGS} -O2 -pipe\""
476 + echo "CXXFLAGS=\"${CXXFLAGS} -O2 -pipe\""
477 + echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
478 + niceness=$(portageq envvar PORTAGE_NICENESS || true)
479 + [[ -n ${niceness} ]] &&
480 + echo "PORTAGE_NICENESS=\"${niceness}\""
481 + echo
482 + echo "# Mirrors from parent prefix."
483 + echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
484 + echo
485 + echo "# Below comes the prefix-stack setup. Only change things"
486 + echo "# if you know exactly what you are doing!"
487 + echo "EPREFIX=\"${CHILD_EPREFIX}\""
488 + echo "PORTAGE_OVERRIDE_EPREFIX=\"${PARENT_EPREFIX}\""
489 + echo "BROOT=\"${PARENT_EPREFIX}\""
490 + echo "PORTAGE_TMPDIR=\"\${EPREFIX}/var/tmp/portage\""
491 + # Since EAPI 7 there is BDEPEND, which is DEPEND in EAPI up to 6.
492 + # We do not want to pull DEPEND from EAPI <= 6, but RDEPEND only.
493 + echo "EMERGE_DEFAULT_OPTS=\"--root-deps=rdeps\""
494 + if [[ -n ${CHILD_CHOST} ]] ; then
495 + echo "CHOST=\"${CHILD_CHOST}\""
496 + fi
497 +) > "${CHILD_EPREFIX}"/etc/portage/make.conf
498 +eend_exit $?
499 +
500 +ebegin "creating use.mask/prefix-stack"
501 +printf -- '-%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.mask/prefix-stack
502 +eend_exit $?
503 +
504 +ebegin "creating use.force/prefix-stack"
505 +printf -- '%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.force/prefix-stack
506 +eend_exit $?
507 +
508 +ebegin "creating env/host-cc.conf"
509 +cat > "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf <<-EOM
510 + CC=${PARENT_CHOST}-gcc
511 + CXX=${PARENT_CHOST}-g++
512 + # Inherited compiler flags from parent prefix,
513 + # as the child prefix may have a different compiler.
514 + CFLAGS="$(portageq envvar CFLAGS)"
515 + CXXFLAGS="$(portageq envvar CXXFLAGS)"
516 + EOM
517 +eend_exit $?
518 +
519 +ebegin "creating package.env/prefix-stack"
520 +cat > "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack <<-'EOM'
521 + # merge with the parent's chost. this forces the use of the parent
522 + # compiler, which generally would be illegal - this is an exception.
523 + # This is required for example on winnt, because the wrapper has to
524 + # be able to use/resolve symlinks, etc. native winnt binaries miss
525 + # that ability, but cygwin binaries don't.
526 + sys-devel/gcc-config host-cc.conf
527 + sys-apps/gentoo-functions host-cc.conf
528 + EOM
529 +eend_exit $?
530 +
531 +#
532 +# create the make.profile symlinks.
533 +#
534 +ebegin "creating make.profile"
535 +(
536 + ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
537 +)
538 +eend_exit $?
539 +
540 +#
541 +# adjust permissions of generated files.
542 +#
543 +ebegin "adjusting permissions"
544 +(
545 + set -e
546 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
547 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf
548 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack
549 +)
550 +eend_exit $?
551 +
552 +#
553 +# now merge some basics.
554 +#
555 +ebegin "installing required basic packages"
556 +(
557 + set -e
558 + export PORTAGE_CONFIGROOT@=@"${CHILD_EPREFIX}"
559 + export EPREFIX@=@"${CHILD_EPREFIX}"
560 + export PORTAGE_OVERRIDE_EPREFIX@=@"${PARENT_EPREFIX}"
561 +
562 + # let baselayout create the directories
563 + USE@=@"${USE} build" \
564 + emerge --verbose --nodeps --oneshot \
565 + '>=baselayout-prefix-2.6'
566 +
567 + # In prefix-stack, app-portage/prefix-toolkit does
568 + # install/update an etc/portage/profile/packages file,
569 + # removing all @system packages from current make.profile,
570 + # and adding itself to @system set instead.
571 + emerge --verbose --nodeps --oneshot \
572 + app-portage/prefix-toolkit
573 +
574 + # In prefix-stack, prefix-toolkit does have an RDEPEND on them,
575 + # to hold them in the @system set.
576 + emerge --verbose --nodeps --oneshot \
577 + sys-apps/gentoo-functions \
578 + app-portage/elt-patches \
579 + sys-devel/gnuconfig \
580 + sys-devel/gcc-config
581 +
582 + # select the stack wrapper profile from gcc-config
583 + env -i PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" \
584 + "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
585 +)
586 +eend_exit $?
587 +
588 +#
589 +# wow, all ok :)
590 +#
591 +ewarn
592 +ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
593 +ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
594 +ewarn
595 +EOIN
596 +
597 +: prefix-stack-ccwrap <<'EOIN'
598 +#!@GENTOO_PORTAGE_BPREFIX@/bin/bash
599 +
600 +if [ -r /cygdrive/. ]; then
601 + winpath2unix() { cygpath -u "$1"; }
602 + unixpath2win() { cygpath -w "$1"; }
603 +fi
604 +
605 +myself=${0##*/} # basename $0
606 +link_dirs=()
607 +opts=()
608 +chost="@GENTOO_PORTAGE_CHOST@"
609 +prefix="@GENTOO_PORTAGE_EPREFIX@"
610 +absprefix=${prefix}
611 +if [[ ${chost} == *"-winnt"* ]]; then
612 + # we may get called from windows binary, like pkgdata in dev-libs/icu
613 + # in this case, PATH elements get the "/dev/fs/C/WINDOWS/SUA" prefix
614 + absprefix=$(winpath2unix "$(unixpath2win "${absprefix}")")
615 +fi
616 +[[ ${myself} == *windres* ]] && mode=compile || mode=link
617 +orig_args=("$@")
618 +
619 +for opt in "$@"
620 +do
621 + case "$opt" in
622 + -L)
623 + link_dirs=("${link_dirs[@]}" "-L$1")
624 + shift
625 + ;;
626 + -L*)
627 + link_dirs=("${link_dirs[@]}" "${opt}")
628 + ;;
629 + *)
630 + case "${opt}" in
631 + -v)
632 + # -v done right: only use mode version if -v is the _only_
633 + # argument on the command line.
634 + [[ ${#orig_args[@]} -gt 1 ]] || mode=version
635 + ;;
636 + --version) mode=version ;;
637 + -c|-E|-S) mode=compile ;;
638 + -print-search-dirs) mode=dirs ;;
639 + esac
640 + opts=("${opts[@]}" "${opt}")
641 + ;;
642 + esac
643 +done
644 +
645 +# remove any path to current prefix, need base prefix only
646 +new_path=
647 +save_ifs=$IFS
648 +IFS=':'
649 +for p in $PATH
650 +do
651 + IFS=$save_ifs
652 + [[ ${p#${absprefix}} != "${p}" ]] && continue
653 + if [[ -z "${new_path}" ]]; then
654 + new_path="${p}"
655 + else
656 + new_path="${new_path}:${p}"
657 + fi
658 +done
659 +IFS=$save_ifs
660 +
661 +PATH=${new_path}
662 +
663 +pfx_comp=("-I${prefix}/include" "-I${prefix}/usr/include")
664 +pfx_link=("-L${prefix}/usr/lib" "-L${prefix}/lib")
665 +# binutils-config's ldwrapper understands '-R' for aix and hpux too.
666 +pfx_link_r=("-Wl,-R,${prefix}/lib" "-Wl,-R,${prefix}/usr/lib")
667 +case "${chost}" in
668 +*-winnt*)
669 + # parity (winnt) understands -rpath only ...
670 + pfx_link_r=("-Wl,-rpath,${prefix}/lib" "-Wl,-rpath,${prefix}/usr/lib")
671 + ;;
672 +*-linux*)
673 + # With gcc, -isystem would avoid warning messages in installed headers,
674 + # but that breaks with AIX host headers.
675 + pfx_comp=("-isystem" "${prefix}/include" "-isystem" "${prefix}/usr/include")
676 + ;;
677 +esac
678 +
679 +# ensure we run the right chost program in base prefix
680 +[[ ${myself} == *-*-*-* ]] || myself=${chost}-${myself#${chost}-}
681 +
682 +case "$mode" in
683 +link) exec "${myself}" "${link_dirs[@]}" "${pfx_link[@]}" "${opts[@]}" "${pfx_comp[@]}" "${pfx_link_r[@]}" ;;
684 +compile) exec "${myself}" "${link_dirs[@]}" "${opts[@]}" "${pfx_comp[@]}" ;;
685 +version) exec "${myself}" "${orig_args[@]}" ;;
686 +dirs)
687 + "${myself}" "${orig_args[@]}" | while read line; do
688 + if [[ "${line}" == "libraries: ="* ]]; then
689 + echo "libraries: =${prefix}/usr/lib:${prefix}/lib:${line#"libraries: ="}"
690 + else
691 + echo "${line}"
692 + fi
693 + done
694 + ;;
695 +*) echo "cannot infer ${myself}'s mode from comamnd line arguments"; exit 1 ;;
696 +esac
697 +EOIN