Parcourir la source

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 il y a 16 ans
Parent
commit
9bb208a833
7 fichiers modifiés avec 38 ajouts et 4 suppressions
  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.
   * Securely remove newly installed files when rolling-back a failed unpack.
   * Change default lzma compression level from 9 to 6.
   * Change default lzma compression level from 9 to 6.
     Thanks to Jonathan Nieder for the initial patch.
     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 ]
   [ Modestas Vainius ]
   * Implement symbol patterns (Closes: #563752). From now on, it is possible to
   * 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
 Package: dpkg
 Architecture: any
 Architecture: any
 Essential: yes
 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}
 Depends: ${misc:Depends}
 Conflicts: sysvinit (<< 2.82-1), dpkg-iasearch (<< 0.11),
 Conflicts: sysvinit (<< 2.82-1), dpkg-iasearch (<< 0.11),
  dpkg-dev (<< 1.14.16), apt (<< 0.7.7), aptitude (<< 0.4.7-1)
  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"
 "                                     packages).\n"
 "  -z#                              Set the compression level when building.\n"
 "  -z#                              Set the compression level when building.\n"
 "  -Z<type>                         Set the compression type used 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"));
 "\n"));
 
 
   printf(_(
   printf(_(

+ 28 - 0
lib/dpkg/compress.c

@@ -321,6 +321,33 @@ struct compressor compressor_bzip2 = {
 	.decompress = decompress_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.
  * Lzma compressor.
  */
  */
@@ -355,6 +382,7 @@ struct compressor compressor_lzma = {
 static struct compressor *compressor_array[] = {
 static struct compressor *compressor_array[] = {
 	&compressor_none,
 	&compressor_none,
 	&compressor_gzip,
 	&compressor_gzip,
+	&compressor_xz,
 	&compressor_bzip2,
 	&compressor_bzip2,
 	&compressor_lzma,
 	&compressor_lzma,
 };
 };

+ 2 - 0
lib/dpkg/compress.h

@@ -27,6 +27,7 @@
 DPKG_BEGIN_DECLS
 DPKG_BEGIN_DECLS
 
 
 #define GZIP		"gzip"
 #define GZIP		"gzip"
+#define XZ		"xz"
 #define BZIP2		"bzip2"
 #define BZIP2		"bzip2"
 #define LZMA		"lzma"
 #define LZMA		"lzma"
 
 
@@ -42,6 +43,7 @@ struct compressor {
 
 
 struct compressor compressor_none;
 struct compressor compressor_none;
 struct compressor compressor_gzip;
 struct compressor compressor_gzip;
+struct compressor compressor_xz;
 struct compressor compressor_bzip2;
 struct compressor compressor_bzip2;
 struct compressor compressor_lzma;
 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
 It contains the filesystem as a tar archive, either
 not compressed (supported since dpkg 1.10.24), or compressed with
 not compressed (supported since dpkg 1.10.24), or compressed with
 gzip (with \fB.gz\fP extension),
 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
 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).
 lzma (with \fB.lzma\fP extension, supported since dpkg 1.13.25).
 .PP
 .PP

+ 2 - 2
man/dpkg-deb.1

@@ -191,8 +191,8 @@ when building a package.
 .TP
 .TP
 .BI \-Z compress_type
 .BI \-Z compress_type
 Specify which compression type to use when building a package. Allowed
 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
 .TP
 .BR \-\-new
 .BR \-\-new
 Ensures that
 Ensures that