Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] should startprefix read prefixed etc/profile?
View unanswered posts
View posts from last 24 hours

 
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Gentoo for Mac OS X (Portage for Mac OS X)
View previous topic :: View next topic  
Author Message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Sun Jul 08, 2007 4:10 pm    Post subject: [SOLVED] should startprefix read prefixed etc/profile? Reply with quote

The bootstrap documentation suggests using a script called startprefix created with the bootstrap script:
Code:
$ cd $EPREFIX/usr/portage/scripts
$ ./bootstrap-prefix.sh $EPREFIX startscript
that will "will drop you into a prefix shell, where for example emerge is directly at your disposal".

I followed these instructions, but when I run startprefix the prefixed profile (~/Library/etc/profile) is never sourced. Thus my PATH isn't set and nothing from the prefix is at my disposal. Should the prefixed bash be reading my prefixed profile and bashrc?
_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire


Last edited by tallest on Mon Jul 09, 2007 8:15 pm; edited 2 times in total
Back to top
View user's profile Send private message
didymos
Advocate
Advocate


Joined: 10 Oct 2005
Posts: 4798
Location: California

PostPosted: Mon Jul 09, 2007 12:38 am    Post subject: Reply with quote

Why not just source it manually?
_________________
Thomas S. Howard
Back to top
View user's profile Send private message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Mon Jul 09, 2007 1:00 am    Post subject: Reply with quote

Any recommendations on how to do this?

If I just try
Code:
$ ~/Library/Gentoo/bin/bash --init-file ~/Library/Gentoo/etc/profile
bash doesn't source ~/.bashrc.

If I try
Code:
$ ~/Library/Gentoo/bin/bash --init-file ~/Library/Gentoo/etc/profile -c 'source ~/.bashrc'
~/.bashrc still isn't sourced.

I'd prefer not to put it into my ~/.bashrc as I'd like that to be the last thing sourced.

Thanks ,
Aaron
_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire
Back to top
View user's profile Send private message
didymos
Advocate
Advocate


Joined: 10 Oct 2005
Posts: 4798
Location: California

PostPosted: Mon Jul 09, 2007 3:06 am    Post subject: Reply with quote

Is ~/.bashrc executable? Also, when you specify --init-file, it overrides the normal "read ~/.bashrc" behavior. What I meant was to execute the shell, then at the prompt do "source ~/Library/Gentoo/etc/profile", and see if that sets the env stuff you need. I don't think the order in which things are sourced is going to matter much. Is the startprefix script very long? If not, I wouldn't mind having a look at it. You could also try executing bash like so:
Code:

~/Library/Gentoo/bin/bash -l


which will make it behave like a login shell. The -c option is usually used for noninteractive purposes. If you do:
Code:
bash -c 'echo "Hey, where all the white women at?"'


it'll just print the line and exit, leaving you in your original shell.
_________________
Thomas S. Howard
Back to top
View user's profile Send private message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Mon Jul 09, 2007 4:24 am    Post subject: Reply with quote

Yeah, all startprefix does is reset $SHELL and run
Code:
~/Library/Gentoo/bin/bash -l


The problem is that the prefixed bash is not reading the prefixed etc/profile. Everything is fine if I source it myself, but I'd like to automate the process without modifying my ~/.bashrc or ~/.profile so that I can get into the default (non-Gentoo) environment easily without sourcing the prefixed profile.

This means that I need a command to launch the prefixed bash, followed by a source of the prefixed etc/profile and my ~/.bashrc. The other option is to add a source ~/.bashrc to the prefixed etc/profile and use the --init-file option.

My question still stands though, why doesn't the prefixed bash source the prefixed etc/profile. I've even tried compiling it myself with
Code:
./configure --prefix=/Users/wilson/Library/Gentoo --sysconfdir=/Users/wilson/Library/Gentoo/etc
but it still just sources /etc/profile. The configure script has this to say about the --sysconfdir option
Code:
$ ./configure --help|grep sysconf
  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]

