Merge commit 'b5be6201e00421a59e574a07b3d28cde5defff84'
[foam-extend-4.0.git] / bin / foamPackBin
blob5371f6b4b7d96732c4bb43d702094bce05516a4c
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 4.0
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamPackBin <arch> [outputDir]
28 # Description
29 # Packs and compresses binary version of foam for release
31 #------------------------------------------------------------------------------
33 if [ $# -eq 0 ]
34 then
35 echo "Error: architecture type expected, exiting"
36 echo
37 echo "Usage : ${0##*/} <arch> [outputDir]"
38 echo
39 exit 1
41 arch=$1
43 # base arch (w/o precision, optimization, etc)
44 baseArch=$(echo "$arch" | sed -e 's@[DS]P.*$@@')
46 timeStamp=$(date +%Y-%m-%d)
47 packDir=$WM_PROJECT-$WM_PROJECT_VERSION
48 packFile=${packDir}.${arch}_${timeStamp}.gtgz
50 # add optional output directory
51 if [ -d "$2" ]
52 then
53 packFile="$2/$packFile"
56 if [ -f $packFile ]
57 then
58 echo "Error: $packFile already exists"
59 exit 1
62 # check for essential directories
63 for dir in $packDir $packDir/lib/$arch $packDir/applications/bin/$arch
65 if [ ! -d $dir ]
66 then
67 echo "Error: directory $dir does not exist"
68 exit 1
70 done
72 # get list of directories
73 dirList=$(
74 for dir in \
75 $packDir/lib/$arch \
76 $packDir/applications/bin/$arch \
77 $packDir/wmake/rules \
78 $packDir/wmake/bin/$baseArch \
81 [ -d $dir ] && echo $dir
82 done
85 echo
86 echo "Packing $arch ($baseArch) port of $packDir into $packFile"
87 echo
89 tar czpf $packFile $dirList
91 if [ $? -eq 0 ]
92 then
93 echo "Finished packing and compressing file $packFile"
94 else
95 echo "Error: failure packing $packFile"
96 rm -f $packFile 2>/dev/null
99 #------------------------------------------------------------------------------