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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# Copyright (C) 2016-2018 Wind River Systems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import logging
import json
from collections import OrderedDict, defaultdict
from urllib.parse import unquote, urlparse
import layerindexlib
import layerindexlib.plugin
logger = logging.getLogger('BitBake.layerindexlib.cooker')
import bb.utils
def plugin_init(plugins):
return CookerPlugin()
class CookerPlugin(layerindexlib.plugin.IndexPlugin):
def __init__(self):
self.type = "cooker"
self.server_connection = None
self.ui_module = None
self.server = None
def load_index(self, url, load):
"""
Fetches layer information from a build configuration.
The return value is a dictionary containing API,
layer, branch, dependency, recipe, machine, distro, information.
url type should be 'cooker'.
url path is ignored
"""
up = urlparse(url)
if up.scheme != 'cooker':
raise layerindexlib.plugin.LayerIndexPluginUrlError(self.type, url)
d = self.layerindex.data
params = self.layerindex._parse_params(up.params)
# Only reason to pass a branch is to emulate them...
if 'branch' in params:
branches = params['branch'].split(',')
else:
branches = ['HEAD']
logger.debug(1, "Loading cooker data branches %s" % branches)
import bblayerlib
bblayers = bblayerlib.BBLayers(d)
index = bblayers.load_bblayers(branches=branches)
index.config = {}
index.config['TYPE'] = self.type
index.config['URL'] = url
if 'desc' in params:
index.config['DESCRIPTION'] = unquote(params['desc'])
else:
index.config['DESCRIPTION'] = 'local'
if 'cache' in params:
index.config['CACHE'] = params['cache']
index.config['BRANCH'] = branches
if 'layerDependencies' in load:
index = bblayers.load_layerDependencies()
if False and 'recipes' in load:
# Requires server access, which we don't have
index = bblayers.load_recipes(server)
if 'machines' in load:
index = bblayers.load_machines()
if 'distros' in load:
index = bblayers.load_distros()
return index
|