lzma/xz compression for xml

Anders F Björklund <[email protected]> Sun, 18 Sep 2011 18:15:45 +0200
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
I added support for lzma/xz compression to libxml2,
so that one doesn't have to uncompress those first.

It already handles libz compression transparently,
extended that to also support liblzma compression...

http://bugzilla.gnome.org/show_bug.cgi?id=659404

Then yum-metadata-parser should be able to handle it ?

--anders

PS. Attaching the previous hackaround, if forgotten.
    It used a temporary file and cloned an "unxz"...

_______________________________________________
Rpm-metadata mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/rpm-metadata
yum-metadata-parser-xz.diff (application/octet-stream, 1.4 KB)
diff --git a/sqlitecache.c b/sqlitecache.c
index 3857be7..f95ee50 100644
--- a/sqlitecache.c
+++ b/sqlitecache.c
@@ -17,6 +17,8 @@
 
 #include <Python.h>
 
+#include <unistd.h>
+
 #include "xml-parser.h"
 #include "db.h"
 #include "package.h"
@@ -393,12 +395,37 @@ update_packages (UpdateInfo *update_info,
                  GError **err)
 {
     char *db_filename;
+    char *temp_filename;
+
+    char *template;
+    char *input;
+    char *output;
+    char *command;
+
+    gchar *std_out;
+    gchar *std_err;
+    gint status;
 
     db_filename = yum_db_filename (md_filename);
     update_info->db = yum_db_open (db_filename, checksum,
                                    update_info->create_tables,
                                    err);
 
+    if (strstr (md_filename, ".lzma") || strstr (md_filename, ".xz")) {
+        template = g_strdup ("/tmp/unxzXXXXXX");
+        temp_filename = g_strconcat (mktemp (template), ".xml", NULL);
+        input = g_shell_quote (md_filename);
+        output = g_shell_quote (temp_filename);
+        command = g_strdup_printf ("%s <%s >%s", "unxz", input, output);
+        g_spawn_command_line_sync( command, &std_out, &std_err, &status, err);
+        g_free(command);
+        g_free(output);
+        g_free(input);
+        md_filename = temp_filename;
+    }
+    else
+        temp_filename = NULL;
+
     if (*err)
         goto cleanup;