Package: debianutils
Followup-For: Bug #587766

If you want to use it, here is a patch that lets people pass in a strength
option for the compression program.

It leaves the strength for xz blank, and xz chooses a number based on physical 
RAM.

(As a minor note xz can take -0, but the others can't so I left it out.)

-- System Information:
Debian Release: 5.0.5
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.30 (SMP w/8 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages debianutils depends on:
ii  libc6                         2.11.1-3   Embedded GNU C Library: Shared lib
ii  sensible-utils                0.0.4      Utilities for sensible alternative

debianutils recommends no packages.

debianutils suggests no packages.

-- no debconf information
diff -Naur debianutils-3.3.old/savelog debianutils-3.3/savelog
--- debianutils-3.3.old/savelog	2010-06-30 10:40:39.000000000 -0400
+++ debianutils-3.3/savelog	2010-07-08 08:40:20.874623104 -0400
@@ -27,6 +27,7 @@
 #       -p        - preserve mode/user/group of original file
 #	-j        - use bzip2 instead of gzip
 #	-J        - use xz instead of gzip
+#	-1 .. -9  - compression strength or memory usage (default: 9, except for xz)
 #	-x script - invoke script with rotated log file in $FILE
 #	-n	  - do not rotate empty files
 #	-q	  - be quiet
@@ -81,7 +82,8 @@
 # common location
 export PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin
 COMPRESS="gzip"
-COMPRESS_OPTS="-9f"
+COMPRESS_OPTS="-f"
+COMPRESS_STRENGTH_DEF="-9";
 DOT_Z=".gz"
 DATUM=`date +%Y%m%d%H%M%S`
 
@@ -118,6 +120,7 @@
     echo "	-p         - preserve mode/user/group of original file"
     echo "	-j         - use bzip2 instead of gzip"
     echo "	-J         - use xz instead of gzip"
+    echo "	-1 .. -9   - compression strength or memory usage (default: 9, except for xz)"
     echo "	-x script  - invoke script with rotated log file in \$FILE"
     echo "	-n         - do not rotate empty files"
     echo "	-q         - suppress rotation message"
@@ -139,7 +142,7 @@
 }
 
 
-while getopts m:u:g:c:r:CdD:tlphjJx:nq opt ; do
+while getopts m:u:g:c:r:CdD:tlphjJ123456789x:nq opt ; do
 	case "$opt" in
 	m) mode="$OPTARG" ;;
 	u) user="$OPTARG" ;;
@@ -150,8 +153,9 @@
 	d) datum=1 ;;
 	D) DATUM=$(date +$OPTARG) ;;
 	t) touch=1 ;;
-	j) COMPRESS="bzip2"; COMPRESS_OPTS="-9f"; DOT_Z=".bz2" ;;
-	J) COMPRESS="xz"; COMPRESS_OPTS="-9f"; DOT_Z=".xz" ;;
+	j) COMPRESS="bzip2"; COMPRESS_OPTS="-f"; COMPRESS_STRENGTH_DEF="-9"; DOT_Z=".bz2" ;;
+	J) COMPRESS="xz"; COMPRESS_OPTS="-f"; COMPRESS_STRENGTH_DEF=""; DOT_Z=".xz" ;;
+	[1-9]) COMPRESS_STRENGTH="-$opt" ;;
 	x) hookscript="$OPTARG" ;;
 	l) COMPRESS="" ;;
 	p) preserve=1 ;;
@@ -174,6 +178,12 @@
        exit 2
 fi
 
+if [ -n "$COMPRESS_STRENGTH" ]; then
+	COMPRESS_OPTS="$COMPRESS_OPTS $COMPRESS_STRENGTH"
+else
+	COMPRESS_OPTS="$COMPRESS_OPTS $COMPRESS_STRENGTH_DEF"
+fi
+
 # cycle thru filenames
 while [ $# -gt 0 ]; do
 
diff -Naur debianutils-3.3.old/savelog.8 debianutils-3.3/savelog.8
--- debianutils-3.3.old/savelog.8	2010-06-30 10:40:39.000000000 -0400
+++ debianutils-3.3/savelog.8	2010-07-08 09:08:19.223572465 -0400
@@ -5,7 +5,7 @@
 .SH SYNOPSIS
 .B savelog
 [\-m mode] [\-u user] [\-g group] [\-t] [\-p] [\-c cycle] [\-l] [\-j]
-[\-J] [\-C] [\-d] [\-l] [\-r rolldir] [\-n] [\-q] [\-D dateformat] file ...
+[\-J] [\-1\ .\|.\ \-9] [\-C] [\-d] [\-l] [\-r rolldir] [\-n] [\-q] [\-D dateformat] file ...
 .SH DESCRIPTION
 The
 .B savelog
@@ -122,6 +122,11 @@
 .TP
 .B \-J
 compress with xz instead of gzip
+
+For xz no strength option is set, and xz decides on the default based on the total amount of physical RAM. Note that xz can use a very large amount of memory for the higher compression levels.
+.TP
+.B \-1\ .\|.\ \-9
+compression strength or memory usage (default: 9, except for xz)
 .TP
 .B \-C
 force cleanup of cycled logfiles

Reply via email to