diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-09-27 15:46:12 +0200 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-09-28 11:23:19 +0200 |
commit | 075ffefa8035422841eca13e56384859a03abfad (patch) | |
tree | 4b1e0d80b9877abc2ce7f4f68dbe6d186a7870ca | |
parent | 092038d2c1436c3fd6d62eb550b9fc6d97fec874 (diff) | |
download | buildstream-valentindavid/silverblue-path-1.2.tar.gz |
Fix outside-of-project check when project path is not canonical.valentindavid/silverblue-path-1.2
The issue happens on Silverblue where /home is a symlink to /var/home.
With this element-path is something like
/var/home/user/project/elements, when the project path is
/home/usr/project. Comparing canonical paths solves the issue.
Fixes #673
-rw-r--r-- | buildstream/_yaml.py | 2 | ||||
-rw-r--r-- | tests/format/project.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 66500fbad..4ee12a18c 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -467,7 +467,7 @@ def node_get_project_path(node, key, project_dir, *, "{}: Specified path '{}' does not exist" .format(provenance, path_str)) - is_inside = project_dir_path in full_resolved_path.parents or ( + is_inside = project_dir_path.resolve() in full_resolved_path.parents or ( full_resolved_path == project_dir_path) if path.is_absolute() or not is_inside: diff --git a/tests/format/project.py b/tests/format/project.py index df1a2364b..a27f3a5f7 100644 --- a/tests/format/project.py +++ b/tests/format/project.py @@ -181,3 +181,15 @@ def test_project_refs_options(cli, datafiles): # Assert that the cache keys are different assert result1.output != result2.output + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path')) +def test_element_path_project_path_contains_symlinks(cli, datafiles, tmpdir): + real_project = str(datafiles) + linked_project = os.path.join(str(tmpdir), 'linked') + os.symlink(real_project, linked_project) + os.makedirs(os.path.join(real_project, 'elements'), exist_ok=True) + with open(os.path.join(real_project, 'elements', 'element.bst'), 'w') as f: + f.write("kind: manual\n") + result = cli.run(project=linked_project, args=['show', 'element.bst']) + result.assert_success() |