summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-04-20 10:31:29 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-06 10:12:16 +0100
commit24f5c32b805bdc58202bf4ce239fee3b3b1de365 (patch)
tree8807759e115573101db4cd05a63e15fa575aab77 /bitbake
parent21b314d4d1e5b8fbeb4cc57006f0a110f0b3aa8f (diff)
downloadpoky-24f5c32b805bdc58202bf4ce239fee3b3b1de365.tar.gz
bitbake: bitbake: main: set defaults from env variables
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. (Bitbake rev: 87040be4ff54cd460961318224deef8f2ea4c85a) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/lib/bb/main.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index 08ecddaabd..b843b7dd70 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -194,18 +194,16 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
194 parser.add_option("-P", "--profile", help = "Profile the command and save reports.", 194 parser.add_option("-P", "--profile", help = "Profile the command and save reports.",
195 action = "store_true", dest = "profile", default = False) 195 action = "store_true", dest = "profile", default = False)
196 196
197 env_ui = os.environ.get('BITBAKE_UI', None)
198 default_ui = env_ui or 'knotty'
199 # @CHOICES@ is substituted out by BitbakeHelpFormatter above 197 # @CHOICES@ is substituted out by BitbakeHelpFormatter above
200 parser.add_option("-u", "--ui", help = "The user interface to use (@CHOICES@ - default %default).", 198 parser.add_option("-u", "--ui", help = "The user interface to use (@CHOICES@ - default %default).",
201 action="store", dest="ui", default=default_ui) 199 action="store", dest="ui", default=os.environ.get('BITBAKE_UI', 'knotty'))
202 200
203 # @CHOICES@ is substituted out by BitbakeHelpFormatter above 201 # @CHOICES@ is substituted out by BitbakeHelpFormatter above
204 parser.add_option("-t", "--servertype", help = "Choose which server type to use (@CHOICES@ - default %default).", 202 parser.add_option("-t", "--servertype", help = "Choose which server type to use (@CHOICES@ - default %default).",
205 action = "store", dest = "servertype", default = "process") 203 action = "store", dest = "servertype", default = ["process", "xmlrpc"]["BBSERVER" in os.environ])
206 204
207 parser.add_option("", "--token", help = "Specify the connection token to be used when connecting to a remote server.", 205 parser.add_option("", "--token", help = "Specify the connection token to be used when connecting to a remote server.",
208 action = "store", dest = "xmlrpctoken") 206 action = "store", dest = "xmlrpctoken", default = os.environ.get("BBTOKEN"))
209 207
210 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not.", 208 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not.",
211 action = "store_true", dest = "revisions_changed", default = False) 209 action = "store_true", dest = "revisions_changed", default = False)
@@ -223,7 +221,7 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
223 action = "store_true", dest = "setsceneonly", default = False) 221 action = "store_true", dest = "setsceneonly", default = False)
224 222
225 parser.add_option("", "--remote-server", help = "Connect to the specified server.", 223 parser.add_option("", "--remote-server", help = "Connect to the specified server.",
226 action = "store", dest = "remote_server", default = False) 224 action = "store", dest = "remote_server", default = os.environ.get("BBSERVER"))
227 225
228 parser.add_option("-m", "--kill-server", help = "Terminate the remote server.", 226 parser.add_option("-m", "--kill-server", help = "Terminate the remote server.",
229 action = "store_true", dest = "kill_server", default = False) 227 action = "store_true", dest = "kill_server", default = False)
@@ -235,21 +233,11 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
235 action = "store_true", dest = "status_only", default = False) 233 action = "store_true", dest = "status_only", default = False)
236 234
237 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.", 235 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.",
238 action = "store", dest = "writeeventlog") 236 action = "store", dest = "writeeventlog", default = os.environ.get("BBEVENTLOG"))
239 237
240 options, targets = parser.parse_args(argv) 238 options, targets = parser.parse_args(argv)
241 239
242 # some environmental variables set also configuration options 240 # use configuration files from environment variables
243 if "BBSERVER" in os.environ:
244 options.servertype = "xmlrpc"
245 options.remote_server = os.environ["BBSERVER"]
246
247 if "BBTOKEN" in os.environ:
248 options.xmlrpctoken = os.environ["BBTOKEN"]
249
250 if "BBEVENTLOG" in os.environ:
251 options.writeeventlog = os.environ["BBEVENTLOG"]
252
253 if "BBPRECONF" in os.environ: 241 if "BBPRECONF" in os.environ:
254 option.prefile.append(os.environ["BBPRECONF"]) 242 option.prefile.append(os.environ["BBPRECONF"])
255 243