Skip to content
Snippets Groups Projects
Commit f86ab8f6 authored by richardmaw-codethink's avatar richardmaw-codethink
Browse files

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 !783
parents fc7f83ac f06f234a
No related branches found
No related tags found
Loading
Pipeline #30187674 passed
......@@ -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))
......
......@@ -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))
......
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")
'
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}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment