Exporting existing environment variables into mock

Arun SAG sagarun at gmail.com
Thu Mar 5 02:14:45 UTC 2015


Hi,

I figured out the problem. Mock is called by consolehelper.
Consolehelper by default sanitizes the environment variables. You can
tell consolehelper what environment variable to keep by editing
/etc/security/console.apps/mock and adding the environment variable to
KEEP_ENV_VARS.

$ cat /etc/security/console.apps/mock
USER=root
PROGRAM=/usr/sbin/mock
SESSION=false
FALLBACK=false
KEEP_ENV_VARS=COLUMNS,SSH_AUTH_SOCK,BUILD_NUMBER

On Thu, Feb 26, 2015 at 6:28 PM, Arun SAG <sagarun at gmail.com> wrote:
> My build environment (jenkins) has an environment variable named
> 'BUILD_NUMBER', i want it to be available as a macro. To achieve this
> i have added something like this to my mock configuration file
>
> config_opts['macros']['%build_number'] = os.getenv('BUILD_NUMBER') if
> os.getenv('BUILD_NUMBER') != None else time.strftime('%d%m%Y%I%M')
>
>
> But, this os.getenv('BUILD_NUMBER') always returns 'None'. The
> environment variable which is available outside mock never gets
> exported to mock environment. My mock version  is 1.2.7.
>
> --
> Arun S A G
> http://zer0c00l.in/



-- 
Arun S A G
http://zer0c00l.in/


More information about the buildsys mailing list