def handle_inherit(d):
    """
    Handle inheriting of classes. This will load all default classes.
    It could be faster, it could detect infinite loops but this is todo
    Also this delayed loading of bb.parse could impose a penalty
    """
    from bb.parse import handle

    files = (data.getVar('INHERIT', d, True) or "").split()
    if not "base" in i:
        files[0:0] = ["base"]

    __inherit_cache = data.getVar('__inherit_cache', d) or []
    for f in files:
        file = data.expand(f, d)
        if file[0] != "/" and file[-8:] != ".bbclass":
            file = os.path.join('classes', '%s.bbclass' % file)

        if not file in __inherit_cache:
            debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file))
            __inherit_cache.append( file )

            try:
                handle(file, d, True)
            except IOError:
                print "Failed to inherit %s" % file
    data.setVar('__inherit_cache', __inherit_cache, d)
Example #2
0
    def fileBuild( self, params, cmd = "build" ):
        """Parse and build a .bb file"""
        global last_exception
        name = params[0]
        bf = completeFilePath( name )
        print "SHELL: Calling '%s' on '%s'" % ( cmd, bf )

        oldcmd = cooker.configuration.cmd
        cooker.configuration.cmd = cmd

        thisdata = copy.deepcopy( initdata )
        # Caution: parse.handle modifies thisdata, hence it would
        # lead to pollution cooker.configuration.data, which is
        # why we use it on a safe copy we obtained from cooker right after
        # parsing the initial *.conf files
        try:
            bbfile_data = parse.handle( bf, thisdata )
        except parse.ParseError:
            print "ERROR: Unable to open or parse '%s'" % bf
        else:
            # Remove stamp for target if force mode active
            if cooker.configuration.force:
                bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (cmd, bf))
                bb.build.del_stamp('do_%s' % cmd, bbfile_data)

            item = data.getVar('PN', bbfile_data, 1)
            data.setVar( "_task_cache", [], bbfile_data ) # force
            try:
                cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True )
            except build.EventException, e:
                print "ERROR: Couldn't build '%s'" % name
                last_exception = e
def include(oldfn, fn, data, error_out):
    """
    error_out If True a ParseError will be raised if the to be included
    config-files could not be included.
    """
    if oldfn == fn: # prevent infinite recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, bb.data.getVar("BBPATH", data, 1))
        abs_fn = bb.utils.which(bbpath, fn)
        if abs_fn:
            fn = abs_fn

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
        logger.debug(2, "CONF file '%s' not found", fn)
Example #4
0
    def fileBuild( self, params, cmd = "build" ):
        """Parse and build a .bb file"""
        global last_exception
        name = params[0]
        bf = completeFilePath( name )
        print "SHELL: Calling '%s' on '%s'" % ( cmd, bf )

        oldcmd = cooker.configuration.cmd
        cooker.configuration.cmd = cmd

        thisdata = data.createCopy(cooker.configuration.data)
        data.update_data(thisdata)
        data.expandKeys(thisdata)

        try:
            bbfile_data = parse.handle( bf, thisdata )
        except parse.ParseError:
            print "ERROR: Unable to open or parse '%s'" % bf
        else:
            # Remove stamp for target if force mode active
            if cooker.configuration.force:
                bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (cmd, bf))
                bb.build.del_stamp('do_%s' % cmd, bbfile_data)

            item = data.getVar('PN', bbfile_data, 1)
            data.setVar( "_task_cache", [], bbfile_data ) # force
            try:
                cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True )
            except build.EventException, e:
                print "ERROR: Couldn't build '%s'" % name
                last_exception = e
Example #5
0
    def load_bbfile(bbfile, appends, config):
        """
        Load and parse one .bb build file
        Return the data and whether parsing resulted in the file being skipped
        """
        chdir_back = False

        from bb import data, parse

        # expand tmpdir to include this topdir
        data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
        bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
        oldpath = os.path.abspath(os.getcwd())
        parse.cached_mtime_noerror(bbfile_loc)
        bb_data = data.init_db(config)
        # The ConfHandler first looks if there is a TOPDIR and if not
        # then it would call getcwd().
        # Previously, we chdir()ed to bbfile_loc, called the handler
        # and finally chdir()ed back, a couple of thousand times. We now
        # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
        if not data.getVar('TOPDIR', bb_data):
            chdir_back = True
            data.setVar('TOPDIR', bbfile_loc, bb_data)
        try:
            if appends:
                data.setVar('__BBAPPEND', " ".join(appends), bb_data)
            bb_data = parse.handle(bbfile, bb_data)
            if chdir_back:
                os.chdir(oldpath)
            return bb_data
        except:
            if chdir_back:
                os.chdir(oldpath)
            raise
