Explorar el Código

Add support for xz compressed data.tar member of binary packages

Use the xz command from xz-utils to support xz-compressed binary
packages. Add xz-utils to dpkg's Pre-Depends.

The xz format is very similar to the lzma format, but it fixes
some omissions in the latter, most notably a magic number for
identification by file(1).

Closes: #542160

Based-on-patch-by: Jonathan Nieder <jrnieder@gmail.com>
Guillem Jover hace 16 años
padre
commit
9bb208a833
Se han modificado 7 ficheros con 38 adiciones y 4 borrados
  1. 3 0
      debian/changelog
  2. 1 1
      debian/control
  3. 1 1
      dpkg-deb/main.c
  4. 28 0
      lib/dpkg/compress.c
  5. 2 0
      lib/dpkg/compress.h
  6. 1 0
      man/deb.5
  7. 2 2
      man/dpkg-deb.1

+ 3 - 0
debian/changelog

@@ -115,6 +115,9 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * Securely remove newly installed files when rolling-back a failed unpack.
   * Change default lzma compression level from 9 to 6.
     Thanks to Jonathan Nieder for the initial patch.
+  * Add support for xz compressed data.tar member of binary packages. Add
+    xz-utils to dpkg's Pre-Depends. Closes: #542160
+    Thanks to Jonathan Nieder for the initial patch.
 
   [ Modestas Vainius ]
   * Implement symbol patterns (Closes: #563752). From now on, it is possible to

+ 1 - 1
debian/control

@@ -17,7 +17,7 @@ Build-Depends: debhelper (>= 6.0.7), pkg-config, po4a (>= 0.33.1),
 Package: dpkg
 Architecture: any
 Essential: yes
-Pre-Depends: ${shlibs:Depends}, coreutils (>= 5.93-1), lzma
+Pre-Depends: ${shlibs:Depends}, coreutils (>= 5.93-1), lzma, xz-utils
 Depends: ${misc:Depends}
 Conflicts: sysvinit (<< 2.82-1), dpkg-iasearch (<< 0.11),
  dpkg-dev (<< 1.14.16), apt (<< 0.7.7), aptitude (<< 0.4.7-1)

+ 1 - 1
dpkg-deb/main.c

@@ -103,7 +103,7 @@ usage(const struct cmdinfo *cip, const char *value)
 "                                     packages).\n"
 "  -z#                              Set the compression level when building.\n"
 "  -Z<type>                         Set the compression type used when building.\n"
-"                                     Allowed values: gzip, bzip2, lzma, none.\n"
+"                                     Allowed types: gzip, xz, bzip2, lzma, none.\n"
 "\n"));
 
   printf(_(

+ 28 - 0
lib/dpkg/compress.c

@@ -321,6 +321,33 @@ struct compressor compressor_bzip2 = {
 	.decompress = decompress_bzip2,
 };
 
+/*
+ * Xz compressor.
+ */
+
+static void
+decompress_xz(int fd_in, int fd_out, const char *desc)
+{
+	fd_fd_filter(fd_in, fd_out, desc, XZ, "-dc", NULL);
+}
+
+static void
+compress_xz(int fd_in, int fd_out, int compress_level, const char *desc)
+{
+	char combuf[6];
+
+	snprintf(combuf, sizeof(combuf), "-c%d", compress_level);
+	fd_fd_filter(fd_in, fd_out, desc, XZ, combuf, NULL);
+}
+
+struct compressor compressor_xz = {
+	.name = "xz",
+	.extension = ".xz",
+	.default_level = 6,
+	.compress = compress_xz,
+	.decompress = decompress_xz,
+};
+
 /*
  * Lzma compressor.
  */
@@ -355,6 +382,7 @@ struct compressor compressor_lzma = {
 static struct compressor *compressor_array[] = {
 	&compressor_none,
 	&compressor_gzip,
+	&compressor_xz,
 	&compressor_bzip2,
 	&compressor_lzma,
 };

+ 2 - 0
lib/dpkg/compress.h

@@ -27,6 +27,7 @@
 DPKG_BEGIN_DECLS
 
 #define GZIP		"gzip"
+#define XZ		"xz"
 #define BZIP2		"bzip2"
 #define LZMA		"lzma"
 
@@ -42,6 +43,7 @@ struct compressor {
 
 struct compressor compressor_none;
 struct compressor compressor_gzip;
+struct compressor compressor_xz;
 struct compressor compressor_bzip2;
 struct compressor compressor_lzma;
 

+ 1 - 0
man/deb.5

@@ -56,6 +56,7 @@ The third, last required member is named
 It contains the filesystem as a tar archive, either
 not compressed (supported since dpkg 1.10.24), or compressed with
 gzip (with \fB.gz\fP extension),
+xz (with \fB.xz\fP extension, supported since dpkg 1.15.6),
 bzip2 (with \fB.bz2\fP extension, supported since dpkg 1.10.24) or
 lzma (with \fB.lzma\fP extension, supported since dpkg 1.13.25).
 .PP

+ 2 - 2
man/dpkg-deb.1

@@ -191,8 +191,8 @@ when building a package.
 .TP
 .BI \-Z compress_type
 Specify which compression type to use when building a package. Allowed
-values are \fIgzip\fP, \fIbzip2\fP, \fIlzma\fP, and \fInone\fP (default
-is \fIgzip\fP).
+values are \fIgzip\fP, \fIxz\fP, \fIbzip2\fP, \fIlzma\fP, and \fInone\fP
+(default is \fIgzip\fP).
 .TP
 .BR \-\-new
 Ensures that