This patch replaces the absolute paths that are injected into BBLAYERS
by relative ones. These are relative to TOPDIR.
By that, the whole build directory becomes relocatable.
This is of value when using a shared sstate cache and build machines
with varying build locations (e.g. gitlab-ci runners).
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
kas/libcmds.py | 7 ++++++-
tests/test_layers.py | 12 +++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/kas/libcmds.py b/kas/libcmds.py
index 4a646f3..db94bae 100644
--- a/kas/libcmds.py
+++ b/kas/libcmds.py
@@ -253,6 +253,10 @@ class WriteBBConfig(Command):
return 'write_bbconfig'
def execute(self, ctx):
+ def _relative_to_topdir(ctx, layer):
+ relpath = os.path.relpath(layer, ctx.build_dir)
+ return '${TOPDIR}/' + relpath
+
def _write_bblayers_conf(ctx):
filename = ctx.build_dir + '/conf/bblayers.conf'
if not os.path.isdir(os.path.dirname(filename)):
@@ -261,7 +265,8 @@ class WriteBBConfig(Command):
fds.write(ctx.config.get_bblayers_conf_header())
fds.write('BBLAYERS ?= " \\\n ')
fds.write(' \\\n '.join(
- sorted(layer for repo in ctx.config.get_repos()
+ sorted(_relative_to_topdir(ctx, layer)
+ for repo in ctx.config.get_repos()
for layer in repo.layers)))
fds.write('"\n')
fds.write('BBPATH ?= "${TOPDIR}"\n')
diff --git a/tests/test_layers.py b/tests/test_layers.py
index 6981abc..3882701 100644
--- a/tests/test_layers.py
+++ b/tests/test_layers.py
@@ -26,6 +26,8 @@ from kas import kas
import pytest
+LAYERBASE = '${TOPDIR}/..'
+
@pytest.fixture
def dokas(tmpdir):
@@ -42,7 +44,7 @@ def test_layers_default(dokas):
match = 0
with open('build/conf/bblayers.conf', 'r') as f:
for line in f:
- if 'test_layers/kas ' in line:
+ if f'{LAYERBASE}/kas ' in line:
match += 1
assert(match == 1)
@@ -51,7 +53,7 @@ def test_layers_include(dokas):
match = 0
with open('build/conf/bblayers.conf', 'r') as f:
for line in f:
- if 'test_layers/kas1/meta-' in line:
+ if f'{LAYERBASE}/kas1/meta-' in line:
match += 1
assert(match == 2)
@@ -59,11 +61,11 @@ def test_layers_include(dokas):
def test_layers_exclude(dokas):
with open('build/conf/bblayers.conf', 'r') as f:
for line in f:
- assert('test_layers/kas2' not in line)
+ assert(f'{LAYERBASE}/kas2' not in line)
def test_layers_strip_dot(dokas):
with open('build/conf/bblayers.conf', 'r') as f:
lines = f.readlines()
- assert(any('test_layers/kas3 ' in x for x in lines))
- assert(any('test_layers/kas3/meta-bar' in x for x in lines))
+ assert(any(f'{LAYERBASE}/kas3 ' in x for x in lines))
+ assert(any(f'{LAYERBASE}/kas3/meta-bar' in x for x in lines))
--
2.30.2