richardmaw-codethink pushed to branch master at BuildStream / buildstream
Commits:
-
233a7d83
by Richard Maw at 2018-09-14T08:53:14Z
-
f06f234a
by Richard Maw at 2018-09-14T08:53:14Z
-
f86ab8f6
by richardmaw-codethink at 2018-09-14T09:46:07Z
5 changed files:
- buildstream/_artifactcache/cascache.py
- buildstream/utils.py
- + tests/integration/project/elements/sockets/make-builddir-socket.bst
- + tests/integration/project/elements/sockets/make-install-root-socket.bst
- + tests/integration/sockets.py
Changes:
... | ... | @@ -684,6 +684,9 @@ class CASCache(ArtifactCache): |
684 | 684 |
symlinknode = directory.symlinks.add()
|
685 | 685 |
symlinknode.name = name
|
686 | 686 |
symlinknode.target = os.readlink(full_path)
|
687 |
+ elif stat.S_ISSOCK(mode):
|
|
688 |
+ # The process serving the socket can't be cached anyway
|
|
689 |
+ pass
|
|
687 | 690 |
else:
|
688 | 691 |
raise ArtifactError("Unsupported file type for {}".format(full_path))
|
689 | 692 |
|
... | ... | @@ -372,6 +372,8 @@ def copy_files(src, dest, *, files=None, ignore_missing=False, report_written=Fa |
372 | 372 |
Directories in `dest` are replaced with files from `src`,
|
373 | 373 |
unless the existing directory in `dest` is not empty in which
|
374 | 374 |
case the path will be reported in the return value.
|
375 |
+ |
|
376 |
+ UNIX domain socket files from `src` are ignored.
|
|
375 | 377 |
"""
|
376 | 378 |
presorted = False
|
377 | 379 |
if files is None:
|
... | ... | @@ -414,6 +416,8 @@ def link_files(src, dest, *, files=None, ignore_missing=False, report_written=Fa |
414 | 416 |
|
415 | 417 |
If a hardlink cannot be created due to crossing filesystems,
|
416 | 418 |
then the file will be copied instead.
|
419 |
+ |
|
420 |
+ UNIX domain socket files from `src` are ignored.
|
|
417 | 421 |
"""
|
418 | 422 |
presorted = False
|
419 | 423 |
if files is None:
|
... | ... | @@ -841,6 +845,13 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result, |
841 | 845 |
os.mknod(destpath, file_stat.st_mode, file_stat.st_rdev)
|
842 | 846 |
os.chmod(destpath, file_stat.st_mode)
|
843 | 847 |
|
848 |
+ elif stat.S_ISFIFO(mode):
|
|
849 |
+ os.mkfifo(destpath, mode)
|
|
850 |
+ |
|
851 |
+ elif stat.S_ISSOCK(mode):
|
|
852 |
+ # We can't duplicate the process serving the socket anyway
|
|
853 |
+ pass
|
|
854 |
+ |
|
844 | 855 |
else:
|
845 | 856 |
# Unsupported type.
|
846 | 857 |
raise UtilError('Cannot extract {} into staging-area. Unsupported type.'.format(srcpath))
|
1 |
+kind: manual
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: base.bst
|
|
5 |
+ type: build
|
|
6 |
+ |
|
7 |
+config:
|
|
8 |
+ build-commands:
|
|
9 |
+ - |
|
|
10 |
+ python3 -c '
|
|
11 |
+ from socket import socket, AF_UNIX, SOCK_STREAM
|
|
12 |
+ s = socket(AF_UNIX, SOCK_STREAM)
|
|
13 |
+ s.bind("testsocket")
|
|
14 |
+ '
|
1 |
+kind: manual
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: base.bst
|
|
5 |
+ type: build
|
|
6 |
+ |
|
7 |
+config:
|
|
8 |
+ install-commands:
|
|
9 |
+ - |
|
|
10 |
+ python3 -c '
|
|
11 |
+ from os.path import join
|
|
12 |
+ from sys import argv
|
|
13 |
+ from socket import socket, AF_UNIX, SOCK_STREAM
|
|
14 |
+ s = socket(AF_UNIX, SOCK_STREAM)
|
|
15 |
+ s.bind(join(argv[1], "testsocket"))
|
|
16 |
+ ' %{install-root}
|
1 |
+import os
|
|
2 |
+import pytest
|
|
3 |
+ |
|
4 |
+from buildstream import _yaml
|
|
5 |
+ |
|
6 |
+from tests.testutils import cli_integration as cli
|
|
7 |
+from tests.testutils.integration import assert_contains
|
|
8 |
+ |
|
9 |
+ |
|
10 |
+pytestmark = pytest.mark.integration
|
|
11 |
+ |
|
12 |
+DATA_DIR = os.path.join(
|
|
13 |
+ os.path.dirname(os.path.realpath(__file__)),
|
|
14 |
+ "project"
|
|
15 |
+)
|
|
16 |
+ |
|
17 |
+ |
|
18 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
19 |
+def test_builddir_socket_ignored(cli, tmpdir, datafiles):
|
|
20 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
21 |
+ element_name = 'sockets/make-builddir-socket.bst'
|
|
22 |
+ |
|
23 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
24 |
+ assert result.exit_code == 0
|
|
25 |
+ |
|
26 |
+ |
|
27 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
28 |
+def test_install_root_socket_ignored(cli, tmpdir, datafiles):
|
|
29 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
30 |
+ element_name = 'sockets/make-install-root-socket.bst'
|
|
31 |
+ |
|
32 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
33 |
+ assert result.exit_code == 0
|