Bug 4031 - utils.py: BB_ENV_WHITELIST doesn't work well
Summary: utils.py: BB_ENV_WHITELIST doesn't work well
Status: VERIFIED FIXED
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: 1.4
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.4 M6
Assignee: Robert Yang
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2013-03-15 10:19 UTC by Robert Yang
Modified: 2013-04-10 06:12 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Yang 2013-03-15 10:19:56 UTC
The BB_ENV_WHITELIST doesn't work well and flushes BB_ENV_EXTRAWHITE, here is an example:

$ export BB_ENV_WHITELIST

$ export BB_NUMBER_THREADS=10 (or other value)

Edit conf/local.conf, change "BB_NUMBER_THREADS =" to "BB_NUMBER_THREADS ?="

$ bitbake -e | grep '^BB_NUMBER_THREADS ='
 we will notice that BB_NUMBER_THREADS' value doesn't change, though BB_NUMBER_THREADS in both BB_ENV_WHITELIST and BB_ENV_EXTRAWHITE.

This is because in bitbake/lib/bb/utils.py:

def approved_variables():
    """
    Determine and return the list of whitelisted variables which are approved
    to remain in the envrionment.
    """
    approved = []
    if 'BB_ENV_WHITELIST' in os.environ:
        approved = os.environ['BB_ENV_WHITELIST'].split()
    else:
        approved = preserved_envvars()
    if 'BB_ENV_EXTRAWHITE' in os.environ:
        approved.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
    return approved

The "approved" doesn't include BB_ENV_WHITELIST or BB_ENV_EXTRAWHITE when BB_ENV_WHITELIST is set (they are from preserved_envvars()), so the BB_ENV_WHITELIST and BB_ENV_EXTRAWHITE will removed from the env, and when the approved_variables () function is called again by cooker.py, their value will be None, the vars inside them will be removed from the env.

Add BB_ENV_WHITELIST and BB_ENV_EXTRAWHITE to the "approved" would fix the problem. I will send a patch sooner.
Comment 2 Ning Zhang 2013-04-10 06:12:08 UTC
Verified env:
    poky: bdca49274173153b1b0a72887de6321b4756b684
    branch: 1.4_M5

Verified steps:
1. setup poky env.
2. input below cli:
export BB_ENV_WHITELIST
export BB_NUMBER_THREADS=10
3. modify conf/local.conf, modify 'BB_NUMBER_THREADS = "4"' to 'BB_NUMBER_THREADS ?= ""'
4. execute: bitbake -e | grep '^BB_NUMBER_THREADS='

log:
builder@pek-yocto-build1:/buildarea3/zn/20130410$ export BB_ENV_WHITELIST
builder@pek-yocto-build1:/buildarea3/zn/20130410$ export BB_NUMBER_THREADS=10
builder@pek-yocto-build1:/buildarea3/zn/20130410$ echo $BB_ENV_WHITELIST
builder@pek-yocto-build1:/buildarea3/zn/20130410$ 
builder@pek-yocto-build1:/buildarea3/zn/20130410$ echo $BB_NUMBER_THREADS
10
builder@pek-yocto-build1:/buildarea3/zn/20130410$ bitbake -e | grep '^BB_NUMBER_THREADS='
BB_NUMBER_THREADS="10"
builder@pek-yocto-build1:/buildarea3/zn/20130410$