mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve debian handling in foamEtcFile
- remove all corresponding logic from foamExec
This commit is contained in:
120
bin/foamEtcFile
120
bin/foamEtcFile
@ -52,10 +52,9 @@ options:
|
|||||||
-list list the directories to be searched
|
-list list the directories to be searched
|
||||||
-mode <mode> any combination of u(user), g(group), o(other)
|
-mode <mode> any combination of u(user), g(group), o(other)
|
||||||
-prefix <dir> specify an alternative installation prefix
|
-prefix <dir> specify an alternative installation prefix
|
||||||
(default: $WM_PROJECT_INST_DIR)
|
|
||||||
-quiet suppress all normal output
|
-quiet suppress all normal output
|
||||||
-version <ver> specify an alternative OpenFOAM version
|
-version <ver> specify an alternative OpenFOAM version
|
||||||
(default: $WM_PROJECT_VERSION)
|
in the form Maj.Min.Rev (eg, 1.7.0)
|
||||||
-help print the usage
|
-help print the usage
|
||||||
|
|
||||||
Locate user/group/shipped file with semantics similar to the
|
Locate user/group/shipped file with semantics similar to the
|
||||||
@ -73,20 +72,64 @@ USAGE
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||||
|
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# the bindir:
|
||||||
|
binDir="${0%/*}"
|
||||||
|
|
||||||
|
# the project dir:
|
||||||
|
projectDir="${binDir%/bin}"
|
||||||
|
|
||||||
|
# the prefix dir (same as foamInstall):
|
||||||
|
prefixDir="${projectDir%/*}"
|
||||||
|
|
||||||
|
# the name used for the project directory
|
||||||
|
projectDirName="${projectDir##*/}"
|
||||||
|
|
||||||
|
# version number used for debian packaging
|
||||||
|
unset versionNum
|
||||||
|
|
||||||
|
#
|
||||||
|
# handle standard and debian naming convention
|
||||||
|
#
|
||||||
|
case "$projectDirName" in
|
||||||
|
OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION>
|
||||||
|
version="${projectDirName##OpenFOAM-}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
openfoam[0-9]*) # debian naming convention 'openfoam<VERSION>'
|
||||||
|
versionNum="${projectDirName##openfoam}"
|
||||||
|
case "$versionNum" in
|
||||||
|
??) # convert 2 digit version number to decimal delineated
|
||||||
|
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@')
|
||||||
|
;;
|
||||||
|
???) # convert 3 digit version number to decimal delineated
|
||||||
|
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@')
|
||||||
|
;;
|
||||||
|
????) # convert 4 digit version number to decimal delineated
|
||||||
|
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@')
|
||||||
|
;;
|
||||||
|
*) # failback - use current environment setting
|
||||||
|
version="$WM_PROJECT_VERSION"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Error : unknown/unsupported naming convention"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
# default mode is 'ugo'
|
# default mode is 'ugo'
|
||||||
mode=ugo
|
mode=ugo
|
||||||
|
|
||||||
# default prefix/version correspond to the active values,
|
|
||||||
# but could also extract from the $0 value.
|
|
||||||
prefix="$WM_PROJECT_INST_DIR"
|
|
||||||
version="$WM_PROJECT_VERSION"
|
|
||||||
|
|
||||||
# default naming convention is "OpenFOAM-<VERSION>"
|
|
||||||
projectNamePrefix="${WM_PROJECT:-OpenFOAM}-"
|
|
||||||
|
|
||||||
|
|
||||||
unset listOpt quietOpt
|
unset listOpt quietOpt
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -96,7 +139,6 @@ do
|
|||||||
;;
|
;;
|
||||||
-l | -list)
|
-l | -list)
|
||||||
listOpt=true
|
listOpt=true
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
-m | -mode)
|
-m | -mode)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
@ -110,21 +152,29 @@ do
|
|||||||
usage "'$1' option with invalid mode '$mode'"
|
usage "'$1' option with invalid mode '$mode'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
-p | -prefix)
|
-p | -prefix)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
prefix="$2"
|
prefixDir="$2"
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
-q | -quiet)
|
-q | -quiet)
|
||||||
quietOpt=true
|
quietOpt=true
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
version="$2"
|
version="$2"
|
||||||
shift 2
|
# convert x.y.z -> xyz version (if installation looked like debian)
|
||||||
|
if [ -n "$versionNum" ]
|
||||||
|
then
|
||||||
|
versionNum=$(echo "$version" | sed -e 's@\.@@g')
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "unknown option: '$*'"
|
usage "unknown option: '$*'"
|
||||||
@ -133,23 +183,16 @@ do
|
|||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
#
|
# debugging:
|
||||||
# handle standard and debian naming convention
|
# echo "Installed locations:"
|
||||||
#
|
# for i in projectDir prefixDir projectDirName version versionNum
|
||||||
case "$version" in
|
# do
|
||||||
OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION>
|
# eval echo "$i=\$$i"
|
||||||
projectNamePrefix="OpenFOAM-"
|
# done
|
||||||
version="${version##OpenFOAM-}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
openfoam[0-9]*) # debian naming convention 'openfoam<VERSION>'
|
|
||||||
projectNamePrefix="openfoam"
|
|
||||||
version="${version##openfoam}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
# Save the essential bits of information:
|
# Save the essential bits of information:
|
||||||
@ -167,14 +210,21 @@ esac
|
|||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
*g*) # group
|
*g*) # group
|
||||||
dirList="$dirList $prefix/site/$version"
|
dirList="$dirList $prefixDir/site/$version"
|
||||||
dirList="$dirList $prefix/site"
|
dirList="$dirList $prefixDir/site"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
*o*) # other (shipped)
|
*o*) # other (shipped)
|
||||||
dirList="$dirList $prefix/$projectNamePrefix$version/etc"
|
if [ -n "$versionNum" ]
|
||||||
|
then
|
||||||
|
# debian packaging
|
||||||
|
dirList="$dirList $prefixDir/openfoam$versionNum/etc"
|
||||||
|
else
|
||||||
|
# standard packaging
|
||||||
|
dirList="$dirList $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
set -- $dirList
|
set -- $dirList
|
||||||
|
|||||||
68
bin/foamExec
68
bin/foamExec
@ -35,10 +35,8 @@
|
|||||||
# mpirun -np <nProcs> \
|
# mpirun -np <nProcs> \
|
||||||
# foamExec -v <foamVersion> <foamCommand> ... -parallel
|
# foamExec -v <foamVersion> <foamCommand> ... -parallel
|
||||||
#
|
#
|
||||||
# Note: - not consistent with foamEtcFiles - does not search 'site'
|
# SeeAlso
|
||||||
# directories
|
# foamEtcFile
|
||||||
# - version switch -v will not work with the debian naming
|
|
||||||
# openfoamXXX
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
@ -48,7 +46,7 @@ Usage: ${0##*/} [OPTION] <application> ...
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
-version <ver> specify an alternative OpenFOAM version
|
-version <ver> specify an alternative OpenFOAM version
|
||||||
(default: taken from \$0 parameter)
|
pass through to foamEtcFile
|
||||||
-help this usage
|
-help this usage
|
||||||
|
|
||||||
* run a particular OpenFOAM version of <application>
|
* run a particular OpenFOAM version of <application>
|
||||||
@ -57,54 +55,14 @@ USAGE
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||||
#
|
#
|
||||||
|
# foamEtcFile is found in the same directory
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
# the bindir:
|
unset etcOpts
|
||||||
binDir="${0%/*}"
|
|
||||||
|
|
||||||
# the project dir:
|
|
||||||
projectDir="${binDir%/bin}"
|
|
||||||
export WM_PROJECT_DIR="$projectDir"
|
|
||||||
|
|
||||||
# the prefix dir (same as foamInstall):
|
|
||||||
prefixDir="${projectDir%/*}"
|
|
||||||
foamInstall="$prefixDir"
|
|
||||||
|
|
||||||
# the name used for the project directory
|
|
||||||
projectDirName="${projectDir##*/}"
|
|
||||||
|
|
||||||
#
|
|
||||||
# handle standard and debian naming convention
|
|
||||||
#
|
|
||||||
case "$projectDirName" in
|
|
||||||
OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION>
|
|
||||||
projectNamePrefix="OpenFOAM-"
|
|
||||||
version="${projectDirName##OpenFOAM-}"
|
|
||||||
versionNum=$version
|
|
||||||
;;
|
|
||||||
|
|
||||||
openfoam[0-9]*) # debian naming convention 'openfoam<VERSION>'
|
|
||||||
projectNamePrefix="openfoam"
|
|
||||||
versionNum="${projectDirName##openfoam}"
|
|
||||||
version=$WM_PROJECT_DIR
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error : unknown/unsupported naming convention"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
# debugging:
|
|
||||||
# echo "Installed locations:"
|
|
||||||
# for i in projectDir prefixDir foamInstall projectDirName version versionNum
|
|
||||||
# do
|
|
||||||
# eval echo "$i=\$$i"
|
|
||||||
# done
|
|
||||||
|
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -112,11 +70,10 @@ do
|
|||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-v | version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
version=$2
|
etcOpts="-version $2"
|
||||||
versionNum=$version
|
shift
|
||||||
shift 2
|
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
@ -129,14 +86,13 @@ do
|
|||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$#" -ge 1 ] || usage "no application specified"
|
[ "$#" -ge 1 ] || usage "no application specified"
|
||||||
|
|
||||||
|
|
||||||
# find OpenFOAM settings (bashrc)
|
# find OpenFOAM settings (bashrc)
|
||||||
foamDotFile="$($binDir/foamEtcFile -version $version bashrc)"
|
foamDotFile="$(${0%/*}/foamEtcFile $etcOpts bashrc)" || {
|
||||||
[ $? -eq 0 ] || {
|
|
||||||
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user