STYLE: remove special '.' version handling in foamEtcFile

- this would automatically change openfoam<digits> into maj.min.rel
  values, thus transforming openfoam1806 into a version "1.8.0.6" !
This commit is contained in:
Mark Olesen
2018-11-24 00:36:31 +01:00
parent b105f926b1
commit 7964d31d03

View File

@ -16,31 +16,29 @@
# Description
# Locate user/group/other file as per '#includeEtc'.
#
# The -mode option can be used to allow chaining from personal settings
# to site-wide settings.
#
# For example, within the user ~/.OpenFOAM/<VER>/config.sh/compiler:
# \code
# eval $(foamEtcFile -sh -mode=go config.sh/compiler)
# \endcode
#
# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure
# The -mode option is used within etc/{bashrc,cshrc} to ensure
# that system prefs are respected:
# \code
# eval $(foamEtcFile -sh -mode=o prefs.sh)
# eval $(foamEtcFile -sh -mode=ug prefs.sh)
# \endcode
#
# The -mode option can also be used when chaining settings.
# For example, in the user ~/.OpenFOAM/<VERSION>/config.sh/compiler
# \code
# eval $(foamEtcFile -sh -mode=go config.sh/compiler)
# \endcode
#
# Environment
# - WM_PROJECT: (unset defaults to OpenFOAM)
# - WM_PROJECT_SITE: (unset defaults to PREFIX/site)
# - WM_PROJECT_VERSION: (unset defaults to detect from path)
# - WM_PROJECT (unset defaults to OpenFOAM)
# - WM_PROJECT_VERSION (unset defaults to detect from path)
# - WM_PROJECT_SITE (unset defaults to PREFIX/site)
#
# Note
# This script must exist in one of these locations:
# - $WM_PROJECT_INST_DIR/OpenFOAM-<VERSION>/bin
# - $WM_PROJECT_INST_DIR/openfoam-<VERSION>/bin
# - $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian version)
# - PREFIX/OpenFOAM-<VERSION>/bin
# - PREFIX/openfoam-<VERSION>/bin
# - PREFIX/openfoam<VERSION>/bin
#
#-------------------------------------------------------------------------------
printHelp() {
@ -55,7 +53,7 @@ options:
-list-test List (existing) directories or files to be checked
-mode=MODE Any combination of u(user), g(group), o(other)
-prefix=DIR Specify an alternative installation prefix
-version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
-version=VER Specify alternative OpenFOAM version (eg, 1712, 1806, ...)
-csh Produce 'source FILE' output for a csh eval
-sh Produce '. FILE' output for a sh eval
-csh-verbose As per -csh, with additional verbosity
@ -119,41 +117,33 @@ userDir="$HOME/.OpenFOAM" # Hard-coded as per foamVersion.H
#-------------------------------------------------------------------------------
# Guess project version or simply get the stem part of the projectDirName.
# Handle standard and debian naming conventions.
# Handle standard naming conventions:
#
# * OpenFOAM-<version>[-extra...]
# * openfoam-<version>[-extra...]
# * openfoam<digits>
#
# - projectVersion: update unless already set
#
# Helper variables:
# - dirBase (for reassembling name) == projectDirName without the version
# - versionNum (debian packaging)
unset dirBase versionNum
unset dirBase
guessVersion()
{
local version
case "$projectDirName" in
(OpenFOAM-* | openfoam-*)
# Standard naming: OpenFOAM-<VERSION> or openfoam-<VERSION>
# Dashed naming: OpenFOAM-<VERSION> or openfoam-<VERSION>
dirBase="${projectDirName%%-*}-"
version="${projectDirName#*-}"
version="${version%%*-}" # Extra safety, eg openfoam-version-packager
;;
(openfoam[0-9]*)
# Debian naming: openfoam<VERSION>
# Debian-style naming: openfoam<VERSION>
dirBase="openfoam"
version="${projectDirName#openfoam}"
versionNum="$version"
# Convert digits version number to decimal delineated
case "${#versionNum}" in (2|3|4)
version=$(echo "$versionNum" | sed -e 's@\([0-9]\)@\1.@g')
version="${version%.}"
;;
esac
# Ignore special treatment if no decimals were inserted.
[ "${#version}" -gt "${#versionNum}" ] || unset versionNum
;;
(*)
@ -174,16 +164,11 @@ setVersion()
# Need dirBase when reassembling projectDirName
[ -n "$dirBase" ] || guessVersion
# Debian: update x.y.z -> xyz version
if [ -n "$versionNum" ]
then
versionNum=$(echo "$projectVersion" | sed -e 's@\.@@g')
fi
projectDirName="$dirBase${versionNum:-$projectVersion}"
projectDirName="$dirBase$projectVersion"
}
#-------------------------------------------------------------------------------
optMode=ugo # Default mode is always 'ugo'
unset shellOutput verboseOutput
unset optAll optConfig optList optVersion