Example #6
0
def include(oldfn, fn, lineno, data, error_out):
    """
    error_out: A string indicating the verb (e.g. "include", "inherit") to be
    used in a ParseError that will be raised if the file to be included could
    not be included. Specify False to avoid raising an error in this case.
    """
    if oldfn == fn:  # prevent infinite recursion
        return None

    import bb

    fn = data.expand(fn)
    oldfn = data.expand(oldfn)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, data.getVar("BBPATH", 1))
        abs_fn = bb.utils.which(bbpath, fn)
        if abs_fn:
            fn = abs_fn

    from bb.parse import handle

    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno)
        logger.debug(2, "CONF file '%s' not found", fn)
Example #7
0
    def fileBuild( self, params, cmd = "build" ):
        """Parse and build a .bb file"""
        name = params[0]
        bf = completeFilePath( name )
        print "SHELL: Calling '%s' on '%s'" % ( cmd, bf )

        oldcmd = cooker.configuration.cmd
        cooker.configuration.cmd = cmd
        cooker.build_cache = []
        cooker.build_cache_fail = []

        thisdata = copy.deepcopy( initdata )
        # Caution: parse.handle modifies thisdata, hence it would
        # lead to pollution cooker.configuration.data, which is
        # why we use it on a safe copy we obtained from cooker right after
        # parsing the initial *.conf files
        try:
            bbfile_data = parse.handle( bf, thisdata )
        except parse.ParseError:
            print "ERROR: Unable to open or parse '%s'" % bf
        else:
            item = data.getVar('PN', bbfile_data, 1)
            data.setVar( "_task_cache", [], bbfile_data ) # force
            try:
                cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True )
            except build.EventException, e:
                print "ERROR: Couldn't build '%s'" % name
                global last_exception
                last_exception = e
Example #8
0
    def load_bbfile( self, bbfile , config):
        """
        Load and parse one .bb build file
        Return the data and whether parsing resulted in the file being skipped
        """

        import bb
        from bb import utils, data, parse, debug, event, fatal

        # expand tmpdir to include this topdir
        data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
        bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
        oldpath = os.path.abspath(os.getcwd())
        if bb.parse.cached_mtime_noerror(bbfile_loc):
            os.chdir(bbfile_loc)
        bb_data = data.init_db(config)
        try:
            bb_data = parse.handle(bbfile, bb_data) # read .bb data
            os.chdir(oldpath)
            return bb_data, False
        except bb.parse.SkipPackage:
            os.chdir(oldpath)
            return bb_data, True
        except:
            os.chdir(oldpath)
            raise
Example #9
0
def include(oldfn, fn, data, error_out):
    """

    error_out If True a ParseError will be reaised if the to be included
    """
    if oldfn == fn:  # prevent infinate recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, bb.data.getVar("BBPATH", data, 1))
        abs_fn = bb.which(bbpath, fn)
        if abs_fn:
            fn = abs_fn

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars())
        bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
def include(oldfn, fn, lineno, data, error_out):
    """
    error_out: A string indicating the verb (e.g. "include", "inherit") to be
    used in a ParseError that will be raised if the file to be included could
    not be included. Specify False to avoid raising an error in this case.
    """
    if oldfn == fn: # prevent infinite recursion
        return None

    import bb
    fn = data.expand(fn)
    oldfn = data.expand(oldfn)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, data.getVar("BBPATH", True))
        abs_fn, attempts = bb.utils.which(bbpath, fn, history=True)
        if abs_fn and bb.parse.check_dependency(data, abs_fn):
            bb.warn("Duplicate inclusion for %s in %s" % (abs_fn, data.getVar('FILE', True)))
        for af in attempts:
            bb.parse.mark_dependency(data, af)
        if abs_fn:
            fn = abs_fn
    elif bb.parse.check_dependency(data, fn):
        bb.warn("Duplicate inclusion for %s in %s" % (fn, data.getVar('FILE', True)))

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except (IOError, OSError):
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno)
        logger.debug(2, "CONF file '%s' not found", fn)
        bb.parse.mark_dependency(data, fn)
Example #11
0
    def load_bbfile(bbfile, appends, config):
        """
        Load and parse one .bb build file
        Return the data and whether parsing resulted in the file being skipped
        """
        chdir_back = False

        from bb import data, parse

        # expand tmpdir to include this topdir
        data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
        bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
        oldpath = os.path.abspath(os.getcwd())
        parse.cached_mtime_noerror(bbfile_loc)
        bb_data = data.init_db(config)
        # The ConfHandler first looks if there is a TOPDIR and if not
        # then it would call getcwd().
        # Previously, we chdir()ed to bbfile_loc, called the handler
        # and finally chdir()ed back, a couple of thousand times. We now
        # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
        if not data.getVar('TOPDIR', bb_data):
            chdir_back = True
            data.setVar('TOPDIR', bbfile_loc, bb_data)
        try:
            if appends:
                data.setVar('__BBAPPEND', " ".join(appends), bb_data)
            bb_data = parse.handle(bbfile, bb_data)
            if chdir_back:
                os.chdir(oldpath)
            return bb_data
        except:
            if chdir_back:
                os.chdir(oldpath)
            raise
