Preserve extended attributes in tar archives
tar doesn't preserve extended attributes by default, causing Docker images to not have any correct set-capabilities bits set on binaries such as ping. This is fixed by adding the --xattrs flag to the tar command
This commit is contained in:
parent
3c3ad79cfd
commit
49aaa59bf0
@ -37,7 +37,7 @@ class ArchiveTar(object):
|
||||
[
|
||||
'tar', '-C', source_dir
|
||||
] + options + [
|
||||
'-c', '-f', self.filename
|
||||
'--xattrs', '-c', '-f', self.filename
|
||||
] + self.__get_archive_items(source_dir, exclude)
|
||||
)
|
||||
|
||||
@ -48,7 +48,7 @@ class ArchiveTar(object):
|
||||
[
|
||||
'tar', '-C', source_dir
|
||||
] + options + [
|
||||
'-cJ', '-f', self.filename + '.xz'
|
||||
'--xattrs', '-c', '-J', '-f', self.filename + '.xz'
|
||||
] + self.__get_archive_items(source_dir, exclude)
|
||||
)
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ Requires: python3-lxml
|
||||
# tools used by kiwi
|
||||
Requires: kiwi-tools
|
||||
Requires: rsync
|
||||
Requires: tar
|
||||
Requires: tar >= 1.2.7
|
||||
Requires: gptfdisk
|
||||
Requires: qemu-tools
|
||||
Requires: dosfstools
|
||||
|
||||
@ -25,7 +25,10 @@ class TestArchiveTar(object):
|
||||
mock_os_dir.return_value = ['foo', 'bar']
|
||||
self.archive.create('source-dir')
|
||||
mock_command.assert_called_once_with(
|
||||
['tar', '-C', 'source-dir', '-c', '-f', 'foo.tar', 'foo', 'bar']
|
||||
[
|
||||
'tar', '-C', 'source-dir',
|
||||
'--xattrs', '-c', '-f', 'foo.tar', 'foo', 'bar'
|
||||
]
|
||||
)
|
||||
|
||||
@patch('kiwi.archive.tar.Command.run')
|
||||
@ -34,7 +37,7 @@ class TestArchiveTar(object):
|
||||
archive.create('source-dir', ['foo', 'bar'])
|
||||
mock_command.assert_called_once_with(
|
||||
[
|
||||
'tar', '-C', 'source-dir', '-c', '-f', 'foo.tar',
|
||||
'tar', '-C', 'source-dir', '--xattrs', '-c', '-f', 'foo.tar',
|
||||
'.', '--exclude', './foo', '--exclude', './bar'
|
||||
]
|
||||
)
|
||||
@ -47,7 +50,7 @@ class TestArchiveTar(object):
|
||||
mock_command.assert_called_once_with(
|
||||
[
|
||||
'tar', '-C', 'source-dir',
|
||||
'-cJ', '-f', 'foo.tar.xz', 'foo', 'bar'
|
||||
'--xattrs', '-c', '-J', '-f', 'foo.tar.xz', 'foo', 'bar'
|
||||
]
|
||||
)
|
||||
|
||||
@ -69,5 +72,5 @@ class TestArchiveTar(object):
|
||||
mock_os_dir.return_value = ['foo', 'bar']
|
||||
self.archive.create('source-dir', ['foo'])
|
||||
mock_command.assert_called_once_with(
|
||||
['tar', '-C', 'source-dir', '-c', '-f', 'foo.tar', 'bar']
|
||||
['tar', '-C', 'source-dir', '--xattrs', '-c', '-f', 'foo.tar', 'bar']
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user