STYLE: date
[OpenFOAM-2.0.x.git] / bin / foamPackDeps
blob0f4d040fffd1fc724aceed81bab91bf6abb6fa1b
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamPackDeps [OPTION]
28 # Description
29 # Pack and compress *.dep files from OpenFOAM
31 # Script
32 # foamPackDeps [OPTION]
34 # Description
35 # Pack and compress *.dep files from OpenFOAM ThirdParty
37 #------------------------------------------------------------------------------
38 toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
40 case "${0##*/}" in
41 *ThirdParty*)
42 # for ThirdParty
43 codeBase="OpenFOAM ThirdParty"
44 packDir=ThirdParty-$WM_PROJECT_VERSION
47 # regular
48 codeBase="OpenFOAM"
49 packDir=$WM_PROJECT-$WM_PROJECT_VERSION
51 esac
54 usage() {
55 exec 1>&2
56 while [ "$#" -gt 0 ]; do echo "$1"; shift; done
57 cat <<USAGE
58 Usage: ${0##*/} [OPTION]
59 options:
60 -b, -bzip2 use bzip2 instead of gzip compression
61 -c, -current for compatibility - currently ignored
62 -o, -output <dir> specify alternative output directory
64 * Pack and compress *.dep files from $codeBase
66 USAGE
67 exit 1
71 unset archOptions outputDir
72 packExt=tgz
74 # parse options
75 while [ "$#" -gt 0 ]
77 case "$1" in
78 -h | -help)
79 usage
81 -b | -bzip2)
82 packExt=tbz
83 shift
85 -c | -current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt'
86 archOptions="$WM_OPTIONS"
87 shift
89 -o | -output)
90 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
91 outputDir=${2%%/}
92 shift 2
94 -*)
95 usage "unknown option: '$*'"
98 break
100 esac
101 done
103 # check for essential directories
104 [ -d $packDir ] || {
105 echo "Error: directory $packDir does not exist" 1>&2
106 exit 1
110 #------------------------------------------------------------------------------
111 timeStamp=$(date +%Y-%m-%d)
112 packBase=${packDir}.deps_${timeStamp}
114 # add optional output directory
115 [ -d "$outputDir" ] && packBase="$outputDir/$packBase"
116 packFile=$packBase.$packExt
118 # avoid overwriting old pack file
119 if [ -f $packFile ]
120 then
121 echo "Error: $packFile already exists" 1>&2
122 exit 1
125 cat <<INFO 1>&2
126 -------------------------------------------------------------------------------
127 Packing *.dep files into $packFile
129 INFO
132 # bzip2 or gzip compression
133 case "$packFile" in
134 *tbz)
135 tarOpt=cpjf
138 tarOpt=cpzf
140 esac
143 # Clean up on Ctrl-C
144 trap 'rm -f $packFile 2>/dev/null' INT
146 find -H $packDir -name '*.dep' -type f -print | tar $tarOpt $packFile -T -
148 if [ $? -eq 0 ]
149 then
150 echo "Finished packing *.dep files into $packFile" 1>&2
151 else
152 echo "Error: failure packing *.dep files into $packFile" 1>&2
153 rm -f $packFile 2>/dev/null
156 #------------------------------------------------------------------------------