Skip to content

Commit

Permalink
Merge pull request #2330 from OSInside/delete_xattr_requirement
Browse files Browse the repository at this point in the history
Delete (py)xattr module requirement
  • Loading branch information
Conan-Kudo authored Jul 20, 2023
2 parents e0c3451 + b7a64fe commit dcf38b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
9 changes: 4 additions & 5 deletions kiwi/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
import os
import errno
import logging
from stat import ST_MODE
from typing import List
import xattr

# project
from kiwi.command import Command
Expand Down Expand Up @@ -134,9 +134,8 @@ def target_supports_extended_attributes(self) -> bool:
:rtype: bool
"""
try:
xattr.getxattr(self.target_dir, 'user.mime_type')
except Exception as e:
if format(e).startswith('[Errno 95]'):
# libc interface [Errno 95] Operation not supported:
os.getxattr(self.target_dir, 'user.mime_type')
except OSError as e:
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
return False
return True
10 changes: 0 additions & 10 deletions package/python-kiwi-spec-template
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,6 @@ Requires: python%{python3_pkgversion}-docopt
Requires: python%{python3_pkgversion}-lxml
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-setuptools
%if (0%{?suse_version} && 0%{?suse_version} < 1550)
Requires: python%{python3_pkgversion}-xattr
%else
Requires: python%{python3_pkgversion}-pyxattr
%endif
%if ! (0%{?rhel} && 0%{?rhel} < 8)
Recommends: kiwi-man-pages
%endif
Expand Down Expand Up @@ -620,11 +615,6 @@ Provides manual pages to describe the kiwi commands
# as an independent script
sed -e "s|#!/usr/bin/env python||" -i kiwi/xml_parse.py

%if 0%{?suse_version} && 0%{?suse_version} < 1550
# For older SUSE distributions, use the other xattr Python module
sed -e "s|pyxattr|xattr|" -i setup.py
%endif

%build
# Build C-Tools
make CFLAGS="${RPM_OPT_FLAGS}" tools
Expand Down
4 changes: 2 additions & 2 deletions test/unit/utils/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def test_sync_data_force_trailing_slash(
['rsync', 'source_dir/', 'target_dir']
)

@patch('xattr.getxattr')
@patch('os.getxattr')
def test_target_supports_extended_attributes(self, mock_getxattr):
assert self.sync.target_supports_extended_attributes() is True
mock_getxattr.assert_called_once_with(
'target_dir', 'user.mime_type'
)

@patch('xattr.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"""
Expand Down

0 comments on commit dcf38b6

Please sign in to comment.