This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=0124692643c6bf25034dbb16e74205d911aa23e3

commit 0124692643c6bf25034dbb16e74205d911aa23e3
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Mar 17 23:58:22 2022 +0100

    Dpkg::Compression: Conditionally use the gzip --rsyncable option
    
    The gzip --rsyncable option is not universally supported, so we need to
    conditionally use it. Ideally we would invoke «gzip --help» and check
    whether the option is supported, but that would imply forking and
    executing that process for any module that ends up loading this one,
    which is not acceptable performance-wise. Instead we will approximate it
    by Perl's osname, which is not ideal, but better than nothing.
    
    Requires GNU gzip >= 1.7 for the --rsyncable option. On AIX GNU gzip
    is too old. On the BSDs they use their own implementation based on zlib,
    which does not currently support the --rsyncable option.
    
    Fixes: commit 3a7db14e4a881d28fb73b29c126ea6f3ac4d0831
    Fixes: https://rt.cpan.org/Ticket/Display.html?id=141805
---
 scripts/Dpkg/Compression.pm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/scripts/Dpkg/Compression.pm b/scripts/Dpkg/Compression.pm
index c2c703e2c..a95fa8664 100644
--- a/scripts/Dpkg/Compression.pm
+++ b/scripts/Dpkg/Compression.pm
@@ -35,6 +35,7 @@ our @EXPORT = qw(
 
 use Exporter qw(import);
 use Config;
+use List::Util qw(any);
 
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
@@ -53,10 +54,9 @@ interact with the set of supported compression methods.
 =cut
 
 my $COMP = {
-    # Requires gzip >= 1.7 for the --rsyncable option.
     gzip => {
        file_ext => 'gz',
-       comp_prog => [ 'gzip', '--no-name', '--rsyncable' ],
+       comp_prog => [ 'gzip', '--no-name' ],
        decomp_prog => [ 'gunzip' ],
        default_level => 9,
     },
@@ -80,6 +80,20 @@ my $COMP = {
     },
 };
 
+# The gzip --rsyncable option is not universally supported, so we need to
+# conditionally use it. Ideally we would invoke 'gzip --help' and check
+# whether the option is supported, but that would imply forking and executing
+# that process for any module that ends up loading this one, which is not
+# acceptable performance-wise. Instead we will approximate it by osname, which
+# is not ideal, but better than nothing.
+#
+# Requires GNU gzip >= 1.7 for the --rsyncable option. On AIX GNU gzip is
+# too old. On the BSDs they use their own implementation based on zlib,
+# which does not currently support the --rsyncable option.
+if (any { $Config{osname} eq $_ } qw(linux gnu)) {
+    push @{$COMP->{gzip}->{comp_prog}}, '--rsyncable';
+}
+
 my $default_compression = 'xz';
 my $default_compression_level = undef;
 

-- 
Dpkg.Org's dpkg

Reply via email to