2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2011-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 # foamPackMake [OPTION] <archOptions>
29 # Pack and compress OpenFOAM Make/<archOptions> directories
32 # foamPackThirdPartyMake [OPTION] <archOptions>
35 # Pack and compress OpenFOAM ThirdParty Make/<archOptions> directories
37 #------------------------------------------------------------------------------
38 toolsDir
="${0%/*}/tools" # this script is located in the tools/ parent dir
43 codeBase
="OpenFOAM ThirdParty"
44 packDir
=ThirdParty-
$WM_PROJECT_VERSION
49 packDir
=$WM_PROJECT-$WM_PROJECT_VERSION
56 while [ "$#" -gt 0 ]; do echo "$1"; shift; done
58 Usage: ${0##*/} [OPTION] <archOptions>
59 ${0##*/} [OPTION] -current
61 -b, -bzip2 use bzip2 instead of gzip compression
62 -c, -current use current value of \$WM_OPTIONS
63 -o, -output <dir> specify alternative output directory
65 * Pack and compress $codeBase Make/<archOptions> directories
67 The value of 'archOptions' normally corresponds to \$WM_OPTIONS
68 The current value of \$WM_OPTIONS = $WM_OPTIONS
75 unset archOptions outputDir
89 -c |
-current) # use $WM_OPTIONS - eg, 'linux64GccDPOpt'
90 archOptions
="$WM_OPTIONS"
94 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
99 usage
"unknown option: '$*'"
107 if [ -n "$archOptions" ]
109 [ $# -eq 0 ] || usage
"Error: cannot specify both -current and architecture"
112 [ $# -eq 1 ] || usage
"Error: specify architecture"
116 #------------------------------------------------------------------------------
117 timeStamp
=$
(date +%Y-
%m-
%d
)
118 packBase
=${packDir}.Make-${archOptions}_${timeStamp}
120 # add optional output directory
121 [ -d "$outputDir" ] && packBase
="$outputDir/$packBase"
122 packFile
=$packBase.
$packExt
124 # avoid overwriting old pack file
127 echo "Error: $packFile already exists" 1>&2
132 -------------------------------------------------------------------------------
133 Pack and compress Make/$archOptions* directories into $packFile
138 # bzip2 or gzip compression
150 trap 'rm -f $packFile 2>/dev/null' INT
152 find -H $packDir -depth -name Make
-type d
-print | \
153 xargs -i find '{}' -depth -name "$archOptions*" -type d
-print | \
154 tar $tarOpt $packFile -T -
158 echo "Finished packing Make/$archOptions directories into $packFile" 1>&2
160 echo "Error: failure packing Make/$archOptions directories into $packFile" 1>&2
161 rm -f $packFile 2>/dev
/null
164 #------------------------------------------------------------------------------