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/, app-portage/prefix-chain-setup/files/
Date: Wed, 05 Apr 2017 14:59:50
Message-Id: 1491404269.6eea20e90c36c7ebfcdf3943e41c26d7c0b24fe0.haubi@gentoo
1 commit: 6eea20e90c36c7ebfcdf3943e41c26d7c0b24fe0
2 Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 5 14:54:51 2017 +0000
4 Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 5 14:57:49 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6eea20e9
7
8 app-portage/prefix-chain-setup: maintain single script inside ebuild
9
10 Instead of versioning the single script file within files/, just keep
11 the script content inside the ebuild, for easy versioning.
12
13 Package-Manager: portage-2.3.3
14
15 .../prefix-chain-setup/files/prefix-chain-setup.in | 191 -------------------
16 .../prefix-chain-setup-0.5.ebuild | 205 ++++++++++++++++++++-
17 2 files changed, 201 insertions(+), 195 deletions(-)
18
19 diff --git a/app-portage/prefix-chain-setup/files/prefix-chain-setup.in b/app-portage/prefix-chain-setup/files/prefix-chain-setup.in
20 deleted file mode 100644
21 index d3923f1b438..00000000000
22 --- a/app-portage/prefix-chain-setup/files/prefix-chain-setup.in
23 +++ /dev/null
24 @@ -1,191 +0,0 @@
25 -#!/usr/bin/env bash
26 -
27 -PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
28 -PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
29 -CHILD_EPREFIX=
30 -CHILD_PROFILE=
31 -DO_MINIMAL=no
32 -DO_SOURCES=no
33 -PORT_TMPDIR=
34 -
35 -#
36 -# get ourselfs the functions.sh script for ebegin/eend/etc.
37 -#
38 -for f in \
39 - /lib/gentoo/functions.sh \
40 - /etc/init.d/functions.sh \
41 - /sbin/functions.sh \
42 -; do
43 - if [[ -r ${PARENT_EPREFIX}${f} ]]; then
44 - . "${PARENT_EPREFIX}${f}"
45 - f=found
46 - break
47 - fi
48 -done
49 -
50 -if [[ ${f} != found ]]; then
51 - echo "Cannot find Gentoo functions, aborting." >&2
52 - exit 1
53 -fi
54 -
55 -for arg in "$@"; do
56 - case "${arg}" in
57 - --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
58 - --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
59 - --sources) DO_SOURCES=yes ;;
60 - --portage-tmpdir=*) PORT_TMPDIR="${arg#--portage-tmpdir=}" ;;
61 -
62 - --help)
63 - einfo "$0 usage:"
64 - einfo " --eprefix=[PATH] Path to new EPREFIX to create chained to the prefix"
65 - einfo " where this script is installed (${PARENT_EPREFIX})"
66 - einfo " --profile=[PATH] The absolute path to the profile to use. This path"
67 - einfo " must point to a directory within ${PARENT_EPREFIX}"
68 - einfo " --sources inherit 'source' statements from the parent make.conf"
69 - einfo " --portage-tmpdir=DIR use DIR as portage temporary directory."
70 - exit 0
71 - ;;
72 - esac
73 -done
74 -
75 -#
76 -# sanity check of given values
77 -#
78 -
79 -test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
80 -test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
81 -test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
82 -test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
83 -if test -n "${PORT_TMPDIR}"; then
84 - if ! test -d "${PORT_TMPDIR}"; then
85 - einfo "creating temporary directory ${PORT_TMPDIR}"
86 - mkdir -p "${PORT_TMPDIR}"
87 - fi
88 -fi
89 -
90 -einfo "creating chained prefix ${CHILD_EPREFIX}"
91 -
92 -#
93 -# functions needed below.
94 -#
95 -eend_exit() {
96 - eend $1
97 - [[ $1 != 0 ]] && exit 1
98 -}
99 -
100 -#
101 -# create the directories required to bootstrap the least.
102 -#
103 -ebegin "creating directory structure"
104 -(
105 - set -e
106 - mkdir -p "${CHILD_EPREFIX}"/etc/portage
107 - mkdir -p "${CHILD_EPREFIX}"/var/log
108 -)
109 -eend_exit $?
110 -
111 -#
112 -# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
113 -#
114 -ebegin "creating make.conf"
115 -(
116 - set -e
117 - echo "#"
118 - echo "# The following values where taken from the parent prefix's"
119 - echo "# environment. Feel free to adopt them as you like."
120 - echo "#"
121 - echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
122 - echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
123 - echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
124 - niceness=$(portageq envvar PORTAGE_NICENESS || true)
125 - [[ -n ${niceness} ]] &&
126 - echo "PORTAGE_NICENESS=\"${niceness}\""
127 - echo "USE=\"prefix-chaining\""
128 - echo
129 - echo "# Mirrors from parent prefix."
130 - echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
131 - echo
132 - echo "#"
133 - echo "# Below comes the chained-prefix setup. Only change things"
134 - echo "# if you know exactly what you are doing!"
135 - echo "# by default, only DEPEND is inherited from the parent in"
136 - echo "# the chain. if you want more, make it a comma seperated"
137 - echo "# list - like this: DEPEND,RDEPEND,PDEPEN - which would the"
138 - echo "# all that is possible"
139 - echo "#"
140 - echo "PORTDIR=\"$(portageq envvar PORTDIR)\""
141 - echo "SYNC=\"$(portageq envvar SYNC || true)\""
142 - if test -z "${PORT_TMPDIR}"; then
143 - case "${CHILD_PROFILE}" in
144 - *winnt*) echo "PORTAGE_TMPDIR=/var/tmp" ;;
145 - *) echo "PORTAGE_TMPDIR=\"${CHILD_EPREFIX}/var/tmp\"" ;;
146 - esac
147 - else
148 - echo "PORTAGE_TMPDIR=\"${PORT_TMPDIR}\""
149 - fi
150 - echo "READONLY_EPREFIX=\"${PARENT_EPREFIX}:DEPEND\""
151 -
152 - if test "${DO_SOURCES}" == "yes"; then
153 - # don't fail if nothing found
154 - for f in /etc/portage/make.conf /etc/make.conf; do
155 - if [[ -r ${PARENT_EPREFIX}${f} ]]; then
156 - egrep "^source .*" "${PARENT_EPREFIX}${f}" 2>/dev/null || true
157 - break;
158 - fi
159 - done
160 - fi
161 -) > "${CHILD_EPREFIX}"/etc/portage/make.conf
162 -eend_exit $?
163 -
164 -#
165 -# create the make.profile symlinks.
166 -#
167 -ebegin "creating make.profile"
168 -(
169 - ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
170 -)
171 -eend_exit $?
172 -
173 -#
174 -# adjust permissions of generated files.
175 -#
176 -ebegin "adjusting permissions"
177 -(
178 - chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
179 -)
180 -eend_exit $?
181 -
182 -#
183 -# now merge some basics.
184 -#
185 -ebegin "installing required basic packages"
186 -(
187 - # this -pv is there to avoid the global update output, which is
188 - # there on the first emerge run. (thus, just cosmetics).
189 - PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -p1qO baselayout-prefix > /dev/null 2>&1
190 -
191 - set -e
192 - PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO gentoo-functions baselayout-prefix prefix-chain-utils
193 -
194 - # merge with the parent's chost. this forces the use of the parent
195 - # compiler, which generally would be illegal - this is an exception.
196 - # This is required for example on winnt, because the wrapper has to
197 - # be able to use/resolve symlinks, etc. native winnt binaries miss that
198 - # ability, but interix binaries don't.
199 - PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" CHOST="${PARENT_CHOST}" emerge -1qO gcc-config
200 -
201 - # select the chain wrapper profile from gcc-config
202 - env -i "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
203 -
204 - # do this _AFTER_ selecting the correct compiler!
205 - PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO libtool
206 -)
207 -eend_exit $?
208 -
209 -#
210 -# wow, all ok :)
211 -#
212 -ewarn
213 -ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
214 -ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
215 -ewarn
216
217 diff --git a/app-portage/prefix-chain-setup/prefix-chain-setup-0.5.ebuild b/app-portage/prefix-chain-setup/prefix-chain-setup-0.5.ebuild
218 index 1285b03d119..6ec586c0c17 100644
219 --- a/app-portage/prefix-chain-setup/prefix-chain-setup-0.5.ebuild
220 +++ b/app-portage/prefix-chain-setup/prefix-chain-setup-0.5.ebuild
221 @@ -15,9 +15,206 @@ IUSE=""
222 DEPEND=""
223 RDEPEND=""
224
225 +S="${WORKDIR}"
226 +
227 src_install() {
228 - cp "${FILESDIR}"/prefix-chain-setup.in "${T}"/prefix-chain-setup
229 - eprefixify "${T}"/prefix-chain-setup
230 - sed -e "s,@GENTOO_PORTAGE_CHOST@,${CHOST}," -i "${T}"/prefix-chain-setup
231 - dobin "${T}"/prefix-chain-setup
232 + eprefixify ${PN}
233 + sed -e "s,@GENTOO_PORTAGE_CHOST@,${CHOST}," -i ${PN}
234 + dobin ${PN}
235 +}
236 +
237 +src_unpack() {
238 + { cat > "${PN}" || die; } <<'EOF'
239 +#!/usr/bin/env bash
240 +
241 +PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
242 +PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
243 +CHILD_EPREFIX=
244 +CHILD_PROFILE=
245 +DO_MINIMAL=no
246 +DO_SOURCES=no
247 +PORT_TMPDIR=
248 +
249 +#
250 +# get ourselfs the functions.sh script for ebegin/eend/etc.
251 +#
252 +for f in \
253 + /lib/gentoo/functions.sh \
254 + /etc/init.d/functions.sh \
255 + /sbin/functions.sh \
256 +; do
257 + if [[ -r ${PARENT_EPREFIX}${f} ]]; then
258 + . "${PARENT_EPREFIX}${f}"
259 + f=found
260 + break
261 + fi
262 +done
263 +
264 +if [[ ${f} != found ]]; then
265 + echo "Cannot find Gentoo functions, aborting." >&2
266 + exit 1
267 +fi
268 +
269 +for arg in "$@"; do
270 + case "${arg}" in
271 + --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
272 + --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
273 + --sources) DO_SOURCES=yes ;;
274 + --portage-tmpdir=*) PORT_TMPDIR="${arg#--portage-tmpdir=}" ;;
275 +
276 + --help)
277 + einfo "$0 usage:"
278 + einfo " --eprefix=[PATH] Path to new EPREFIX to create chained to the prefix"
279 + einfo " where this script is installed (${PARENT_EPREFIX})"
280 + einfo " --profile=[PATH] The absolute path to the profile to use. This path"
281 + einfo " must point to a directory within ${PARENT_EPREFIX}"
282 + einfo " --sources inherit 'source' statements from the parent make.conf"
283 + einfo " --portage-tmpdir=DIR use DIR as portage temporary directory."
284 + exit 0
285 + ;;
286 + esac
287 +done
288 +
289 +#
290 +# sanity check of given values
291 +#
292 +
293 +test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
294 +test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
295 +test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
296 +test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
297 +if test -n "${PORT_TMPDIR}"; then
298 + if ! test -d "${PORT_TMPDIR}"; then
299 + einfo "creating temporary directory ${PORT_TMPDIR}"
300 + mkdir -p "${PORT_TMPDIR}"
301 + fi
302 +fi
303 +
304 +einfo "creating chained prefix ${CHILD_EPREFIX}"
305 +
306 +#
307 +# functions needed below.
308 +#
309 +eend_exit() {
310 + eend $1
311 + [[ $1 != 0 ]] && exit 1
312 +}
313 +
314 +#
315 +# create the directories required to bootstrap the least.
316 +#
317 +ebegin "creating directory structure"
318 +(
319 + set -e
320 + mkdir -p "${CHILD_EPREFIX}"/etc/portage
321 + mkdir -p "${CHILD_EPREFIX}"/var/log
322 +)
323 +eend_exit $?
324 +
325 +#
326 +# create a make.conf and set PORTDIR and PORTAGE_TMPDIR
327 +#
328 +ebegin "creating make.conf"
329 +(
330 + set -e
331 + echo "#"
332 + echo "# The following values where taken from the parent prefix's"
333 + echo "# environment. Feel free to adopt them as you like."
334 + echo "#"
335 + echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
336 + echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
337 + echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
338 + niceness=$(portageq envvar PORTAGE_NICENESS || true)
339 + [[ -n ${niceness} ]] &&
340 + echo "PORTAGE_NICENESS=\"${niceness}\""
341 + echo "USE=\"prefix-chaining\""
342 + echo
343 + echo "# Mirrors from parent prefix."
344 + echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS || true)\""
345 + echo
346 + echo "#"
347 + echo "# Below comes the chained-prefix setup. Only change things"
348 + echo "# if you know exactly what you are doing!"
349 + echo "# by default, only DEPEND is inherited from the parent in"
350 + echo "# the chain. if you want more, make it a comma seperated"
351 + echo "# list - like this: DEPEND,RDEPEND,PDEPEN - which would the"
352 + echo "# all that is possible"
353 + echo "#"
354 + echo "PORTDIR=\"$(portageq envvar PORTDIR)\""
355 + echo "SYNC=\"$(portageq envvar SYNC || true)\""
356 + if test -z "${PORT_TMPDIR}"; then
357 + case "${CHILD_PROFILE}" in
358 + *winnt*) echo "PORTAGE_TMPDIR=/var/tmp" ;;
359 + *) echo "PORTAGE_TMPDIR=\"${CHILD_EPREFIX}/var/tmp\"" ;;
360 + esac
361 + else
362 + echo "PORTAGE_TMPDIR=\"${PORT_TMPDIR}\""
363 + fi
364 + echo "READONLY_EPREFIX=\"${PARENT_EPREFIX}:DEPEND\""
365 +
366 + if test "${DO_SOURCES}" == "yes"; then
367 + # don't fail if nothing found
368 + for f in /etc/portage/make.conf /etc/make.conf; do
369 + if [[ -r ${PARENT_EPREFIX}${f} ]]; then
370 + egrep "^source .*" "${PARENT_EPREFIX}${f}" 2>/dev/null || true
371 + break;
372 + fi
373 + done
374 + fi
375 +) > "${CHILD_EPREFIX}"/etc/portage/make.conf
376 +eend_exit $?
377 +
378 +#
379 +# create the make.profile symlinks.
380 +#
381 +ebegin "creating make.profile"
382 +(
383 + ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/portage/make.profile"
384 +)
385 +eend_exit $?
386 +
387 +#
388 +# adjust permissions of generated files.
389 +#
390 +ebegin "adjusting permissions"
391 +(
392 + chmod 644 "${CHILD_EPREFIX}"/etc/portage/make.conf
393 +)
394 +eend_exit $?
395 +
396 +#
397 +# now merge some basics.
398 +#
399 +ebegin "installing required basic packages"
400 +(
401 + # this -pv is there to avoid the global update output, which is
402 + # there on the first emerge run. (thus, just cosmetics).
403 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -p1qO baselayout-prefix > /dev/null 2>&1
404 +
405 + set -e
406 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO gentoo-functions baselayout-prefix prefix-chain-utils
407 +
408 + # merge with the parent's chost. this forces the use of the parent
409 + # compiler, which generally would be illegal - this is an exception.
410 + # This is required for example on winnt, because the wrapper has to
411 + # be able to use/resolve symlinks, etc. native winnt binaries miss that
412 + # ability, but interix binaries don't.
413 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" CHOST="${PARENT_CHOST}" emerge -1qO gcc-config
414 +
415 + # select the chain wrapper profile from gcc-config
416 + env -i "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
417 +
418 + # do this _AFTER_ selecting the correct compiler!
419 + PORTAGE_CONFIGROOT="${CHILD_EPREFIX}" EPREFIX="${CHILD_EPREFIX}" emerge -1qO libtool
420 +)
421 +eend_exit $?
422 +
423 +#
424 +# wow, all ok :)
425 +#
426 +ewarn
427 +ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/portage/make.conf."
428 +ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
429 +ewarn
430 +EOF
431 }