stage: pass store instead of cache & var

Instead of passing separate `cache` and `var` variables, which are
both determined by the store, just pass the store.
This commit is contained in:
Christian Kellner 2021-01-05 20:02:36 +01:00 committed by Tom Gundersen
parent de021b468a
commit d028ea5b16
2 changed files with 11 additions and 18 deletions

View file

@ -54,15 +54,9 @@ class Stage:
m.update(json.dumps(self.options, sort_keys=True).encode())
return m.hexdigest()
def run(self,
tree,
runner,
build_tree,
cache,
monitor,
libdir,
var="/var/tmp"):
with buildroot.BuildRoot(build_tree, runner, libdir, var=var) as build_root, \
def run(self, tree, runner, build_tree, store, monitor, libdir):
var = store.store
with buildroot.BuildRoot(build_tree, runner, libdir, var) as build_root, \
tempfile.TemporaryDirectory(prefix="osbuild-sources-output-", dir=var) as sources_output:
args = {
@ -84,7 +78,7 @@ class Stage:
src = sources.SourcesServer(libdir,
self.sources,
os.path.join(cache, "sources"),
os.path.join(store.store, "sources"),
sources_output)
build_root.register_api(src)
@ -231,10 +225,9 @@ class Pipeline:
r = stage.run(path,
self.runner,
build_path,
object_store.store,
object_store,
monitor,
libdir,
var=object_store.store)
libdir)
monitor.result(r)

View file

@ -13,6 +13,7 @@ import osbuild
import osbuild.meta
from osbuild.formats import v1 as fmt
from osbuild.monitor import NullMonitor
from osbuild.objectstore import ObjectStore
from osbuild.pipeline import detect_host_runner
from .. import test
@ -46,16 +47,15 @@ class TestDescriptions(unittest.TestCase):
with tempfile.TemporaryDirectory() as tmpdir:
data = pathlib.Path(tmpdir, "data")
cache = pathlib.Path(tmpdir, "cache")
storedir = pathlib.Path(tmpdir, "store")
root = pathlib.Path("/")
runner = detect_host_runner()
monitor = NullMonitor(sys.stderr.fileno())
libdir = os.path.abspath(os.curdir)
store = ObjectStore(storedir)
data.mkdir()
for p in [data, cache]:
p.mkdir()
res = stage.run(data, runner, root, cache, monitor, libdir)
res = stage.run(data, runner, root, store, monitor, libdir)
self.assertEqual(res.success, True)
self.assertEqual(res.id, stage.id)