Valentin David pushed to branch valentindavid/staging_order_and_link_files at BuildStream / buildstream
Commits:
-
df9dbaed
by Valentin David at 2018-10-04T07:58:48Z
4 changed files:
- buildstream/utils.py
- tests/integration/compose-symlinks.py
- + tests/integration/project/elements/compose-symlinks/a-overlay.bst
- + tests/integration/project/elements/compose-symlinks/compose-reverse.bst
Changes:
| ... | ... | @@ -821,12 +821,17 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result, |
| 821 | 821 |
permissions.append((destpath, os.stat(srcpath).st_mode))
|
| 822 | 822 |
|
| 823 | 823 |
elif stat.S_ISLNK(mode):
|
| 824 |
- if not safe_remove(destpath):
|
|
| 825 |
- result.ignored.append(path)
|
|
| 826 |
- continue
|
|
| 827 |
- |
|
| 828 | 824 |
target = os.readlink(srcpath)
|
| 829 | 825 |
target = _relative_symlink_target(destdir, destpath, target)
|
| 826 |
+ |
|
| 827 |
+ if os.path.isdir(destpath):
|
|
| 828 |
+ shutil.move(destpath,
|
|
| 829 |
+ os.path.join(os.path.dirname(destpath), target))
|
|
| 830 |
+ else:
|
|
| 831 |
+ if not safe_remove(destpath):
|
|
| 832 |
+ result.ignored.append(path)
|
|
| 833 |
+ continue
|
|
| 834 |
+ |
|
| 830 | 835 |
os.symlink(target, destpath)
|
| 831 | 836 |
|
| 832 | 837 |
elif stat.S_ISREG(mode):
|
| ... | ... | @@ -22,7 +22,9 @@ DATA_DIR = os.path.join( |
| 22 | 22 |
#
|
| 23 | 23 |
# Regression test for https://gitlab.com/BuildStream/buildstream/issues/270
|
| 24 | 24 |
@pytest.mark.datafiles(DATA_DIR)
|
| 25 |
-def test_compose_symlinks(cli, tmpdir, datafiles):
|
|
| 25 |
+@pytest.mark.parametrize("element", ["compose-symlinks/compose.bst",
|
|
| 26 |
+ "compose-symlinks/compose-reverse.bst"])
|
|
| 27 |
+def test_compose_symlinks(cli, tmpdir, datafiles, element):
|
|
| 26 | 28 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
| 27 | 29 |
checkout = os.path.join(cli.directory, 'checkout')
|
| 28 | 30 |
element_path = os.path.join(project, 'elements')
|
| ... | ... | @@ -33,10 +35,10 @@ def test_compose_symlinks(cli, tmpdir, datafiles): |
| 33 | 35 |
symlink_file = os.path.join(project_files, 'sbin')
|
| 34 | 36 |
os.symlink(os.path.join('usr', 'sbin'), symlink_file, target_is_directory=True)
|
| 35 | 37 |
|
| 36 |
- result = cli.run(project=project, args=['build', 'compose-symlinks/compose.bst'])
|
|
| 38 |
+ result = cli.run(project=project, args=['build', element])
|
|
| 37 | 39 |
result.assert_success()
|
| 38 | 40 |
|
| 39 |
- result = cli.run(project=project, args=['checkout', 'compose-symlinks/compose.bst', checkout])
|
|
| 41 |
+ result = cli.run(project=project, args=['checkout', element, checkout])
|
|
| 40 | 42 |
result.assert_success()
|
| 41 | 43 |
|
| 42 | 44 |
assert set(walk_dir(checkout)) == set(['/sbin', '/usr', '/usr/sbin',
|
| 1 |
+kind: import
|
|
| 2 |
+ |
|
| 3 |
+sources:
|
|
| 4 |
+- kind: local
|
|
| 5 |
+ path: files/compose-symlinks/overlay
|
| 1 |
+kind: compose
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: compose-symlinks/a-overlay.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+- filename: compose-symlinks/base.bst
|
|
| 7 |
+ type: build
|
|
| 8 |
+ |
|
| 9 |
+config:
|
|
| 10 |
+ include:
|
|
| 11 |
+ - runtime
|
