From portage(5): /etc/portage/ bashrc If needed this file can be used to setup a different environment for ebuilds than the root environment. Syn- tax is the same as any other bash script. Currently /etc/portage/bashrc is sourced via being the BASH_RC env to the spawn of ebuild.sh. However in ebuild.sh /etc/profile.env is sourced; so settings in /etc/profile.env override those in /etc/portage/bashrc. This is inconsistent with the behaviour described in the above documentation. I suggest that /etc/portage/bashrc should instead be sourced inside ebuild.sh, after /etc/profile.env is sourced: --- /usr/sbin/ebuild.sh 2004/05/14 22:13:08 1.1 +++ /usr/sbin/ebuild.sh 2004/05/14 22:15:41 @@ -64,6 +64,10 @@ fi [ ! -z "$OCC" ] && export CC="$OCC" [ ! -z "$OCXX" ] && export CXX="$OCXX" +if [ -f /etc/portage/bashrc ]; then + source /etc/profile/bashrc +fi + export PATH="/sbin:/usr/sbin:/usr/lib/portage/bin:/bin:/usr/bin:${ROOTPATH}" [ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH" It should go after CC/CXX are saved and restored from sourcing profile.env, because the admin may wish to override CC for a particular package in /etc/portage/bashrc.
Sorry, that should be =================================================================== RCS file: /usr/sbin/ebuild.sh,v retrieving revision 1.1 diff -up -r1.1 /usr/sbin/ebuild.sh --- /usr/sbin/ebuild.sh 2004/05/14 22:13:08 1.1 +++ /usr/sbin/ebuild.sh 2004/05/14 22:20:16 @@ -64,6 +64,10 @@ fi [ ! -z "$OCC" ] && export CC="$OCC" [ ! -z "$OCXX" ] && export CXX="$OCXX" +if [ -f /etc/portage/bashrc ]; then + source /etc/portage/bashrc +fi + export PATH="/sbin:/usr/sbin:/usr/lib/portage/bin:/bin:/usr/bin:${ROOTPATH}" [ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH"
Aargh, of course I did that against /usr/sbin/ebuild.sh not /usr/lib/portage/bin/ebuild.sh. Sorry for the bugspam. Also this patch puts it after PATH is munged as bashrc may wish to alter that as well. --- /usr/lib/portage/bin/ebuild.sh 2004/05/14 22:23:06 1.1 +++ /usr/lib/portage/bin/ebuild.sh 2004/05/14 22:23:54 @@ -67,6 +67,10 @@ fi export PATH="/sbin:/usr/sbin:/usr/lib/portage/bin:/bin:/usr/bin:${ROOTPATH}" [ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH" +if [ -f /etc/portage/bashrc ]; then + source /etc/portage/bashrc +fi + # Grab our new utility functions. source /usr/lib/portage/bin/extra_functions.sh
The problem is repetition... BASH_RC is an environment variable... and left alone it does bad things by using custom root user rc's. If you source it, you're duplicating the data. This potentially can cause inconsistencies if the variables are not solidly defined. It needs to be looked into further.
Ok. /etc/portage/bashrc is now sourced immediately after profile.env. >=portage-2.0.51_pre9
*** Bug 51552 has been marked as a duplicate of this bug. ***
Bug has been fixed and released in stable portages on or before 2.0.51-r2