Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 51095

Summary: ebuild.sh lets /etc/profile.env override /etc/portage/bashrc
Product: Gentoo Linux Reporter: Ed Catmur <ed>
Component: [OLD] Core systemAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal CC: robbat2, robmoss
Priority: High Keywords: InVCS
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 44209, 51061    

Description Ed Catmur 2004-05-14 15:16:54 UTC
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.
Comment 1 Ed Catmur 2004-05-14 15:20:36 UTC
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"
  
Comment 2 Ed Catmur 2004-05-14 15:25:38 UTC
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
  
Comment 3 Nicholas Jones (RETIRED) gentoo-dev 2004-05-14 15:32:59 UTC
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.
Comment 4 Nicholas Jones (RETIRED) gentoo-dev 2004-05-18 07:50:01 UTC
Ok. /etc/portage/bashrc is now sourced immediately after profile.env.

>=portage-2.0.51_pre9
Comment 5 Jason Stubbs (RETIRED) gentoo-dev 2004-05-20 04:38:30 UTC
*** Bug 51552 has been marked as a duplicate of this bug. ***
Comment 6 Nicholas Jones (RETIRED) gentoo-dev 2004-10-22 08:47:33 UTC
Bug has been fixed and released in stable portages on or before 2.0.51-r2