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