summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haubenwallner <haubi@gentoo.org>2019-03-20 10:35:34 +0100
committerSam James <sam@gentoo.org>2023-05-26 06:59:06 +0100
commita5921f9abc0ff4353907b5c4f879eeff2d0a696f (patch)
tree805883e57891911aa86c444233e3ef9bc1c11857 /prefix-stack-setup
downloadprefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.tar.gz
prefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.tar.bz2
prefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.zip
app-portage/prefix-toolkit: new packageprefix-toolkit-0
* For any Gentoo Prefix, provides the 'startprefix' script, and should provide some 'runprefix' script later on, as inspired in Bug: https://bugs.gentoo.org/673816 * For base Gentoo Prefix (as in "not stacked"), provides the 'prefix-stack-setup' script, superseding app-portage/prefix-chain-setup, does force the prefix-stack implit USE flag in the stacked Prefix. * For stacked Gentoo Prefix (set up using 'prefix-stack-setup'), provides the toolchain wrapper, superseding sys-apps/prefix-chain-utils. Bug: https://bugs.gentoo.org/658572 Closes: https://bugs.gentoo.org/509142 Package-Manager: Portage-2.3.51, Repoman-2.3.11 Signed-off-by: Michael Haubenwallner <haubi@gentoo.org> (cherry picked from commit 84b9f582e8c8db69a3b3677de702c7cc00ac3dab)
Diffstat (limited to 'prefix-stack-setup')
-rw-r--r--prefix-stack-setup201
1 files changed, 201 insertions, 0 deletions
diff --git a/prefix-stack-setup b/prefix-stack-setup
new file mode 100644
index 0000000..28e3efa
--- /dev/null
+++ b/prefix-stack-setup
@@ -0,0 +1,201 @@
+#!@GENTOO_PORTAGE_EPREFIX@/bin/bash
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
+PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
+CHILD_EPREFIX=
+CHILD_PROFILE=
+
+#
+# get ourselfs the functions.sh script for ebegin/eend/etc.
+#
+for f in \
+ /lib/gentoo/functions.sh \
+ /etc/init.d/functions.sh \
+ /sbin/functions.sh \
+; do
+ if [[ -r ${PARENT_EPREFIX}${f} ]] ; then
+ . "${PARENT_EPREFIX}${f}"
+ f=found
+ break
+ fi
+done
+
+if [[ ${f} != found ]] ; then
+ echo "Cannot find Gentoo functions, aborting." >&2
+ exit 1
+fi
+
+for arg in "$@"; do
+ case "${arg}" in
+ --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
+ --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
+
+ --help)
+ einfo "$0 usage:"
+ einfo " --eprefix=[PATH] Path to new EPREFIX to create stacked to the prefix"
+ einfo " where this script is installed (${PARENT_EPREFIX})"
+ einfo " --profile=[PATH] The absolute path to the profile to use. This path"
+ einfo " must point to a directory within ${PARENT_EPREFIX}"
+ exit 0
+ ;;
+ esac
+done
+
+#
+# sanity check of given values
+#
+
+test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
+test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
+test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
+test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
+
+einfo "creating stacked prefix ${CHILD_EPREFIX}"
+
+#
+# functions needed below.
+#
+eend_exit() {
+ eend $1
+ [[ $1 != 0 ]] && exit 1
+}
+
+#
+# create the directories required to bootstrap the least.
+#
+ebegin "creating directory structure"
+(
+ set -e
+ mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.mask
+ mkdir -p "${CHILD_EPREFIX}"/etc/portage/profile/use.force
+ mkdir -p "${CHILD_EPREFIX}"/etc/portage/env
+ mkdir -p "${CHILD_EPREFIX}"/etc/portage/package.env
+ ln -s "${PARENT_EPREFIX}"/etc/portage/repos.conf "${CHILD_EPREFIX}"/etc/portage/repos.conf
+)
+eend_exit $?
+
+#
+# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
+#
+ebegin "creating make.conf"
+(
+ set -e
+ echo "#"
+ echo "# The following values where taken from the parent prefix's"
+ echo "# environment. Feel free to adopt them as you like."
+ echo "#"
+ echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
+ echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
+ echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
+ niceness=$(portageq envvar PORTAGE_NICENESS || true)
+ [[ -n ${niceness} ]] &&
+ echo "PORTAGE_NICENESS=\"${niceness}\""
+ echo
+ echo "# Mirrors from parent prefix."
+ echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
+ echo
+ echo "# Below comes the prefix-stack setup. Only change things"
+ echo "# if you know exactly what you are doing!"
+ echo "EPREFIX=\"${CHILD_EPREFIX}\""
+ echo "PORTAGE_OVERRIDE_EPREFIX=\"${PARENT_EPREFIX}\""
+ echo "BROOT=\"${PARENT_EPREFIX}\""
+) > "${CHILD_EPREFIX}"/etc/portage/make.conf
+eend_exit $?
+
+ebegin "creating use.mask/prefix-stack"
+printf -- '-%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.mask/prefix-stack
+eend_exit $?
+
+ebegin "creating use.force/prefix-stack"
+printf -- '%s\n' prefix{,-guest,-stack} > "${CHILD_EPREFIX}"/etc/portage/profile/use.force/prefix-stack
+eend_exit $?
+
+ebegin "creating env/host-cc.conf"
+cat > "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf <<-EOM
+ CC=${PARENT_CHOST}-gcc
+ CXX=${PARENT_CHOST}-g++
+ EOM
+eend_exit $?
+
+ebegin "creating package.env/prefix-stack"
+cat > "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack <<-'EOM'
+ # merge with the parent's chost. this forces the use of the parent
+ # compiler, which generally would be illegal - this is an exception.
+ # This is required for example on winnt, because the wrapper has to
+ # be able to use/resolve symlinks, etc. native winnt binaries miss
+ # that ability, but cygwin binaries don't.
+ sys-devel/gcc-config host-cc.conf
+ sys-apps/gentoo-functions host-cc.conf
+ EOM
+eend_exit $?
+
+#
+# create the make.profile symlinks.
+#
+ebegin "creating make.profile"
+(
+ ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
+)
+eend_exit $?
+
+#
+# adjust permissions of generated files.
+#
+ebegin "adjusting permissions"
+(
+ set -e
+ chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
+ chmod 644 "${CHILD_EPREFIX}"/etc/portage/env/host-cc.conf
+ chmod 644 "${CHILD_EPREFIX}"/etc/portage/package.env/prefix-stack
+)
+eend_exit $?
+
+#
+# now merge some basics.
+#
+ebegin "installing required basic packages"
+(
+ set -e
+ export PORTAGE_CONFIGROOT@=@"${CHILD_EPREFIX}"
+ export EPREFIX@=@"${CHILD_EPREFIX}"
+ export PORTAGE_OVERRIDE_EPREFIX@=@"${PARENT_EPREFIX}"
+
+# # this -pv is there to avoid the global update output, which is
+# # there on the first emerge run. (thus, just cosmetics).
+# emerge --pretend --oneshot --nodeps baselayout-prefix
+
+ # let baselayout create the directories
+ USE@=@"${USE} build" \
+ emerge --verbose --nodeps --oneshot \
+ '>=baselayout-prefix-2.6'
+
+ # Record the prefix-toolkit into @world file, as it provides the
+ # env.d telling the PM to manage this stacked Prefix, but may not
+ # (unlike baselayout) be part of @system set per the profile.
+ emerge --verbose --nodeps \
+ prefix-toolkit
+
+ emerge --verbose --nodeps --oneshot \
+ gentoo-functions \
+ elt-patches \
+ gnuconfig \
+ gcc-config
+
+ # select the stack wrapper profile from gcc-config
+ env -i PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
+
+ # do this _after_ selecting the correct compiler!
+ emerge --verbose --nodeps --oneshot \
+ libtool
+)
+eend_exit $?
+
+#
+# wow, all ok :)
+#
+ewarn
+ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
+ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
+ewarn