[csw-devel] SF.net SVN: gar:[16787] csw/mgar/gar/v2/bin/mkpackage

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Tue Jan 17 22:07:37 CET 2012


Revision: 16787
          http://gar.svn.sourceforge.net/gar/?rev=16787&view=rev
Author:   dmichelsen
Date:     2012-01-17 21:07:37 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
mGAR v2: Make compression level adjustable as reported in #65

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/mkpackage

Modified: csw/mgar/gar/v2/bin/mkpackage
===================================================================
--- csw/mgar/gar/v2/bin/mkpackage	2012-01-17 19:34:52 UTC (rev 16786)
+++ csw/mgar/gar/v2/bin/mkpackage	2012-01-17 21:07:37 UTC (rev 16787)
@@ -65,6 +65,7 @@
     prog_exec_error     => 9,
     spec_error          => 10,
     dumped_env          => 11,
+    bad_ziplevel        => 12,
     unknown             => 42,
 );
 
@@ -317,6 +318,7 @@
         'transfer!'    => \$config{transfer},
         'overwrite!'   => \$config{overwrite},
         'compress!'    => \$config{compress},
+        'ziplevel|z=i' => \$config{ziplevel},
         'usebzip'      => \$config{usebzip},
         'usepigz'      => \$config{usepigz},
         'quiet|q'      => \$config{quiet},
@@ -399,6 +401,9 @@
     $config{overwrite} = 0 unless defined $config{overwrite};
     $config{usebzip}   = 0 unless defined $config{usebzip};
     $config{usepigz}   = 0 unless defined $config{usepigz};
+    $config{ziplevel}  = 9 unless defined $config{ziplevel};
+    Die( $exit{bad_ziplevel}, "Invalid --ziplevel '$config{ziplevel}'" )
+      if $config{ziplevel} < 1 or $config{ziplevel} > 9;
 
     # Export variables to the spec
     $ENV{$_} = $config{$_} foreach qw/
@@ -912,10 +917,10 @@
     if ( $config{compress} ) {
         my $compress =
           $config{usebzip}
-          ? 'bzip2 -9 -f %s'
-          : ($config{usepigz} ? 'pigz -9 -f %s' : 'gzip -9 -f %s');
+          ? 'bzip2 -%d -f %s'
+          : ($config{usepigz} ? 'pigz -%d -f %s' : 'gzip -%d -f %s');
 
-        vexec( sprintf( $compress, $tmppkg ), "Failed to compress $tmppkg" );
+        vexec( sprintf( $compress, $config{ziplevel}, $tmppkg ), "Failed to compress $tmppkg" );
         $tmppkg .= $config{usebzip} ? ".bz2" : ".gz";
     }
 
@@ -954,9 +959,10 @@
 
  mkpackage --spec <path> [--destdir <path>] [--workdir <path>]
         [--spooldir <path>] [--pkgroot <path>] [--tmpdir <path>]
-        [--[no]transfer] [--[no]overwrite] [--[no]compress]
-        [--usebzip] [--usepigz] [-v var=value...] [--dump <var>|-dumpall]
-        [--quiet] [--help] [--manual] [--version]
+        [--[no]transfer] [--[no]overwrite] [--[no]compress] 
+        [--ziplevel N] [--usebzip] [--usepigz] [-v var=value...] 
+        [--dump <var>|-dumpall] [--quiet] [--help] [--manual]
+        [--version]
 
 =head1 DESCRIPTION
 
@@ -1028,6 +1034,11 @@
 this option is ignored when --notransfer is specified, as in this case no
 bistream package will be created.
 
+=head2 --ziplevel,-z
+
+Set compression level. Option accepts a single integer from 1 to 9.
+The meaning is the same as for -# gzip option. (Default: 9)
+
 =head2 --usebzip
 
 Enable bzip2 compression.  Unless --nocompress and/or --notransfer options are

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list