[diffoscope] 01/02: Assume BSD-style stat(1) on FreeBSD. (Closes: #855169)

Chris Lamb chris at chris-lamb.co.uk
Sat Feb 18 01:03:05 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch experimental
in repository diffoscope.

commit 1edef9032118e049a0f7aa64b5e4254ce73c0779
Author: Ed Maste <emaste at freebsd.org>
Date:   Tue Feb 14 16:42:20 2017 -0500

    Assume BSD-style stat(1) on FreeBSD. (Closes: #855169)
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/comparators/directory.py | 44 +++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index d30cb64..1327912 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -45,25 +45,31 @@ def list_files(path):
     return all_files
 
 
-class Stat(Command):
-    @tool_required('stat')
-    def cmdline(self):
-        return ['stat', self.path]
-
-    FILE_RE = re.compile(r'^\s*File:.*$')
-    DEVICE_RE = re.compile(r'Device: [0-9a-f]+h/[0-9]+d\s+')
-    INODE_RE = re.compile(r'Inode: [0-9]+\s+')
-    ACCESS_TIME_RE = re.compile(r'^Access: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
-    CHANGE_TIME_RE = re.compile(r'^Change: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
-
-    def filter(self, line):
-        line = line.decode('utf-8')
-        line = Stat.FILE_RE.sub('', line)
-        line = Stat.DEVICE_RE.sub('', line)
-        line = Stat.INODE_RE.sub('', line)
-        line = Stat.ACCESS_TIME_RE.sub('', line)
-        line = Stat.CHANGE_TIME_RE.sub('', line)
-        return line.encode('utf-8')
+if os.uname()[0] == 'FreeBSD':
+    class Stat(Command):
+        @tool_required('stat')
+        def cmdline(self):
+            return ['stat', '-t', '%Y-%m-%d %H:%M:%S', '-f', '%Sp %l %Su %Sg %z %Sm %k %b %#Xf', self.path]
+else:
+    class Stat(Command):
+        @tool_required('stat')
+        def cmdline(self):
+            return ['stat', self.path]
+
+        FILE_RE = re.compile(r'^\s*File:.*$')
+        DEVICE_RE = re.compile(r'Device: [0-9a-f]+h/[0-9]+d\s+')
+        INODE_RE = re.compile(r'Inode: [0-9]+\s+')
+        ACCESS_TIME_RE = re.compile(r'^Access: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
+        CHANGE_TIME_RE = re.compile(r'^Change: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
+
+        def filter(self, line):
+            line = line.decode('utf-8')
+            line = Stat.FILE_RE.sub('', line)
+            line = Stat.DEVICE_RE.sub('', line)
+            line = Stat.INODE_RE.sub('', line)
+            line = Stat.ACCESS_TIME_RE.sub('', line)
+            line = Stat.CHANGE_TIME_RE.sub('', line)
+            return line.encode('utf-8')
 
 
 @tool_required('lsattr')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list