Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 650284 - bootstrap-prefix.sh and eclassses should call bash with --noprofile --norc
Summary: bootstrap-prefix.sh and eclassses should call bash with --noprofile --norc
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo non-Linux Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-12 14:18 UTC by Martin Mokrejš
Modified: 2018-04-20 14:40 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Mokrejš 2018-03-12 14:18:25 UTC
Hi,
  I already email about this Benda but let me open a ticket for this. My host's /etc/profile calls modules to load some stuff. I can do the below (shown a s a "patch" to existing documentation at https://wiki.gentoo.org/wiki/Project:Prefix/Bootstrap

- ./bootstrap-bash.sh /var/tmp/bash 
+ ~/bash-4.4/bash ./bootstrap-bash.sh --noprofile --norc /var/tmp/bash 


  Unfortunately, bootstrap-prefix.sh calls several times bash on its own and also, portage does too. That is a problem. There should a way to pass some options to all bash calls, in my case passing down " --noprofile --norc".



  Here is what I get for many packages during stage1. Probably you can trace it down to some eclasses.


2018-03-12 15:06:58 (2.06 MB/s) - `/home/mmokrejs/gentoo/usr/portage/distfiles/ncurses-6.1.tar.gz' saved [3365395/3365395]

 * ncurses-6.1.tar.gz BLAKE2B SHA512 size ;-) ...                        [ ok ]
[sys-libs/ncurses-6.1-r1] bash: BASH_FUNC_module(): line 0: syntax error near unexpected token `)'
[sys-libs/ncurses-6.1-r1] bash: BASH_FUNC_module(): line 0: `BASH_FUNC_module() () {  eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)'
[sys-libs/ncurses-6.1-r1] bash: error importing function definition for `BASH_FUNC_module'
[sys-libs/ncurses-6.1-r1] bash: BASH_FUNC_ml(): line 0: syntax error near unexpected token `)'
[sys-libs/ncurses-6.1-r1] bash: BASH_FUNC_ml(): line 0: `BASH_FUNC_ml() () {  eval $($LMOD_DIR/ml_cmd "$@")'
[sys-libs/ncurses-6.1-r1] bash: error importing function definition for `BASH_FUNC_ml'
>>> Unpacking source...
>>> Unpacking ncurses-6.1.tar.gz to /home/mmokrejs/gentoo/tmp/var/tmp/portage/sys-libs/ncurses-6.1-r1/work
>>> Source unpacked in /home/mmokrejs/gentoo/tmp/var/tmp/portage/sys-libs/ncurses-6.1-r1/work
>>> Preparing source in /home/mmokrejs/gentoo/tmp/var/tmp/portage/sys-libs/ncurses-6.1-r1/work/ncurses-6.1 ...
 * Applying ncurses-6.0-gfbsd.patch ...
 [ ok ]
 * Applying ncurses-5.7-nongnu.patch ...
 [ ok ]




  I tried to edit
export PORTAGE_BASH="${ROOT}"/tmp/bin/bash
  and passing to it "--noprofile --norc" but that generates some errors elsewhere. I believe it is clear that /etc/profile and /etc/bashrc should not be executed, ever, during bootstrapping.
Comment 1 Fabian Groffen gentoo-dev 2018-03-12 14:31:16 UTC
IMO, if we use --noprofile --norc or something  during early stage1, then after bash is installed, we shouldn't have this problem any more
Comment 2 Martin Mokrejš 2018-03-12 14:39:56 UTC
Practically we do have this still. We cannot guarantee the apps called in parent's /etc/profile are executable at all inside Gentoo-Prefix. In my cause, the /etc/profile calls some apps via modules, and I just do not have them installed inside Gentoo-Prefix. Anyway, it could be differnet ARCH so I doubt it makes sense to even try this.
Comment 3 Martin Mokrejš 2018-03-12 14:57:25 UTC
Another example is here:



2018-03-10 04:43:57 (7.15 MB/s) - “prefix-portage-2.3.18.tar.bz2” saved [1230290/1230290]

* Unpacking prefix-portage
* Compiling prefix-portage
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for x86_64-pc-linux-gnu-gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... none
checking whether ln -s works... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for id... /usr/bin/id
checking whether /usr/bin/id is good enough... yes
checking for python... /apps/gentoo/tmp/usr/bin/python
checking whether /apps/gentoo/tmp/usr/bin/python 2.7.3 >= 2.7... yes
checking for rm... /bin/rm
checking for mv... /bin/mv
checking for basename... /bin/basename
checking for dirname... /usr/bin/dirname
checking for bash... /apps/gentoo/tmp/bin/bash
checking whether /apps/gentoo/tmp/bin/bash is GNU bash... yes
checking for sed... /bin/sed
checking whether /bin/sed is GNU sed... yes
checking for wget... /usr/bin/wget
checking whether /usr/bin/wget is GNU wget... yes
checking for find... /usr/bin/find
checking whether /usr/bin/find is GNU find... yes
checking for xargs... /usr/bin/xargs
checking whether /usr/bin/xargs is GNU xargs... yes
checking for grep... /bin/grep
checking whether /bin/grep is GNU grep... yes
checking for user id of mmokrejs... 3900
checking for group id of mmokrejs... 4011
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating subst-install
config.status: WARNING:  'subst-install.in' seems to ignore the --datarootdir setting
config.status: creating Makefile
config.status: creating man/Makefile
config.status: creating bin/Makefile
config.status: creating pym/Makefile
config.status: creating cnf/Makefile
config.status: WARNING:  'cnf/Makefile.in' seems to ignore the --datarootdir setting
config.status: executing depfiles commands
/apps/gentoo/tmp/bin/bash: BASH_FUNC_ml(): line 0: syntax error near unexpected token `)'
/apps/gentoo/tmp/bin/bash: BASH_FUNC_ml(): line 0: `BASH_FUNC_ml() () {  eval $($LMOD_DIR/ml_cmd "$@")'
/apps/gentoo/tmp/bin/bash: error importing function definition for `BASH_FUNC_ml'
/apps/gentoo/tmp/bin/bash: BASH_FUNC_module(): line 0: syntax error near unexpected token `)'
/apps/gentoo/tmp/bin/bash: BASH_FUNC_module(): line 0: `BASH_FUNC_module() () {  eval $($LMOD_CMD bash "$@");'
/apps/gentoo/tmp/bin/bash: error importing function definition for `BASH_FUNC_module'
Making all in man
make[1]: Entering directory `/apps/gentoo/var/tmp/portage-2.3.18/prefix-portage-2.3.18/man'
...
Comment 4 Larry the Git Cow gentoo-dev 2018-03-13 08:14:39 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=bdb73088dff33872b9f18a81fcc353aacab2e4c2

commit bdb73088dff33872b9f18a81fcc353aacab2e4c2
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-03-13 08:11:31 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-03-13 08:11:31 +0000

    scripts/bootstrap-prefix: lift restriction on bash-4.2
    
    Allow older bash (like 2.59 or 3.00) to be used in chost, interactive,
    stage1, since the latter builds bash in such a way that stage2 and 3 can
    use more advanced features.
    
    Bug: https://bugs.gentoo.org/650278
    Bug: https://bugs.gentoo.org/650284

 scripts/bootstrap-prefix.sh | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)}
