[Yum-devel] [PATCH 2/2] Also add .xz compressed metadata in compat mode

Zdeněk Pavlas zpavlas at redhat.com
Wed Oct 24 15:03:05 UTC 2012


---
 createrepo/__init__.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 2c10654..f563bd5 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -128,6 +128,14 @@ class SimpleMDCallBack(object):
         sys.stdout.flush()
 
 
+class RepoDataList(RepoData):
+    def __init__(self, *repodata):
+        self.repodata = repodata
+    def dump_xml(self):
+        # join xml dumps of repodata instances
+        return ''.join([i.dump_xml() for i in self.repodata])
+
+
 class MetaDataGenerator:
     def __init__(self, config_obj=None, callback=None):
         self.conf = config_obj
@@ -1034,6 +1042,10 @@ class MetaDataGenerator:
                     if self.compat_compress:
                         compress_type = 'bz2'
                     data = compress(compress_type)
+                    if self.compat_compress and 'xz' in _available_compression:
+                        # we can also compress better
+                        data = RepoDataList(compress('xz'), data)
+                        data.type = db_data_type
 
                     # remove the uncompressed file
                     os.unlink(resultpath)
-- 
1.7.4.4



More information about the Yum-devel mailing list