From 1896047bae2d855bc8c3fe84c5a6fdce1f04f74f Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 20 May 2020 12:28:21 +0200 Subject: [PATCH] sources: pass the library dir to the sources The idea is that source can themselves spawn other modules, esp. new secrets modules. For this they need to know the library dir, aka 'libdir' throughout the osbuild source. Therefore change the SourceServer to directly get the library directory instead of just the sub-directory to the sources. Then pass the library directory to via the JSON API to the source. Adjust all usage of the SourceServer, including the tests. --- osbuild/pipeline.py | 4 +--- osbuild/sources.py | 9 +++++---- test/run/test_sources.py | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index 0b8c48b6..772a4c68 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -86,13 +86,11 @@ class Stage: "options": self.options, } - sources_dir = f"{libdir}/sources" if libdir else "/usr/lib/osbuild/sources" - ro_binds = [f"{sources_output}:/run/osbuild/sources"] with API(f"{build_root.api}/osbuild", args, interactive) as api, \ sources.SourcesServer(f"{build_root.api}/sources", - sources_dir, + libdir or "/usr/lib/osbuild", self.sources, f"{cache}/sources", sources_output, diff --git a/osbuild/sources.py b/osbuild/sources.py index 78c72858..fd389c55 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -7,9 +7,9 @@ from .util import jsoncomm class SourcesServer: # pylint: disable=too-many-instance-attributes - def __init__(self, socket_address, sources_libdir, options, cache, output, secrets=None): + def __init__(self, socket_address, libdir, options, cache, output, secrets=None): self.socket_address = socket_address - self.sources_libdir = sources_libdir + self.libdir = libdir self.cache = cache self.output = output self.options = options or {} @@ -24,11 +24,12 @@ class SourcesServer: "secrets": self.secrets.get(source, {}), "cache": f"{self.cache}/{source}", "output": f"{self.output}/{source}", - "checksums": checksums + "checksums": checksums, + "libdir": self.libdir } r = subprocess.run( - [f"{self.sources_libdir}/{source}"], + [f"{self.libdir}/sources/{source}"], input=json.dumps(msg), stdout=subprocess.PIPE, encoding="utf-8", diff --git a/test/run/test_sources.py b/test/run/test_sources.py index cf7cff36..8bbb35dd 100644 --- a/test/run/test_sources.py +++ b/test/run/test_sources.py @@ -92,7 +92,7 @@ class TestSources(unittest.TestCase): fileServer(), \ osbuild.sources.SourcesServer( f"{tmpdir}/sources-api", - "./sources", source_options, + "./", source_options, f"{tmpdir}/cache", f"{tmpdir}/dst"): self.check_case(source, case_options, f"{tmpdir}/sources-api") self.check_case(source, case_options, f"{tmpdir}/sources-api")