Comment 5 Fabian Groffen gentoo-dev 2018-03-19 13:00:51 UTC
I think with the refinement in bootstrap_bash we should be doing better on this.  In addition, bootstrap_bash is now /always/ run to ensure having a bash that is resistant to this.
Comment 6 Martin Mokrejš 2018-03-20 22:12:48 UTC
(In reply to Fabian Groffen from comment #5)
> I think with the refinement in bootstrap_bash we should be doing better on
> this.  In addition, bootstrap_bash is now /always/ run to ensure having a
> bash that is resistant to this.

I fetched current version of bootstrap-prefix.sh but still, during src_prepare() ? is called new bash which sources /etc/profile ... so the issue is not gone in my opinion. I will upload the stage?.log files after the attempt completes.
Comment 7 Martin Mokrejš 2018-03-20 22:44:46 UTC
And probably you want to update https://wiki.gentoo.org/wiki/Project:Prefix/Bootstrap to reflect that bootstrap-bash.sh is somewhat functionally called from within bootstrap-prefix.sh.
Comment 8 Martin Mokrejš 2018-04-20 13:07:04 UTC
I re-tested and as of know, the /etc/profile -related errors appear only until bash-4.4_p19 is emerged during bootstrap.sh with this checksum:

$ sha1sum bootstrap-prefix.sh 
4a8edf9c7bd7b29a23da26f98757c1044aced8b3  bootstrap-prefix.sh
$

I placed the stage?.log logs at http://195.113.57.32/~mmokrejs/stage.log.tar.bz2 in case you want to check.
Comment 9 Fabian Groffen gentoo-dev 2018-04-20 13:22:24 UTC
But it does succeed eventually, does it?  Some errors cannot be avoided
Comment 10 Martin Mokrejš 2018-04-20 14:40:45 UTC
It does sems happy, according to the last message and I can get a shell afterwards. From this perspective, it was "OK" in this way even before your changes.

As of now I get:

$ /tmp/gentoo_test/startprefix 
Entering Gentoo Prefix /tmp/gentoo_test
prefix $ bash
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
prefix $ 

Well, I just wanted to report back, don't worry.