Merge commit 'b5be6201e00421a59e574a07b3d28cde5defff84'
[foam-extend-4.0.git] / bin / foamPackSource
bloba54703eb47ff00f3bd67440d4a23a5335df2c1ea
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 # foamPackSource <directory> <tarFile>
28 # Description
29 # Packs and compresses the .C and .H files and Make/options
30 # and Make/files in a given directory.
32 #------------------------------------------------------------------------------
33 tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
35 if [ $# -ne 2 ]
36 then
37 echo "Usage : ${0##*/} directory tarFile"
38 echo ""
39 echo "Packs all .C and .H files and Make/options and Make/files into"
40 echo "<tarFile>"
41 echo ""
42 exit 1
45 # canonical form (no double and no trailing dashes)
46 packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
47 packFile=$2
49 if [ ! -d $packDir ]
50 then
51 echo "Error: directory $packDir does not exist"
52 exit 1
55 if [ -f $packFile ]
56 then
57 echo "Error: $packFile already exists"
58 exit 1
61 # Clean up on termination and on Ctrl-C
62 trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
64 find -H $packDir \
65 ! -type d \
66 \( -type f -o -type l \) \
67 ! -name "*~" \
68 -a ! -name ".*~" \
69 -a ! -name "*.orig" \
70 -a ! -name "*.dep" \
71 -a ! -name "*.o" \
72 -a ! -name "*.so" \
73 -a ! -name "*.a" \
74 -a ! -name "*.tgz" \
75 -a ! -name "core" \
76 -a ! -name "core.[1-9]*" \
77 -a ! -name "log[0-9]*" \
78 -a ! -name "libccmio*" \
79 -a ! -name "\.ebrowse" \
80 | sed \
81 -e "\@$packDir/.git/@d" \
82 -e "\@.svn/@d" \
83 -e "\@$packDir/lib/@d" \
84 -e '\@/\.git/@d' \
85 -e '\@/\.tags/@d' \
86 -e '\@applications/bin/@d' \
87 -e '\@wmake/bin/@d' \
88 -e '\@/t/@d' \
89 -e '\@/Make[.A-Za-z]*/[^/]*/@d'\
90 -e '\@/platforms/@d' \
91 -e '\@libccmio.*/@d' \
92 -e '\@/.svn/@d' \
93 -e "\@$packDir/ThirdParty/rpmBuild/@d"\
94 > $tmpFile
97 # provide some feedback
98 wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}'
100 tar czpf $packFile --files-from $tmpFile
102 if [ $? -eq 0 ]
103 then
104 echo "Finished packing and compressing $packDir into file $packFile"
105 else
106 echo "Error: failure packing $packDir into file $packFile"
107 rm -f $packFile 2>/dev/null
110 #------------------------------------------------------------------------------