Example #12
0
def include(oldfn, fn, lineno, data, error_out):
    """
    error_out: A string indicating the verb (e.g. "include", "inherit") to be
    used in a ParseError that will be raised if the file to be included could
    not be included. Specify False to avoid raising an error in this case.
    """
    if oldfn == fn:  # prevent infinite recursion
        return None

    import bb
    fn = data.expand(fn)
    oldfn = data.expand(oldfn)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, data.getVar("BBPATH", True))
        abs_fn = bb.utils.which(bbpath, fn)
        if abs_fn:
            fn = abs_fn

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars(),
                             oldfn, lineno)
        logger.debug(2, "CONF file '%s' not found", fn)
Example #13
0
    def load_bbfile( self, bbfile , config):
        """
        Load and parse one .bb build file
        Return the data and whether parsing resulted in the file being skipped
        """

        import bb
        from bb import utils, data, parse, debug, event, fatal

        # expand tmpdir to include this topdir
        data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
        bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
        oldpath = os.path.abspath(os.getcwd())
        if self.mtime(bbfile_loc):
            os.chdir(bbfile_loc)
        bb_data = data.init_db(config)
        try:
            bb_data = parse.handle(bbfile, bb_data) # read .bb data
            os.chdir(oldpath)
            return bb_data, False
        except bb.parse.SkipPackage:
            os.chdir(oldpath)
            return bb_data, True
        except:
            os.chdir(oldpath)
            raise
Example #14
0
def load_bbfile( bbfile ):
    """Load and parse one .bb build file"""

    if not cache in [None, '']:
        cache_bbfile = bbfile.replace( '/', '_' )

        try:
            cache_mtime = os.stat( "%s/%s" % ( cache, cache_bbfile ) )[8]
        except OSError:
            cache_mtime = 0
        file_mtime = parse.cached_mtime(bbfile)

        if file_mtime > cache_mtime:
            #print " : '%s' dirty. reparsing..." % bbfile
            pass
        else:
            #print " : '%s' clean. loading from cache..." % bbfile
            cache_data = unpickle_bb( cache_bbfile )
            if deps_clean(cache_data):
                return cache_data, True

    topdir = data.getVar('TOPDIR', cfg)
    if not topdir:
        topdir = os.path.abspath(os.getcwd())
        # set topdir to here
        data.setVar('TOPDIR', topdir, cfg)
    bbfile = os.path.abspath(bbfile)
    bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
    # expand tmpdir to include this topdir
    data.setVar('TMPDIR', data.getVar('TMPDIR', cfg, 1) or "", cfg)
    # set topdir to location of .bb file
    topdir = bbfile_loc
    #data.setVar('TOPDIR', topdir, cfg)
    # go there
    oldpath = os.path.abspath(os.getcwd())
    os.chdir(topdir)
    bb = data.createCopy(cfg)
    try:
        parse.handle(bbfile, bb) # read .bb data
        if not cache in [None, '']: pickle_bb( cache_bbfile, bb) # write cache
        os.chdir(oldpath)
        return bb, False
    finally:
        os.chdir(oldpath)
Example #15
0
def load_bbfile( bbfile ):
    """Load and parse one .bb build file"""

    if not cache in [None, '']:
        # get the times
        cache_mtime = data.init_db_mtime(cache, bbfile)
        file_mtime = parse.cached_mtime(bbfile)

        if file_mtime > cache_mtime:
            #print " : '%s' dirty. reparsing..." % bbfile
            pass
        else:
            #print " : '%s' clean. loading from cache..." % bbfile
            cache_data = data.init_db( cache, bbfile, False )
            if deps_clean(cache_data):
                return cache_data, True

    topdir = data.getVar('TOPDIR', cfg)
    if not topdir:
        topdir = os.path.abspath(os.getcwd())
        # set topdir to here
        data.setVar('TOPDIR', topdir, cfg)
    bbfile = os.path.abspath(bbfile)
    bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
    # expand tmpdir to include this topdir
    data.setVar('TMPDIR', data.getVar('TMPDIR', cfg, 1) or "", cfg)
    # set topdir to location of .bb file
    topdir = bbfile_loc
    #data.setVar('TOPDIR', topdir, cfg)
    # go there
    oldpath = os.path.abspath(os.getcwd())
    os.chdir(topdir)
    bb = data.init_db(cache,bbfile, True, cfg)
    try:
        parse.handle(bbfile, bb) # read .bb data
        if not cache in [None, '']:
            bb.commit(parse.cached_mtime(bbfile)) # write cache
        os.chdir(oldpath)
        return bb, False
    finally:
        os.chdir(oldpath)
