Backporting prefs treatment
This commit is contained in:
parent
0dbc4554a2
commit
e83ac65b74
3 changed files with 48 additions and 79 deletions
|
@ -3,9 +3,9 @@
|
||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM.
|
# This file is part of OpenFOAM.
|
||||||
#
|
#
|
||||||
|
@ -33,14 +33,18 @@
|
||||||
# personal settings to site-wide settings.
|
# personal settings to site-wide settings.
|
||||||
#
|
#
|
||||||
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
|
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
|
||||||
# @verbatim
|
# \code
|
||||||
# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \
|
# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \
|
||||||
# && _foamSource $foamPrefs
|
# && _foamSource $foamPrefs
|
||||||
# @endverbatim
|
# \endcode
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
# Note
|
||||||
|
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||||
|
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
[ "$quietOpt" = true ] && exit 1
|
[ "${optQuiet:-$optSilent}" = true ] && exit 1
|
||||||
|
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
@ -49,10 +53,12 @@ usage() {
|
||||||
Usage: ${0##*/} [OPTION] fileName
|
Usage: ${0##*/} [OPTION] fileName
|
||||||
${0##*/} [OPTION] -list
|
${0##*/} [OPTION] -list
|
||||||
options:
|
options:
|
||||||
|
-all return all files (otherwise stop after the first match)
|
||||||
-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
|
||||||
-quiet suppress all normal output
|
-quiet suppress all normal output
|
||||||
|
-silent suppress all stderr output
|
||||||
-version <ver> specify an alternative OpenFOAM version
|
-version <ver> specify an alternative OpenFOAM version
|
||||||
in the form Maj.Min.Rev (eg, 1.7.0)
|
in the form Maj.Min.Rev (eg, 1.7.0)
|
||||||
-help print the usage
|
-help print the usage
|
||||||
|
@ -72,11 +78,7 @@ USAGE
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#-------------------------------------------------------------------------------
|
||||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
|
||||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# the bin dir:
|
# the bin dir:
|
||||||
binDir="${0%/*}"
|
binDir="${0%/*}"
|
||||||
|
@ -128,7 +130,7 @@ esac
|
||||||
|
|
||||||
# default mode is 'ugo'
|
# default mode is 'ugo'
|
||||||
mode=ugo
|
mode=ugo
|
||||||
unset listOpt quietOpt
|
unset optAll optList optQuiet optSilent
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
|
@ -137,8 +139,11 @@ do
|
||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
-a | -all)
|
||||||
|
optAll=true
|
||||||
|
;;
|
||||||
-l | -list)
|
-l | -list)
|
||||||
listOpt=true
|
optList=true
|
||||||
;;
|
;;
|
||||||
-m | -mode)
|
-m | -mode)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
@ -160,7 +165,10 @@ do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-q | -quiet)
|
-q | -quiet)
|
||||||
quietOpt=true
|
optQuiet=true
|
||||||
|
;;
|
||||||
|
-s | -silent)
|
||||||
|
optSilent=true
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
@ -204,15 +212,15 @@ fileName="${1#~OpenFOAM/}"
|
||||||
unset dirList
|
unset dirList
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
*u*) # user
|
*u*) # user
|
||||||
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$version"
|
userDir="$HOME/.${WM_PROJECT:-OpenFOAM}"
|
||||||
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}"
|
dirList="$dirList $userDir/$version $userDir"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
*g*) # group
|
*g*) # group (site)
|
||||||
dirList="$dirList $prefixDir/site/$version"
|
siteDir="${WM_PROJECT_SITE:-$prefixDir/site}"
|
||||||
dirList="$dirList $prefixDir/site"
|
dirList="$dirList $siteDir/$version $siteDir"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -235,14 +243,15 @@ set -- $dirList
|
||||||
# The main routine
|
# The main routine
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ "$listOpt" = true ]
|
exitCode=0
|
||||||
|
if [ "$optList" = true ]
|
||||||
then
|
then
|
||||||
|
|
||||||
# list directories, or potential file locations
|
# list directories, or potential file locations
|
||||||
[ "$nArgs" -le 1 ] || usage
|
[ "$nArgs" -le 1 ] || usage
|
||||||
|
|
||||||
# a silly combination, but -quiet has precedence
|
# a silly combination, but -quiet does have precedence
|
||||||
[ "$quietOpt" = true ] && exit 0
|
[ "$optQuiet" = true ] && exit 0
|
||||||
|
|
||||||
for dir
|
for dir
|
||||||
do
|
do
|
||||||
|
@ -253,25 +262,32 @@ then
|
||||||
echo "$dir"
|
echo "$dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
exit 0
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
[ "$nArgs" -eq 1 ] || usage
|
[ "$nArgs" -eq 1 ] || usage
|
||||||
|
|
||||||
|
# general error, eg file not found
|
||||||
|
exitCode=2
|
||||||
|
|
||||||
for dir
|
for dir
|
||||||
do
|
do
|
||||||
if [ -f "$dir/$fileName" ]
|
if [ -f "$dir/$fileName" ]
|
||||||
then
|
then
|
||||||
[ "$quietOpt" = true ] || echo "$dir/$fileName"
|
exitCode=0
|
||||||
exit 0
|
if [ "$optQuiet" = true ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$dir/$fileName"
|
||||||
|
[ "$optAll" = true ] || break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# general error, eg file not found
|
exit $exitCode
|
||||||
exit 2
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
|
@ -125,7 +125,7 @@ _foamSource()
|
||||||
{
|
{
|
||||||
while [ $# -ge 1 ]
|
while [ $# -ge 1 ]
|
||||||
do
|
do
|
||||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
|
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
|
||||||
. $1
|
. $1
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
53
etc/cshrc
53
etc/cshrc
|
@ -31,51 +31,9 @@
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# make sure that this variable is set un purpose
|
|
||||||
unset WM_PROJECT_VERSION_ADDITION
|
|
||||||
unsetenv WM_PROJECT_VERSION_ADDITION
|
|
||||||
|
|
||||||
set called=($_)
|
|
||||||
set prefSettingFile=$called[2].preset
|
|
||||||
|
|
||||||
if ( -r $prefSettingFile ) then
|
|
||||||
# echo "Found presettings $prefSettingFile"
|
|
||||||
source $prefSettingFile
|
|
||||||
endif
|
|
||||||
|
|
||||||
setenv WM_PROJECT OpenFOAM
|
setenv WM_PROJECT OpenFOAM
|
||||||
setenv WM_PROJECT_VERSION 1.6-ext
|
setenv WM_PROJECT_VERSION 1.6-ext
|
||||||
|
|
||||||
if( ! $?WM_PROJECT_VERSION_ADDITION ) then
|
|
||||||
set fullScriptPath = `pwd`"/$called[2]"
|
|
||||||
set canonicalFullScriptPath = `readlink -f $fullScriptPath |& cat`
|
|
||||||
if( $? != 0 ) then
|
|
||||||
# System with simpler readlink (BSD, Darwin) try replacement
|
|
||||||
set canonicalFullScriptPath=`greadlink -f $fullScriptPath |& cat`
|
|
||||||
if ( $? != 0 ) then
|
|
||||||
# we give up
|
|
||||||
set canonicalFullScriptPath=""
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if ( "$canonicalFullScriptPath" != "" ) then
|
|
||||||
set pathHere=`dirname $canonicalFullScriptPath`
|
|
||||||
set pathHere=`dirname $pathHere`
|
|
||||||
set dirName=`basename $pathHere`
|
|
||||||
set rest=`echo $dirName | sed -e "s/OpenFOAM-$WM_PROJECT_VERSION//"`
|
|
||||||
if ( "$rest" != "" ) then
|
|
||||||
setenv WM_PROJECT_VERSION_ADDITION `echo $rest | sed -e "s/-//"`
|
|
||||||
endif
|
|
||||||
unset dirName pathHere rest
|
|
||||||
endif
|
|
||||||
unset fullScriptPath canonicalFullScriptPath
|
|
||||||
endif
|
|
||||||
unset prefSettingFile called
|
|
||||||
|
|
||||||
if ( $?WM_PROJECT_VERSION_ADDITION ) then
|
|
||||||
setenv WM_PROJECT_VERSION $WM_PROJECT_VERSION-$WM_PROJECT_VERSION_ADDITION
|
|
||||||
endif
|
|
||||||
|
|
||||||
# helps to easily write #ifdefs to detect a dev-version
|
# helps to easily write #ifdefs to detect a dev-version
|
||||||
setenv FOAM_DEV 1
|
setenv FOAM_DEV 1
|
||||||
|
|
||||||
|
@ -116,16 +74,10 @@ setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
||||||
setenv WM_THIRD_PARTY_DIR $WM_PROJECT_DIR/ThirdParty
|
setenv WM_THIRD_PARTY_DIR $WM_PROJECT_DIR/ThirdParty
|
||||||
|
|
||||||
# Source files, possibly with some verbosity
|
# Source files, possibly with some verbosity
|
||||||
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*'
|
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
|
||||||
|
|
||||||
# Add in preset user or site preferences:
|
# Add in preset user or site preferences:
|
||||||
set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
||||||
if ( $status == 0 ) then
|
|
||||||
if ( $?foamPrefs ) then
|
|
||||||
_foamSource $foamPrefs
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
unset foamPrefs
|
|
||||||
|
|
||||||
# Evaluate command-line parameters
|
# Evaluate command-line parameters
|
||||||
while ( $#argv > 0 )
|
while ( $#argv > 0 )
|
||||||
|
@ -399,3 +351,4 @@ unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
|
||||||
unalias _foamSource
|
unalias _foamSource
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Reference in a new issue