[Reproducible-commits] [debbindiff] 02/02: Also compare stat, acl, and xattrs when comparing directories
Jérémy Bobbio
lunar at moszumanska.debian.org
Thu Feb 26 15:57:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit 3b1c7ad216abbb1d6c5dec655975b8b4a1e47be6
Author: Jérémy Bobbio <lunar at debian.org>
Date: Thu Feb 26 15:57:30 2015 +0000
Also compare stat, acl, and xattrs when comparing directories
---
README | 2 +
debbindiff/comparators/directory.py | 74 +++++++++++++++++++++++++++++++++----
debian/control | 4 +-
3 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/README b/README
index 03acf44..3425664 100644
--- a/README
+++ b/README
@@ -32,10 +32,12 @@ in the path:
| bzip2 | bzip2 |
| cpio | cpio |
| file | file |
+| getfacl | acl |
| ghc | ghc |
| gpg | gnupg |
| gzip | gzip |
| ls | coreutils |
+| lsattr | e2fsprogs |
| msgunfmt | gettext |
| objdump | binutils-multiarch |
| pdftk | pdftk |
diff --git a/debbindiff/comparators/directory.py b/debbindiff/comparators/directory.py
index 836c116..3f9cd8c 100644
--- a/debbindiff/comparators/directory.py
+++ b/debbindiff/comparators/directory.py
@@ -18,28 +18,86 @@
# along with debbindiff. If not, see <http://www.gnu.org/licenses/>.
import os.path
+import re
import subprocess
+from debbindiff import logger
from debbindiff.difference import Difference
import debbindiff.comparators
def ls(path):
- return subprocess.check_output(['ls', '-l', path], shell=False).decode('utf-8')
+ return subprocess.check_output(['ls', path], shell=False).decode('utf-8')
+
+
+def stat(path):
+ output = subprocess.check_output(['stat', path], shell=False).decode('utf-8')
+ output = re.sub(r'^\s*File:.*$', '', output, flags=re.MULTILINE)
+ output = re.sub(r'Inode: [0-9]+', '', output)
+ return output
+
+
+def lsattr(path):
+ try:
+ return subprocess.check_output(['lsattr', '-d', path], shell=False, stderr=subprocess.STDOUT).decode('utf-8')
+ except subprocess.CalledProcessError as e:
+ if e.returncode == 1:
+ # filesystem doesn't support xattrs
+ return ''
+
+
+def getfacl(path):
+ return subprocess.check_output(['getfacl', '-p', '-c', path], shell=False).decode('utf-8')
+
+
+def compare_meta(path1, path2):
+ logger.debug('compare_meta(%s, %s)' % (path1, path2))
+ differences = []
+ stat1 = stat(path1)
+ stat2 = stat(path2)
+ if stat1 != stat2:
+ differences.append(Difference(
+ stat1.splitlines(1), stat2.splitlines(1),
+ path1, path2, source="stat"))
+ lsattr1 = lsattr(path1)
+ lsattr2 = lsattr(path2)
+ if lsattr1 != lsattr2:
+ differences.append(Difference(
+ lsattr1.splitlines(1), lsattr2.splitlines(1),
+ path1, path2, source="lattr"))
+ acl1 = getfacl(path1)
+ acl2 = getfacl(path2)
+ if acl1 != acl2:
+ differences.append(Difference(
+ acl1.splitlines(1), acl2.splitlines(1),
+ path1, path2, source="getfacl"))
+ return differences
def compare_directories(path1, path2, source=None):
differences = []
- for name in sorted(set(os.listdir(path1)).intersection(os.listdir(path2))):
+ logger.debug('path1 files: %s' % sorted(set(os.listdir(path1))))
+ logger.debug('path2 files: %s' % sorted(set(os.listdir(path2))))
+ for name in sorted(set(os.listdir(path1)).intersection(set(os.listdir(path2)))):
+ logger.debug('compare %s' % name)
in_path1 = os.path.join(path1, name)
in_path2 = os.path.join(path2, name)
- differences.extend(debbindiff.comparators.compare_files(
- in_path1, in_path2, source=name))
- ls1 = ls(path1)
- ls2 = ls(path2)
+ in_differences = debbindiff.comparators.compare_files(
+ in_path1, in_path2, source=name)
+ if not os.path.isdir(in_path1):
+ if in_differences:
+ in_differences[0].add_details(compare_meta(in_path1, in_path2))
+ else:
+ d = Difference(None, None, path1, path2, source=name)
+ d.add_details(compare_meta(in_path1, in_path2))
+ in_differences = [d]
+ differences.extend(in_differences)
+ ls1 = sorted(ls(path1))
+ ls2 = sorted(ls(path2))
if ls1 != ls2:
differences.append(Difference(
- ls1.splitlines(1), ls2.splitlines(2),
- path1, path2, source="ls -l"))
+ ls1.splitlines(1), ls2.splitlines(1),
+ path1, path2, source="ls"))
+ differences.extend(compare_meta(path1, path2))
if differences:
d = Difference(None, None, path1, path2, source=source)
d.add_details(differences)
diff --git a/debian/control b/debian/control
index dcd5432..2c3798b 100644
--- a/debian/control
+++ b/debian/control
@@ -19,10 +19,12 @@ Vcs-Browser: https://anonscm.debian.org/cgit/reproducible/debbindiff.git
Package: debbindiff
Architecture: all
-Depends: binutils-multiarch,
+Depends: acl,
+ binutils-multiarch,
bzip2,
cpio,
diffutils,
+ e2fsprogs,
file,
fontforge-extras,
gettext,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list