mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add support for WM_PROJECT_SITE env variable
- alternative to WM_PROJECT_INST_DIR/site for systems with locked down installation paths (eg, when packaged as RPM or deb) When "$WM_PROJECT_SITE" is defined, it is used in favour of "$WM_PROJECT_INST_DIR/site"
This commit is contained in:
@ -204,15 +204,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
|
||||||
|
|
||||||
|
|||||||
10
bin/foamLog
10
bin/foamLog
@ -33,6 +33,8 @@
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
toolsDir=${0%/*}/tools
|
toolsDir=${0%/*}/tools
|
||||||
|
siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-<unknown>}/site}
|
||||||
|
userDir=$HOME/.OpenFOAM
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
@ -84,10 +86,10 @@ The value taken will be the first (non-space)word after this column.
|
|||||||
The database ($Script.db) will taken from these locations:
|
The database ($Script.db) will taken from these locations:
|
||||||
|
|
||||||
.
|
.
|
||||||
$HOME/.OpenFOAM/$WM_PROJECT_VERSION
|
$userDir/$WM_PROJECT_VERSION
|
||||||
$HOME/.OpenFOAM
|
$userDir
|
||||||
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION
|
$siteDir/$WM_PROJECT_VERSION
|
||||||
$WM_PROJECT_INST_DIR/site
|
$siteDir
|
||||||
$WM_PROJECT_DIR/etc
|
$WM_PROJECT_DIR/etc
|
||||||
$toolsDir
|
$toolsDir
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
# - requires rsync
|
# - requires rsync
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
siteDir=${WM_PROJECT_INST_DIR:-unknown}/site
|
siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-<unknown>}/site}
|
||||||
userDir=$HOME/.OpenFOAM
|
userDir=$HOME/.OpenFOAM
|
||||||
version=${WM_PROJECT_VERSION:-unknown}
|
version=${WM_PROJECT_VERSION:-unknown}
|
||||||
templateDir="appTemplates"
|
templateDir="appTemplates"
|
||||||
|
|||||||
@ -67,6 +67,11 @@ alias foamSol 'cd $FOAM_SOLVERS'
|
|||||||
alias foamTuts 'cd $FOAM_TUTORIALS'
|
alias foamTuts 'cd $FOAM_TUTORIALS'
|
||||||
alias foamUtils 'cd $FOAM_UTILITIES'
|
alias foamUtils 'cd $FOAM_UTILITIES'
|
||||||
alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR'
|
alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR'
|
||||||
alias foamSite 'cd $WM_PROJECT_INST_DIR/site'
|
|
||||||
|
if ( $?WM_PROJECT_SITE ) then
|
||||||
|
alias foamSite 'cd $WM_PROJECT_SITE'
|
||||||
|
else
|
||||||
|
alias foamSite 'cd $WM_PROJECT_INST_DIR/site'
|
||||||
|
endif
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@ -72,6 +72,12 @@ alias foamSol='cd $FOAM_SOLVERS'
|
|||||||
alias foamTuts='cd $FOAM_TUTORIALS'
|
alias foamTuts='cd $FOAM_TUTORIALS'
|
||||||
alias foamUtils='cd $FOAM_UTILITIES'
|
alias foamUtils='cd $FOAM_UTILITIES'
|
||||||
alias foam3rdParty='cd $WM_THIRD_PARTY_DIR'
|
alias foam3rdParty='cd $WM_THIRD_PARTY_DIR'
|
||||||
alias foamSite='cd $WM_PROJECT_INST_DIR/site'
|
|
||||||
|
if [ -n "$WM_PROJECT_SITE" ]
|
||||||
|
then
|
||||||
|
alias foamSite='cd $WM_PROJECT_SITE'
|
||||||
|
else
|
||||||
|
alias foamSite='cd $WM_PROJECT_INST_DIR/site'
|
||||||
|
fi
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@ -148,6 +148,9 @@ setenv FOAM_LIBBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib
|
|||||||
# external (ThirdParty) libraries
|
# external (ThirdParty) libraries
|
||||||
setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib
|
setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib
|
||||||
|
|
||||||
|
# default location of site-specific templates etc
|
||||||
|
# setenv WM_PROJECT_SITE $WM_PROJECT_INST_DIR/site
|
||||||
|
|
||||||
# shared site executables/libraries
|
# shared site executables/libraries
|
||||||
# similar naming convention as ~OpenFOAM expansion
|
# similar naming convention as ~OpenFOAM expansion
|
||||||
setenv FOAM_SITE_APPBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
|
setenv FOAM_SITE_APPBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
|
||||||
|
|||||||
@ -169,6 +169,9 @@ export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib
|
|||||||
# external (ThirdParty) libraries
|
# external (ThirdParty) libraries
|
||||||
export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib
|
export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib
|
||||||
|
|
||||||
|
# default location of site-specific templates etc
|
||||||
|
# export WM_PROJECT_SITE=$WM_PROJECT_INST_DIR/site
|
||||||
|
|
||||||
# shared site executables/libraries
|
# shared site executables/libraries
|
||||||
# similar naming convention as ~OpenFOAM expansion
|
# similar naming convention as ~OpenFOAM expansion
|
||||||
export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
|
export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
|
||||||
|
|||||||
@ -253,19 +253,20 @@ bool Foam::chDir(const fileName& dir)
|
|||||||
|
|
||||||
Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
||||||
{
|
{
|
||||||
// Search user files:
|
//
|
||||||
// ~~~~~~~~~~~~~~~~~~
|
// search for user files in
|
||||||
|
// * ~/.OpenFOAM/VERSION
|
||||||
|
// * ~/.OpenFOAM
|
||||||
|
//
|
||||||
fileName searchDir = home()/".OpenFOAM";
|
fileName searchDir = home()/".OpenFOAM";
|
||||||
if (isDir(searchDir))
|
if (isDir(searchDir))
|
||||||
{
|
{
|
||||||
// Check for user file in ~/.OpenFOAM/VERSION
|
|
||||||
fileName fullName = searchDir/FOAMversion/name;
|
fileName fullName = searchDir/FOAMversion/name;
|
||||||
if (isFile(fullName))
|
if (isFile(fullName))
|
||||||
{
|
{
|
||||||
return fullName;
|
return fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for version-independent user file in ~/.OpenFOAM
|
|
||||||
fullName = searchDir/name;
|
fullName = searchDir/name;
|
||||||
if (isFile(fullName))
|
if (isFile(fullName))
|
||||||
{
|
{
|
||||||
@ -274,32 +275,61 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Search site files:
|
//
|
||||||
// ~~~~~~~~~~~~~~~~~~
|
// search for group (site) files in
|
||||||
searchDir = getEnv("WM_PROJECT_INST_DIR");
|
// * $WM_PROJECT_SITE/VERSION
|
||||||
if (isDir(searchDir))
|
// * $WM_PROJECT_SITE
|
||||||
|
//
|
||||||
|
searchDir = getEnv("WM_PROJECT_SITE");
|
||||||
|
if (searchDir.size())
|
||||||
{
|
{
|
||||||
// Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
|
if (isDir(searchDir))
|
||||||
fileName fullName = searchDir/"site"/FOAMversion/name;
|
|
||||||
if (isFile(fullName))
|
|
||||||
{
|
{
|
||||||
return fullName;
|
fileName fullName = searchDir/FOAMversion/name;
|
||||||
}
|
if (isFile(fullName))
|
||||||
|
{
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for version-independent site file in $WM_PROJECT_INST_DIR/site
|
fullName = searchDir/name;
|
||||||
fullName = searchDir/"site"/name;
|
if (isFile(fullName))
|
||||||
if (isFile(fullName))
|
{
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// OR search for group (site) files in
|
||||||
|
// * $WM_PROJECT_INST_DIR/site/VERSION
|
||||||
|
// * $WM_PROJECT_INST_DIR/site
|
||||||
|
//
|
||||||
|
searchDir = getEnv("WM_PROJECT_INST_DIR");
|
||||||
|
if (isDir(searchDir))
|
||||||
{
|
{
|
||||||
return fullName;
|
fileName fullName = searchDir/"site"/FOAMversion/name;
|
||||||
|
if (isFile(fullName))
|
||||||
|
{
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullName = searchDir/"site"/name;
|
||||||
|
if (isFile(fullName))
|
||||||
|
{
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search installation files:
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//
|
||||||
|
// search for other (shipped) files in
|
||||||
|
// * $WM_PROJECT_DIR/etc
|
||||||
|
//
|
||||||
searchDir = getEnv("WM_PROJECT_DIR");
|
searchDir = getEnv("WM_PROJECT_DIR");
|
||||||
if (isDir(searchDir))
|
if (isDir(searchDir))
|
||||||
{
|
{
|
||||||
// Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
|
|
||||||
fileName fullName = searchDir/"etc"/name;
|
fileName fullName = searchDir/"etc"/name;
|
||||||
if (isFile(fullName))
|
if (isFile(fullName))
|
||||||
{
|
{
|
||||||
@ -311,7 +341,8 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
|||||||
// abort if the file is mandatory, otherwise return null
|
// abort if the file is mandatory, otherwise return null
|
||||||
if (mandatory)
|
if (mandatory)
|
||||||
{
|
{
|
||||||
std::cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
std::cerr
|
||||||
|
<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
||||||
" could not find mandatory file\n '"
|
" could not find mandatory file\n '"
|
||||||
<< name.c_str() << "'\n\n" << std::endl;
|
<< name.c_str() << "'\n\n" << std::endl;
|
||||||
::exit(1);
|
::exit(1);
|
||||||
|
|||||||
@ -93,22 +93,22 @@ fileName cwd();
|
|||||||
// else return false
|
// else return false
|
||||||
bool chDir(const fileName& dir);
|
bool chDir(const fileName& dir);
|
||||||
|
|
||||||
//- Search for \em name
|
//- Search for a file from user/group/shipped directories.
|
||||||
// in the following hierarchy:
|
// The search scheme allows for version-specific and
|
||||||
// -# personal settings:
|
// version-independent files using the following hierarchy:
|
||||||
// - ~/.OpenFOAM/\<VERSION\>/
|
// - \b user settings:
|
||||||
// <em>for version-specific files</em>
|
// - ~/.OpenFOAM/\<VERSION\>
|
||||||
// - ~/.OpenFOAM/
|
// - ~/.OpenFOAM/
|
||||||
// <em>for version-independent files</em>
|
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
|
||||||
// -# site-wide settings:
|
// - $WM_PROJECT_SITE/\<VERSION\>
|
||||||
|
// - $WM_PROJECT_SITE
|
||||||
|
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
|
||||||
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>
|
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>
|
||||||
// <em>for version-specific files</em>
|
|
||||||
// - $WM_PROJECT_INST_DIR/site/
|
// - $WM_PROJECT_INST_DIR/site/
|
||||||
// <em>for version-independent files</em>
|
// - \b other (shipped) settings:
|
||||||
// -# shipped settings:
|
|
||||||
// - $WM_PROJECT_DIR/etc/
|
// - $WM_PROJECT_DIR/etc/
|
||||||
//
|
//
|
||||||
// \return the full path name or fileName() if the name cannot be found
|
// \return The full path name or fileName() if the name cannot be found
|
||||||
// Optionally abort if the file cannot be found
|
// Optionally abort if the file cannot be found
|
||||||
fileName findEtcFile(const fileName&, bool mandatory=false);
|
fileName findEtcFile(const fileName&, bool mandatory=false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user