summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichardmaw-codethink <richard.maw@codethink.co.uk>2018-09-14 09:46:07 +0000
committerrichardmaw-codethink <richard.maw@codethink.co.uk>2018-09-14 09:46:07 +0000
commitf86ab8f6f5623da2988ab1ea7b83e8a655632177 (patch)
treeb3dd4602f754c9fa242dfc30f3bea6cca3fdb1c7
parentfc7f83ac1d48e4d9684296153082ce32231bdcb0 (diff)
parentf06f234a964b15ed35554739affb43f084d32604 (diff)
downloadbuildstream-f86ab8f6f5623da2988ab1ea7b83e8a655632177.tar.gz
Merge branch 'richardmaw/builddir-sockets' into 'master'
Fix: While caching build artifact: "Cannot extract [path to socket file] into staging-area. Unsupported type." See merge request BuildStream/buildstream!783
-rw-r--r--buildstream/_artifactcache/cascache.py3
-rw-r--r--buildstream/utils.py11
-rw-r--r--tests/integration/project/elements/sockets/make-builddir-socket.bst14
-rw-r--r--tests/integration/project/elements/sockets/make-install-root-socket.bst16
-rw-r--r--tests/integration/sockets.py33
5 files changed, 77 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index a93ec01ea..78191ccf8 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -684,6 +684,9 @@ class CASCache(ArtifactCache):
symlinknode = directory.symlinks.add()
symlinknode.name = name
symlinknode.target = os.readlink(full_path)
+ elif stat.S_ISSOCK(mode):
+ # The process serving the socket can't be cached anyway
+ pass
else:
raise ArtifactError("Unsupported file type for {}".format(full_path))
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 1aeea52be..60211f35b 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -372,6 +372,8 @@ def copy_files(src, dest, *, files=None, ignore_missing=False, report_written=Fa
Directories in `dest` are replaced with files from `src`,
unless the existing directory in `dest` is not empty in which
case the path will be reported in the return value.
+
+ UNIX domain socket files from `src` are ignored.
"""
presorted = False
if files is None:
@@ -414,6 +416,8 @@ def link_files(src, dest, *, files=None, ignore_missing=False, report_written=Fa
If a hardlink cannot be created due to crossing filesystems,
then the file will be copied instead.
+
+ UNIX domain socket files from `src` are ignored.
"""
presorted = False
if files is None:
@@ -841,6 +845,13 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result,
os.mknod(destpath, file_stat.st_mode, file_stat.st_rdev)
os.chmod(destpath, file_stat.st_mode)
+ elif stat.S_ISFIFO(mode):
+ os.mkfifo(destpath, mode)
+
+ elif stat.S_ISSOCK(mode):
+ # We can't duplicate the process serving the socket anyway
+ pass
+
else:
# Unsupported type.
raise UtilError('Cannot extract {} into staging-area. Unsupported type.'.format(srcpath))
diff --git a/tests/integration/project/elements/sockets/make-builddir-socket.bst b/tests/integration/project/elements/sockets/make-builddir-socket.bst
new file mode 100644
index 000000000..c19cd85b0
--- /dev/null
+++ b/tests/integration/project/elements/sockets/make-builddir-socket.bst
@@ -0,0 +1,14 @@
+kind: manual
+
+depends:
+- filename: base.bst
+ type: build
+
+config:
+ build-commands:
+ - |
+ python3 -c '
+ from socket import socket, AF_UNIX, SOCK_STREAM
+ s = socket(AF_UNIX, SOCK_STREAM)
+ s.bind("testsocket")
+ '
diff --git a/tests/integration/project/elements/sockets/make-install-root-socket.bst b/tests/integration/project/elements/sockets/make-install-root-socket.bst
new file mode 100644
index 000000000..85171bf54
--- /dev/null
+++ b/tests/integration/project/elements/sockets/make-install-root-socket.bst
@@ -0,0 +1,16 @@
+kind: manual
+
+depends:
+- filename: base.bst
+ type: build
+
+config:
+ install-commands:
+ - |
+ python3 -c '
+ from os.path import join
+ from sys import argv
+ from socket import socket, AF_UNIX, SOCK_STREAM
+ s = socket(AF_UNIX, SOCK_STREAM)
+ s.bind(join(argv[1], "testsocket"))
+ ' %{install-root}
diff --git a/tests/integration/sockets.py b/tests/integration/sockets.py
new file mode 100644
index 000000000..a2685062d
--- /dev/null
+++ b/tests/integration/sockets.py
@@ -0,0 +1,33 @@
+import os
+import pytest
+
+from buildstream import _yaml
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "project"
+)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_builddir_socket_ignored(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ element_name = 'sockets/make-builddir-socket.bst'
+
+ result = cli.run(project=project, args=['build', element_name])
+ assert result.exit_code == 0
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_install_root_socket_ignored(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ element_name = 'sockets/make-install-root-socket.bst'
+
+ result = cli.run(project=project, args=['build', element_name])
+ assert result.exit_code == 0