We are using prefixed gentoo to create a standard C++ development environment for our team. After bootstrapping the prefix, we need an additional set of commands to be run inside it to install the packages that we need. However, it's not possible to pass commands to ./startprefix script as it does not pass its arguments to the underlying bash call. We apply the patch below to startprefix to be able to issue commands in the following way: ./prefix/startprefix -c "emerge -nvt -j2 gst-plugins-meta" || exit 15 The patch also makes sure the return value is propagated so that the parent script can detect errors and act accordingly. diff --git a/prefix/startprefix b/prefix/startprefix index fc13dd8..0a0126c 100755 --- a/prefix/startprefix +++ b/prefix/startprefix @@ -45,8 +45,10 @@ RETAIN="HOME=$HOME TERM=$TERM USER=$USER SHELL=$SHELL" # if we're on some X terminal, makes sense to inherit that too [[ -n ${DISPLAY} ]] && RETAIN+=" DISPLAY=$DISPLAY" # do it! -env -i $RETAIN $SHELL -l +env -i $RETAIN $SHELL -l "$@" +retcode=$? # and leave a message when we exit... the shell might return non-zero # without having real problems, so don't send alarming messages about # that echo "Leaving Gentoo Prefix with exit status $?" +exit $? Reproducible: Always
isn't it sufficient to run EPREFIX/usr/bin/emerge for this purpose?
Thanks Burak. As pointed out by Fabian, please just call EPREFIX/usr/bin/emerge directly.
Actually, I do second the OP's request - we do have similar requirements here, and a script shebang like '#! /prefix/startprefix' would be nice.
Ok, let's call it "runprefix" for the moment. I think runprefix - should be quiet (no echos about what it's going to do, etc) - possibly prepares a clean environment, not sure - runs $@ with $EPREFIX/bin/sh -c
*** Bug 543714 has been marked as a duplicate of this bug. ***
I'm about to introduce some app-portage/prefix-toolkit package for things like this. For now, these utilities come to my mind to provide: * /runprefix: This very one. * /startprefix: Extract from bootstrap-prefix.sh, to become updateable. * /usr/bin/prefix-stack-setup: Set up some Stacked Prefix (EAPI 7 related, formerly called Prefix Chaining). Thoughts? (category and package name, different/additional content, repo, ...) For /runprefix: Maybe this could be /usr/bin/prefixenv or /usr/bin/gentooenv or even /usr/bin/envrun, to be useful even for non-sh scripts (csh, Python, Perl, ...) - with usability similar to /usr/bin/env? For additional content: I've seen that we do not use toolchain-prefix-wrapper any more, but maintain the ldwrapper right within prefix-overlay/binutils-config/files/ now. Maybe that would fit into this prefix-toolkit.git repo, to have binutils-config use the prefix-toolkit distfile instead? For a repo: While it may be handy to maintain the scripts right within some FILESDIR, this might not be loved by non-prefix devs at least. There already is a proj/prefix/ namespace on gitweb.g.o, with 3 empty (sigh!) repos...
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=84b9f582e8c8db69a3b3677de702c7cc00ac3dab commit 84b9f582e8c8db69a3b3677de702c7cc00ac3dab Author: Michael Haubenwallner <haubi@gentoo.org> AuthorDate: 2019-03-20 09:35:34 +0000 Commit: Michael Haubenwallner <haubi@gentoo.org> CommitDate: 2019-03-25 14:18:51 +0000 app-portage/prefix-toolkit: new package * 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> app-portage/prefix-toolkit/metadata.xml | 8 + app-portage/prefix-toolkit/prefix-toolkit-0.ebuild | 565 +++++++++++++++++++++ 2 files changed, 573 insertions(+)
a suggestion for a runprefix script is welcome