aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/layerconfparse.py
blob: 3a453bd156b2484948da89e589e7f3a517121376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Utility functions for parsing layer.conf using bitbake within layerindex-web
#
# Copyright (C) 2016 Wind River Systems
# Author: Liam R. Howlett <liam.howlett@windriver.com>
#
# Licensed under the MIT license, see COPYING.MIT for details
#

import sys
import os
import os.path
import utils
import tempfile
import re

class LayerConfParse:
    def __init__(self, enable_tracking=False, logger=None, bitbakepath=None, tinfoil=None):
        import settings
        self.logger = logger

        if not bitbakepath:
            fetchdir = settings.LAYER_FETCH_DIR
            bitbakepath = os.path.join(fetchdir, 'bitbake')
        self.bbpath = bitbakepath

        # Set up BBPATH.
        os.environ['BBPATH'] = str("%s" % self.bbpath)
        self.tinfoil = tinfoil

        if not self.tinfoil:
            self.tinfoil = utils.setup_tinfoil(self.bbpath, enable_tracking)

        self.config_data_copy = bb.data.createCopy(self.tinfoil.config_data)

    def parse_layer(self, layerbranch, layerdir):

        utils.checkout_layer_branch(layerbranch, layerdir, self.logger)


        # This is not a valid layer, parsing will cause exception.
        if not utils.is_layer_valid(layerdir):
            return None

        utils.parse_layer_conf(layerdir, self.config_data_copy, logger=self.logger)
        return self.config_data_copy

    def shutdown(self):
        self.tinfoil.shutdown()