]> arthur.barton.de Git - bup.git/commitdiff
metadata: use python-xattr pyxattr compat code
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 16 Dec 2019 09:12:24 +0000 (10:12 +0100)
committerRob Browning <rlb@defaultvalue.org>
Thu, 9 Jan 2020 05:46:23 +0000 (23:46 -0600)
Newer versions of python-xattr have pyxattr compatibility code
(since my pull request https://github.com/xattr/xattr/pull/38).

Modify bup to allow using it; prefer pyxattr since it's faster,
but sometimes due to other dependencies python-xattr might be
present already (and since it conflicts with pyxattr, it's not
possible to install both.)

Also add a .cirrus.yml task to test this on Debian.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
.cirrus.yml
dev/prep-for-debianish-build
lib/bup/metadata.py

index a2fe9ccad984f94ab582fea143058894e1e43b95..f2de0afc2c3d254ca48b0f6d005a041933ed3f12 100644 (file)
@@ -13,6 +13,20 @@ task:
     chown -R bup:bup .
     su -l bup -c "eatmydata make -j3 -C '$(pwd)' check"
 
+task:
+  name: debian (xattr)
+  container:
+    image: debian:buster
+    cpu: 2
+    memory: 8
+  script: |
+    set -xe
+    dev/prep-for-debianish-build python2 xattr
+    dev/system-info
+    adduser --disabled-password --gecos '' bup
+    chown -R bup:bup .
+    su -l bup -c "eatmydata make -j3 -C '$(pwd)' check"
+
 task:
   name: freebsd
   freebsd_instance:
index aab8c2d02bf38a1e7e38e9b1dd576d52ee160474..d91a1a03ba169a7970ca6447d4fa43cdeb197be3 100755 (executable)
@@ -4,7 +4,7 @@ set -exuo pipefail
 
 usage()
 {
-    echo "Usage: prep-for-debianish-build [python2|python3]"
+    echo "Usage: prep-for-debianish-build [python2|python3] [pyxattr|xattr]"
 }
 
 export DEBIAN_FRONTEND=noninteractive
@@ -14,19 +14,20 @@ common_debs='gcc make linux-libc-dev git rsync eatmydata acl attr par2'
 common_debs="$common_debs duplicity rdiff-backup rsnapshot"
 
 pyver="${1:-python2}"
+xattr="${2:-pyxattr}"
 
 case "$pyver" in
     python2)
         apt-get install -y \
                 $common_debs \
                 python2.7-dev python-fuse \
-                python-pyxattr python-pylibacl python-tornado
+                python-"$xattr" python-pylibacl python-tornado
         ;;
     python3)
         apt-get install -y \
                 $common_debs \
                 python3.7-dev python3-distutils python3-fuse \
-                python3-pyxattr python3-pylibacl python3-tornado
+                python3-"$xattr" python3-pylibacl python3-tornado
         ;;
     *)
         usage 1>&2
index 84b0f2a23597c5f61be21808d88b61c1c545833b..fe1d5f378e5750da4d52c707241c0d7787f4cc19 100644 (file)
@@ -20,16 +20,18 @@ 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:
+            from xattr import pyxattr_compat as xattr
+        except ImportError:
             log('Warning: python-xattr module is too old; '
-                'install python-pyxattr instead.\n')
+                'upgrade or install python-pyxattr instead.\n')
             xattr = None
 
 posix1e = None