[Reproducible-commits] [debbindiff] 01/01: Don't follow symlinks, but print their targets
Reiner Herrmann
reiner at reiner-h.de
Mon Jun 15 20:58:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository debbindiff.
commit d02fc2ecd3b77d184c6917c4951d309e9264387d
Author: Reiner Herrmann <reiner at reiner-h.de>
Date: Mon Jun 15 22:51:16 2015 +0200
Don't follow symlinks, but print their targets
Symbolic links can potentially also point outside of the
compared directory. To prevent opening and comparing files
from the host, only the state (target) of symlinks should
be displayed.
This also speeds up the comparison if multiple links
are pointing to the same file (like with BusyBox in
OpenWrt images).
---
debbindiff/comparators/__init__.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/debbindiff/comparators/__init__.py b/debbindiff/comparators/__init__.py
index 0246afc..23ec04f 100644
--- a/debbindiff/comparators/__init__.py
+++ b/debbindiff/comparators/__init__.py
@@ -23,6 +23,7 @@ import os.path
import re
import sys
from debbindiff import logger, tool_required
+from debbindiff.difference import Difference
from debbindiff.comparators.binary import \
compare_binary_files, are_same_binaries
from debbindiff.comparators.bzip2 import compare_bzip2_files
@@ -110,6 +111,23 @@ SMALL_FILE_THRESHOLD = 65536 # 64 kiB
def compare_files(path1, path2, source=None):
+ if os.path.islink(path1) or os.path.islink(path2):
+ try:
+ dest1 = os.readlink(path1)
+ text1 = "%s -> %s" % (path1, dest1)
+ except OSError:
+ text1 = "[ No symlink ]"
+
+ try:
+ dest2 = os.readlink(path2)
+ text2 = "%s -> %s" % (path2, dest2)
+ except OSError:
+ text2 = "[ No symlink ]"
+
+ if dest1 == dest2:
+ return []
+ return [Difference.from_unicode(text1, text2, path1, path2, source=source, comment="symlink")]
+
if os.path.isdir(path1) and os.path.isdir(path2):
return compare_directories(path1, path2, source)
if not os.path.isfile(path1):
--
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