From dd22de68d4c8f71fea57f80180ed821c4e68f942 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 15 Feb 2011 11:04:08 +0100 Subject: [PATCH] ENH: support bzip2 compression for foamPack* --- bin/foamPackBin | 18 ++++++++++++++++-- bin/foamPackDeps | 22 ++++++++++++++++++++-- bin/foamPackDoxygen | 23 ++++++++++++++++++++--- bin/foamPackMake | 21 +++++++++++++++++++-- bin/tools/foamListSourceFiles | 2 ++ bin/tools/foamPackSource | 12 +++++++++++- 6 files changed, 88 insertions(+), 10 deletions(-) diff --git a/bin/foamPackBin b/bin/foamPackBin index 67738d1ea8..3ee4641383 100755 --- a/bin/foamPackBin +++ b/bin/foamPackBin @@ -59,6 +59,7 @@ cat <&2 Usage: ${0##*/} [OPTION] ${0##*/} [OPTION] -current options: + -b, -bzip2 use bzip2 instead of gzip compression -c, -current use current value of \$WM_OPTIONS -o, -output specify alternative output directory @@ -73,6 +74,7 @@ USAGE unset archOptions outputDir +packExt=tgz # parse options while [ "$#" -gt 0 ] @@ -81,6 +83,10 @@ do -h | -help) usage ;; + -b | -bzip2) + packExt=tbz + shift + ;; -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt' archOptions="$WM_OPTIONS" shift @@ -110,7 +116,6 @@ fi #------------------------------------------------------------------------------ timeStamp=$(date +%Y-%m-%d) -packExt=tgz packBase=${packDir}.${archOptions}_${timeStamp} # add optional output directory @@ -137,11 +142,20 @@ else exit 1 fi +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT -tar cpzf $packFile $dirList +tar $tarOpt $packFile $dirList if [ $? -eq 0 ] then echo "Finished packing file $packFile" 1>&2 diff --git a/bin/foamPackDeps b/bin/foamPackDeps index 67a885b900..1de69167df 100755 --- a/bin/foamPackDeps +++ b/bin/foamPackDeps @@ -56,6 +56,7 @@ usage() { cat <&2 Usage: ${0##*/} [OPTION] options: + -b, -bzip2 use bzip2 instead of gzip compression -o, -output specify alternative output directory * Pack and compress *.dep files from $codeBase @@ -66,6 +67,8 @@ USAGE unset outputDir +packExt=tgz + # parse options while [ "$#" -gt 0 ] do @@ -73,6 +76,10 @@ do -h | -help) usage ;; + -b | -bzip2) + packExt=tbz + shift + ;; -o | -output) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" outputDir=${2%%/} @@ -96,7 +103,6 @@ done #------------------------------------------------------------------------------ timeStamp=$(date +%Y-%m-%d) -packExt=tgz packBase=${packDir}.deps_${timeStamp} # add optional output directory @@ -116,10 +122,22 @@ Packing *.dep files into $packFile INFO + +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + + # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT -find -H $packDir -name '*.dep' -type f -print | tar cpzf $packFile -T - +find -H $packDir -name '*.dep' -type f -print | tar $tarOpt $packFile -T - if [ $? -eq 0 ] then diff --git a/bin/foamPackDoxygen b/bin/foamPackDoxygen index 6f1b17ca27..a5104e39b9 100755 --- a/bin/foamPackDoxygen +++ b/bin/foamPackDoxygen @@ -37,6 +37,7 @@ usage() { cat <&2 Usage: ${0##*/} [OPTION] options: + -b, -bzip2 use bzip2 instead of gzip compression -o, -output specify alternative output directory -prefix use alternative prefix @@ -46,7 +47,10 @@ USAGE exit 1 } + unset prefix outputDir +packExt=tgz + # parse options while [ "$#" -gt 0 ] do @@ -54,6 +58,10 @@ do -h | -help) usage ;; + -b | -bzip2) + packExt=tbz + shift + ;; -o | -output) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" outputDir=${2%%/} @@ -87,7 +95,6 @@ then fi #------------------------------------------------------------------------------ -packExt=tgz packName=${packDir}_Doxygen # add optional output directory @@ -107,15 +114,25 @@ Packing doxygen html into $packFile INFO +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT if [ -n "$prefix" ] then # requires GNU tar - tar cpzf $packFile --transform="s@^@$prefix/@" $htmlDir + tar $tarOpt $packFile --transform="s@^@$prefix/@" $htmlDir else - tar cpzf $packFile $packDir/$htmlDir + tar $tarOpt $packFile $packDir/$htmlDir fi if [ $? -eq 0 ] diff --git a/bin/foamPackMake b/bin/foamPackMake index c4325723e3..f930e633c7 100755 --- a/bin/foamPackMake +++ b/bin/foamPackMake @@ -57,6 +57,7 @@ cat <&2 Usage: ${0##*/} [OPTION] ${0##*/} [OPTION] -current options: + -b, -bzip2 use bzip2 instead of gzip compression -c, -current use current value of \$WM_OPTIONS -o, -output specify alternative output directory @@ -71,6 +72,7 @@ USAGE unset archOptions outputDir +packExt=tgz # parse options while [ "$#" -gt 0 ] @@ -79,6 +81,10 @@ do -h | -help) usage ;; + -b | -bzip2) + packExt=tbz + shift + ;; -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt' archOptions="$WM_OPTIONS" shift @@ -108,7 +114,6 @@ fi #------------------------------------------------------------------------------ timeStamp=$(date +%Y-%m-%d) -packExt=tgz packBase=${packDir}.Make-${archOptions}_${timeStamp} # add optional output directory @@ -128,12 +133,24 @@ Pack and compress Make/$archOptions* directories into $packFile INFO + +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + + # Clean up on Ctrl-C trap 'rm -f $packFile 2>/dev/null' INT find -H $packDir -depth -name Make -type d -print | \ xargs -i find '{}' -depth -name "$archOptions*" -type d -print | \ - tar cpzf $packFile -T - + tar $tarOpt $packFile -T - if [ $? -eq 0 ] then diff --git a/bin/tools/foamListSourceFiles b/bin/tools/foamListSourceFiles index a8d4d59091..2deedeac8c 100755 --- a/bin/tools/foamListSourceFiles +++ b/bin/tools/foamListSourceFiles @@ -71,6 +71,8 @@ find -H $packDir \ -a ! -name "*.tar" \ -a ! -name "*.tar.gz" \ -a ! -name "*.tgz" \ + -a ! -name "*.tar.bz2" \ + -a ! -name "*.tbz" \ -a ! -name "core" \ -a ! -name "core.[1-9]*" \ -a ! -name "libccmio*" \ diff --git a/bin/tools/foamPackSource b/bin/tools/foamPackSource index a4d014cfcf..83fe64391f 100755 --- a/bin/tools/foamPackSource +++ b/bin/tools/foamPackSource @@ -78,10 +78,20 @@ INFO wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}' 1>&2 +# bzip2 or gzip compression +case "$packFile" in +*tbz) + tarOpt=cpjf + ;; +*) + tarOpt=cpzf + ;; +esac + # Clean up on Ctrl-C trap 'rm -f $packFile $tmpFile 2>/dev/null' INT -tar cpzf $packFile --files-from $tmpFile +tar $tarOpt $packFile --files-from $tmpFile if [ $? -eq 0 ] then echo "Finished packing $packDir into $packFile" 1>&2