summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/remotedata.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:07:06 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 12:25:07 +0000
commit7d5c9860de05efc4272256ccefc530113f01d24e (patch)
tree659eb51c50941c2920215512e38d59da9cb85ee5 /bitbake/lib/bb/remotedata.py
parente271d7dc606185130e0e47327205bd423490b7c2 (diff)
downloadpoky-7d5c9860de05efc4272256ccefc530113f01d24e.tar.gz
bitbake: tinfoil: rewrite as a wrapper around the UI
Rewrite tinfoil as a wrapper around the UI, instead of the earlier approach of starting up just enough of cooker to do what we want. This has several advantages: * It now works when bitbake is memory-resident instead of failing with "ERROR: Only one copy of bitbake should be run against a build directory". * We can now connect an actual UI, thus you get things like the recipe parsing / cache loading progress bar and parse error handling for free * We can now handle events generated by the server if we wish to do so * We can potentially extend this to do more stuff, e.g. actually running build operations - this needs to be made more practical before we can use it though (since you effectively have to become the UI yourself for this at the moment.) The downside is that tinfoil no longer has direct access to cooker, the global datastore, or the cache. To mitigate this I have extended data_smart to provide remote access capability for the datastore, and created "fake" cooker and cooker.recipecache / cooker.collection adapter objects in order to avoid breaking too many tinfoil-using scripts that might be out there (we've never officially documented tinfoil or BitBake's internal code, but we can still make accommodations where practical). I've at least gone far enough to support all of the utilities that use tinfoil in OE-Core with some changes, but I know there are scripts such as Chris Larson's "bb" out there that do make other calls into BitBake code that I'm not currently providing access to through the adapters. Part of the fix for [YOCTO #5470]. (Bitbake rev: 3bbf8d611c859f74d563778115677a04f5c4ab43) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/remotedata.py')
-rw-r--r--bitbake/lib/bb/remotedata.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/bitbake/lib/bb/remotedata.py b/bitbake/lib/bb/remotedata.py
new file mode 100644
index 0000000000..932ee430ea
--- /dev/null
+++ b/bitbake/lib/bb/remotedata.py
@@ -0,0 +1,74 @@
1"""
2BitBake 'remotedata' module
3
4Provides support for using a datastore from the bitbake client
5"""
6
7# Copyright (C) 2016 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22import bb.data
23
24class RemoteDatastores:
25 """Used on the server side to manage references to server-side datastores"""
26 def __init__(self, cooker):
27 self.cooker = cooker
28 self.datastores = {}
29 self.locked = []
30 self.nextindex = 1
31
32 def __len__(self):
33 return len(self.datastores)
34
35 def __getitem__(self, key):
36 if key is None:
37 return self.cooker.data
38 else:
39 return self.datastores[key]
40
41 def items(self):
42 return self.datastores.items()
43
44 def store(self, d, locked=False):
45 """
46 Put a datastore into the collection. If locked=True then the datastore
47 is understood to be managed externally and cannot be released by calling
48 release().
49 """
50 idx = self.nextindex
51 self.datastores[idx] = d
52 if locked:
53 self.locked.append(idx)
54 self.nextindex += 1
55 return idx
56
57 def check_store(self, d, locked=False):
58 """
59 Put a datastore into the collection if it's not already in there;
60 in either case return the index
61 """
62 for key, val in self.datastores.items():
63 if val is d:
64 idx = key
65 break
66 else:
67 idx = self.store(d, locked)
68 return idx
69
70 def release(self, idx):
71 """Discard a datastore in the collection"""
72 if idx in self.locked:
73 raise Exception('Tried to release locked datastore %d' % idx)
74 del self.datastores[idx]