_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire
Back to top
View user's profile Send private message
didymos
Advocate
Advocate


Joined: 10 Oct 2005
Posts: 4798
Location: California

PostPosted: Mon Jul 09, 2007 6:00 am    Post subject: Reply with quote

OK, in /etc/profile is this comment:
Quote:

if [ -f /etc/bash/bashrc ] ; then
# Bash login shells run only /etc/profile
# Bash non-login shells run only /etc/bash/bashrc
# Since we want to run /etc/bash/bashrc regardless, we source it
# from here. It is unfortunate that there is no way to do
# this *after* the user's .bash_profile runs (without putting
# it in the user's dot-files), but it shouldn't make any
# difference.
. /etc/bash/bashrc


What you want, I think, is to do the equivalent for the ~/ files. For bash, it's ~/bash_profile (although it will also look for .profile and .bash_login), and the default contents are:
Code:

# /etc/skel/.bash_profile

# This file is sourced by bash for login shells.  The following line
# runs your .bashrc and is recommended by the bash info pages.
[[ -f ~/.bashrc ]] && . ~/.bashrc


which is why I asked about .bashrc being executable. I still don't know why it refuses to read the prefixed etc/profile, but I'd just add the "--init-file ~/Library/Gentoo/etc/profile" to the startprefix script. Of course all this depends on the current contents of ~/.profile, so if it already has the command to run .bashrc in it, then I've just wasted your time (unless .bashrc isn't executable).
_________________
Thomas S. Howard
Back to top
View user's profile Send private message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Mon Jul 09, 2007 4:28 pm    Post subject: Reply with quote

OK, I think I've found a kludge that seems to work. I was able to leave ~/Library/Gentoo/startprefix, /etc/profile, ~/Library/Gentoo/etc/profile, and ~/Library/Gentoo/etc/bash/bashrc in their original forms and added
~/.bashrc:
# if we are in the prefixed gentoo
if `echo $SHELL|grep Gentoo 1>/dev/null 2>&1` ; then
        # source prefixed profile
        source ${HOME}/Library/Gentoo/etc/profile
        # fix color ls
        alias ls='ls --color'
        # disable bold in PS1
        PS1=`echo $PS1|sed s/01\;/00\;/g`
        PS1=$PS1' '
        export PS1
fi
before I do anything else in my ~/.bashrc
_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire
Back to top
View user's profile Send private message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Mon Jul 09, 2007 8:17 pm    Post subject: Reply with quote

An update: Fabian Groffen, of prefixed portage, has fixed the issue. The prefixed bash now sources the prefixed etc files as expected. There is no need for my hack.

Thanks,
Aaron
_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire
Back to top
View user's profile Send private message
didymos
Advocate
Advocate


Joined: 10 Oct 2005
Posts: 4798
Location: California

PostPosted: Mon Jul 09, 2007 8:20 pm    Post subject: Reply with quote

Well, what was the fix?
_________________
Thomas S. Howard
Back to top
View user's profile Send private message
tallest
Tux's lil' helper
Tux's lil' helper


Joined: 09 Mar 2004
Posts: 145
Location: Socorro, NM, USA

PostPosted: Tue Jul 10, 2007 2:28 am    Post subject: Reply with quote

Fabian Groffen wrote:
On 09-07-2007 14:19:47 -0600, Aaron Wilson wrote:
> Thank you very much, it works as expected now. Out of curiosity, and so
> that your solution is googleable for anyone else who might run into this,
> what was the problem?

Due to some very wrong approach of patching files, I wiped out the
prefix patches, such that bash was compiled to be just a normal bash.
I now changed the approach to patch files, such that updates will either
just work or break the patch, alarming that something needs to be done.

--
Fabian Groffen
Gentoo on a different level

--
gentoo-alt@gentoo.org mailing list

_________________
Those who can make you believe in absurdities can make you commit atrocities. --Voltaire
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Gentoo for Mac OS X (Portage for Mac OS X) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum