From 3669d8cad5899ffd30a201676e6be89d5c5af6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Tue, 25 Jul 2023 17:24:36 +0200 Subject: [PATCH] Fixed check for extended attributes Only if libc reports errno 95 Operation not supported the method should return that extended attributes are not supported. Also add a debug information about the result of the call to get further information in the log file --- kiwi/utils/sync.py | 5 ++++- test/unit/utils/sync_test.py | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kiwi/utils/sync.py b/kiwi/utils/sync.py index 4ced42d6bad..2c02d2480d9 100644 --- a/kiwi/utils/sync.py +++ b/kiwi/utils/sync.py @@ -136,6 +136,9 @@ def target_supports_extended_attributes(self) -> bool: try: os.getxattr(self.target_dir, 'user.mime_type') except OSError as e: - if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA): + log.debug( + f'Check for extended attributes on {self.target_dir} said: {e}' + ) + if e.errno == errno.ENOTSUP: return False return True diff --git a/test/unit/utils/sync_test.py b/test/unit/utils/sync_test.py index 9077d4572c9..6d0ff580863 100644 --- a/test/unit/utils/sync_test.py +++ b/test/unit/utils/sync_test.py @@ -1,4 +1,5 @@ import os +import errno import logging from pytest import fixture from stat import ST_MODE @@ -66,7 +67,7 @@ def test_target_supports_extended_attributes(self, mock_getxattr): @patch('os.getxattr') def test_target_does_not_support_extended_attributes(self, mock_getxattr): - mock_getxattr.side_effect = OSError( - """[Errno 95] Operation not supported: b'/boot/efi""" - ) + effect = OSError() + effect.errno = errno.ENOTSUP + mock_getxattr.side_effect = effect assert self.sync.target_supports_extended_attributes() is False