]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/metadata.py
metadata: accept only fixed python-xattr in python3
[bup.git] / lib / bup / metadata.py
index e0923808ff60395027d069e2452a5c2b0a97b8dc..43694d4a1dc636a58b8a42d466d8687a1dd7b5b0 100644 (file)
@@ -15,22 +15,27 @@ import errno, os, sys, stat, time, pwd, grp, socket, struct
 from bup import vint, xstat
 from bup.drecurse import recursive_dirlist
 from bup.helpers import add_error, mkdirp, log, is_superuser, format_filesize
-from bup.helpers import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name
+from bup.pwdgrp import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name
 from bup.xstat import utime, lutime
 
 xattr = None
 if sys.platform.startswith('linux'):
+    # prefer python-pyxattr (it's a lot faster), but fall back to python-xattr
+    # as the two are incompatible and only one can be installed on a system
     try:
         import xattr
     except ImportError:
         log('Warning: Linux xattr support missing; install python-pyxattr.\n')
-    if xattr:
+    if xattr and getattr(xattr, 'get_all', None) is None:
         try:
-            xattr.get_all
-        except AttributeError:
-            log('Warning: python-xattr module is too old; '
-                'install python-pyxattr instead.\n')
+            from xattr import pyxattr_compat as xattr
+            if not isinstance(xattr.NS_USER, bytes):
+                xattr = None
+        except ImportError:
             xattr = None
+        if xattr is None:
+            log('Warning: python-xattr module is too old; '
+                'upgrade or install python-pyxattr instead.\n')
 
 posix1e = None
 if not (sys.platform.startswith('cygwin') \
@@ -357,7 +362,7 @@ class Metadata:
             os.mknod(path, 0o600 | stat.S_IFBLK, self.rdev)
         elif stat.S_ISFIFO(self.mode):
             assert(self._recognized_file_type())
-            os.mknod(path, 0o600 | stat.S_IFIFO)
+            os.mkfifo(path, 0o600 | stat.S_IFIFO)
         elif stat.S_ISSOCK(self.mode):
             try:
                 os.mknod(path, 0o600 | stat.S_IFSOCK)