diff options
Diffstat (limited to 'bitbake/lib/bb/shell.py')
| -rw-r--r-- | bitbake/lib/bb/shell.py | 113 |
1 files changed, 70 insertions, 43 deletions
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py index 93ad00d1ed..760c371d90 100644 --- a/bitbake/lib/bb/shell.py +++ b/bitbake/lib/bb/shell.py | |||
| @@ -56,9 +56,8 @@ try: | |||
| 56 | set | 56 | set |
| 57 | except NameError: | 57 | except NameError: |
| 58 | from sets import Set as set | 58 | from sets import Set as set |
| 59 | import sys, os, imp, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch | 59 | import sys, os, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch |
| 60 | imp.load_source( "bitbake", os.path.dirname( sys.argv[0] )+"/bitbake" ) | 60 | from bb import data, parse, build, fatal, cache, taskdata, runqueue, providers as Providers |
| 61 | from bb import data, parse, build, fatal | ||
| 62 | 61 | ||
| 63 | __version__ = "0.5.3.1" | 62 | __version__ = "0.5.3.1" |
| 64 | __credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 63 | __credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
| @@ -108,7 +107,7 @@ class BitBakeShellCommands: | |||
| 108 | preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 ) | 107 | preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 ) |
| 109 | if not preferred: preferred = item | 108 | if not preferred: preferred = item |
| 110 | try: | 109 | try: |
| 111 | lv, lf, pv, pf = cooker.findBestProvider( preferred ) | 110 | lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status, cooker.build_cache_fail) |
| 112 | except KeyError: | 111 | except KeyError: |
| 113 | if item in cooker.status.providers: | 112 | if item in cooker.status.providers: |
| 114 | pf = cooker.status.providers[item][0] | 113 | pf = cooker.status.providers[item][0] |
| @@ -156,14 +155,39 @@ class BitBakeShellCommands: | |||
| 156 | cooker.build_cache = [] | 155 | cooker.build_cache = [] |
| 157 | cooker.build_cache_fail = [] | 156 | cooker.build_cache_fail = [] |
| 158 | 157 | ||
| 159 | for name in names: | 158 | td = taskdata.TaskData(cooker.configuration.abort) |
| 160 | try: | 159 | |
| 161 | cooker.buildProvider( name, data.getVar("BUILD_ALL_DEPS", cooker.configuration.data, True) ) | 160 | try: |
| 162 | except build.EventException, e: | 161 | tasks = [] |
| 163 | print "ERROR: Couldn't build '%s'" % name | 162 | for name in names: |
| 164 | global last_exception | 163 | td.add_provider(cooker.configuration.data, cooker.status, name) |
| 165 | last_exception = e | 164 | providers = td.get_provider(name) |
| 166 | break | 165 | |
| 166 | if len(providers) == 0: | ||
| 167 | raise Providers.NoProvider | ||
| 168 | |||
| 169 | tasks.append([name, "do_%s" % cooker.configuration.cmd]) | ||
| 170 | |||
| 171 | td.add_unresolved(cooker.configuration.data, cooker.status) | ||
| 172 | |||
| 173 | rq = runqueue.RunQueue() | ||
| 174 | rq.prepare_runqueue(cooker.configuration.data, cooker.status, td, tasks) | ||
| 175 | rq.execute_runqueue(cooker, cooker.configuration.data, cooker.status, td, tasks) | ||
| 176 | |||
| 177 | except Providers.NoProvider: | ||
| 178 | print "ERROR: No Provider" | ||
| 179 | global last_exception | ||
| 180 | last_exception = Providers.NoProvider | ||
| 181 | |||
| 182 | except runqueue.TaskFailure, (fnid, fn, taskname): | ||
| 183 | print "ERROR: '%s, %s' failed" % (fn, taskname) | ||
| 184 | global last_exception | ||
| 185 | last_exception = runqueue.TaskFailure | ||
| 186 | |||
| 187 | except build.EventException, e: | ||
| 188 | print "ERROR: Couldn't build '%s'" % names | ||
| 189 | global last_exception | ||
| 190 | last_exception = e | ||
| 167 | 191 | ||
| 168 | cooker.configuration.cmd = oldcmd | 192 | cooker.configuration.cmd = oldcmd |
| 169 | 193 | ||
| @@ -233,7 +257,7 @@ class BitBakeShellCommands: | |||
| 233 | item = data.getVar('PN', bbfile_data, 1) | 257 | item = data.getVar('PN', bbfile_data, 1) |
| 234 | data.setVar( "_task_cache", [], bbfile_data ) # force | 258 | data.setVar( "_task_cache", [], bbfile_data ) # force |
| 235 | try: | 259 | try: |
| 236 | cooker.tryBuildPackage( os.path.abspath( bf ), item, bbfile_data ) | 260 | cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True ) |
| 237 | except build.EventException, e: | 261 | except build.EventException, e: |
| 238 | print "ERROR: Couldn't build '%s'" % name | 262 | print "ERROR: Couldn't build '%s'" % name |
| 239 | global last_exception | 263 | global last_exception |
| @@ -255,8 +279,7 @@ class BitBakeShellCommands: | |||
| 255 | 279 | ||
| 256 | def fileRebuild( self, params ): | 280 | def fileRebuild( self, params ): |
| 257 | """Rebuild (clean & build) a .bb file""" | 281 | """Rebuild (clean & build) a .bb file""" |
| 258 | self.fileClean( params ) | 282 | self.fileBuild( params, "rebuild" ) |
| 259 | self.fileBuild( params ) | ||
| 260 | fileRebuild.usage = "<bbfile>" | 283 | fileRebuild.usage = "<bbfile>" |
| 261 | 284 | ||
| 262 | def fileReparse( self, params ): | 285 | def fileReparse( self, params ): |
| @@ -265,14 +288,19 @@ class BitBakeShellCommands: | |||
| 265 | print "SHELL: Parsing '%s'" % bbfile | 288 | print "SHELL: Parsing '%s'" % bbfile |
| 266 | parse.update_mtime( bbfile ) | 289 | parse.update_mtime( bbfile ) |
| 267 | cooker.bb_cache.cacheValidUpdate(bbfile) | 290 | cooker.bb_cache.cacheValidUpdate(bbfile) |
| 268 | fromCache = cooker.bb_cache.loadData(bbfile, cooker) | 291 | fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data) |
| 269 | cooker.bb_cache.sync() | 292 | cooker.bb_cache.sync() |
| 270 | if False: #from Cache | 293 | if False: #fromCache: |
| 271 | print "SHELL: File has not been updated, not reparsing" | 294 | print "SHELL: File has not been updated, not reparsing" |
| 272 | else: | 295 | else: |
| 273 | print "SHELL: Parsed" | 296 | print "SHELL: Parsed" |
| 274 | fileReparse.usage = "<bbfile>" | 297 | fileReparse.usage = "<bbfile>" |
| 275 | 298 | ||
| 299 | def abort( self, params ): | ||
| 300 | """Toggle abort task execution flag (see bitbake -k)""" | ||
| 301 | cooker.configuration.abort = not cooker.configuration.abort | ||
| 302 | print "SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort ) | ||
| 303 | |||
| 276 | def force( self, params ): | 304 | def force( self, params ): |
| 277 | """Toggle force task execution flag (see bitbake -f)""" | 305 | """Toggle force task execution flag (see bitbake -f)""" |
| 278 | cooker.configuration.force = not cooker.configuration.force | 306 | cooker.configuration.force = not cooker.configuration.force |
| @@ -365,18 +393,14 @@ SRC_URI = "" | |||
| 365 | new.usage = "<directory> <filename>" | 393 | new.usage = "<directory> <filename>" |
| 366 | 394 | ||
| 367 | def pasteBin( self, params ): | 395 | def pasteBin( self, params ): |
| 368 | """Send a command + output buffer to http://pastebin.com""" | 396 | """Send a command + output buffer to the pastebin at http://rafb.net/paste""" |
| 369 | index = params[0] | 397 | index = params[0] |
| 370 | contents = self._shell.myout.buffer( int( index ) ) | 398 | contents = self._shell.myout.buffer( int( index ) ) |
| 371 | status, error, location = sendToPastebin( contents ) | 399 | sendToPastebin( "output of " + params[0], contents ) |
| 372 | if status == 302: | ||
| 373 | print "SHELL: Pasted to %s" % location | ||
| 374 | else: | ||
| 375 | print "ERROR: %s %s" % ( status, error ) | ||
| 376 | pasteBin.usage = "<index>" | 400 | pasteBin.usage = "<index>" |
| 377 | 401 | ||
| 378 | def pasteLog( self, params ): | 402 | def pasteLog( self, params ): |
| 379 | """Send the last event exception error log (if there is one) to http://oe.pastebin.com""" | 403 | """Send the last event exception error log (if there is one) to http://rafb.net/paste""" |
| 380 | if last_exception is None: | 404 | if last_exception is None: |
| 381 | print "SHELL: No Errors yet (Phew)..." | 405 | print "SHELL: No Errors yet (Phew)..." |
| 382 | else: | 406 | else: |
| @@ -387,12 +411,8 @@ SRC_URI = "" | |||
| 387 | filename = filename.strip() | 411 | filename = filename.strip() |
| 388 | print "SHELL: Pasting log file to pastebin..." | 412 | print "SHELL: Pasting log file to pastebin..." |
| 389 | 413 | ||
| 390 | status, error, location = sendToPastebin( open( filename ).read() ) | 414 | file = open( filename ).read() |
| 391 | 415 | sendToPastebin( "contents of " + filename, file ) | |
| 392 | if status == 302: | ||
| 393 | print "SHELL: Pasted to %s" % location | ||
| 394 | else: | ||
| 395 | print "ERROR: %s %s" % ( status, error ) | ||
| 396 | 416 | ||
| 397 | def patch( self, params ): | 417 | def patch( self, params ): |
| 398 | """Execute 'patch' command on a providee""" | 418 | """Execute 'patch' command on a providee""" |
| @@ -401,12 +421,13 @@ SRC_URI = "" | |||
| 401 | 421 | ||
| 402 | def parse( self, params ): | 422 | def parse( self, params ): |
| 403 | """(Re-)parse .bb files and calculate the dependency graph""" | 423 | """(Re-)parse .bb files and calculate the dependency graph""" |
| 404 | cooker.status = cooker.ParsingStatus() | 424 | cooker.status = cache.CacheData() |
| 405 | ignore = data.getVar("ASSUME_PROVIDED", cooker.configuration.data, 1) or "" | 425 | ignore = data.getVar("ASSUME_PROVIDED", cooker.configuration.data, 1) or "" |
| 406 | cooker.status.ignored_dependencies = set( ignore.split() ) | 426 | cooker.status.ignored_dependencies = set( ignore.split() ) |
| 407 | cooker.handleCollections( data.getVar("BBFILE_COLLECTIONS", cooker.configuration.data, 1) ) | 427 | cooker.handleCollections( data.getVar("BBFILE_COLLECTIONS", cooker.configuration.data, 1) ) |
| 408 | 428 | ||
| 409 | cooker.collect_bbfiles( cooker.myProgressCallback ) | 429 | (filelist, masked) = cooker.collect_bbfiles() |
| 430 | cooker.parse_bbfiles(filelist, masked, cooker.myProgressCallback) | ||
| 410 | cooker.buildDepgraph() | 431 | cooker.buildDepgraph() |
| 411 | global parsed | 432 | global parsed |
| 412 | parsed = True | 433 | parsed = True |
| @@ -434,7 +455,7 @@ SRC_URI = "" | |||
| 434 | name, var = params | 455 | name, var = params |
| 435 | bbfile = self._findProvider( name ) | 456 | bbfile = self._findProvider( name ) |
| 436 | if bbfile is not None: | 457 | if bbfile is not None: |
| 437 | the_data = cooker.bb_cache.loadDataFull(bbfile, cooker) | 458 | the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data) |
| 438 | value = the_data.getVar( var, 1 ) | 459 | value = the_data.getVar( var, 1 ) |
| 439 | print value | 460 | print value |
| 440 | else: | 461 | else: |
| @@ -538,7 +559,8 @@ SRC_URI = "" | |||
| 538 | if not preferred: preferred = item | 559 | if not preferred: preferred = item |
| 539 | 560 | ||
| 540 | try: | 561 | try: |
| 541 | lv, lf, pv, pf = cooker.findBestProvider( preferred ) | 562 | lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status, |
| 563 | cooker.build_cache_fail) | ||
| 542 | except KeyError: | 564 | except KeyError: |
| 543 | lv, lf, pv, pf = (None,)*4 | 565 | lv, lf, pv, pf = (None,)*4 |
| 544 | 566 | ||
| @@ -565,24 +587,29 @@ def completeFilePath( bbfile ): | |||
| 565 | return key | 587 | return key |
| 566 | return bbfile | 588 | return bbfile |
| 567 | 589 | ||
| 568 | def sendToPastebin( content ): | 590 | def sendToPastebin( desc, content ): |
| 569 | """Send content to http://oe.pastebin.com""" | 591 | """Send content to http://oe.pastebin.com""" |
| 570 | mydata = {} | 592 | mydata = {} |
| 571 | mydata["parent_pid"] = "" | 593 | mydata["lang"] = "Plain Text" |
| 572 | mydata["format"] = "bash" | 594 | mydata["desc"] = desc |
| 573 | mydata["code2"] = content | 595 | mydata["cvt_tabs"] = "No" |
| 574 | mydata["paste"] = "Send" | 596 | mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" ) |
| 575 | mydata["poster"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" ) | 597 | mydata["text"] = content |
| 576 | params = urllib.urlencode( mydata ) | 598 | params = urllib.urlencode( mydata ) |
| 577 | headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} | 599 | headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} |
| 578 | 600 | ||
| 579 | conn = httplib.HTTPConnection( "oe.pastebin.com:80" ) | 601 | host = "rafb.net" |
| 580 | conn.request("POST", "/", params, headers ) | 602 | conn = httplib.HTTPConnection( "%s:80" % host ) |
| 603 | conn.request("POST", "/paste/paste.php", params, headers ) | ||
| 581 | 604 | ||
| 582 | response = conn.getresponse() | 605 | response = conn.getresponse() |
| 583 | conn.close() | 606 | conn.close() |
| 584 | 607 | ||
| 585 | return response.status, response.reason, response.getheader( "location" ) or "unknown" | 608 | if response.status == 302: |
| 609 | location = response.getheader( "location" ) or "unknown" | ||
| 610 | print "SHELL: Pasted to http://%s%s" % ( host, location ) | ||
| 611 | else: | ||
| 612 | print "ERROR: %s %s" % ( response.status, response.reason ) | ||
| 586 | 613 | ||
| 587 | def completer( text, state ): | 614 | def completer( text, state ): |
| 588 | """Return a possible readline completion""" | 615 | """Return a possible readline completion""" |
