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