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-chain-setup/
Date: Wed, 05 Apr 2017 14:59:51
Message-Id: 1491404270.192b682840b8b6cfbe056af4681e1ac190f0a1a5.haubi@gentoo
1 commit: 192b682840b8b6cfbe056af4681e1ac190f0a1a5
2 Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 5 14:57:38 2017 +0000
4 Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 5 14:57:50 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=192b6828
7
8 app-portage/prefix-chain-setup: install elt-patches+gnuconfig in chained prefix
9
10 Package-Manager: portage-2.3.3
11
12 .../prefix-chain-setup-0.6.ebuild | 223 +++++++++++++++++++++
13 1 file changed, 223 insertions(+)
14
15 diff --git a/app-portage/prefix-chain-setup/prefix-chain-setup-0.6.ebuild b/app-portage/prefix-chain-setup/prefix-chain-setup-0.6.ebuild
16 new file mode 100644
17 index 00000000000..da26e810781
18 --- /dev/null
19 +++ b/app-portage/prefix-chain-setup/prefix-chain-setup-0.6.ebuild
20 @@ -0,0 +1,223 @@
21 +# Copyright 1999-2017 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=6
25 +
26 +inherit prefix
27 +
28 +DESCRIPTION="Chained EPREFIX bootstrapping utility"
29 +HOMEPAGE="https://prefix.gentoo.org/"
30 +SRC_URI=""
31 +
32 +LICENSE="GPL-3"
33 +SLOT="0"
34 +KEYWORDS="~ppc-aix ~x64-cygwin ~x86-linux ~sparc-solaris ~x86-solaris"
35 +IUSE=""
36 +
37 +DEPEND=""
38 +RDEPEND=""
39 +
40 +S="${WORKDIR}"
41 +
42 +src_install() {
43 + eprefixify ${PN}
44 + sed -e "s,@GENTOO_PORTAGE_CHOST@,${CHOST}," -i ${PN}
45 + dobin ${PN}
46 +}
47 +
48 +src_unpack() {
49 + { cat > "${PN}" || die; } <<'EOF'
50 +#!/usr/bin/env bash
51 +
52 +PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
53 +PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
54 +CHILD_EPREFIX=
55 +CHILD_PROFILE=
56 +DO_MINIMAL=no
57 +DO_SOURCES=no
58 +PORT_TMPDIR=
59 +
60 +#
61 +# get ourselfs the functions.sh script for ebegin/eend/etc.
62 +#
63 +for f in \
64 + /lib/gentoo/functions.sh \
65 + /etc/init.d/functions.sh \
66 + /sbin/functions.sh \
67 +; do
68 + if [[ -r ${PARENT_EPREFIX}${f} ]]; then
69 + . "${PARENT_EPREFIX}${f}"
70 + f=found
71 + break
72 + fi
73 +done
74 +
75 +if [[ ${f} != found ]]; then
76 + echo "Cannot find Gentoo functions, aborting." >&2
77 + exit 1
78 +fi
79 +
80 +for arg in "$@"; do
81 + case "${arg}" in
82 + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
83 + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
84 + --sources) DO_SOURCES=yes ;;
85 + --portage-tmpdir=*) PORT_TMPDIR="${arg#--portage-tmpdir=}" ;;
86 +
87 + --help)
88 + einfo "$0 usage:"
89 + einfo " --eprefix=[PATH] Path to new EPREFIX to create chained to the prefix"
90 + einfo " where this script is installed (${PARENT_EPREFIX})"
91 + einfo " --profile=[PATH] The absolute path to the profile to use. This path"
92 + einfo " must point to a directory within ${PARENT_EPREFIX}"
93 + einfo " --sources inherit 'source' statements from the parent make.conf"
94 + einfo " --portage-tmpdir=DIR use DIR as portage temporary directory."
95 + exit 0
96 + ;;
97 + esac
98 +done
99 +
100 +#
101 +# sanity check of given values
102 +#
103 +
104 +test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
105 +test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
106 +test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
107 +test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
108 +if test -n "${PORT_TMPDIR}"; then
109 + if ! test -d "${PORT_TMPDIR}"; then
110 + einfo "creating temporary directory ${PORT_TMPDIR}"
111 + mkdir -p "${PORT_TMPDIR}"
112 + fi
113 +fi
114 +
115 +einfo "creating chained prefix ${CHILD_EPREFIX}"
116 +
117 +#
118 +# functions needed below.
119 +#
120 +eend_exit() {
121 + eend $1
122 + [[ $1 != 0 ]] && exit 1
123 +}
124 +
125 +#
126 +# create the directories required to bootstrap the least.
127 +#
128 +ebegin "creating directory structure"
129 +(
130 + set -e
131 + mkdir -p "${CHILD_EPREFIX}"/etc/portage
132 + mkdir -p "${CHILD_EPREFIX}"/var/log
133 +)
134 +eend_exit $?
135 +
136 +#
137 +# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
138 +#
139 +ebegin "creating make.conf"
140 +(
141 + set -e
142 + echo "#"
143 + echo "# The following values where taken from the parent prefix's"
144 + echo "# environment. Feel free to adopt them as you like."
145 + echo "#"
146 + echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
147 + echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
148 + echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
149 + niceness=$(portageq envvar PORTAGE_NICENESS || true)
150 + [[ -n ${niceness} ]] &&
151 + echo "PORTAGE_NICENESS=\"${niceness}\""
152 + echo "USE=\"prefix-chaining\""
153 + echo
154 + echo "# Mirrors from parent prefix."
155 + echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
156 + echo
157 + echo "#"
158 + echo "# Below comes the chained-prefix setup. Only change things"
159 + echo "# if you know exactly what you are doing!"
160 + echo "# by default, only DEPEND is inherited from the parent in"
161 + echo "# the chain. if you want more, make it a comma seperated"
162 + echo "# list - like this: DEPEND,RDEPEND,PDEPEN - which would the"
163 + echo "# all that is possible"
164 + echo "#"
165 + echo "PORTDIR=\"$(portageq envvar PORTDIR)\""
166 + echo "SYNC=\"$(portageq envvar SYNC || true)\""
167 + if test -z "${PORT_TMPDIR}"; then
168 + case "${CHILD_PROFILE}" in
169 + *winnt*) echo "PORTAGE_TMPDIR=/var/tmp" ;;
170 + *) echo "PORTAGE_TMPDIR=\"${CHILD_EPREFIX}/var/tmp\"" ;;
171 + esac
172 + else
173 + echo "PORTAGE_TMPDIR=\"${PORT_TMPDIR}\""
174 + fi
175 + echo "READONLY_EPREFIX=\"${PARENT_EPREFIX}:DEPEND\""
176 +
177 + if test "${DO_SOURCES}" == "yes"; then
178 + # don't fail if nothing found
179 + for f in /etc/portage/make.conf /etc/make.conf; do
180 + if [[ -r ${PARENT_EPREFIX}${f} ]]; then
181 + egrep "^source .*" "${PARENT_EPREFIX}${f}" 2>/dev/null || true
182 + break;
183 + fi
184 + done
185 + fi
186 +) > "${CHILD_EPREFIX}"/etc/portage/make.conf
187 +eend_exit $?
188 +
189 +#
190 +# create the make.profile symlinks.
191 +#
192 +ebegin "creating make.profile"
193 +(
194 + ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
195 +)
196 +eend_exit $?
197 +
198 +#
199 +# adjust permissions of generated files.
200 +#
201 +ebegin "adjusting permissions"
202 +(
203 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
204 +)
205 +eend_exit $?
206 +
207 +#
208 +# now merge some basics.
209 +#
210 +ebegin "installing required basic packages"
211 +(
212 + # this -pv is there to avoid the global update output, which is
213 + # there on the first emerge run. (thus, just cosmetics).
214 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -p1qO baselayout-prefix > /dev/null 2>&1
215 +
216 + set -e
217 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO \
218 + gentoo-functions baselayout-prefix elt-patches gnuconfig prefix-chain-utils
219 +
220 + # merge with the parent's chost. this forces the use of the parent
221 + # compiler, which generally would be illegal - this is an exception.
222 + # This is required for example on winnt, because the wrapper has to
223 + # be able to use/resolve symlinks, etc. native winnt binaries miss that
224 + # ability, but interix binaries don't.
225 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" CHOST="${PARENT_CHOST}" emerge -1qO gcc-config
226 +
227 + # select the chain wrapper profile from gcc-config
228 + env -i "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
229 +
230 + # do this _AFTER_ selecting the correct compiler!
231 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO libtool
232 +)
233 +eend_exit $?
234 +
235 +#
236 +# wow, all ok :)
237 +#
238 +ewarn
239 +ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
240 +ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
241 +ewarn
242 +EOF
243 +}