]> git.ipfire.org Git - pakfire.git/commitdiff
Add support for old xattr module api.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Mar 2011 17:52:51 +0000 (18:52 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Mar 2011 17:52:51 +0000 (18:52 +0100)
pakfire/packages/file.py

index 81b816aa53bdddb632a67e4fe9978074f1926ce7..fe666b73ef62e4a0fef30af0d4879d9f7ad8fb17 100644 (file)
@@ -28,7 +28,17 @@ class InnerTarFile(tarfile.TarFile):
                tarinfo = self.gettarinfo(name, arcname)
 
                if tarinfo.isreg():
-                       attrs = xattr.get_all(name)
+                       attrs = []
+
+                       # Use new modules code...
+                       if hasattr(xattr, "get_all"):
+                               attrs = xattr.get_all(name)
+
+                       # ...or use the deprecated API.
+                       else:
+                               for attr in xattr.listxattr(name):
+                                       val = xattr.getxattr(name, attr)
+                                       attrs.append((attr, val))
 
                        for attr, val in attrs:
                                # Skip all attrs that are not supported (e.g. selinux).
@@ -68,7 +78,11 @@ class InnerTarFile(tarfile.TarFile):
                                        continue
 
                                logging.debug("Restoring xattr %s=%s to %s" % (attr, val, target))
-                               xattr.set(target, attr, val)
+                               if hasattr(xattr, "set"):
+                                       xattr.set(target, attr, val)
+
+                               else:
+                                       xattr.setxattr(target, attr, val)
 
 
 class FilePackage(Package):