Esempio n. 1
0
    def __init__(self, options, args, config):
        self.options = options
        self.debug = self.options.debug
        self.debug_loglines = getattr(self.options, 'debug_loglines', None)

        # Bakery 3 compatibility, configure the logging module
        if (not hasattr(oebakery, "__version__")
                or oebakery.__version__.split(".")[0] < 4):
            logging.basicConfig(format="%(message)s")
            if self.debug:
                logging.getLogger().setLevel(logging.DEBUG)
            else:
                logging.getLogger().setLevel(logging.INFO)

        self.config = oelite.meta.DictMeta(meta=config)
        self.config["OE_IMPORTS"] = INITIAL_OE_IMPORTS
        self.config.import_env()
        os.environ.clear()
        self.config.pythonfunc_init()
        self.topdir = self.config.get("TOPDIR", True)
        self.set_manifest_origin()
        # FIXME: self.config.freeze("TOPDIR")

        self.confparser = confparse.ConfParser(self.config)
        self.confparser.parse("conf/oe-lite.conf")

        oelite.pyexec.exechooks(self.config, "post_conf_parse")

        # FIXME: refactor oelite.arch.init to a post_conf_parse hook
        oelite.arch.init(self.config)

        # Handle any INHERITs and inherit the base class
        inherits = ["core"] + (self.config.get("INHERIT", 1) or "").split()
        self.oeparser = oeparse.OEParser(self.config)
        for inherit in inherits:
            self.oeparser.reset_lexstate()
            self.oeparser.parse("classes/%s.oeclass" % (inherit), require=True)

        oelite.pyexec.exechooks(self.config, "post_common_inherits")

        self.cookbook = CookBook(self)

        # things (ritem, item, recipe, or package) to do
        if args:
            self.things_todo = args
        elif "OE_DEFAULT_THING" in self.config:
            self.things_todo = self.config.get("OE_DEFAULT_THING", 1).split()
        else:
            self.things_todo = ["world"]

        recipe_types = ("machine", "native", "sdk", "cross", "sdk-cross",
                        "canadian-cross")

        def thing_todo(thing):
            if not thing in self.things_todo:
                self.things_todo.append(thing)

        def dont_do_thing(thing):
            while thing in self.things_todo:
                self.things_todo.remove(thing)

        self.recipes_todo = set()
        if "universe" in self.things_todo:
            dont_do_thing("universe")
            for recipe_type in recipe_types:
                thing_todo(recipe_type + ":world")

        return