mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00

The current approach to remote datastores used in tinfoil is breaking. For example, adding a devupstream extension to a recipe with a git upstream, making it the preferred version and then running "devtool modify" on it causes get_srcrev() circular dependency issues. The problem is the override handling in the datastore is broken. This gets broken since remotedata:recieve_datastore() sets d.dict but doesn't update d.overridedata (or d.inchistory or d.varhistory). We could play whack-a-mole but the current implementation seems to be flawed to me. It also doesn't cover, or only partially covers some datastore operations and each needs new dedicated command API. Instead, step back and reimplement the way the datastore connector works. With this change, the datastore is either remote or local but the data is not spread on two sides of the connection. All the API is proxied over the connection by a single function for the datastore (and two to support variable history and include history). This code does not support using the datastore as a parameter to any data store functions. We did have one case of that but its just bad code and can be replaced. The result is something which is much simpler and less invasive to the datastore code itself, meaning its behaviour should be much more consistent. The existing tests for the remote data no longer make any sense and are removed. The one bug this code would have is if key/value pairs are returned over the IPC and those values contained a DataSmart object since we don't recurse into return values to find such things. Nothing appears to do that currently so lets worry about it if its ever an issue. This change should simplfy a ton of other issues and avoid a ton of other bugs so is a huge net gain. Tested with bitbake's and OE's selftests. (Bitbake rev: 85e03a64dd0a4ebe71009ec4bdf4192c04a9786e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
"""
|
|
BitBake 'remotedata' module
|
|
|
|
Provides support for using a datastore from the bitbake client
|
|
"""
|
|
|
|
# Copyright (C) 2016 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
import bb.data
|
|
|
|
class RemoteDatastores:
|
|
"""Used on the server side to manage references to server-side datastores"""
|
|
def __init__(self, cooker):
|
|
self.cooker = cooker
|
|
self.datastores = {}
|
|
self.locked = []
|
|
self.datastores[0] = self.cooker.data
|
|
self.nextindex = 1
|
|
|
|
def __len__(self):
|
|
return len(self.datastores)
|
|
|
|
def __getitem__(self, key):
|
|
# Cooker could have changed its datastore from under us
|
|
self.datastores[0] = self.cooker.data
|
|
return self.datastores[key]
|
|
|
|
def items(self):
|
|
return self.datastores.items()
|
|
|
|
def store(self, d, locked=False):
|
|
"""
|
|
Put a datastore into the collection. If locked=True then the datastore
|
|
is understood to be managed externally and cannot be released by calling
|
|
release().
|
|
"""
|
|
idx = self.nextindex
|
|
self.datastores[idx] = d
|
|
if locked:
|
|
self.locked.append(idx)
|
|
self.nextindex += 1
|
|
return idx
|
|
|
|
def check_store(self, d, locked=False):
|
|
"""
|
|
Put a datastore into the collection if it's not already in there;
|
|
in either case return the index
|
|
"""
|
|
for key, val in self.datastores.items():
|
|
if val is d:
|
|
idx = key
|
|
break
|
|
else:
|
|
idx = self.store(d, locked)
|
|
return idx
|
|
|
|
def release(self, idx):
|
|
"""Discard a datastore in the collection"""
|
|
if idx in self.locked:
|
|
raise Exception('Tried to release locked datastore %d' % idx)
|
|
del self.datastores[idx]
|
|
|