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
|
||||
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
|
||||
|
||||
|
||||
10
bin/foamLog
10
bin/foamLog
@ -33,6 +33,8 @@
|
||||
#------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
toolsDir=${0%/*}/tools
|
||||
siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-<unknown>}/site}
|
||||
userDir=$HOME/.OpenFOAM
|
||||
|
||||
usage() {
|
||||
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:
|
||||
|
||||
.
|
||||
$HOME/.OpenFOAM/$WM_PROJECT_VERSION
|
||||
$HOME/.OpenFOAM
|
||||
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION
|
||||
$WM_PROJECT_INST_DIR/site
|
||||
$userDir/$WM_PROJECT_VERSION
|
||||
$userDir
|
||||
$siteDir/$WM_PROJECT_VERSION
|
||||
$siteDir
|
||||
$WM_PROJECT_DIR/etc
|
||||
$toolsDir
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
# - requires rsync
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
siteDir=${WM_PROJECT_INST_DIR:-unknown}/site
|
||||
siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-<unknown>}/site}
|
||||
userDir=$HOME/.OpenFOAM
|
||||
version=${WM_PROJECT_VERSION:-unknown}
|
||||
templateDir="appTemplates"
|
||||
|
||||
@ -67,6 +67,11 @@ alias foamSol 'cd $FOAM_SOLVERS'
|
||||
alias foamTuts 'cd $FOAM_TUTORIALS'
|
||||
alias foamUtils 'cd $FOAM_UTILITIES'
|
||||
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 foamUtils='cd $FOAM_UTILITIES'
|
||||
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
|
||||
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
|
||||
# similar naming convention as ~OpenFOAM expansion
|
||||
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
|
||||
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
|
||||
# similar naming convention as ~OpenFOAM expansion
|
||||
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)
|
||||
{
|
||||
// Search user files:
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// search for user files in
|
||||
// * ~/.OpenFOAM/VERSION
|
||||
// * ~/.OpenFOAM
|
||||
//
|
||||
fileName searchDir = home()/".OpenFOAM";
|
||||
if (isDir(searchDir))
|
||||
{
|
||||
// Check for user file in ~/.OpenFOAM/VERSION
|
||||
fileName fullName = searchDir/FOAMversion/name;
|
||||
if (isFile(fullName))
|
||||
{
|
||||
return fullName;
|
||||
}
|
||||
|
||||
// Check for version-independent user file in ~/.OpenFOAM
|
||||
fullName = searchDir/name;
|
||||
if (isFile(fullName))
|
||||
{
|
||||
@ -274,32 +275,61 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
||||
}
|
||||
|
||||
|
||||
// Search site files:
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
searchDir = getEnv("WM_PROJECT_INST_DIR");
|
||||
if (isDir(searchDir))
|
||||
//
|
||||
// search for group (site) files in
|
||||
// * $WM_PROJECT_SITE/VERSION
|
||||
// * $WM_PROJECT_SITE
|
||||
//
|
||||
searchDir = getEnv("WM_PROJECT_SITE");
|
||||
if (searchDir.size())
|
||||
{
|
||||
// Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
|
||||
fileName fullName = searchDir/"site"/FOAMversion/name;
|
||||
if (isFile(fullName))
|
||||
if (isDir(searchDir))
|
||||
{
|
||||
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/"site"/name;
|
||||
if (isFile(fullName))
|
||||
fullName = searchDir/name;
|
||||
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");
|
||||
if (isDir(searchDir))
|
||||
{
|
||||
// Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
|
||||
fileName fullName = searchDir/"etc"/name;
|
||||
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
|
||||
if (mandatory)
|
||||
{
|
||||
std::cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
||||
std::cerr
|
||||
<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
||||
" could not find mandatory file\n '"
|
||||
<< name.c_str() << "'\n\n" << std::endl;
|
||||
::exit(1);
|
||||
|
||||
@ -93,22 +93,22 @@ fileName cwd();
|
||||
// else return false
|
||||
bool chDir(const fileName& dir);
|
||||
|
||||
//- Search for \em name
|
||||
// in the following hierarchy:
|
||||
// -# personal settings:
|
||||
// - ~/.OpenFOAM/\<VERSION\>/
|
||||
// <em>for version-specific files</em>
|
||||
//- Search for a file from user/group/shipped directories.
|
||||
// The search scheme allows for version-specific and
|
||||
// version-independent files using the following hierarchy:
|
||||
// - \b user settings:
|
||||
// - ~/.OpenFOAM/\<VERSION\>
|
||||
// - ~/.OpenFOAM/
|
||||
// <em>for version-independent files</em>
|
||||
// -# site-wide settings:
|
||||
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
|
||||
// - $WM_PROJECT_SITE/\<VERSION\>
|
||||
// - $WM_PROJECT_SITE
|
||||
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
|
||||
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>
|
||||
// <em>for version-specific files</em>
|
||||
// - $WM_PROJECT_INST_DIR/site/
|
||||
// <em>for version-independent files</em>
|
||||
// -# shipped settings:
|
||||
// - \b other (shipped) settings:
|
||||
// - $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
|
||||
fileName findEtcFile(const fileName&, bool mandatory=false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user