ENH: update, cleanup foam packing routines

- update packing for FOAM_EXT_LIBBIN and newer FOAM_APPBIN
- pack OpenFOAM source via 'git archive' for consistency with
  the git repository (use -nogit option to revert to manual packing)
- combine foamPackBin + foamPackThirdPartyBin
- add foamPackThirdPartyBinAll (like foamPackBinAll)

- relocate service scripts into bin/tools
- use more standard 'tgz' instead of 'gtgz'
This commit is contained in:
Mark Olesen
2011-01-02 21:39:41 +01:00
parent 6091cdb0a5
commit a3a2ea78be
13 changed files with 691 additions and 396 deletions

View File

@ -1,60 +0,0 @@
#!/bin/sh
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamBinDirs <packDir> <arch>
#
# Description
# Returns all directories containing binary files of OpenFOAM
#
#------------------------------------------------------------------------------
if [ $# -ne 2 ]
then
echo "Error: architecture type expected, exiting"
echo
echo "Usage : ${0##*/} <packDir> <arch>"
echo
exit 1
fi
packDir=$1
arch=$2
# base arch (w/o precision, optimization, etc)
baseArch=$(echo "$arch" | sed -e 's@[DS]P.*$@@')
# get list of directories
(
for dir in \
$packDir/lib/$arch \
$packDir/applications/bin/$arch \
$packDir/wmake/rules \
$packDir/wmake/bin/$baseArch \
;
do
[ -d $dir ] && echo $dir
done
)
#------------------------------------------------------------------------------

View File

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
#---------------------------------*- sh -*------------------------------------- #------------------------------------------------------------------------------
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -23,47 +23,102 @@
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# #
# Script # Script
# foamPack [outputDir] # foamPack [OPTION]
# #
# Description # Description
# Packs and compresses the OpenFOAM directory for release # Pack and compress the OpenFOAM directory for release
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
timeStamp=$(date +%Y-%m-%d)
packDir=$WM_PROJECT-$WM_PROJECT_VERSION packDir=$WM_PROJECT-$WM_PROJECT_VERSION
packFile=${packDir}_${timeStamp}.gtgz toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
if [ ! -d $packDir ] usage() {
then while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done
echo "Error: directory $packDir does not exist" cat <<USAGE 1>&2
Usage: ${0##*/} [OPTION]
options:
-o <dir> specify alternative output directory
-nogit bypass using 'git archive'
* Pack and compress OpenFOAM directory for release
USAGE
exit 1 exit 1
fi }
# add optional output directory unset prefix outputDir nogit
if [ -d "$1" ] # parse options
then while [ "$#" -gt 0 ]
packFile="$1/$packFile" do
fi case "$1" in
-h | -help)
usage
;;
-nogit)
nogit=true
shift
;;
-o | -output)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
outputDir=${2%%/}
shift 2
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
if [ -f $packFile ] # check for essential directories
then for dir in $packDir
echo "Error: $packFile already exists" do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1 exit 1
fi }
done
# Create time stamp file
# ~~~~~~~~~~~~~~~~~~~~~~ #------------------------------------------------------------------------------
timeStamp=$(date +%Y-%m-%d)
echo $timeStamp 2>/dev/null > $packDir/.timeStamp packExt=tgz
packBase=${packDir}_${timeStamp}
# Pack and compress the packFile
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # add optional output directory
[ -d "$outputDir" ] && packBase="$outputDir/$packBase"
echo packFile=$packBase.$packExt
echo "Packing $packDir source files into $packFile"
echo # avoid overwriting old pack file
if [ -f $packFile ]
foamPackSource $packDir $packFile then
echo "Error: $packFile already exists" 1>&2
exit 1
fi
# add time-stamp file before packing
echo $timeStamp 2>/dev/null > $packDir/.timeStamp
# check for git (program and .git directory)
(cd $packDir && git branch) > /dev/null 2>&1 || nogit=true
if [ "$nogit" = true ]
then
echo "pack manually" 1>&2
$toolsDir/foamPackSource $packDir $packFile
else
echo "pack with git-archive" 1>&2
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar
echo "add in time-stamp and lnInclude directories" 1>&2
tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build `find -H $packDir -type d -name lnInclude`
tar Af $packBase.tar $packBase.tar2
echo "gzip tar file" 1>&2
gzip -c9 $packBase.tar > $packFile
rm -f $packBase.tar $packBase.tar2 2>/dev/null
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -23,66 +23,119 @@
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# #
# Script # Script
# foamPackBin <arch> [outputDir] # foamPackBin [OPTION] <archOptions>
# #
# Description # Description
# Packs and compresses binary version of OpenFOAM for release # Pack and compress binary version of OpenFOAM for release
#
# Script
# foamPackThirdPartyBin [OPTION] <archOptions>
#
# Description
# Pack and compress binary version of OpenFOAM ThirdParty for release
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
if [ $# -eq 0 ] case "${0##*/}" in
then *ThirdParty*)
echo "Error: architecture type expected, exiting" # for ThirdParty
echo codeBase="OpenFOAM ThirdParty"
echo "Usage : ${0##*/} <arch> [outputDir]" packDir=ThirdParty-$WM_PROJECT_VERSION
echo listBinDirs=$toolsDir/foamListThirdPartyBinDirs
;;
*)
# regular
codeBase="OpenFOAM ThirdParty"
packDir=$WM_PROJECT-$WM_PROJECT_VERSION
listBinDirs=$toolsDir/foamListBinDirs
;;
esac
usage() {
while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done
cat <<USAGE 1>&2
Usage: ${0##*/} [OPTION] <archOptions>
options:
-o <dir> specify alternative output directory
* Pack and compress binary version of $codeBase for release
The value of 'archOptions' normally corresponds to \$WM_OPTIONS
The current value of \$WM_OPTIONS = $WM_OPTIONS
USAGE
exit 1 exit 1
fi }
arch=$1
# base arch (w/o precision, optimization, etc)
baseArch=$(echo "$arch" | sed -e 's@[DS]P.*$@@')
timeStamp=$(date +%Y-%m-%d) unset prefix outputDir
packDir=$WM_PROJECT-$WM_PROJECT_VERSION # parse options
packFile=${packDir}.${arch}_${timeStamp}.gtgz while [ "$#" -gt 0 ]
# add optional output directory
if [ -d "$2" ]
then
packFile="$2/$packFile"
fi
if [ -f $packFile ]
then
echo "Error: $packFile already exists"
exit 1
fi
# check for essential directories
for dir in $packDir $packDir/lib/$arch $packDir/applications/bin/$arch
do do
if [ ! -d $dir ] case "$1" in
then -h | -help)
echo "Error: directory $dir does not exist" usage
exit 1 ;;
fi -o | -output)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
outputDir=${2%%/}
shift 2
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done done
[ $# -eq 1 ] || usage "Error: specify architecture"
# same as $WM_OPTIONS - eg, 'linux64GccDPOpt'
archOptions="$1"
#------------------------------------------------------------------------------
timeStamp=$(date +%Y-%m-%d)
packExt=tgz
packBase=${packDir}.${archOptions}_${timeStamp}
# add optional output directory
[ -d "$outputDir" ] && packBase="$outputDir/$packBase"
packFile=$packBase.$packExt
# avoid overwriting old pack file
if [ -f $packFile ]
then
echo "Error: $packFile already exists" 1>&2
exit 1
fi
#------------------------------------------------------------------------------
# get list of directories # get list of directories
dirList=`foamBinDirs $packDir $arch` dirList=$( $listBinDirs $packDir $archOptions )
if [ $? -eq 0 -a -n "$dirList" ]
then
echo "Pack into $packFile" 1>&2
echo 1>&2
else
exit 1
fi
echo
echo "Packing $arch ($baseArch) port of $packDir into $packFile"
echo
tar czpf $packFile $dirList # Clean up on Ctrl-C
trap 'rm -f $packFile 2>/dev/null' INT
tar cpzf $packFile $dirList
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "Finished packing and compressing file $packFile" echo "Finished packing file $packFile" 1>&2
else else
echo "Error: failure packing $packFile" echo "Error: failure packing $packFile" 1>&2
rm -f $packFile 2>/dev/null rm -f $packFile 2>/dev/null
fi fi

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -23,24 +23,44 @@
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# #
# Script # Script
# foamPackBinAll [outputDir] # foamPackBinAll [OPTION]
# #
# Description # Description
# Packs and compresses all binary versions of foam for release # Pack and compress all binary versions of OpenFOAM for release
#
# Script
# foamPackThirdPartyBinAll [OPTION]
#
# Description
# Pack and compress all binary versions of OpenFOAM ThirdParty for release
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
packDir=$WM_PROJECT-$WM_PROJECT_VERSION binDir="${0%/*}" # this script is located in the bin/ dir
if [ ! -d $packDir ] case "${0##*/}" in
then *ThirdParty*)
echo "Error: directory $packDir does not exist" # for ThirdParty
packDir=ThirdParty-$WM_PROJECT_VERSION
packBin=foamPackThirdPartyBin
;;
*)
# regular
packDir=$WM_PROJECT-$WM_PROJECT_VERSION
packBin=foamPackBin
;;
esac
[ -d $packDir ] || {
echo "Error: directory $packDir does not exist" 1>&2
exit 1 exit 1
fi }
# obtain arch types from lib/
for bin in $packDir/lib/* # obtain archOptions types from lib/
for archOptions in $packDir/lib/*
do do
foamPackBin ${bin##*/} $@ $binDir/$packBin $@ ${archOptions##*/}
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -26,39 +26,44 @@
# foamPackDoxygen [-prefix DIR] [-o outputDir] # foamPackDoxygen [-prefix DIR] [-o outputDir]
# #
# Description # Description
# Packs and compresses the OpenFOAM doxygen html for release # Pack and compress the OpenFOAM doxygen html for release
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
packDir=$WM_PROJECT-$WM_PROJECT_VERSION packDir=$WM_PROJECT-$WM_PROJECT_VERSION
packTag=_Doxygen.gtgz htmlDir=doc/Doxygen/html
usage() { usage() {
while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done
cat <<USAGE 1>&2 cat <<USAGE 1>&2
Usage: ${0##*/} [-prefix DIR] [-o outputDir] Usage: ${0##*/} [OPTION]
options:
-prefix <dir> use alternative prefix
-o <dir> specify alternative output directory
Packs and compresses the OpenFOAM doxygen html for release * Pack and compress the OpenFOAM doxygen html for release
USAGE USAGE
exit 1 exit 1
} }
unset prefix outputDir unset prefix outputDir
# parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case $1 in case $1 in
-prefix | --prefix ) -h | -help)
usage
;;
-prefix | --prefix)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
prefix=${2%%/} prefix=${2%%/}
shift 2 shift 2
;; ;;
-o | -output ) -o | -output)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
outputDir=${2%%/} outputDir=${2%%/}
shift 2 shift 2
;; ;;
-h | -help )
usage
;;
-*) -*)
usage "unknown option: '$*'" usage "unknown option: '$*'"
;; ;;
@ -81,41 +86,44 @@ then
exit 1 exit 1
fi fi
# #------------------------------------------------------------------------------
packExt=tgz
packName=${packDir}_Doxygen
# add optional output directory # add optional output directory
# [ -d "$outputDir" ] && packName="$outputDir/$packName"
if [ -d "$outputDir" ] packFile=$packName.$packExt
then
packFile="$outputDir/$packDir$packTag"
else
packFile="$packDir$packTag"
fi
if [ -f $packFile ] if [ -f $packFile ]
then then
echo "Error: $packFile already exists" echo "Error: $packFile already exists" 1>&2
exit 1 exit 1
fi fi
# Pack and compress the packFile using GNU tar cat <<INFO 1>&2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------------------------------------------------------------
echo Packing doxygen html into $packFile
echo "Packing doxygen html into $packFile"
echo INFO
# Clean up on Ctrl-C
trap 'rm -f $packFile 2>/dev/null' INT
if [ -n "$prefix" ] if [ -n "$prefix" ]
then then
tar czpf $packFile --transform="s@^@$prefix/@" doc/Doxygen/html # requires GNU tar
tar cpzf $packFile --transform="s@^@$prefix/@" $htmlDir
else else
tar czpf $packFile $packDir/doc/Doxygen/html tar cpzf $packFile $packDir/$htmlDir
fi fi
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "Finished packing doxygen html into file $packFile" echo "Finished packing doxygen html into file $packFile" 1>&2
else else
echo "Error: failure packing doxygen html file $packFile" echo "Error: failure packing doxygen html file $packFile" 1>&2
rm -f $packFile 2>/dev/null
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
#---------------------------------*- sh -*------------------------------------- #------------------------------------------------------------------------------
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -23,48 +23,86 @@
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# #
# Script # Script
# foamPackThirdParty [outputDir] # foamPackThirdParty [OPTION]
# #
# Description # Description
# Packs and compresses the OpenFOAM ThirdParty directory for release # Pack and compress the OpenFOAM ThirdParty directory for release
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
packDir=ThirdParty-$WM_PROJECT_VERSION
toolsDir="${0%/*}/tools" # this script is located in the tools/ parent dir
timeStamp=$(date +%Y-%m-%d) usage() {
packDir=${WM_THIRD_PARTY_DIR:-ThirdParty} while [ $# -gt 0 ]; do echo "$1" 1>&2; shift; done
packDir=${packDir##*/} cat <<USAGE 1>&2
packFile=${packDir}_${timeStamp}.gtgz Usage: ${0##*/} [OPTION]
options:
-o <dir> specify alternative output directory
if [ ! -d $packDir ] * Pack and compress ThirdParty directory for release
then
echo "Error: directory $packDir does not exist" USAGE
exit 1 exit 1
fi }
unset prefix outputDir nogit
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-nogit)
nogit=true
shift
;;
-o | -output)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
outputDir=${2%%/}
shift 2
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# check for essential directories
for dir in $packDir
do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1
}
done
#------------------------------------------------------------------------------
timeStamp=$(date +%Y-%m-%d)
packExt=tgz
packBase=${packDir}_${timeStamp}
# add optional output directory # add optional output directory
if [ -d "$1" ] [ -d "$outputDir" ] && packBase="$outputDir/$packBase"
then packFile=$packBase.$packExt
packFile="$1/$packFile"
fi
# avoid overwriting old pack file
if [ -f $packFile ] if [ -f $packFile ]
then then
echo "Error: $packFile already exists" echo "Error: $packFile already exists"
exit 1 exit 1
fi fi
# Create time stamp file
# ~~~~~~~~~~~~~~~~~~~~~~ #------------------------------------------------------------------------------
echo $timeStamp 2>/dev/null > $packDir/.timeStamp # add time-stamp file before packing
echo $timeStamp 2>/dev/null > $packDir/.timeStamp
# Pack and compress the packFile echo "pack manually" 1>&2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $toolsDir/foamPackSource $packDir $packFile
echo
echo "Packing $packDir source files into $packFile"
echo
foamPackSource $packDir $packFile
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,88 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamPackThirdPartyBin <archOptions> [outputDir]
#
# Description
# Packs and compresses binary version of OpenFOAM ThirdParty for release
#
#------------------------------------------------------------------------------
if [ $# -eq 0 ]
then
echo "Error: archOptions type expected, exiting"
echo
echo "Usage : ${0##*/} <archOptions> [outputDir]"
echo
exit 1
fi
archOptions=$1
arch=${archOptions%%G*} # TODO: works for Gcc only
arch3264=$(echo "$arch" | sed -e 's@64@-64@')
echo "archOptions=$archOptions"
echo "arch=$arch"
echo "arch3264=$arch3264"
timeStamp=$(date +%Y-%m-%d)
packDir=${WM_THIRD_PARTY_DIR:-ThirdParty}
packDir=${packDir##*/}
packFile=${packDir}.${archOptions}_${timeStamp}.gtgz
if [ ! -d $packDir ]
then
echo "Error: directory $packDir does not exist"
exit 1
fi
# add optional output directory
if [ -d "$2" ]
then
packFile="$2/$packFile"
fi
if [ -f $packFile ]
then
echo "Error: $packFile already exists"
exit 1
fi
# get list of directories
dirList=`find $packDir -type d -name $arch -o -type d -name $archOptions'*' -o -type l -name $arch3264`
echo
echo "Packing $archOptions port of $packDir into $packFile"
echo
tar czpf $packFile $dirList
if [ $? -eq 0 ]
then
echo "Finished packing and compressing file $packFile"
else
echo "Error: failure packing $packFile"
rm -f $packFile 2>/dev/null
fi
#------------------------------------------------------------------------------

1
bin/foamPackThirdPartyBin Symbolic link
View File

@ -0,0 +1 @@
foamPackBin

View File

@ -0,0 +1 @@
foamPackBinAll

View File

@ -1,81 +0,0 @@
#!/bin/sh
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamSourceFiles <directory>
#
# Description
# Returns all the .C and .H files and Make/options
# and Make/files in a given directory.
#
#------------------------------------------------------------------------------
if [ $# -ne 1 ]
then
echo "Usage : ${0##*/} directory"
echo ""
echo "Returns all .C and .H files and Make/options and Make/files."
echo ""
exit 1
fi
# canonical form (no double and no trailing dashes)
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
if [ ! -d $packDir ]
then
echo "Error: directory $packDir does not exist"
exit 1
fi
find -H $packDir \
! -type d \
\( -type f -o -type l \) \
! -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 "libccmio*" \
| sed \
-e "\@$packDir/lib/@d" \
-e '\@/\.git/@d' \
-e '\@/\.gitignore@d' \
-e '\@/\.tags/@d' \
-e '\@/\README\.org@d' \
-e '\@applications/bin/@d' \
-e '\@wmake/bin/@d' \
-e '\@/t/@d' \
-e '\@/Make[.A-Za-z]*/[^/]*/@d'\
-e '\@/platforms/@d' \
-e '\@/download/@d' \
-e '\@/libccmio-.*/@d' \
-e '\@/debian/@d'
#------------------------------------------------------------------------------

121
bin/tools/foamListBinDirs 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-2011 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListBinDirs <directory> <archOptions>
#
# Description
# Lists directories containing binary files of OpenFOAM
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
toolsDir="${0%/*}" # this script is already located in the tools/ directory
[ $# -eq 2 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} <packDir> <archOptions>
* Lists directories containing binary files for OpenFOAM
The value of 'archOptions' normally corresponds to \$WM_OPTIONS
The current value of \$WM_OPTIONS = $WM_OPTIONS
USAGE
exit 1
}
#------------------------------------------------------------------------------
packDir="$1"
# same as $WM_OPTIONS - eg, 'linux64GccDPOpt'
archOptions="$2"
# base arch (w/o precision, optimization, etc)
# same as "$WM_ARCH$WM_COMPILER"
archCompiler=$(echo "$archOptions" | sed -e 's@[DS]P.*$@@')
# same as $WM_ARCH - eg, 'linux64'
# TODO: only works for Gcc, Icc, Clang
archOS=$(echo "$archOptions" | sed -e 's@[GI]cc.*$@@' -e 's@Clang.*$@@')
# links for 32-bit version, eg convert linux64 -> linux-64
arch3264=$(echo "$archOS" | sed -e 's@64@-64@')
#------------------------------------------------------------------------------
# check for essential directories
for dir in $packDir $packDir/lib/$archOptions
do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1
}
done
# check new/old places for executables - same as $FOAM_APPBIN
[ -d $packDir/bin/$archOptions -o -d $packDir/applications/bin/$archOptions ] || {
cat <<BIN_CHECK 1>&2
Error: no directory for executables exists:
$packDir/bin/$archOptions
$packDir/applications/bin/$archOptions
BIN_CHECK
exit 1
}
#------------------------------------------------------------------------------
# list of directories
dirList=$(
for dir in \
$packDir/bin/$archOptions \
$packDir/lib/$archOptions \
$packDir/applications/bin/$archOptions \
$packDir/wmake/bin/$archCompiler \
$packDir/wmake/bin/$archOS \
$packDir/wmake/rules/General \
$packDir/wmake/rules/$archCompiler \
$packDir/wmake/rules/$archOS \
;
do
[ -d $dir ] && echo $dir
done
)
cat <<INFO 1>&2
-------------------------------------------------------------------------------
Packing $archOptions ($archCompiler) port of $packDir
archOS = $archOS
32bit archOS = $arch3264
dirs:
$(echo ${dirList:-NONE})
INFO
echo "$dirList"
#------------------------------------------------------------------------------

93
bin/tools/foamListSourceFiles Executable file
View File

@ -0,0 +1,93 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2011 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListSourceFiles <directory>
#
# Description
# Lists source files and Make/{files,options} in given directory
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
[ $# -eq 1 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} directory
* Lists source files and Make/{files,options} in given directory
USAGE
exit 1
}
# canonical form (no double and no trailing dashes)
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
# check for essential directories
[ -d $packDir ] || {
echo "Error: directory $packDir does not exist" 1>&2
exit 1
}
#
# list of files but excluding
# - dependent files (dep, obj, lib), archives
# - exclude Doxygen documentation etc
#
find -H $packDir \
! -type d \
\( -type f -o -type l \) \
! -name "*~" \
-a ! -name ".*~" \
-a ! -name "*.orig" \
-a ! -name "*.dep" \
-a ! -name "*.o" \
-a ! -name "*.so" \
-a ! -name "*.a" \
-a ! -name "*.tar" \
-a ! -name "*.tar.gz" \
-a ! -name "*.tgz" \
-a ! -name "core" \
-a ! -name "core.[1-9]*" \
-a ! -name "libccmio*" \
| sed \
-e "\@$packDir/lib/@d" \
-e '\@/\.git/@d' \
-e '\@/\.tags/@d' \
-e '\@/README\.org@d' \
-e '\@/bin/[^/]*/@{ \@/bin/tools/@!d }' \
-e '\@/lib/@d' \
-e '\@/platforms/@d' \
-e '\@/t/@d' \
-e '\@/Make[.A-Za-z]*/[^/]*/@d' \
-e '\@/[Dd]oxygen/html/@d' \
-e '\@/download/@d' \
-e '\@/libccmio-.*/@d' \
-e '\@/debian/@d'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,121 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2011 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListThirdPartyBinDirs <directory> <archOptions>
#
# Description
# Lists directories containing binary files for OpenFOAM ThirdParty
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
toolsDir="${0%/*}" # this script is already located in the tools/ directory
[ $# -eq 2 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} <packDir> <archOptions>
* List directories containing binary files for OpenFOAM ThirdParty
The value of 'archOptions' normally corresponds to \$WM_OPTIONS
The current value of \$WM_OPTIONS = $WM_OPTIONS
USAGE
exit 1
}
#------------------------------------------------------------------------------
packDir="$1"
# same as $WM_OPTIONS - eg, 'linux64GccDPOpt'
archOptions="$2"
# base arch (w/o precision, optimization, etc)
# same as "$WM_ARCH$WM_COMPILER"
archCompiler=$(echo "$archOptions" | sed -e 's@[DS]P.*$@@')
# same as $WM_ARCH - eg, 'linux64'
# TODO: only works for Gcc, Icc, Clang
archOS=$(echo "$archOptions" | sed -e 's@[GI]cc.*$@@' -e 's@Clang.*$@@')
# links for 32-bit version, eg convert linux64 -> linux-64
arch3264=$(echo "$archOS" | sed -e 's@64@-64@')
#------------------------------------------------------------------------------
# check for essential directories
for dir in $packDir $packDir/lib/$archOptions
do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1
}
done
#------------------------------------------------------------------------------
# list of directories
dirList=$(
for dir in \
$packDir/bin/$archOptions \
$packDir/bin/$archCompiler \
$packDir/bin/$archOS \
$packDir/lib/$archOptions \
$packDir/lib/$archCompiler \
$packDir/lib/$archOS \
$packDir/platforms/$archOptions \
$packDir/platforms/$archCompiler \
$packDir/platforms/$archOS \
;
do
[ -d $dir ] && echo $dir
done
# add in links for 32-bit version
if [ "$archOS" != "$arch3264" ]
then
for dir in \
$packDir/platforms/$arch3264 \
;
do
[ -d $dir -a -L $dir ] && echo $dir
done
fi
)
cat <<INFO 1>&2
-------------------------------------------------------------------------------
Packing $archOptions ($archCompiler) port of $packDir
archOS = $archOS
32bit archOS = $arch3264
dirs:
$(echo ${dirList:-NONE})
INFO
echo "$dirList"
#------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -26,54 +26,67 @@
# foamPackSource <directory> <tarFile> # foamPackSource <directory> <tarFile>
# #
# Description # Description
# Packs and compresses the .C and .H files and Make/options # Pack and compress all source files from a given directory.
# and Make/files in a given directory.
# #
# Note
# Not normally called directly by the user
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$ tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$
toolsDir="${0%/*}" # this script is already located in the tools/ directory
if [ $# -ne 2 ] [ $# -eq 2 ] || {
then cat <<USAGE 1>&2
echo "Usage : ${0##*/} directory tarFile" Usage : ${0##*/} directory tarFile
echo ""
echo "Packs all .C and .H files and Make/options and Make/files into" * Pack and compress all source files from a given directory into <tarFile>
echo "<tarFile>"
echo "" USAGE
exit 1 exit 1
fi }
# canonical form (no double and no trailing dashes) # canonical form (no double and no trailing dashes)
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@') packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
packFile=$2 packFile=$2
if [ ! -d $packDir ] # check for essential directories
then [ -d $packDir ] || {
echo "Error: directory $packDir does not exist" echo "Error: directory $packDir does not exist" 1>&2
exit 1 exit 1
fi }
# avoid overwriting old pack file
if [ -f $packFile ] if [ -f $packFile ]
then then
echo "Error: $packFile already exists" echo "Error: $packFile already exists" 1>&2
exit 1 exit 1
fi fi
# Clean up on termination and on Ctrl-C # Clean up on termination and on Ctrl-C
trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
foamSourceFiles $packDir > $tmpFile # get all names
$toolsDir/foamListSourceFiles $packDir > $tmpFile
# provide some feedback # provide some feedback
wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}' cat <<INFO 1>&2
-------------------------------------------------------------------------------
Packing $packDir source files into $packFile
tar czpf $packFile --files-from $tmpFile INFO
wc $tmpFile | awk '{print "Packing",$1,"files - this could take some time ..."}' 1>&2
# Clean up on Ctrl-C
trap 'rm -f $packFile $tmpFile 2>/dev/null' INT
tar cpzf $packFile --files-from $tmpFile
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "Finished packing and compressing $packDir into file $packFile" echo "Finished packing $packDir into file $packFile" 1>&2
else else
echo "Error: failure packing $packDir into file $packFile" echo "Error: failure packing $packDir into file $packFile" 1>&2
rm -f $packFile 2>/dev/null rm -f $packFile 2>/dev/null
fi fi