ENH: polyBoundaryMesh: improved error message
[OpenFOAM-2.0.x.git] / bin / foamPackDoxygen
blob4b34c8ecd8f37fae49859e99d0004027fb74e23e
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 # foamPackDoxygen [-prefix DIR] [-o outputDir]
28 # Description
29 # Pack and compress the OpenFOAM doxygen html for release
31 #------------------------------------------------------------------------------
32 packDir=$WM_PROJECT-$WM_PROJECT_VERSION
33 htmlDir=doc/Doxygen/html
35 usage() {
36 exec 1>&2
37 while [ "$#" -gt 0 ]; do echo "$1"; shift; done
38 cat <<USAGE
39 Usage: ${0##*/} [OPTION]
40 options:
41 -b, -bzip2 use bzip2 instead of gzip compression
42 -o, -output <dir> specify alternative output directory
43 -prefix <dir> use alternative prefix
45 * Pack and compress the OpenFOAM doxygen html for release
47 USAGE
48 exit 1
52 unset prefix outputDir
53 packExt=tgz
55 # parse options
56 while [ "$#" -gt 0 ]
58 case $1 in
59 -h | -help)
60 usage
62 -b | -bzip2)
63 packExt=tbz
64 shift
66 -o | -output)
67 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
68 outputDir=${2%%/}
69 shift 2
71 -prefix | --prefix)
72 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
73 prefix=${2%%/}
74 shift 2
76 -*)
77 usage "unknown option: '$*'"
79 esac
80 done
82 # if packing from within the directory, use -prefix form
83 if [ "${PWD##*/}" = "$packDir" ]
84 then
85 : ${prefix:=$packDir}
88 # pack the directories directly and add prefix afterwards
89 if [ -n "$prefix" ]
90 then
91 packDir="$prefix"
92 elif [ ! -d $packDir ]
93 then
94 echo "Error: directory $packDir does not exist" 1>&2
95 exit 1
98 #------------------------------------------------------------------------------
99 packName=${packDir}_Doxygen
101 # add optional output directory
102 [ -d "$outputDir" ] && packName="$outputDir/$packName"
103 packFile=$packName.$packExt
106 if [ -f $packFile ]
107 then
108 echo "Error: $packFile already exists" 1>&2
109 exit 1
112 cat <<INFO 1>&2
113 -------------------------------------------------------------------------------
114 Packing doxygen html into $packFile
116 INFO
118 # bzip2 or gzip compression
119 case "$packFile" in
120 *tbz)
121 tarOpt=cpjf
124 tarOpt=cpzf
126 esac
128 # Clean up on Ctrl-C
129 trap 'rm -f $packFile 2>/dev/null' INT
131 if [ -n "$prefix" ]
132 then
133 # requires GNU tar
134 tar $tarOpt $packFile --transform="s@^@$prefix/@" $htmlDir
135 else
136 tar $tarOpt $packFile $packDir/$htmlDir
139 if [ $? -eq 0 ]
140 then
141 echo "Finished packing doxygen html into $packFile" 1>&2
142 else
143 echo "Error: failure packing doxygen html into $packFile" 1>&2
144 rm -f $packFile 2>/dev/null
147 #------------------------------------------------------------------------------