The following commit has been merged in the master branch:
commit 625a24bbc8280362c2ab0e3f2f83aacbf25283e0
Author: Guillem Jover <[email protected]>
Date: Tue Nov 22 07:09:31 2011 +0100
dpkg-deb: Treat compression levels independently for each backend
Even if the compression level allowed range supported by gzip/zlib
compatible interfaces is almost the same (0-9), its actual meaning
is backend specific, so treat it that way.
This allows to get native meanings for at least level 0, which maps
to 1 for bzip2, and becomes a new allowed level for xz and lzma.
The reason for the previous behaviour regarding level 0 is historic,
due to zlib treating it that way, and was inadvertently carried over
when new compressors were added to libdpkg.
diff --git a/debian/changelog b/debian/changelog
index 5f40f17..190370b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,9 @@ dpkg (1.16.2) UNRELEASED; urgency=low
* Add new deb-origin.5 man page. Closes: #608884
Thanks to Matt Kraai <[email protected]>.
* Return correct status on start-stop-daemon --status when using --pidfile.
+ * Treat dpkg-deb compression level independently for each backend. This
+ has the effect of changing the current behaviour for level 0 on all
+ compressors except gzip.
[ Raphaƫl Hertzog ]
* Update Dpkg::Shlibs to look into multiarch paths when cross-building
diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 59ffa94..fb761d5 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -77,6 +77,7 @@ struct compressor {
const char *name;
const char *extension;
int default_level;
+ void (*fixup_params)(struct compress_params *params);
void (*compress)(int fd_in, int fd_out, struct compress_params *params,
const char *desc);
void (*decompress)(int fd_in, int fd_out, const char *desc);
@@ -87,6 +88,11 @@ struct compressor {
*/
static void
+fixup_none_params(struct compress_params *params)
+{
+}
+
+static void
decompress_none(int fd_in, int fd_out, const char *desc)
{
fd_fd_copy(fd_in, fd_out, -1, _("%s: decompression"), desc);
@@ -102,6 +108,7 @@ static const struct compressor compressor_none = {
.name = "none",
.extension = "",
.default_level = 0,
+ .fixup_params = fixup_none_params,
.compress = compress_none,
.decompress = decompress_none,
};
@@ -110,6 +117,14 @@ static const struct compressor compressor_none = {
* Gzip compressor.
*/
+static void
+fixup_gzip_params(struct compress_params *params)
+{
+ /* Normalize compression level. */
+ if (params->level == 0)
+ params->type = compressor_type_none;
+}
+
#ifdef WITH_ZLIB
static void
decompress_gzip(int fd_in, int fd_out, const char *desc)
@@ -210,6 +225,7 @@ static const struct compressor compressor_gzip = {
.name = "gzip",
.extension = ".gz",
.default_level = 9,
+ .fixup_params = fixup_gzip_params,
.compress = compress_gzip,
.decompress = decompress_gzip,
};
@@ -218,6 +234,14 @@ static const struct compressor compressor_gzip = {
* Bzip2 compressor.
*/
+static void
+fixup_bzip2_params(struct compress_params *params)
+{
+ /* Normalize compression level. */
+ if (params->level == 0)
+ params->level = 1;
+}
+
#ifdef WITH_BZ2
static void
decompress_bzip2(int fd_in, int fd_out, const char *desc)
@@ -323,6 +347,7 @@ static const struct compressor compressor_bzip2 = {
.name = "bzip2",
.extension = ".bz2",
.default_level = 9,
+ .fixup_params = fixup_bzip2_params,
.compress = compress_bzip2,
.decompress = decompress_bzip2,
};
@@ -350,6 +375,7 @@ static const struct compressor compressor_xz = {
.name = "xz",
.extension = ".xz",
.default_level = 6,
+ .fixup_params = fixup_none_params,
.compress = compress_xz,
.decompress = decompress_xz,
};
@@ -377,6 +403,7 @@ static const struct compressor compressor_lzma = {
.name = "lzma",
.extension = ".lzma",
.default_level = 6,
+ .fixup_params = fixup_none_params,
.compress = compress_lzma,
.decompress = decompress_lzma,
};
@@ -434,6 +461,12 @@ compressor_find_by_extension(const char *extension)
return compressor_type_unknown;
}
+static void
+compressor_fixup_params(struct compress_params *params)
+{
+ compressor_get(params->type)->fixup_params(params);
+}
+
void
decompress_filter(enum compressor_type type, int fd_in, int fd_out,
const char *desc_fmt, ...)
@@ -462,12 +495,12 @@ compress_filter(struct compress_params *params, int
fd_in, int fd_out,
varbuf_vprintf(&desc, desc_fmt, args);
va_end(args);
+ compressor_fixup_params(params);
+
compressor = compressor_get(params->type);
if (params->level < 0)
params->level = compressor->default_level;
- else if (params->level == 0)
- compressor = &compressor_none;
compressor->compress(fd_in, fd_out, params, desc.buf);
}
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 26b684c..d5fc5b5 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -1,4 +1,4 @@
-.TH dpkg\-deb 1 "2011-08-14" "Debian Project" "dpkg suite"
+.TH dpkg\-deb 1 "2011-11-22" "Debian Project" "dpkg suite"
.SH NAME
dpkg\-deb \- Debian package archive (.deb) manipulation tool
.
@@ -197,6 +197,9 @@ The default for this field is "${Package}\\t${Version}\\n".
.BI \-z compress-level
Specify which compression level to use on the compressor backend, when
building a package (default is 9 for gzip and bzip2, 6 for xz and lzma).
+The accepted values are 0-9 with: 0 being mapped to compressor none for
+gzip and 0 mapped to 1 for bzip2. Before dpkg 1.16.2 level 0 was
+equivalent to compressor none for all compressors.
.TP
.BI \-Z compress-type
Specify which compression type to use when building a package. Allowed
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]