scripts/functions: compress with gzip level 3, as stated in the documentation
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Apr 13 21:47:34 2010 +0200 (2010-04-13)
changeset 1908d77f3f04a227
parent 1907 2a40681d94c7
child 1909 5921089b34bd
scripts/functions: compress with gzip level 3, as stated in the documentation

Thanks to Bruno Tarquini <btarquini@gmail.com> for the report.
scripts/functions
     1.1 --- a/scripts/functions	Tue Apr 13 20:52:38 2010 +0200
     1.2 +++ b/scripts/functions	Tue Apr 13 21:47:34 2010 +0200
     1.3 @@ -917,16 +917,18 @@
     1.4      local tarball="$2"
     1.5      shift 2
     1.6      local -a extra_tar_opts=( "$@" )
     1.7 -    local tar_opt
     1.8 +    local -a compress
     1.9  
    1.10      case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
    1.11 -        y)  tar_opt=-z; tar_ext=.gz;;
    1.12 -        *)  tar_opt=;   tar_ext=;;
    1.13 +        y)  compress=( gzip -c -3 - ); tar_ext=.gz;;
    1.14 +        *)  compress=( cat - );        tar_ext=;;
    1.15      esac
    1.16  
    1.17      if [ -d "${dir}" ]; then
    1.18          CT_DoLog DEBUG "  Saving '${dir}'"
    1.19 -        CT_DoExecLog DEBUG tar c -C "${dir}" -v ${tar_opt} -f "${tarball}.tar${tar_ext}" "${extra_tar_opts[@]}" .
    1.20 +        { tar c -C "${dir}" -v -f - "${extra_tar_opts[@]}" .    \
    1.21 +          |"${compress[@]}" >"${tarball}.tar${tar_ext}"         ;
    1.22 +        } 2>&1 |sed -r -e 's/^/    /;' |CT_DoLog DEBUG
    1.23      else
    1.24          CT_DoLog DEBUG "  Not saving '${dir}': does not exist"
    1.25      fi
    1.26 @@ -940,18 +942,20 @@
    1.27      local dir="$2"
    1.28      shift 2
    1.29      local -a extra_tar_opts=( "$@" )
    1.30 -    local tar_opt
    1.31 +    local -a uncompress
    1.32  
    1.33      case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
    1.34 -        y)  tar_opt=-z; tar_ext=.gz;;
    1.35 -        *)  tar_opt=;   tar_ext=;;
    1.36 +        y)  uncompress=( gzip -c -d ); tar_ext=.gz;;
    1.37 +        *)  uncompress=( cat );        tar_ext=;;
    1.38      esac
    1.39  
    1.40      if [ -f "${tarball}.tar${tar_ext}" ]; then
    1.41          CT_DoLog DEBUG "  Restoring '${dir}'"
    1.42          CT_DoForceRmdir "${dir}"
    1.43          CT_DoExecLog DEBUG mkdir -p "${dir}"
    1.44 -        CT_DoExecLog DEBUG tar x -C "${dir}" -v ${tar_opt} -f "${tarball}.tar${tar_ext}" "${extra_tar_opts[@]}"
    1.45 +        { "${uncompress[@]}" "${tarball}.tar${tar_ext}"     \
    1.46 +          |tar x -C "${dir}" -v -f - "${extra_tar_opts[@]}" ;
    1.47 +        } 2>&1 |sed -r -e 's/^/    /;' |CT_DoLog DEBUG
    1.48      else
    1.49          CT_DoLog DEBUG "  Not restoring '${dir}': does not exist"
    1.50      fi