cleanup of foam-pack scripts

- removed legacy foamDiffSourceList, foamPackChanged
  - added foamPackDoxygen for separate distribution of docs
    handles -prefix option
  - misc. cosmetic changes
This commit is contained in:
Mark Olesen
2008-07-20 15:53:43 +02:00
parent 0473f177ad
commit 4d96b876e4
15 changed files with 161 additions and 280 deletions

View File

@ -1,135 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# foamDiffSourceList <oldDir> <newDir> <tarFile>
#
# Description
# Packs and compresses files that have changed (diff -uw) between
# oldDir newDir
#
#------------------------------------------------------------------------------
tmpFile=${TMPDIR:-/tmp}/foamDiffList.$$
if [ $# -ne 3 ]; then
echo "Usage : ${0##*/} oldDir newDir tarFile"
echo ""
echo "Find the files that changed (diff -uw) between <oldDir> and <newDir>"
echo "and pack them into <tarFile>"
echo ""
exit 1
fi
# canonical form (no double and no trailing dashes)
oldDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
newDir=$(echo "$2" | sed -e 's@//*@/@g' -e 's@/$@@')
packFile=$3
if [ ! -d $oldDir ]; then
echo "Error: directory $oldDir does not exist"
exit 1
fi
if [ ! -d $newDir ]; then
echo "Error: directory $newDir does not exist"
exit 1
fi
if [ -f $packFile ]; then
echo "Error: $packFile already exists"
exit 1
fi
# Clean up on termination and on Ctrl-C
trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
fileCount=0
cat /dev/null > $tmpFile
find -H $newDir \
! -type d -type f \
! -name "*~" \
-a ! -name ".*~" \
-a ! -name ".#*" \
-a ! -name "*.orig" \
-a ! -name "*.dep" \
-a ! -name "*.o" \
-a ! -name "*.so" \
-a ! -name "*.a" \
-a ! -name "*.tgz" \
-a ! -name "core" \
-a ! -name "core.[1-9]*" \
-a ! -name "log[0-9]*" \
| sed \
-e "\@$newDir/.git/@d" \
-e "\@$newDir/lib/@d" \
-e '\@applications/bin/@d' \
-e '\@/t/@d' \
-e '\@Make[.A-Za-z]*/[^/]*/@d' \
-e '\@[Dd]oxygen/html@d' \
-e '\@[Dd]oxygen/latex@d' \
-e '\@[Dd]oxygen/man@d' \
-e "s@$newDir/*@@" \
| \
(
while read file
do
(( fileCount=$fileCount + 1))
if [ -f "$oldDir/$file" ]
then
diff -uw $oldDir/$file $newDir/$file >/dev/null 2>&1
if [ $? = 1 ]
then
echo "[DIFF]" $file
echo $newDir/$file >> $tmpFile
continue
fi
else
echo "[NEW]" $file
echo $newDir/$file >> $tmpFile
continue
fi
echo $fileCount $file
done
)
# file fileCount
fileCount=$(cat $tmpFile | wc -l)
echo "----------------------------------------------------------------------"
echo "pack $fileCount changed/new files"
tar -czpf $packFile --files-from $tmpFile
if [ $? = 0 ]
then
echo "Finished packing changed files from $newDir into $packFile"
else
echo "Error: failure packing changed files from $newDir into $packFile"
rm -f $packFile 2>/dev/null
fi
echo "----------------------------------------------------------------------"
# ----------------------------------------------------------------------------

View File

@ -37,13 +37,11 @@
# foamExec -v <foamVersion> <foamCommand> ... -parallel
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [OPTION] <application> ...
usage: ${0##*/} [OPTION] <application> ...
options:
-v ver specify OpenFOAM version

View File

@ -29,13 +29,11 @@
# Description
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [OPTION] <application> ...
usage: ${0##*/} [OPTION] <application> ...
options:
-case dir specify case directory
@ -108,9 +106,9 @@ do
usage
;;
-case)
shift
caseDir=$1
[ "$#" -ge 1 ] || usage "'-case' option requires an argument"
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
caseDir=$2
shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
-s)

View File

@ -30,13 +30,11 @@
# Create a new standard OpenFOAM source file
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script <type> {args}
usage: ${0##*/} <type> {args}
* create a new standard OpenFOAM source file

View File

@ -43,7 +43,8 @@ then
fi
# add optional output directory
if [ -d "$1" ]; then
if [ -d "$1" ]
then
packFile="$1/$packFile"
fi

View File

@ -31,7 +31,7 @@
#
#------------------------------------------------------------------------------
if [ $# = 0 ]
if [ $# -eq 0 ]
then
echo "Error: architecture type expected, exiting"
echo

View File

@ -27,7 +27,7 @@
# foamPackBinAll [outputDir]
#
# Description
# Packs and compresses all binary version of foam for release
# Packs and compresses all binary versions of foam for release
#
#------------------------------------------------------------------------------
packDir=$WM_PROJECT-$WM_PROJECT_VERSION
@ -38,6 +38,7 @@ then
exit 1
fi
# obtain arch types from lib/
for bin in $packDir/lib/*
do
foamPackBin ${bin##*/} $@

View File

@ -1,105 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# foamPackChanged <directory> <tarFile>
#
# Description
# Packs and compresses files that have a corresponding .orig file
#
#------------------------------------------------------------------------------
tmpFile=${TMPDIR:-/tmp}/foamPackChanged.$$
if [ $# -ne 2 ]; then
echo "Usage : ${0##*/} directory tarFile"
echo ""
echo "Packs and compresses files that have a corresponding .orig file"
echo ""
exit 1
fi
# canonical form (no double and no trailing dashes)
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
packFile=$2
if [ ! -d $packDir ]; then
echo "Error: directory $packDir does not exist"
exit 1
fi
# Clean up on termination and on Ctrl-C
trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
fileCount=0
cat /dev/null > $tmpFile
find -H $packDir \
! -type d \
-type f \
-name "*.orig" \
| sed \
-e "\@$packDir/lib/@d" \
-e '\@applications/bin/@d' \
-e '\@/t/@d' \
-e '\@Make[.A-Za-z]*/[^/]*/@d' \
-e '\@[Dd]oxygen/html@d' \
-e '\@[Dd]oxygen/latex@d' \
-e '\@[Dd]oxygen/man@d' \
-e "s@$packDir/*@@" \
| \
(
while read file
do
(( fileCount=$fileCount + 1 ))
file=${file%%.orig}
if [ -f "$packDir/$file" ]
then
echo $fileCount $file
echo $packDir/$file >> $tmpFile
else
echo "[MISSING]" $file
fi
done
)
# file fileCount
fileCount=$(cat $tmpFile | wc -l)
echo "----------------------------------------------------------------------"
echo "pack $fileCount updated (non-.orig) files"
tar -czpf $packFile --files-from $tmpFile
if [ $? = 0 ]
then
echo "Finished packing changed files from $packDir into $packFile"
else
echo "Error: failure packing changed files from $packDir into $packFile"
rm -f $packFile 2>/dev/null
fi
echo "----------------------------------------------------------------------"
# ----------------------------------------------------------------------------

121
bin/foamPackDoxygen Executable file
View File

@ -0,0 +1,121 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# foamPackDoxygen [-prefix DIR] [-o outputDir]
#
# Description
# Packs and compresses the OpenFOAM doxygen html for release
#
#------------------------------------------------------------------------------
packDir=$WM_PROJECT-$WM_PROJECT_VERSION
packTag=_Doxygen.gtgz
usage() {
cat <<USAGE 1>&2
Usage: ${0##*/} [-prefix DIR] [-o outputDir]
Packs and compresses the OpenFOAM doxygen html for release
USAGE
exit 1
}
unset prefix outputDir
while [ "$#" -gt 0 ]
do
case $1 in
-prefix | --prefix )
prefix=${2%%/}
shift 2
;;
-o | -output )
outputDir=${2%%/}
shift 2
;;
-h | -help )
usage
;;
-*)
usage "unknown option: '$*'"
;;
esac
done
# if packing from within the directory, use -prefix form
if [ "${PWD##*/}" = "$packDir" ]
then
: ${prefix:=$packDir}
fi
# pack the directories directly and add prefix afterwards
if [ -n "$prefix" ]
then
packDir="$prefix"
elif [ ! -d $packDir ]
then
echo "Error: directory $packDir does not exist"
exit 1
fi
#
# add optional output directory
#
if [ -d "$outputDir" ]
then
packFile="$outputDir/$packDir$packTag"
else
packFile="$packDir$packTag"
fi
if [ -f $packFile ]
then
echo "Error: $packFile already exists"
exit 1
fi
# Pack and compress the packFile using GNU tar
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo
echo "Packing doxygen html into $packFile"
echo
if [ -n "$prefix" ]
then
tar czpf $packFile --transform="s@^@$prefix/@" doc/Doxygen/html
else
tar czpf $packFile $packDir/doc/Doxygen/html
fi
if [ $? = 0 ]
then
echo "Finished packing doxygen html into file $packFile"
else
echo "Error: failure packing doxygen html file $packFile"
fi
#------------------------------------------------------------------------------

View File

@ -33,7 +33,8 @@
#------------------------------------------------------------------------------
tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
if [ $# -ne 2 ]; then
if [ $# -ne 2 ]
then
echo "Usage : ${0##*/} directory tarFile"
echo ""
echo "Packs all .C and .H files and Make/options and Make/files into"
@ -46,12 +47,14 @@ fi
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
packFile=$2
if [ ! -d $packDir ]; then
if [ ! -d $packDir ]
then
echo "Error: directory $packDir does not exist"
exit 1
fi
if [ -f $packFile ]; then
if [ -f $packFile ]
then
echo "Error: $packFile already exists"
exit 1
fi

View File

@ -33,14 +33,14 @@
if [ $# = 0 ]
then
echo "Error: archOptionsitecture type expected, exiting"
echo "Error: archOptions type expected, exiting"
echo
echo "Usage : ${0##*/} <archOptions> [outputDir]"
echo
exit 1
fi
archOptions=$1
arch=${archOptions%%G*}
arch=${archOptions%%G*} # TODO: works for Gcc only
arch3264=$(echo "$arch" | sed 's@64@-64@')
timeStamp=$(date +%Y-%m-%d)

View File

@ -30,13 +30,11 @@
# start paraview with the OpenFOAM libraries
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [-case dir]
usage: ${0##*/} [-case dir]
* start paraview $ParaView_VERSION with the OpenFOAM libraries
@ -45,25 +43,27 @@ USAGE
}
# parse options
if [ "$#" -gt 0 ]; then
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-case)
shift
caseDir=$1
[ "$#" -ge 1 ] || usage "'-case' option requires an argument"
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
caseDir=$2
shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
fi
done
# get a sensible caseName
caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM"
# parent directory for normal or parallel results
case "$caseName" in
@ -77,8 +77,6 @@ do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done
#caseFile="$caseName.foam"
caseFile="$caseName.OpenFOAM"
case "$ParaView_VERSION" in
2*)

View File

@ -1,3 +1,3 @@
#!/bin/sh
#find . \( -name 'core' \) -exec ls -l {} \; -exec rm {} \;
# find . \( -name 'core' \) -exec ls -l {} \; -exec rm {} \;
find . \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm

View File

@ -1,12 +1,15 @@
#!/bin/sh
if [ $# -eq 0 ]; then
find . \( -name '*.dep' \) -print | xargs -t rm
elif [ $# -eq 1 ]; then
echo "Removing all dep files containing $1..."
find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \;
if [ $# -eq 0 ]
then
find . \( -name '*.dep' \) -print | xargs -t rm
elif [ $# -eq 1 ]
then
echo "Removing all dep files containing $1..."
find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \;
else
echo "Usage: `basename $0` to remove all .dep files"
echo " `basename $0` <file> to remove all .dep files referring to <file>"
exit 1
echo "Usage: ${0##/} to remove all .dep files"
echo " ${0##/} <file> to remove all .dep files referring to <file>"
exit 1
fi

View File

@ -1,3 +1,3 @@
#!/bin/sh
#find . \( -name '*~' -o -name '.*~' \) -exec ls -l {} \; -exec rm {} \;
# find . \( -name '*~' -o -name '.*~' \) -exec ls -l {} \; -exec rm {} \;
find . \( -name '*~' -o -name '.*~' \) -print | xargs -t rm