BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / bin / foamPackSource
blob2153c648611bb1a29bdd9d909cd9422a92bc1137
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 # foamPackSource <directory> <tarFile>
28 # Description
29 # Pack and compress all source files from a given directory.
31 # Note
32 # Not normally called directly by the user
33 #------------------------------------------------------------------------------
34 tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
35 toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
37 [ $# -eq 2 ] || {
38 cat <<USAGE 1>&2
39 Usage : ${0##*/} directory tarFile
41 * Pack and compress all source files from a given directory into <tarFile>
43 USAGE
44 exit 1
47 # canonical form (no double and no trailing dashes)
48 packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
49 packFile=$2
51 # check for essential directories
52 [ -d $packDir ] || {
53 echo "Error: directory $packDir does not exist" 1>&2
54 exit 1
58 # avoid overwriting old pack file
59 if [ -f $packFile ]
60 then
61 echo "Error: $packFile already exists" 1>&2
62 exit 1
65 # Clean up on termination and on Ctrl-C
66 trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
68 # get all names
69 $toolsDir/foamListSourceFiles $packDir > $tmpFile
72 # provide some feedback
73 cat <<INFO 1>&2
74 -------------------------------------------------------------------------------
75 Packing $packDir source files into $packFile
77 INFO
78 wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}' 1>&2
81 # bzip2 or gzip compression
82 case "$packFile" in
83 *tbz)
84 tarOpt=cpjf
87 tarOpt=cpzf
89 esac
91 # Clean up on Ctrl-C
92 trap 'rm -f $packFile $tmpFile 2>/dev/null' INT
94 tar $tarOpt $packFile --files-from $tmpFile
95 if [ $? -eq 0 ]
96 then
97 echo "Finished packing $packDir into $packFile" 1>&2
98 else
99 echo "Error: failure packing $packDir into $packFile" 1>&2
100 rm -f $packFile 2>/dev/null
103 #------------------------------------------------------------------------------