diff options
-rw-r--r-- | prefix-stack-setup | 37 | ||||
-rw-r--r-- | prefix-toolkit-3.ebuild (renamed from prefix-toolkit-2.ebuild) | 37 |
2 files changed, 70 insertions, 4 deletions
diff --git a/prefix-stack-setup b/prefix-stack-setup index 9fa4a1b..2d7ec10 100644 --- a/prefix-stack-setup +++ b/prefix-stack-setup @@ -6,6 +6,7 @@ PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@" PARENT_CHOST="@GENTOO_PORTAGE_CHOST@" CHILD_EPREFIX= CHILD_PROFILE= +CHILD_CHOST= # # get ourselfs the functions.sh script for ebegin/eend/etc. @@ -29,8 +30,9 @@ fi for arg in "$@"; do case "${arg}" in - --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;; - --profile=*) CHILD_PROFILE="${arg#--profile=}" ;; + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;; + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;; + --chost=*) CHILD_CHOST="${arg#--chost=}" ;; --help) einfo "$0 usage:" @@ -38,6 +40,8 @@ for arg in "$@"; do 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}" + einfo " --chost=[CHOST] The CHOST to use for the new EPREFIX, required if" + einfo " the profile does not set CHOST, or to override." exit 0 ;; esac @@ -52,6 +56,32 @@ 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; } +if [[ -z ${CHILD_CHOST} ]] +then + my_lsprofile() { + ( + cd -P "${1:-.}" || exit 1 + [[ -r ./parent ]] && + for p in $(<parent) + do + my_lsprofile "${p}" || exit 1 + done + pwd -P + ) + } + + for profile in $(my_lsprofile "${CHILD_PROFILE}") missing + do + if [[ ${profile} == missing ]] + then + eerror "profile does not set CHOST, need --chost argument" + exit 1 + fi + [[ -s "${profile}/make.defaults" ]] || continue + grep -q '^[ ]*CHOST@=@' "${profile}/make.defaults" && break + done +fi + einfo "creating stacked prefix ${CHILD_EPREFIX}" # @@ -101,6 +131,9 @@ ebegin "creating make.conf" echo "EPREFIX=\"${CHILD_EPREFIX}\"" echo "PORTAGE_OVERRIDE_EPREFIX=\"${PARENT_EPREFIX}\"" echo "BROOT=\"${PARENT_EPREFIX}\"" + if [[ -n ${CHILD_CHOST} ]] ; then + echo "CHOST=\"${CHILD_CHOST}\"" + fi ) > "${CHILD_EPREFIX}"/etc/portage/make.conf eend_exit $? diff --git a/prefix-toolkit-2.ebuild b/prefix-toolkit-3.ebuild index 21c1721..e4719f8 100644 --- a/prefix-toolkit-2.ebuild +++ b/prefix-toolkit-3.ebuild @@ -320,6 +320,7 @@ PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@" PARENT_CHOST="@GENTOO_PORTAGE_CHOST@" CHILD_EPREFIX= CHILD_PROFILE= +CHILD_CHOST= # # get ourselfs the functions.sh script for ebegin/eend/etc. @@ -343,8 +344,9 @@ fi for arg in "$@"; do case "${arg}" in - --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;; - --profile=*) CHILD_PROFILE="${arg#--profile=}" ;; + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;; + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;; + --chost=*) CHILD_CHOST="${arg#--chost=}" ;; --help) einfo "$0 usage:" @@ -352,6 +354,8 @@ for arg in "$@"; do 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}" + einfo " --chost=[CHOST] The CHOST to use for the new EPREFIX, required if" + einfo " the profile does not set CHOST, or to override." exit 0 ;; esac @@ -366,6 +370,32 @@ 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; } +if [[ -z ${CHILD_CHOST} ]] +then + my_lsprofile() { + ( + cd -P "${1:-.}" || exit 1 + [[ -r ./parent ]] && + for p in $(<parent) + do + my_lsprofile "${p}" || exit 1 + done + pwd -P + ) + } + + for profile in $(my_lsprofile "${CHILD_PROFILE}") missing + do + if [[ ${profile} == missing ]] + then + eerror "profile does not set CHOST, need --chost argument" + exit 1 + fi + [[ -s "${profile}/make.defaults" ]] || continue + grep -q '^[ ]*CHOST@=@' "${profile}/make.defaults" && break + done +fi + einfo "creating stacked prefix ${CHILD_EPREFIX}" # @@ -415,6 +445,9 @@ ebegin "creating make.conf" echo "EPREFIX=\"${CHILD_EPREFIX}\"" echo "PORTAGE_OVERRIDE_EPREFIX=\"${PARENT_EPREFIX}\"" echo "BROOT=\"${PARENT_EPREFIX}\"" + if [[ -n ${CHILD_CHOST} ]] ; then + echo "CHOST=\"${CHILD_CHOST}\"" + fi ) > "${CHILD_EPREFIX}"/etc/portage/make.conf eend_exit $? |