2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
8 #-------------------------------------------------------------------------------
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
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/>.
26 # foamPackBin [OPTION] <archOptions>
29 # Pack and compress binary version of OpenFOAM for release
32 # foamPackThirdPartyBin [OPTION] <archOptions>
35 # Pack and compress binary version of OpenFOAM ThirdParty for release
37 #------------------------------------------------------------------------------
38 toolsDir
="${0%/*}/tools" # this script is located in the tools/ parent dir
43 codeBase
="OpenFOAM ThirdParty"
44 packDir
=ThirdParty-
$WM_PROJECT_VERSION
45 listBinDirs
=$toolsDir/foamListThirdPartyBinDirs
50 packDir
=$WM_PROJECT-$WM_PROJECT_VERSION
51 listBinDirs
=$toolsDir/foamListBinDirs
58 while [ "$#" -gt 0 ]; do echo "$1"; shift; done
60 Usage: ${0##*/} [OPTION] <archOptions>
61 ${0##*/} [OPTION] -current
63 -b, -bzip2 use bzip2 instead of gzip compression
64 -c, -current use current value of \$WM_OPTIONS
65 -o, -output <dir> specify alternative output directory
67 * Pack and compress binary version of $codeBase for release
69 The value of 'archOptions' normally corresponds to \$WM_OPTIONS
70 The current value of \$WM_OPTIONS = $WM_OPTIONS
77 unset archOptions outputDir
91 -c |
-current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt'
92 archOptions
="$WM_OPTIONS"
96 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
101 usage
"unknown option: '$*'"
109 if [ -n "$archOptions" ]
111 [ $# -eq 0 ] || usage
"Error: cannot specify both -current and architecture"
114 [ $# -eq 1 ] || usage
"Error: specify architecture"
118 #------------------------------------------------------------------------------
119 timeStamp
=$
(date +%Y-
%m-
%d
)
120 packBase
=${packDir}.${archOptions}_${timeStamp}
122 # add optional output directory
123 [ -d "$outputDir" ] && packBase
="$outputDir/$packBase"
124 packFile
=$packBase.
$packExt
126 # avoid overwriting old pack file
129 echo "Error: $packFile already exists" 1>&2
134 #------------------------------------------------------------------------------
136 # get list of directories
137 dirList
=$
( $listBinDirs $packDir $archOptions )
138 if [ $?
-eq 0 -a -n "$dirList" ]
140 echo "Pack into $packFile" 1>&2
146 # bzip2 or gzip compression
157 trap 'rm -f $packFile 2>/dev/null' INT
159 tar $tarOpt $packFile $dirList
162 echo "Finished packing file $packFile" 1>&2
164 echo "Error: failure packing $packFile" 1>&2
165 rm -f $packFile 2>/dev
/null
168 #------------------------------------------------------------------------------