diff options
author | Michael 'Mickey' Lauer <mickey@vanille-media.de> | 2005-07-06 19:25:34 +0000 |
---|---|---|
committer | Michael 'Mickey' Lauer <mickey@vanille-media.de> | 2005-07-06 19:25:34 +0000 |
commit | c2cb41dc49aee4d6905519ec74c34e957a633b8d (patch) | |
tree | 61db70843a2c901f759d9b2b9df9f6981a68b492 /lib/bb/shell.py | |
parent | 847ab802c90400d4fcde5e6b9d8c8eda0c29d01b (diff) | |
download | bitbake-c2cb41dc49aee4d6905519ec74c34e957a633b8d.tar.gz |
Shell:
- experimental support for glob expression (wildcards) in command 'build'
- add new command 'match <providers|files> <globexpr>' to see what matches against the expression
Diffstat (limited to 'lib/bb/shell.py')
-rw-r--r-- | lib/bb/shell.py | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/lib/bb/shell.py b/lib/bb/shell.py index 13bf9f0ca..f9b06e341 100644 --- a/lib/bb/shell.py +++ b/lib/bb/shell.py @@ -32,7 +32,6 @@ IDEAS: * more shell-like features: - output control, i.e. pipe output into grep, sort, etc. - job control, i.e. bring running commands into background and foreground - - wildcards for commands, i.e. build *opie* * start parsing in background right after startup * ncurses interface @@ -50,7 +49,7 @@ try: set except NameError: from sets import Set as set -import sys, os, imp, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue +import sys, os, imp, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch imp.load_source( "bitbake", os.path.dirname( sys.argv[0] )+"/bitbake" ) from bb import data, parse, build, fatal @@ -139,23 +138,24 @@ class BitBakeShellCommands: def build( self, params, cmd = "build" ): """Build a providee""" - name = params[0] - - oldcmd = cooker.configuration.cmd - cooker.configuration.cmd = cmd - cooker.build_cache = [] - cooker.build_cache_fail = [] - + globexpr = params[0] self._checkParsed() - - try: - cooker.buildProvider( name ) - except build.EventException, e: - print "ERROR: Couldn't build '%s'" % name - global last_exception - last_exception = e - - cooker.configuration.cmd = oldcmd + names = globfilter( cooker.status.pkg_pn.keys(), globexpr ) + if len( names ) == 0: names = [ globexpr ] + print "SHELL: Building %s..." % ' '.join( names ) + + for name in names: + oldcmd = cooker.configuration.cmd + cooker.configuration.cmd = cmd + cooker.build_cache = [] + cooker.build_cache_fail = [] + try: + cooker.buildProvider( name ) + except build.EventException, e: + print "ERROR: Couldn't build '%s'" % name + global last_exception + last_exception = e + cooker.configuration.cmd = oldcmd build.usage = "<providee>" def clean( self, params ): @@ -279,6 +279,19 @@ class BitBakeShellCommands: except IOError: print "ERROR: Couldn't open '%s'" % filename + def match( self, params ): + """Dump all files or providers matching a glob expression""" + what, globexpr = params + if what == "files": + self._checkParsed() + for key in globfilter( cooker.pkgdata.keys(), globexpr ): print key + elif what == "providers": + self._checkParsed() + for key in globfilter( cooker.status.pkg_pn.keys(), globexpr ): print key + else: + print "Usage: match %s" % self.print_.usage + match.usage = "<files|providers> <glob>" + def new( self, params ): """Create a new .bb file and open the editor""" dirname, filename = params @@ -585,6 +598,9 @@ def columnize( alist, width = 80 ): alist ) +def globfilter( names, pattern ): + return fnmatch.filter( names, pattern ) + ########################################################################## # Class MemoryOutput ########################################################################## |