[diffoscope] 01/01: Report differences in extended file attributes when comparing files. (Closes: #888402)
Chris Lamb
chris at chris-lamb.co.uk
Thu Jan 25 05:18:34 CET 2018
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit aa946c2a595e89dd620e53e5ea0c2cec665030ef
Author: Chris Lamb <lamby at debian.org>
Date: Thu Jan 25 15:16:51 2018 +1100
Report differences in extended file attributes when comparing files. (Closes: #888402)
---
debian/control | 1 +
debian/rules | 1 +
diffoscope/comparators/directory.py | 18 +++++++++++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/debian/control b/debian/control
index ead888b..3ddd41e 100644
--- a/debian/control
+++ b/debian/control
@@ -58,6 +58,7 @@ Build-Depends:
python3-progressbar <!nocheck>,
python3-pytest <!nocheck>,
python3-pytest-cov <!nocheck>,
+ python3-pyxattr <!nocheck>,
python3-rpm <!nocheck>,
python3-setuptools,
python3-tlsh (>= 3.4.1) <!nocheck>,
diff --git a/debian/rules b/debian/rules
index cffaf02..235da62 100755
--- a/debian/rules
+++ b/debian/rules
@@ -67,6 +67,7 @@ override_dh_python3:
--recommends=jsondiff \
--recommends=progressbar \
--recommends=python-debian \
+ --recommends=pyxattr \
--recommends=rpm-python \
--recommends=tlsh \
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index fd655a6..df5211a 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -108,6 +108,22 @@ class Getfacl(Command):
return ['getfacl', '-p', '-c', self.path]
+def xattr(path1, path2):
+ try:
+ import xattr
+ except ImportError:
+ return None
+
+ def fn(x):
+ return '\n'.join('{}: {}'.format(
+ k.decode('utf-8', 'ignore'),
+ v.decode('utf-8', 'ignore'),
+ ) for k, v in xattr.get_all(x))
+
+ return Difference.from_text(
+ fn(path1), fn(path2), path1, path2, source='extended file attributes',
+ )
+
def compare_meta(path1, path2):
if Config().exclude_directory_metadata:
logger.debug("Excluding directory metadata for paths (%s, %s)", path1, path2)
@@ -138,9 +154,9 @@ def compare_meta(path1, path2):
))
except RequiredToolNotFound:
logger.info("Unable to find 'lsattr', some directory metadata differences might not be noticed.")
+ differences.append(xattr(path1, path2))
return [d for d in differences if d is not None]
-
def compare_directories(path1, path2, source=None):
return FilesystemDirectory(path1).compare(FilesystemDirectory(path2))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list