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, 05 Jun 2019 15:39:54
Message-Id: 1559749024.37ce4db03cdef74a6ae97466405133bcc85c7b60.haubi@gentoo
1 commit: 37ce4db03cdef74a6ae97466405133bcc85c7b60
2 Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 5 15:35:39 2019 +0000
4 Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 5 15:37:04 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=37ce4db0
7
8 app-portage/prefix-toolkit: revbump
9
10 * In prefix-stack, maintain @system set independent of profile, as in
11 explicitly removing everything found per etc/portage/make.profile, but
12 adding prefix-toolkit, having RDEPENDs for additional @system packages.
13 * Do not install libtool into prefix-stack any more, packages really
14 should not use any installed libtool script, but configure their own.
15 * In prefix-stack toolchain on Linux, use -isystem to avoid warnings
16 from installed header files. Remember: This is known to break on AIX.
17
18 Package-Manager: Portage-2.3.67-prefix, Repoman-2.3.13
19 Signed-off-by: Michael Haubenwallner <haubi <AT> gentoo.org>
20
21 app-portage/prefix-toolkit/prefix-toolkit-2.ebuild | 614 +++++++++++++++++++++
22 1 file changed, 614 insertions(+)
23
24 diff --git a/app-portage/prefix-toolkit/prefix-toolkit-2.ebuild b/app-portage/prefix-toolkit/prefix-toolkit-2.ebuild
25 new file mode 100644
26 index 00000000000..21c172139b1
27 --- /dev/null
28 +++ b/app-portage/prefix-toolkit/prefix-toolkit-2.ebuild
29 @@ -0,0 +1,614 @@
30 +# Copyright 1999-2019 Gentoo Authors
31 +# Distributed under the terms of the GNU General Public License v2
32 +
33 +EAPI=7
34 +
35 +DESCRIPTION="Utilities for users of Gentoo Prefix"
36 +HOMEPAGE="https://prefix.gentoo.org/"
37 +SRC_URI=""
38 +
39 +LICENSE="GPL-3"
40 +SLOT="0"
41 +
42 +[[ ${PV} == 9999 ]] ||
43 +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"
44 +
45 +DEPEND="
46 + !app-portage/prefix-chain-setup
47 + !sys-apps/prefix-chain-utils
48 +"
49 +BDEPEND="${DEPEND}
50 + >sys-apps/portage-2.3.62
51 +"
52 +# In prefix-stack, these dependencies actually are the @system set,
53 +# as we rely on the base prefix anyway for package management,
54 +# which should have a proper @system set.
55 +# See als: pkg_preinst
56 +RDEPEND="${DEPEND}
57 + prefix-stack? (
58 + >=sys-apps/baselayout-prefix-2.6
59 + sys-apps/gentoo-functions
60 + app-portage/elt-patches
61 + sys-devel/gnuconfig
62 + sys-devel/gcc-config
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 +return 0
208 +
209 +: startprefix <<'EOIN'
210 +#!@GENTOO_PORTAGE_EBASH@
211 +# Copyright 1999-2019 Gentoo Authors
212 +# Distributed under the terms of the GNU General Public License v2
213 +
214 +# Fabian Groffen <grobian@g.o> -- 2007-03-10
215 +# Enters the prefix environment by starting a login shell from the
216 +# prefix. The SHELL environment variable is elevated in order to make
217 +# applications that start login shells to work, such as `screen`.
218 +
219 +# if you come from a substantially polluted environment (another
220 +# Prefix), a cleanup as follows resolves most oddities I've ever seen:
221 +# env -i HOME=$HOME TERM=$TERM USER=$USER $SHELL -l
222 +# hence this script starts the Prefix shell like this
223 +
224 +if [[ ${SHELL#@GENTOO_PORTAGE_EPREFIX@} != ${SHELL} ]]
225 +then
226 + echo "You appear to be in prefix already (SHELL=${SHELL})" > /dev/stderr
227 + exit -1
228 +elif [[ ${SHELL#@GENTOO_PORTAGE_BPREFIX@} != ${SHELL} ]] &&
229 + [[ ${EPREFIX-unset} == '@GENTOO_PORTAGE_EPREFIX@' ]]
230 +then
231 + echo "You appear to be in stacked prefix already (EPREFIX=${EPREFIX})" > /dev/stderr
232 + exit -1
233 +fi
234 +
235 +# What is our prefix?
236 +EPREFIX@=@'@GENTOO_PORTAGE_EPREFIX@'
237 +BPREFIX@=@'@GENTOO_PORTAGE_BPREFIX@'
238 +
239 +# not all systems have the same location for shells, however what it
240 +# boils down to, is that we need to know what the shell is, and then we
241 +# can find it in the bin dir of our prefix
242 +for SHELL in \
243 + "${EPREFIX}/bin/${SHELL##*/}" \
244 + "${BPREFIX}/bin/${SHELL##*/}" \
245 + ${SHELL##*/}
246 +do
247 + [[ ${SHELL} == */* && -x ${SHELL} ]] && break
248 +done
249 +
250 +# check if the shell exists
251 +if [[ ${SHELL} != */* ]]
252 +then
253 + echo "Failed to find the Prefix shell, this is probably" > /dev/stderr
254 + echo "because you didn't emerge the shell ${SHELL}" > /dev/stderr
255 + exit 1
256 +fi
257 +
258 +# set the prefix shell in the environment
259 +export SHELL
260 +
261 +# give a small notice
262 +echo "Entering Gentoo Prefix ${EPREFIX}"
263 +# start the login shell, clean the entire environment but what's needed
264 +RETAIN="HOME=$HOME TERM=$TERM USER=$USER SHELL=$SHELL"
265 +# PROFILEREAD is necessary on SUSE not to wipe the env on shell start
266 +[[ -n ${PROFILEREAD} ]] && RETAIN+=" PROFILEREAD=$PROFILEREAD"
267 +# ssh-agent is handy to keep, of if set, inherit it
268 +[[ -n ${SSH_AUTH_SOCK} ]] && RETAIN+=" SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
269 +# if we're on some X terminal, makes sense to inherit that too
270 +[[ -n ${DISPLAY} ]] && RETAIN+=" DISPLAY=$DISPLAY"
271 +# do it!
272 +if [[ ${SHELL#${EPREFIX}} != ${SHELL} ]] ; then
273 + '@GENTOO_PORTAGE_EENV@' -i $RETAIN $SHELL -l
274 +elif [[ ' bash ' == *" ${SHELL##*/} "* ]] ; then
275 + # shell coming from different prefix would load it's own
276 + # etc/profile upon -l, so we have to override
277 + '@GENTOO_PORTAGE_EENV@' -i ${RETAIN} "${SHELL}" --rcfile "${EPREFIX}"/etc/prefix-stack.bash_login -i
278 +else
279 + echo "Only bash is supported with stacked Prefix (you have ${SHELL##*/}), sorry!" > /dev/stderr
280 + exit 1
281 +fi
282 +# and leave a message when we exit... the shell might return non-zero
283 +# without having real problems, so don't send alarming messages about
284 +# that
285 +echo "Leaving Gentoo Prefix with exit status $?"
286 +EOIN
287 +
288 +: prefix-stack.bashrc <<'EOIN'
289 +# Copyright 1999-2019 Gentoo Authors
290 +# Distributed under the terms of the GNU General Public License v2
291 +#
292 +# In stacked Prefix there is no bash installed, yet
293 +# etc/bash/bashrc from base Prefix still is useful.
294 +#
295 +
296 +if [[ $- != *i* ]] ; then
297 + # Shell is non-interactive, bashrc does not apply
298 + return
299 +fi
300 +
301 +if [[ -r @GENTOO_PORTAGE_BPREFIX@/etc/bash/bashrc ]] ; then
302 + source '@GENTOO_PORTAGE_BPREFIX@/etc/bash/bashrc'
303 + # only if base Prefix does have an etc/bash/bashrc, we also
304 + # run bashrc snippets provided by packages in stacked Prefix
305 + for sh in '@GENTOO_PORTAGE_EPREFIX@'/etc/bash/bashrc.d/* ; do
306 + [[ -r ${sh} ]] && source "${sh}"
307 + done
308 + unset sh
309 +else
310 + # etc/profile does expect etc/bash/bashrc to set PS1
311 + PS1='\u@\h \w \$ '
312 +fi
313 +EOIN
314 +
315 +: prefix-stack.bash_login <<'EOIN'
316 +# Copyright 1999-2019 Gentoo Authors
317 +# Distributed under the terms of the GNU General Public License v2
318 +#
319 +# In stacked Prefix there is no bash installed, so there is
320 +# no bash able to load this Prefix' profile as login shell.
321 +# Instead, you can specify this one as bash rcfile to mimic
322 +# a bash login shell using this stacked Prefix profile.
323 +#
324 +
325 +if [[ -s '@GENTOO_PORTAGE_EPREFIX@/etc/profile' ]] ; then
326 + . '@GENTOO_PORTAGE_EPREFIX@/etc/profile'
327 +fi
328 +if [[ -s ~/.bash_profile ]] ; then
329 + . ~/.bash_profile
330 +elif [[ -s ~/.bash_login ]] ; then
331 + . ~/.bash_login
332 +elif [[ -s ~/.profile ]] ; then
333 + . ~/.profile
334 +fi
335 +EOIN
336 +
337 +: prefix-stack.envd.99stack <<'EOIN'
338 +PKG_CONFIG_PATH@=@"@GENTOO_PORTAGE_EPREFIX@/usr/lib/pkgconfig:@GENTOO_PORTAGE_EPREFIX@/usr/share/pkgconfig"
339 +PORTAGE_CONFIGROOT@=@"@GENTOO_PORTAGE_EPREFIX@"
340 +EPREFIX@=@"@GENTOO_PORTAGE_EPREFIX@"
341 +EOIN
342 +
343 +: prefix-stack-setup <<'EOIN'
344 +#!@GENTOO_PORTAGE_EPREFIX@/bin/bash
345 +# Copyright 1999-2019 Gentoo Authors
346 +# Distributed under the terms of the GNU General Public License v2
347 +
348 +PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
349 +PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
350 +CHILD_EPREFIX=
351 +CHILD_PROFILE=
352 +
353 +#
354 +# get ourselfs the functions.sh script for ebegin/eend/etc.
355 +#
356 +for f in \
357 + /lib/gentoo/functions.sh \
358 + /etc/init.d/functions.sh \
359 + /sbin/functions.sh \
360 +; do
361 + if [[ -r ${PARENT_EPREFIX}${f} ]] ; then
362 + . "${PARENT_EPREFIX}${f}"
363 + f=found
364 + break
365 + fi
366 +done
367 +
368 +if [[ ${f} != found ]] ; then
369 + echo "Cannot find Gentoo functions, aborting." >&2
370 + exit 1
371 +fi
372 +
373 +for arg in "$@"; do
374 + case "${arg}" in
375 + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
376 + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
377 +
378 + --help)
379 + einfo "$0 usage:"
380 + einfo " --eprefix=[PATH] Path to new EPREFIX to create stacked to the prefix"
381 + einfo " where this script is installed (${PARENT_EPREFIX})"
382 + einfo " --profile=[PATH] The absolute path to the profile to use. This path"
383 + einfo " must point to a directory within ${PARENT_EPREFIX}"
384 + exit 0
385 + ;;
386 + esac
387 +done
388 +
389 +#
390 +# sanity check of given values
391 +#
392 +
393 +test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
394 +test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
395 +test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
396 +test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
397 +
398 +einfo "creating stacked prefix ${CHILD_EPREFIX}"
399 +
400 +#
401 +# functions needed below.
402 +#
403 +eend_exit() {
404 + eend $1
405 + [[ $1 != 0 ]] && exit 1
406 +}
407 +
408 +#
409 +# create the directories required to bootstrap the least.
410 +#
411 +ebegin "creating directory structure"
412 +(
413 + set -e
414 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.mask
415 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.force
416 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/env
417 + mkdir -p "${CHILD_EPREFIX}"/etc/portage/package.env
418 + ln -s "${PARENT_EPREFIX}"/etc/portage/repos.conf "${CHILD_EPREFIX}"/etc/portage/repos.conf
419 +)
420 +eend_exit $?
421 +
422 +#
423 +# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
424 +#
425 +ebegin "creating make.conf"
426 +(
427 + set -e
428 + echo "#"
429 + echo "# The following values where taken from the parent prefix's"
430 + echo "# environment. Feel free to adopt them as you like."
431 + echo "#"
432 + echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
433 + echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
434 + echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
435 + niceness=$(portageq envvar PORTAGE_NICENESS || true)
436 + [[ -n ${niceness} ]] &&
437 + echo "PORTAGE_NICENESS=\"${niceness}\""
438 + echo
439 + echo "# Mirrors from parent prefix."
440 + echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
441 + echo
442 + echo "# Below comes the prefix-stack setup. Only change things"
443 + echo "# if you know exactly what you are doing!"
444 + echo "EPREFIX=\"${CHILD_EPREFIX}\""
445 + echo "PORTAGE_OVERRIDE_EPREFIX=\"${PARENT_EPREFIX}\""
446 + echo "BROOT=\"${PARENT_EPREFIX}\""
447 +) > "${CHILD_EPREFIX}"/etc/portage/make.conf
448 +eend_exit $?
449 +
450 +ebegin "creating use.mask/prefix-stack"
451 +printf -- '-%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.mask/prefix-stack
452 +eend_exit $?
453 +
454 +ebegin "creating use.force/prefix-stack"
455 +printf -- '%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.force/prefix-stack
456 +eend_exit $?
457 +
458 +ebegin "creating env/host-cc.conf"
459 +cat > "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf <<-EOM
460 + CC=${PARENT_CHOST}-gcc
461 + CXX=${PARENT_CHOST}-g++
462 + EOM
463 +eend_exit $?
464 +
465 +ebegin "creating package.env/prefix-stack"
466 +cat > "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack <<-'EOM'
467 + # merge with the parent's chost. this forces the use of the parent
468 + # compiler, which generally would be illegal - this is an exception.
469 + # This is required for example on winnt, because the wrapper has to
470 + # be able to use/resolve symlinks, etc. native winnt binaries miss
471 + # that ability, but cygwin binaries don't.
472 + sys-devel/gcc-config host-cc.conf
473 + sys-apps/gentoo-functions host-cc.conf
474 + EOM
475 +eend_exit $?
476 +
477 +#
478 +# create the make.profile symlinks.
479 +#
480 +ebegin "creating make.profile"
481 +(
482 + ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
483 +)
484 +eend_exit $?
485 +
486 +#
487 +# adjust permissions of generated files.
488 +#
489 +ebegin "adjusting permissions"
490 +(
491 + set -e
492 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
493 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf
494 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack
495 +)
496 +eend_exit $?
497 +
498 +#
499 +# now merge some basics.
500 +#
501 +ebegin "installing required basic packages"
502 +(
503 + set -e
504 + export PORTAGE_CONFIGROOT@=@"${CHILD_EPREFIX}"
505 + export EPREFIX@=@"${CHILD_EPREFIX}"
506 + export PORTAGE_OVERRIDE_EPREFIX@=@"${PARENT_EPREFIX}"
507 +
508 + # let baselayout create the directories
509 + USE@=@"${USE} build" \
510 + emerge --verbose --nodeps --oneshot \
511 + '>=baselayout-prefix-2.6'
512 +
513 + # In prefix-stack, app-portage/prefix-toolkit does
514 + # install/update an etc/portage/profile/packages file,
515 + # removing all @system packages from current make.profile,
516 + # and adding itself to @system set instead.
517 + emerge --verbose --nodeps --oneshot \
518 + app-portage/prefix-toolkit
519 +
520 + # In prefix-stack, prefix-toolkit does have an RDEPEND on them,
521 + # to hold them in the @system set.
522 + emerge --verbose --nodeps --oneshot \
523 + sys-apps/gentoo-functions \
524 + app-portage/elt-patches \
525 + sys-devel/gnuconfig \
526 + sys-devel/gcc-config
527 +
528 + # select the stack wrapper profile from gcc-config
529 + env -i PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" \
530 + "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
531 +)
532 +eend_exit $?
533 +
534 +#
535 +# wow, all ok :)
536 +#
537 +ewarn
538 +ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
539 +ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
540 +ewarn
541 +EOIN
542 +
543 +: prefix-stack-ccwrap <<'EOIN'
544 +#!@GENTOO_PORTAGE_BPREFIX@/bin/bash
545 +
546 +if [ -r /cygdrive/. ]; then
547 + winpath2unix() { cygpath -u "$1"; }
548 + unixpath2win() { cygpath -w "$1"; }
549 +fi
550 +
551 +myself=${0##*/} # basename $0
552 +link_dirs=()
553 +opts=()
554 +chost="@GENTOO_PORTAGE_CHOST@"
555 +prefix="@GENTOO_PORTAGE_EPREFIX@"
556 +absprefix=${prefix}
557 +if [[ ${chost} == *"-winnt"* ]]; then
558 + # we may get called from windows binary, like pkgdata in dev-libs/icu
559 + # in this case, PATH elements get the "/dev/fs/C/WINDOWS/SUA" prefix
560 + absprefix=$(winpath2unix "$(unixpath2win "${absprefix}")")
561 +fi
562 +[[ ${myself} == *windres* ]] && mode=compile || mode=link
563 +orig_args=("$@")
564 +
565 +for opt in "$@"
566 +do
567 + case "$opt" in
568 + -L)
569 + link_dirs=("${link_dirs[@]}" "-L$1")
570 + shift
571 + ;;
572 + -L*)
573 + link_dirs=("${link_dirs[@]}" "${opt}")
574 + ;;
575 + *)
576 + case "${opt}" in
577 + -v)
578 + # -v done right: only use mode version if -v is the _only_
579 + # argument on the command line.
580 + [[ ${#orig_args[@]} -gt 1 ]] || mode=version
581 + ;;
582 + --version) mode=version ;;
583 + -c|-E|-S) mode=compile ;;
584 + -print-search-dirs) mode=dirs ;;
585 + esac
586 + opts=("${opts[@]}" "${opt}")
587 + ;;
588 + esac
589 +done
590 +
591 +# remove any path to current prefix, need base prefix only
592 +new_path=
593 +save_ifs=$IFS
594 +IFS=':'
595 +for p in $PATH
596 +do
597 + IFS=$save_ifs
598 + [[ ${p#${absprefix}} != "${p}" ]] && continue
599 + if [[ -z "${new_path}" ]]; then
600 + new_path="${p}"
601 + else
602 + new_path="${new_path}:${p}"
603 + fi
604 +done
605 +IFS=$save_ifs
606 +
607 +PATH=${new_path}
608 +
609 +pfx_comp=("-I${prefix}/include" "-I${prefix}/usr/include")
610 +pfx_link=("-L${prefix}/usr/lib" "-L${prefix}/lib")
611 +# binutils-config's ldwrapper understands '-R' for aix and hpux too.
612 +pfx_link_r=("-Wl,-R,${prefix}/lib" "-Wl,-R,${prefix}/usr/lib")
613 +case "${chost}" in
614 +*-winnt*)
615 + # parity (winnt) understands -rpath only ...
616 + pfx_link_r=("-Wl,-rpath,${prefix}/lib" "-Wl,-rpath,${prefix}/usr/lib")
617 + ;;
618 +*-linux*)
619 + # With gcc, -isystem would avoid warning messages in installed headers,
620 + # but that breaks with AIX host headers.
621 + pfx_comp=("-isystem" "${prefix}/include" "-isystem" "${prefix}/usr/include")
622 + ;;
623 +esac
624 +
625 +# ensure we run the right chost program in base prefix
626 +[[ ${myself} == *-*-*-* ]] || myself=${chost}-${myself#${chost}-}
627 +
628 +case "$mode" in
629 +link) exec "${myself}" "${link_dirs[@]}" "${pfx_link[@]}" "${opts[@]}" "${pfx_comp[@]}" "${pfx_link_r[@]}" ;;
630 +compile) exec "${myself}" "${link_dirs[@]}" "${opts[@]}" "${pfx_comp[@]}" ;;
631 +version) exec "${myself}" "${orig_args[@]}" ;;
632 +dirs)
633 + "${myself}" "${orig_args[@]}" | while read line; do
634 + if [[ "${line}" == "libraries: ="* ]]; then
635 + echo "libraries: =${prefix}/usr/lib:${prefix}/lib:${line#"libraries: ="}"
636 + else
637 + echo "${line}"
638 + fi
639 + done
640 + ;;
641 +*) echo "cannot infer ${myself}'s mode from comamnd line arguments"; exit 1 ;;
642 +esac
643 +EOIN