Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 128420 - emerge allows variables in /etc/profile to override those in the calling environment
Summary: emerge allows variables in /etc/profile to override those in the calling envi...
Status: RESOLVED DUPLICATE of bug 51370
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: PPC Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-01 11:05 UTC by Timothy Stotts
Modified: 2006-05-25 21:01 UTC (History)
0 users

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


Attachments
Emerge info output with sensitive information removed. (modified-emerge-info.txt,3.57 KB, text/plain)
2006-04-01 11:05 UTC, Timothy Stotts
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Stotts 2006-04-01 11:05:01 UTC
Expected:
    The following should propagate the LC_ALL value to the build environment.
# LC_ALL="anything" emerge "anything"

Actual:
    The LC_ALL from /etc/profile is always used by emerge, regardless of user environment.

Steps to demonstrate:
    (1) echo 'LC_ALL="en_US.utf-8"' > /etc/env.d/02locale
    (2) env-update && source /etc/profile
    (3) copy any ebuild from /usr/portage to /usr/local/portage
    (4) add the following line immediately past "src_unpack()"
        locale; export | grep LC_ALL; die "just testing env propagation"
    (5) LC_ALL="C" emerge "your_moified_ebuild"

    You will that that the variable LC_ALL="C" did NOT propagate.
    This is irrespective of FEATURES value.

    (6) unset LC_ALL; emerge info
        This command will show LC_ALL as unset, but then builds with LC_ALL from /etc/profile!

Workaround:
    modify /etc/portage/bashrc

    BUT emerge _should_ propagate LC_ALL just like any other variable!

Notes:
    # epm -qG portage
    sys-apps/portage-2.0.54
    
    Root and portage users have no LC_ALL in their bashrc or bash_profile files.
Comment 1 Timothy Stotts 2006-04-01 11:05:25 UTC
Created attachment 83643 [details]
Emerge info output with sensitive information removed.
Comment 2 Timothy Stotts 2006-04-01 11:29:43 UTC
One example of why this is an issue for users with unicode locales.
See: bug 125998 
     http://bugs.gentoo.org/show_bug.cgi?id=125998
Comment 3 SpanKY gentoo-dev 2006-04-01 12:55:32 UTC
works fine for me

added `locale` to the src_install() func of sandboxshell package:
# emerge sandboxshell
...
>>> Install sandboxshell-0.3 into /var/tmp/portage/sandboxshell-0.3/image/
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
...

# LC_ALL=C emerge sandboxshell
...
>>> Install sandboxshell-0.3 into /var/tmp/portage/sandboxshell-0.3/image/
LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
...

# LC_ALL=en_US emerge sandboxshell
...
>>> Install sandboxshell-0.3 into /var/tmp/portage/sandboxshell-0.3/image/
LANG=
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
...
Comment 4 Timothy Stotts 2006-04-01 13:29:12 UTC
(In reply to comment #3)
Sorry, but the bug says the the LC_ALL doesn't propagate if it is set in the global environment.  It is not set in your global environment, as shown by your command:

emerge sandboxshell
...
>>> Install sandboxshell-0.3 into /var/tmp/portage/sandboxshell-0.3/image/
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"


You need to set the global locale first, such that all logins already have a value of LC_ALL.  Then emerge fails to override that value.
Comment 5 Timothy Stotts 2006-04-01 13:40:47 UTC
I set the global locale to:  LC_ALL="en_US.utf-8"
via the file /etc/env.d/02locale

Now, to reproduce your test:

locale; LC_ALL="C" sudo emerge sandboxshell
LANG=
...
LC_ALL=en_US.utf8
Calculating dependencies ...done!
>>> emerge (1 of 1) app-shells/sandboxshell-0.3 to /
>>> md5 files   ;-) sandboxshell-0.3.ebuild
...
>>> Install sandboxshell-0.3 into /var/tmp/portage/sandboxshell-0.3/image/ category app-shells
LANG=
LC_CTYPE="en_US.utf-8"
...
LC_ALL=en_US.utf-8
Comment 6 SpanKY gentoo-dev 2006-04-01 13:53:59 UTC
i was working off of your summary rather than comments

your comment (6) is invalid, that is expected behavior

changing summary to be accurate since this isnt LC_ALL specific at all
Comment 7 Zac Medico gentoo-dev 2006-04-06 11:22:45 UTC
Allowing the calling env to override the build env is a recipe for unpredictable results.  Therefore, I'd say that it should be optional and non-default.  We can recommend /etc/portage/bashrc as the preferred means to override the env.
Comment 8 Timothy Stotts 2006-04-06 14:03:24 UTC
(In reply to comment #7)
Yes. Modifying /etc/portage/bashrc works.  But I don't wish to edit it every time I perform an emerge.

I suppose a set of case statements on $CATEGORY and $P in /etc/portage/bashrc could work, but manual setting of a particular environment variable from the 'emerge' command would be ideal.

Duplicating the behavior of /bin/env is the desired behavior.
Propose:
  - /etc/portage/package.env
  - emerge --env VARIABLE=VALUE ...

Most documentation and discussions indicate use of:
  VARIABLE=VALUE emerge ...

But this will not work across all systems, depending on /etc/env.d, /etc/profile.d, and /etc/profile .
Comment 9 Alec Warner (RETIRED) archtester gentoo-dev Security 2006-05-25 21:01:36 UTC

*** This bug has been marked as a duplicate of 51370 ***