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