foamEtcFile: corrected locating of OpenFOAM installation

This commit is contained in:
Chris Greenshields
2022-07-05 15:19:12 +01:00
parent 2a2cc976c4
commit 80544ff43d

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | Website: https://openfoam.org # \\ / O peration | Website: https://openfoam.org
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -88,7 +88,7 @@ error() {
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# the bin dir: # the bin dir:
binDir="${0%/*}" binDir="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit ; pwd -P)"
# the project dir: # the project dir:
projectDir="${binDir%/bin}" projectDir="${binDir%/bin}"
@ -106,35 +106,39 @@ unset versionNum
# handle standard and debian naming convention # handle standard and debian naming convention
# #
case "$projectDirName" in case "$projectDirName" in
OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION> OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION>
version="${projectDirName##OpenFOAM-}" version="${projectDirName##OpenFOAM-}"
;;
openfoam[0-9]* | openfoam-dev) # 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 openfoam[0-9]*) # debian naming convention
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@') versionNum="${projectDirName##openfoam}"
case "$versionNum" in
[4-9]) # v4-9
version="$versionNum"
;;
[1-2][0-9]) # v10 onwards
version="$versionNum"
;;
3[0-9]) # e.g. v3.0
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@')
;;
[1-2][0-9][0-9]) # e.g. v1.7.0
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@')
;;
*)
version="$WM_PROJECT_VERSION"
;;
esac
;; ;;
????) # convert 4 digit version number to decimal delineated openfoam-dev) # debian naming convention
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@') versionNum="${projectDirName##openfoam}"
version="${versionNum##-}"
;; ;;
*) # failback - use current environment setting *)
version="$WM_PROJECT_VERSION" echo "Error : unknown/unsupported naming convention"
exit 1
;; ;;
esac
;;
*)
echo "Error : unknown/unsupported naming convention"
exit 1
;;
esac esac
# default mode is 'ugo' # default mode is 'ugo'
mode=ugo mode=ugo
unset optAll optList optQuiet optSilent unset optAll optList optQuiet optSilent
@ -294,7 +298,6 @@ else
fi fi
exit $exitCode exit $exitCode
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------