Example #16
0
def include(oldfn, fn, data = bb.data.init()):
    if oldfn == fn: # prevent infinate recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    from bb.parse import handle
    try:
        ret = handle(fn, data, 1)
    except IOError:
        debug(2, "CONF file '%s' not found" % fn)
Example #17
0
    def load_bbfile( self, bbfile , cooker):
        """
        Load and parse one .bb build file
        Return the data and whether parsing resulted in the file being skipped
        """

        import bb
        from bb import utils, data, parse, debug, event, fatal

        topdir = data.getVar('TOPDIR', cooker.configuration.data)
        if not topdir:
            topdir = os.path.abspath(os.getcwd())
            # set topdir to here
            data.setVar('TOPDIR', topdir, cooker.configuration)
        bbfile = os.path.abspath(bbfile)
        bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
        # expand tmpdir to include this topdir
        data.setVar('TMPDIR', data.getVar('TMPDIR', cooker.configuration.data, 1) or "", cooker.configuration.data)
        # set topdir to location of .bb file
        topdir = bbfile_loc
        #data.setVar('TOPDIR', topdir, cfg)
        # go there
        oldpath = os.path.abspath(os.getcwd())
        if self.mtime(topdir):
            os.chdir(topdir)
        bb_data = data.init_db(cooker.configuration.data)
        try:
            parse.handle(bbfile, bb_data) # read .bb data
            os.chdir(oldpath)
            return bb_data, False
        except bb.parse.SkipPackage:
            os.chdir(oldpath)
            return bb_data, True
        except:
            os.chdir(oldpath)
            raise
def include(oldfn, fn, data, error_out):
    """

    error_out If True a ParseError will be reaised if the to be included
    """
    if oldfn == fn: # prevent infinate recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
        bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
Example #19
0
def include(oldfn, fn, data, error_out):
    """

    error_out If True a ParseError will be reaised if the to be included
    """
    if oldfn == fn: # prevent infinate recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
        bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
def include(oldfn, fn, data = bb.data.init(), error_out = False):
    """

    error_out If True a ParseError will be reaised if the to be included
    """
    if oldfn == fn: # prevent infinate recursion
        return None

    import bb
    fn = bb.data.expand(fn, data)
    oldfn = bb.data.expand(oldfn, data)

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except IOError:
        if error_out:
            raise ParseError("Could not include required file %(fn)s" % vars() )
        debug(2, "CONF file '%s' not found" % fn)
def include(oldfn, fn, lineno, data, error_out):
    """
    error_out: A string indicating the verb (e.g. "include", "inherit") to be
    used in a ParseError that will be raised if the file to be included could
    not be included. Specify False to avoid raising an error in this case.
    """
    if oldfn == fn:  # prevent infinite recursion
        return None

    import bb
    fn = data.expand(fn)
    oldfn = data.expand(oldfn)

    if not os.path.isabs(fn):
        dname = os.path.dirname(oldfn)
        bbpath = "%s:%s" % (dname, data.getVar("BBPATH", True))
        abs_fn, attempts = bb.utils.which(bbpath, fn, history=True)
        if abs_fn and bb.parse.check_dependency(data, abs_fn):
            bb.warn("Duplicate inclusion for %s in %s" %
                    (abs_fn, data.getVar('FILE', True)))
        for af in attempts:
            bb.parse.mark_dependency(data, af)
        if abs_fn:
            fn = abs_fn
    elif bb.parse.check_dependency(data, fn):
        bb.warn("Duplicate inclusion for %s in %s" %
                (fn, data.getVar('FILE', True)))

    from bb.parse import handle
    try:
        ret = handle(fn, data, True)
    except (IOError, OSError):
        if error_out:
            raise ParseError("Could not %(error_out)s file %(fn)s" % vars(),
                             oldfn, lineno)
        logger.debug(2, "CONF file '%s' not found", fn)
        bb.parse.mark_dependency(data, fn)
Example #22
0
    def fileBuild( self, params, cmd = "build" ):
        """Parse and build a .bb file"""
        name = params[0]
        bf = completeFilePath( name )
        print "SHELL: Calling '%s' on '%s'" % ( cmd, bf )

        oldcmd = make.options.cmd
        make.options.cmd = cmd
        cooker.build_cache = []
        cooker.build_cache_fail = []

        try:
            bbfile_data = parse.handle( bf, make.cfg )
        except parse.ParseError:
            print "ERROR: Unable to open or parse '%s'" % bf
        else:
            item = data.getVar('PN', bbfile_data, 1)
            data.setVar( "_task_cache", [], bbfile_data ) # force
            try:
                cooker.tryBuildPackage( os.path.abspath( bf ), item, bbfile_data )
            except build.EventException, e:
                print "ERROR: Couldn't build '%s'" % name
                global last_exception
                last_exception = e