[Git][reproducible-builds/diffoscope][fix/python-libarchive-2.8] libarchive: add compatibility with python-libarchive >= 2.8

Levente Polyak gitlab at salsa.debian.org
Mon Jul 2 23:46:32 CEST 2018


Levente Polyak pushed to branch fix/python-libarchive-2.8 at Reproducible Builds / diffoscope


Commits:
820b3cd1 by anthraxx at 2018-07-02T23:45:59+02:00
libarchive: add compatibility with python-libarchive >= 2.8

Python librarchive 2.8 removed the mtime_nsec property from
ArchiveEntry so lets wire the ffi function if available

- - - - -


1 changed file:

- diffoscope/comparators/utils/libarchive.py


Changes:

=====================================
diffoscope/comparators/utils/libarchive.py
=====================================
--- a/diffoscope/comparators/utils/libarchive.py
+++ b/diffoscope/comparators/utils/libarchive.py
@@ -80,6 +80,14 @@ if not hasattr(libarchive.ffi, 'entry_gname'):
         'entry_gname', [libarchive.ffi.c_archive_entry_p], ctypes.c_char_p)
     libarchive.ArchiveEntry.gname = property(
         lambda self: libarchive.ffi.entry_gname(self._entry_p))
+# Monkeypatch libarchive-c (>= 2.8)
+# Wire mtime_nsec attribute as some libarchive versions (>=2.8) don't expose it
+# for ArchiveEntry. Doing this allows a unified API no matter which version is
+# available.
+if not hasattr(libarchive.ArchiveEntry, 'mtime_nsec') and hasattr(libarchive.ffi, 'entry_mtime_nsec'):
+    libarchive.ArchiveEntry.mtime_nsec = property(
+        lambda self: libarchive.ffi.entry_mtime_nsec(self._entry_p))
+
 
 # Monkeypatch libarchive-c so we always get pathname as (Unicode) str
 # Otherwise, we'll get sometimes str and sometimes bytes and always pain.



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/820b3cd1ba59c9882775f5ae9077d871c55d9568

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/820b3cd1ba59c9882775f5ae9077d871c55d9568
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20180702/a531dbf9/attachment.html>


More information about the rb-commits mailing list