bitbake: factor out methods parseConfigurationFile() and handleCollections()
authorMichael 'Mickey' Lauer <mickey@vanille-media.de>
Wed, 25 May 2005 21:02:11 +0000 (21:02 +0000)
committerMichael 'Mickey' Lauer <mickey@vanille-media.de>
Wed, 25 May 2005 21:02:11 +0000 (21:02 +0000)
ChangeLog
MANIFEST
bin/bitbake

index bd7b0e1..adc9978 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,18 @@
 Changes in bitbake Trunk:
-       -kill default arguments in methods in the bb.data module
-       -kill default arguments in methods in the bb.fetch module
-       -the http/https/ftp fetcher will fail if the to be 
-        downloaded file was not found in DL_DIR (this is needed
-        to avoid unpacking the sourceforge mirror page)
-       -Switch to a cow like data instance for persistent and non
-        persisting mode (called data_smart.py)
-       -Changed the callback of bb.make.collect_bbfiles to carry
-        additional parameters
-       -Drastically reduced the amount of needed RAM by not holding
-        each data instance in memory when using a cache/persistent
-        storage
+       - add bitbake interactive shell (bitbake -i)
+       - refactor bitbake utility in OO style
+       - kill default arguments in methods in the bb.data module
+       - kill default arguments in methods in the bb.fetch module
+       - the http/https/ftp fetcher will fail if the to be 
+         downloaded file was not found in DL_DIR (this is needed
+         to avoid unpacking the sourceforge mirror page)
+       - Switch to a cow like data instance for persistent and non
+         persisting mode (called data_smart.py)
+       - Changed the callback of bb.make.collect_bbfiles to carry
+         additional parameters
+       - Drastically reduced the amount of needed RAM by not holding
+         each data instance in memory when using a cache/persistent
+         storage
 
 Changes in bitbake 1.2.1:
        The 1.2.1 release is meant as a intermediate release to lay the
index ea2440d..75eb880 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -17,6 +17,7 @@ lib/bb/manifest.py
 lib/bb/parse/BBHandler.py
 lib/bb/parse/ConfHandler.py
 lib/bb/parse/__init__.py
+lib/bb/shell.py
 doc/COPYING.GPL
 doc/COPYING.MIT
 doc/manual/html.css
index cf75b5d..824dd4d 100755 (executable)
@@ -139,6 +139,10 @@ class BBCooker:
     """
     Manages one bitbake build run
     """
+
+    ParsingStatus = BBParsingStatus     # make it visible from the shell
+    Statistics = BBStatistics           # make it visible from the shell
+
     def __init__( self ):
         self.build_cache_fail = []
         self.build_cache = []
@@ -581,13 +585,45 @@ class BBCooker:
                 self.build_cache_fail.append(fn)
 
     def interactiveMode( self ):
+        """Drop off into a shell"""
         try:
             from bb import shell
-        except ImportError:
-            print "Sorry, the shell is not available yet."
-            sys.exit( -1 )
+        except ImportError, details:
+            bb.fatal("Sorry, shell not available (%s)" % details )
         else:
-            shell.start()
+            shell.start( self )
+            sys.exit( 0 )
+
+    def parseConfigurationFile( self, afile ):
+        try:
+            make.cfg = bb.parse.handle( afile, make.cfg )
+        except IOError:
+            bb.fatal( "Unable to open %s" % afile )
+
+    def handleCollections( self, collections ):
+        """Handle collections"""
+        if collections:
+            collection_list = collections.split()
+            for c in collection_list:
+                regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, make.cfg, 1)
+                if regex == None:
+                    bb.error("BBFILE_PATTERN_%s not defined" % c)
+                    continue
+                priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, make.cfg, 1)
+                if priority == None:
+                    bb.error("BBFILE_PRIORITY_%s not defined" % c)
+                    continue
+                try:
+                    cre = re.compile(regex)
+                except re.error:
+                    bb.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
+                    continue
+                try:
+                    pri = int(priority)
+                    self.status.bbfile_config_priorities.append((cre, pri))
+                except ValueError:
+                    bb.error("invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))
+
 
     def cook( self, args ):
         if not make.options.cmd:
@@ -599,15 +635,9 @@ class BBCooker:
         make.cfg = bb.data.init()
 
         for f in make.options.file:
-            try:
-                make.cfg = bb.parse.handle(f, make.cfg)
-            except IOError:
-                bb.fatal("Unable to open %s" % f)
+            self.parseConfigurationFile( f )
 
-        try:
-            make.cfg = bb.parse.handle(os.path.join('conf', 'bitbake.conf'), make.cfg)
-        except IOError:
-            bb.fatal("Unable to open %s" % os.path.join('conf', 'bitbake.conf'))
+        self.parseConfigurationFile( os.path.join( "conf", "bitbake.conf" ) )
 
         if not bb.data.getVar("BUILDNAME", make.cfg):
             bb.data.setVar("BUILDNAME", os.popen('date +%Y%m%d%H%M').readline().strip(), make.cfg)
@@ -628,28 +658,7 @@ class BBCooker:
         ignore = bb.data.getVar("ASSUME_PROVIDED", make.cfg, 1) or ""
         self.status.ignored_dependencies = Set( ignore.split() )
 
-        collections = bb.data.getVar("BBFILE_COLLECTIONS", make.cfg, 1)
-        if collections:
-            collection_list = collections.split()
-            for c in collection_list:
-                regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, make.cfg, 1)
-                if regex == None:
-                    bb.error("BBFILE_PATTERN_%s not defined" % c)
-                    continue
-                priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, make.cfg, 1)
-                if priority == None:
-                    bb.error("BBFILE_PRIORITY_%s not defined" % c)
-                    continue
-                try:
-                    cre = re.compile(regex)
-                except re.error:
-                    bb.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
-                    continue
-                try:
-                    pri = int(priority)
-                    self.status.bbfile_config_priorities.append((cre, pri))
-                except ValueError:
-                    bb.error("invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))
+        self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", make.cfg, 1) )
 
         pkgs_to_build = None
         if args:
@@ -660,12 +669,11 @@ class BBCooker:
                 bbpkgs = bb.data.getVar('BBPKGS', make.cfg, 1)
                 if bbpkgs:
                         pkgs_to_build = bbpkgs.split()
-        if not pkgs_to_build and not make.options.show_versions:
+        if not pkgs_to_build and not make.options.show_versions and not make.options.interactive:
                 print "Nothing to do.  Use 'bitbake world' to build everything, or run 'bitbake --help'"
                 print "for usage information."
                 sys.exit(0)
 
-
         # Import Psyco if available and not disabled
         if not make.options.disable_psyco:
             try: