From 193c1b896291da42844953bdf693245ec4c8adaa Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Sun, 16 Feb 2014 02:28:34 +0100
Subject: [PATCH 2/4] Add support for uncompressed deb members

---
 udpkg.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/udpkg.c b/udpkg.c
index 73fa9d8..ef6bdf7 100644
--- a/udpkg.c
+++ b/udpkg.c
@@ -18,7 +18,7 @@
 static int force_configure = 0;
 static int loadtemplate = 1;
 
-static const char *data_member_base = "data.tar.";
+static const char *data_member_base = "data.tar";
 
 /* 
  * Main udpkg implementation routines
@@ -144,21 +144,24 @@ typedef enum compression_type compression_type;
 enum compression_type {
 	gz_compression,
 	xz_compression,
+	no_compression,
 	unknown_compression,
 };
 
 static const char *compression_extension (const compression_type t) {
 	switch (t) {
-		case gz_compression: return "gz";
-		case xz_compression: return "xz";
+		case gz_compression: return ".gz";
+		case xz_compression: return ".xz";
+		case no_compression: return "";
 		default: return "";
 	}
 }
 
 static const char *decompression_tool (const compression_type t) {
 	switch (t) {
-		case gz_compression: return "gunzip";
-		case xz_compression: return "unxz";
+		case gz_compression: return "gunzip -c";
+		case xz_compression: return "unxz -c";
+		case no_compression: return "cat";
 		default: return "";
 	}
 }
@@ -200,6 +203,10 @@ static compression_type get_compression_type(struct package_t *pkg,
 	else if (strcmp(extension, compression_extension(xz_compression)) == 0) {
 		return xz_compression;
 	}
+	else if (strcmp(extension, compression_extension(no_compression)) == 0)
+	{
+		return no_compression;
+	}
 	else {
 		FPRINTF(stderr, "Invalid compression type for %s* of %s\n",
 			member_base, pkg->file);
@@ -239,7 +246,7 @@ static int dpkg_dounpack(struct package_t *pkg)
 		return 1;
 	}
 
-	snprintf(buf, sizeof(buf), "ar -p %s %s%s|%s -c|tar -x",
+	snprintf(buf, sizeof(buf), "ar -p %s %s%s|%s|tar -x",
 		pkg->file, data_member_base,
 		compression_extension(compression_type),
 		decompression_tool(compression_type));
@@ -305,7 +312,7 @@ static int dpkg_dounpack(struct package_t *pkg)
 		 * so oddly...
 		 */
 		snprintf(buf, sizeof(buf),
-			"ar -p %s %s%s|%s -c|tar -t",
+			"ar -p %s %s%s|%s|tar -t",
 			pkg->file, data_member_base,
 			compression_extension(compression_type),
 			decompression_tool(compression_type));
-- 
1.9.0.rc3.244.g3497008

