The following commit has been merged in the master branch:
commit ac02d172c0cab7cf06c28326b41dd2cc35da2fdc
Author: Guillem Jover <[email protected]>
Date:   Mon May 28 18:48:10 2012 +0200

    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.

diff --git a/debian/changelog b/debian/changelog
index a9521ad..bfa9ca1 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 9c5bf8b..ad097c4 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 7e1cb4b..12c694c 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 7315d63..319e499 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 5618b44..f9282e0 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

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to