* [PATCH] bitbake: main: add 2 environment variables @ 2016-04-19 14:30 Ed Bartosh 2016-04-19 19:58 ` Richard Purdie 2016-04-20 7:31 ` [PATCH 1/2] " Ed Bartosh 0 siblings, 2 replies; 5+ messages in thread From: Ed Bartosh @ 2016-04-19 14:30 UTC (permalink / raw) To: bitbake-devel Bitbake uses set of environment variables to set command line options, e.g. seeting BBTOKEN variable has the same effect as using --token command line option. Added new environment variables BBPRECONF and BBPOSTCONF that are equivalents of --read and --postread command line options. They can be used by high level scripts to append or prepend configuration files to conf/local.conf [YOCTO #9235] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> --- bitbake/lib/bb/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py index e302173..1dd7877 100755 --- a/bitbake/lib/bb/main.py +++ b/bitbake/lib/bb/main.py @@ -250,6 +250,12 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): if "BBEVENTLOG" in os.environ: options.writeeventlog = os.environ["BBEVENTLOG"] + if "BBPRECONF" in os.environ: + option.prefile = os.environ["BBPRECONF"] + + if "BBPOSTCONF" in os.environ: + option.postfile = os.environ["BBPOSTCONF"] + # fill in proper log name if not supplied if options.writeeventlog is not None and len(options.writeeventlog) == 0: import datetime -- 2.1.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bitbake: main: add 2 environment variables 2016-04-19 14:30 [PATCH] bitbake: main: add 2 environment variables Ed Bartosh @ 2016-04-19 19:58 ` Richard Purdie 2016-04-20 6:20 ` Ed Bartosh 2016-04-20 7:31 ` [PATCH 1/2] " Ed Bartosh 1 sibling, 1 reply; 5+ messages in thread From: Richard Purdie @ 2016-04-19 19:58 UTC (permalink / raw) To: Ed Bartosh, bitbake-devel On Tue, 2016-04-19 at 17:30 +0300, Ed Bartosh wrote: > Bitbake uses set of environment variables to set command line > options, e.g. seeting BBTOKEN variable has the same effect > as using --token command line option. > > Added new environment variables BBPRECONF and BBPOSTCONF that > are equivalents of --read and --postread command line options. > They can be used by high level scripts to append or prepend > configuration files to conf/local.conf > > [YOCTO #9235] > > Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> > --- > bitbake/lib/bb/main.py | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py > index e302173..1dd7877 100755 > --- a/bitbake/lib/bb/main.py > +++ b/bitbake/lib/bb/main.py > @@ -250,6 +250,12 @@ class > BitBakeConfigParameters(cookerdata.ConfigParameters): > if "BBEVENTLOG" in os.environ: > options.writeeventlog = os.environ["BBEVENTLOG"] > > + if "BBPRECONF" in os.environ: > + option.prefile = os.environ["BBPRECONF"] > + > + if "BBPOSTCONF" in os.environ: > + option.postfile = os.environ["BBPOSTCONF"] > + I think for principle of least surprise the commandline should override the environment, append to the environment (but then which order?) or it should just error and tell the user if they specify both the commandline and environment options at the same time. Cheers, Richard ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bitbake: main: add 2 environment variables 2016-04-19 19:58 ` Richard Purdie @ 2016-04-20 6:20 ` Ed Bartosh 0 siblings, 0 replies; 5+ messages in thread From: Ed Bartosh @ 2016-04-20 6:20 UTC (permalink / raw) To: Richard Purdie; +Cc: bitbake-devel On Tue, Apr 19, 2016 at 08:58:56PM +0100, Richard Purdie wrote: > On Tue, 2016-04-19 at 17:30 +0300, Ed Bartosh wrote: > > Bitbake uses set of environment variables to set command line > > options, e.g. seeting BBTOKEN variable has the same effect > > as using --token command line option. > > > > Added new environment variables BBPRECONF and BBPOSTCONF that > > are equivalents of --read and --postread command line options. > > They can be used by high level scripts to append or prepend > > configuration files to conf/local.conf > > > > [YOCTO #9235] > > > > Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> > > --- > > bitbake/lib/bb/main.py | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py > > index e302173..1dd7877 100755 > > --- a/bitbake/lib/bb/main.py > > +++ b/bitbake/lib/bb/main.py > > @@ -250,6 +250,12 @@ class > > BitBakeConfigParameters(cookerdata.ConfigParameters): > > if "BBEVENTLOG" in os.environ: > > options.writeeventlog = os.environ["BBEVENTLOG"] > > > > + if "BBPRECONF" in os.environ: > > + option.prefile = os.environ["BBPRECONF"] > > + > > + if "BBPOSTCONF" in os.environ: > > + option.postfile = os.environ["BBPOSTCONF"] > > + > > I think for principle of least surprise the commandline should override > the environment, append to the environment (but then which order?) or > it should just error and tell the user if they specify both the > commandline and environment options at the same time. > I agree. I found it confusing myself. I did it this way to be consistent with current way of handling env variables in bitbake main(). I'll send v2 soon. -- Regards, Ed ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] bitbake: main: add 2 environment variables 2016-04-19 14:30 [PATCH] bitbake: main: add 2 environment variables Ed Bartosh 2016-04-19 19:58 ` Richard Purdie @ 2016-04-20 7:31 ` Ed Bartosh 2016-04-20 7:31 ` [PATCH 2/2] bitbake: main: set defaults from env variables Ed Bartosh 1 sibling, 1 reply; 5+ messages in thread From: Ed Bartosh @ 2016-04-20 7:31 UTC (permalink / raw) To: bitbake-devel Bitbake uses set of environment variables to set command line options, e.g. seeting BBTOKEN variable has the same effect as using --token command line option. Added new environment variables BBPRECONF and BBPOSTCONF that are equivalents of --read and --postread command line options. They can be used by high level scripts to append or prepend configuration files to conf/local.conf [YOCTO #9235] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> --- bitbake/lib/bb/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py index e302173..08ecdda 100755 --- a/bitbake/lib/bb/main.py +++ b/bitbake/lib/bb/main.py @@ -250,6 +250,12 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): if "BBEVENTLOG" in os.environ: options.writeeventlog = os.environ["BBEVENTLOG"] + if "BBPRECONF" in os.environ: + option.prefile.append(os.environ["BBPRECONF"]) + + if "BBPOSTCONF" in os.environ: + option.postfile.append(os.environ["BBPOSTCONF"]) + # fill in proper log name if not supplied if options.writeeventlog is not None and len(options.writeeventlog) == 0: import datetime -- 2.1.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] bitbake: main: set defaults from env variables 2016-04-20 7:31 ` [PATCH 1/2] " Ed Bartosh @ 2016-04-20 7:31 ` Ed Bartosh 0 siblings, 0 replies; 5+ messages in thread From: Ed Bartosh @ 2016-04-20 7:31 UTC (permalink / raw) To: bitbake-devel Environment variables BBSERVER, BBTOKEN and BBEVENTLOG silently overwrite bitbake command line arguments. This is confusing and can cause issues that are difficult to debug. It's better to use them as default values instead. Used environment variables BBSERVER, BBTOKEN and BBEVENTLOG to set default values for command line arguments. Changed setting default value of --ui command line argument from BITBAKE_UI to look similar way. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> --- bitbake/lib/bb/main.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py index 08ecdda..b843b7d 100755 --- a/bitbake/lib/bb/main.py +++ b/bitbake/lib/bb/main.py @@ -194,18 +194,16 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): parser.add_option("-P", "--profile", help = "Profile the command and save reports.", action = "store_true", dest = "profile", default = False) - env_ui = os.environ.get('BITBAKE_UI', None) - default_ui = env_ui or 'knotty' # @CHOICES@ is substituted out by BitbakeHelpFormatter above parser.add_option("-u", "--ui", help = "The user interface to use (@CHOICES@ - default %default).", - action="store", dest="ui", default=default_ui) + action="store", dest="ui", default=os.environ.get('BITBAKE_UI', 'knotty')) # @CHOICES@ is substituted out by BitbakeHelpFormatter above parser.add_option("-t", "--servertype", help = "Choose which server type to use (@CHOICES@ - default %default).", - action = "store", dest = "servertype", default = "process") + action = "store", dest = "servertype", default = ["process", "xmlrpc"]["BBSERVER" in os.environ]) parser.add_option("", "--token", help = "Specify the connection token to be used when connecting to a remote server.", - action = "store", dest = "xmlrpctoken") + action = "store", dest = "xmlrpctoken", default = os.environ.get("BBTOKEN")) parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not.", action = "store_true", dest = "revisions_changed", default = False) @@ -223,7 +221,7 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): action = "store_true", dest = "setsceneonly", default = False) parser.add_option("", "--remote-server", help = "Connect to the specified server.", - action = "store", dest = "remote_server", default = False) + action = "store", dest = "remote_server", default = os.environ.get("BBSERVER")) parser.add_option("-m", "--kill-server", help = "Terminate the remote server.", action = "store_true", dest = "kill_server", default = False) @@ -235,21 +233,11 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): action = "store_true", dest = "status_only", default = False) parser.add_option("-w", "--write-log", help = "Writes the event log of the build to a bitbake event json file. Use '' (empty string) to assign the name automatically.", - action = "store", dest = "writeeventlog") + action = "store", dest = "writeeventlog", default = os.environ.get("BBEVENTLOG")) options, targets = parser.parse_args(argv) - # some environmental variables set also configuration options - if "BBSERVER" in os.environ: - options.servertype = "xmlrpc" - options.remote_server = os.environ["BBSERVER"] - - if "BBTOKEN" in os.environ: - options.xmlrpctoken = os.environ["BBTOKEN"] - - if "BBEVENTLOG" in os.environ: - options.writeeventlog = os.environ["BBEVENTLOG"] - + # use configuration files from environment variables if "BBPRECONF" in os.environ: option.prefile.append(os.environ["BBPRECONF"]) -- 2.1.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-20 9:51 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-04-19 14:30 [PATCH] bitbake: main: add 2 environment variables Ed Bartosh 2016-04-19 19:58 ` Richard Purdie 2016-04-20 6:20 ` Ed Bartosh 2016-04-20 7:31 ` [PATCH 1/2] " Ed Bartosh 2016-04-20 7:31 ` [PATCH 2/2] bitbake: main: set defaults from env variables Ed Bartosh
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.