summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-05-28 18:48:10 +0200
committerGuillem Jover <guillem@debian.org>2013-07-18 05:39:50 +0200
commitac02d172c0cab7cf06c28326b41dd2cc35da2fdc (patch)
tree0e5ab54e38ec061f851ec5ef45758a2862c41448
parent16ab055e95a804a1fc176c7bd72b52a2be8412ab (diff)
downloaddpkg-ac02d172c0cab7cf06c28326b41dd2cc35da2fdc.tar.gz
dpkg-deb: Add support for gzip compression strategies
This adds support for filtered, huffman, rle and fixed strategies. Those are only usable when dpkg-deb uses zlib, because the command line tool gzip does not have any way to specify them.
-rw-r--r--debian/changelog2
-rw-r--r--dpkg-deb/main.c3
-rw-r--r--lib/dpkg/compress.c29
-rw-r--r--lib/dpkg/compress.h4
-rw-r--r--man/dpkg-deb.13
5 files changed, 38 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index a9521ad95..bfa9ca1dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -125,6 +125,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low
the default dpkg-deb compressor, mainly for downstreams.
* Switch dpkg-deb default compressor from gzip to xz. Build dpkg.deb using
gzip to make debootstrap life easier on non-Debian based systems.
+ * Add support for gzip compression strategies to dpkg-deb. The new
+ strategies are: filtered, huffman, rle and fixed.
[ Updated programs translations ]
* Fix typo in Spanish translation of update-alternatives.
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index 9c5bf8bdb..ad097c451 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -112,7 +112,8 @@ usage(const struct cmdinfo *cip, const char *value)
" -Z<type> Set the compression type used when building.\n"
" Allowed types: gzip, xz, bzip2, none.\n"
" -S<strategy> Set the compression strategy when building.\n"
-" Allowed values: none, extreme (xz).\n"
+" Allowed values: none; extreme (xz);\n"
+" filtered, huffman, rle, fixed (gzip).\n"
"\n"));
printf(_(
diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 7e1cb4bca..12c694c98 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -180,10 +180,22 @@ compress_gzip(int fd_in, int fd_out, struct compress_params *params, const char
{
char buffer[DPKG_BUFFER_SIZE];
char combuf[6];
+ int strategy;
int z_errnum;
gzFile gzfile;
- snprintf(combuf, sizeof(combuf), "w%d", params->level);
+ if (params->strategy == compressor_strategy_filtered)
+ strategy = 'f';
+ else if (params->strategy == compressor_strategy_huffman)
+ strategy = 'h';
+ else if (params->strategy == compressor_strategy_rle)
+ strategy = 'R';
+ else if (params->strategy == compressor_strategy_fixed)
+ strategy = 'F';
+ else
+ strategy = ' ';
+
+ snprintf(combuf, sizeof(combuf), "w%d%c", params->level, strategy);
gzfile = gzdopen(fd_out, combuf);
if (gzfile == NULL)
ohshit(_("%s: error binding output to gzip stream"), desc);
@@ -742,6 +754,14 @@ compressor_get_strategy(const char *name)
{
if (strcmp(name, "none") == 0)
return compressor_strategy_none;
+ if (strcmp(name, "filtered") == 0)
+ return compressor_strategy_filtered;
+ if (strcmp(name, "huffman") == 0)
+ return compressor_strategy_huffman;
+ if (strcmp(name, "rle") == 0)
+ return compressor_strategy_rle;
+ if (strcmp(name, "fixed") == 0)
+ return compressor_strategy_fixed;
if (strcmp(name, "extreme") == 0)
return compressor_strategy_extreme;
@@ -754,6 +774,13 @@ compressor_check_params(struct compress_params *params, struct dpkg_error *err)
if (params->strategy == compressor_strategy_none)
return true;
+ if (params->type == compressor_type_gzip &&
+ (params->strategy == compressor_strategy_filtered ||
+ params->strategy == compressor_strategy_huffman ||
+ params->strategy == compressor_strategy_rle ||
+ params->strategy == compressor_strategy_fixed))
+ return true;
+
if (params->type == compressor_type_xz &&
params->strategy == compressor_strategy_extreme)
return true;
diff --git a/lib/dpkg/compress.h b/lib/dpkg/compress.h
index 7315d63a8..319e4995e 100644
--- a/lib/dpkg/compress.h
+++ b/lib/dpkg/compress.h
@@ -47,6 +47,10 @@ enum compressor_type {
enum compressor_strategy {
compressor_strategy_unknown = -1,
compressor_strategy_none,
+ compressor_strategy_filtered,
+ compressor_strategy_huffman,
+ compressor_strategy_rle,
+ compressor_strategy_fixed,
compressor_strategy_extreme,
};
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 5618b4441..f9282e0bc 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -224,7 +224,8 @@ equivalent to compressor none for all compressors.
.BI \-S compress-strategy
Specify which compression strategy to use on the compressor backend, when
building a package (since dpkg 1.16.2). Allowed values are \fInone\fP (since
-dpkg 1.16.4) and \fIextreme\fP for xz.
+dpkg 1.16.4), \fIfiltered\fP, \fIhuffman\fP, \fIrle\fP and \fIfixed\fP for
+gzip (since dpkg 1.17.0) and \fIextreme\fP for xz.
.TP
.BI \-Z compress-type
Specify which compression type to use when building a package. Allowed