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
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
#
|
||||
|
@ -33,14 +33,18 @@
|
|||
# personal settings to site-wide settings.
|
||||
#
|
||||
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
|
||||
# @verbatim
|
||||
# \code
|
||||
# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \
|
||||
# && _foamSource $foamPrefs
|
||||
# @endverbatim
|
||||
# \endcode
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# Note
|
||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
usage() {
|
||||
[ "$quietOpt" = true ] && exit 1
|
||||
[ "${optQuiet:-$optSilent}" = true ] && exit 1
|
||||
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
|
@ -49,10 +53,12 @@ usage() {
|
|||
Usage: ${0##*/} [OPTION] fileName
|
||||
${0##*/} [OPTION] -list
|
||||
options:
|
||||
-all return all files (otherwise stop after the first match)
|
||||
-list list the directories to be searched
|
||||
-mode <mode> any combination of u(user), g(group), o(other)
|
||||
-prefix <dir> specify an alternative installation prefix
|
||||
-quiet suppress all normal output
|
||||
-silent suppress all stderr output
|
||||
-version <ver> specify an alternative OpenFOAM version
|
||||
in the form Maj.Min.Rev (eg, 1.7.0)
|
||||
-help print the usage
|
||||
|
@ -72,11 +78,7 @@ USAGE
|
|||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# the bin dir:
|
||||
binDir="${0%/*}"
|
||||
|
@ -128,7 +130,7 @@ esac
|
|||
|
||||
# default mode is 'ugo'
|
||||
mode=ugo
|
||||
unset listOpt quietOpt
|
||||
unset optAll optList optQuiet optSilent
|
||||
|
||||
# parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
|
@ -137,8 +139,11 @@ do
|
|||
-h | -help)
|
||||
usage
|
||||
;;
|
||||
-a | -all)
|
||||
optAll=true
|
||||
;;
|
||||
-l | -list)
|
||||
listOpt=true
|
||||
optList=true
|
||||
;;
|
||||
-m | -mode)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
|
@ -160,7 +165,10 @@ do
|
|||
shift
|
||||
;;
|
||||
-q | -quiet)
|
||||
quietOpt=true
|
||||
optQuiet=true
|
||||
;;
|
||||
-s | -silent)
|
||||
optSilent=true
|
||||
;;
|
||||
-v | -version)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
|
@ -204,15 +212,15 @@ fileName="${1#~OpenFOAM/}"
|
|||
unset dirList
|
||||
case "$mode" in
|
||||
*u*) # user
|
||||
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$version"
|
||||
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}"
|
||||
userDir="$HOME/.${WM_PROJECT:-OpenFOAM}"
|
||||
dirList="$dirList $userDir/$version $userDir"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$mode" in
|
||||
*g*) # group
|
||||
dirList="$dirList $prefixDir/site/$version"
|
||||
dirList="$dirList $prefixDir/site"
|
||||
*g*) # group (site)
|
||||
siteDir="${WM_PROJECT_SITE:-$prefixDir/site}"
|
||||
dirList="$dirList $siteDir/$version $siteDir"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -235,14 +243,15 @@ set -- $dirList
|
|||
# The main routine
|
||||
#
|
||||
|
||||
if [ "$listOpt" = true ]
|
||||
exitCode=0
|
||||
if [ "$optList" = true ]
|
||||
then
|
||||
|
||||
# list directories, or potential file locations
|
||||
[ "$nArgs" -le 1 ] || usage
|
||||
|
||||
# a silly combination, but -quiet has precedence
|
||||
[ "$quietOpt" = true ] && exit 0
|
||||
# a silly combination, but -quiet does have precedence
|
||||
[ "$optQuiet" = true ] && exit 0
|
||||
|
||||
for dir
|
||||
do
|
||||
|
@ -253,25 +262,32 @@ then
|
|||
echo "$dir"
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
|
||||
else
|
||||
|
||||
[ "$nArgs" -eq 1 ] || usage
|
||||
|
||||
# general error, eg file not found
|
||||
exitCode=2
|
||||
|
||||
for dir
|
||||
do
|
||||
if [ -f "$dir/$fileName" ]
|
||||
then
|
||||
[ "$quietOpt" = true ] || echo "$dir/$fileName"
|
||||
exit 0
|
||||
exitCode=0
|
||||
if [ "$optQuiet" = true ]
|
||||
then
|
||||
break
|
||||
else
|
||||
echo "$dir/$fileName"
|
||||
[ "$optAll" = true ] || break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# general error, eg file not found
|
||||
exit 2
|
||||
exit $exitCode
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
@ -125,7 +125,7 @@ _foamSource()
|
|||
{
|
||||
while [ $# -ge 1 ]
|
||||
do
|
||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
|
||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
|
||||
. $1
|
||||
shift
|
||||
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_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
|
||||
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
|
||||
|
||||
# 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:
|
||||
set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
||||
if ( $status == 0 ) then
|
||||
if ( $?foamPrefs ) then
|
||||
_foamSource $foamPrefs
|
||||
endif
|
||||
endif
|
||||
unset foamPrefs
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
||||
|
||||
# Evaluate command-line parameters
|
||||
while ( $#argv > 0 )
|
||||
|
@ -399,3 +351,4 @@ unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
|
|||
unalias _foamSource
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
|
Reference in a new issue