From 5fd3b5acda52f48cb6b4ca16be7844cbc58b097a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 2 Jul 2019 06:54:36 +0100 Subject: openfoam: rename openfoam-com to openfoam (#11876) The original packaging, with openfoam as a virtual and with openfoam-com, openfoam-org and openfoam-extend as providers, adds an obfuscation layer without any benefit. - Rename `openfoam-com` to `openfoam`, and remove the `openfoam` virtual package. --- .../repos/builtin/packages/foam-extend/package.py | 11 +- .../builtin/packages/of-adios-write/package.py | 8 +- .../repos/builtin/packages/of-catalyst/package.py | 4 +- .../repos/builtin/packages/of-precice/package.py | 2 +- .../packages/openfoam-com/1612-spack-patches.patch | 876 ------------------- .../packages/openfoam-com/1806-have-kahip.patch | 17 - .../builtin/packages/openfoam-com/common/README | 2 - .../packages/openfoam-com/common/README-spack | 15 - .../packages/openfoam-com/common/change-sitedir.sh | 94 --- .../packages/openfoam-com/common/change-userdir.sh | 94 --- .../packages/openfoam-com/common/spack-Allwmake | 37 - .../openfoam-com/common/spack-derived-Allwmake | 34 - .../repos/builtin/packages/openfoam-com/package.py | 934 --------------------- .../repos/builtin/packages/openfoam-org/package.py | 15 +- .../packages/openfoam/1612-spack-patches.patch | 876 +++++++++++++++++++ .../packages/openfoam/1806-have-kahip.patch | 17 + .../repos/builtin/packages/openfoam/common/README | 1 + .../builtin/packages/openfoam/common/README-spack | 15 + .../packages/openfoam/common/change-sitedir.sh | 94 +++ .../packages/openfoam/common/change-userdir.sh | 94 +++ .../packages/openfoam/common/spack-Allwmake | 37 + .../openfoam/common/spack-derived-Allwmake | 34 + .../repos/builtin/packages/openfoam/package.py | 933 ++++++++++++++++++++ 23 files changed, 2120 insertions(+), 2124 deletions(-) delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/1612-spack-patches.patch delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/1806-have-kahip.patch delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/common/README delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/common/README-spack delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/common/change-sitedir.sh delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/common/change-userdir.sh delete mode 100755 var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake delete mode 100755 var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake delete mode 100644 var/spack/repos/builtin/packages/openfoam-com/package.py create mode 100644 var/spack/repos/builtin/packages/openfoam/1612-spack-patches.patch create mode 100644 var/spack/repos/builtin/packages/openfoam/1806-have-kahip.patch create mode 100644 var/spack/repos/builtin/packages/openfoam/common/README create mode 100644 var/spack/repos/builtin/packages/openfoam/common/README-spack create mode 100644 var/spack/repos/builtin/packages/openfoam/common/change-sitedir.sh create mode 100644 var/spack/repos/builtin/packages/openfoam/common/change-userdir.sh create mode 100755 var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake create mode 100755 var/spack/repos/builtin/packages/openfoam/common/spack-derived-Allwmake create mode 100644 var/spack/repos/builtin/packages/openfoam/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index 6fa59decda..0d29dc13ee 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -24,7 +24,7 @@ # Changes # 2017-03-28 Mark Olesen # - avoid installing intermediate targets. -# - reworked to mirror the openfoam-com package. +# - reworked to mirror the openfoam package. # If changes are needed here, consider if they need applying there too. # # Known issues @@ -37,10 +37,10 @@ import os from spack import * from spack.util.environment import EnvironmentModifications -from spack.pkg.builtin.openfoam_com import OpenfoamArch -from spack.pkg.builtin.openfoam_com import add_extra_files -from spack.pkg.builtin.openfoam_com import write_environ -from spack.pkg.builtin.openfoam_com import rewrite_environ_files +from spack.pkg.builtin.openfoam import OpenfoamArch +from spack.pkg.builtin.openfoam import add_extra_files +from spack.pkg.builtin.openfoam import write_environ +from spack.pkg.builtin.openfoam import rewrite_environ_files import llnl.util.tty as tty @@ -78,7 +78,6 @@ class FoamExtend(Package): variant('source', default=True, description='Install library/application sources and tutorials') - provides('openfoam') depends_on('mpi') depends_on('python') depends_on('zlib') diff --git a/var/spack/repos/builtin/packages/of-adios-write/package.py b/var/spack/repos/builtin/packages/of-adios-write/package.py index f2265cc974..e88a25b7b2 100644 --- a/var/spack/repos/builtin/packages/of-adios-write/package.py +++ b/var/spack/repos/builtin/packages/of-adios-write/package.py @@ -20,7 +20,7 @@ import os import llnl.util.tty as tty from spack import * -from spack.pkg.builtin.openfoam_com import add_extra_files +from spack.pkg.builtin.openfoam import add_extra_files class OfAdiosWrite(Package): @@ -44,9 +44,9 @@ class OfAdiosWrite(Package): variant('source', default=True, description='Install library source') - depends_on('openfoam-com@develop+source', when='@develop') - depends_on('openfoam-com@1706+source', when='@1706') - depends_on('openfoam-com@1612+source', when='@1612') + depends_on('openfoam@develop+source', when='@develop') + depends_on('openfoam@1706+source', when='@1706') + depends_on('openfoam@1612+source', when='@1612') depends_on('adios') # General patches diff --git a/var/spack/repos/builtin/packages/of-catalyst/package.py b/var/spack/repos/builtin/packages/of-catalyst/package.py index 4eea85e8b1..9dfc56d9d5 100644 --- a/var/spack/repos/builtin/packages/of-catalyst/package.py +++ b/var/spack/repos/builtin/packages/of-catalyst/package.py @@ -30,8 +30,8 @@ class OfCatalyst(CMakePackage): variant('full', default=False, description='Build against paraview (full) or catalyst (light)') - depends_on('openfoam-com@1806', when='@1806', type=('build', 'link', 'run')) - depends_on('openfoam-com@develop', when='@develop', type=('build', 'link', 'run')) + depends_on('openfoam@1806', when='@1806', type=('build', 'link', 'run')) + depends_on('openfoam@develop', when='@develop', type=('build', 'link', 'run')) depends_on('catalyst@5.5:', when='~full') depends_on('paraview@5.5:+osmesa~qt', when='+full') diff --git a/var/spack/repos/builtin/packages/of-precice/package.py b/var/spack/repos/builtin/packages/of-precice/package.py index 82e486dbfc..1b833da812 100644 --- a/var/spack/repos/builtin/packages/of-precice/package.py +++ b/var/spack/repos/builtin/packages/of-precice/package.py @@ -8,7 +8,7 @@ import os import llnl.util.tty as tty from spack import * -from spack.pkg.builtin.openfoam_com import add_extra_files +from spack.pkg.builtin.openfoam import add_extra_files class OfPrecice(Package): diff --git a/var/spack/repos/builtin/packages/openfoam-com/1612-spack-patches.patch b/var/spack/repos/builtin/packages/openfoam-com/1612-spack-patches.patch deleted file mode 100644 index 00679c4c1d..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/1612-spack-patches.patch +++ /dev/null @@ -1,876 +0,0 @@ -############################################################################# -# This patch for OpenFOAM-1612 comprises the following changes: -# -# bin/foamEtcFile -# - Adjust to cope with spack naming (eg, openfoam-com-1612-abcxzy). -# Lets us avoid a needless directory layer. -# -# etc/bashrc -# - improved robustness when sourcing. -# - source top-level prefs.sh first (for sysadmin changes) -# -# etc/config.*/settings -# - write job control information to the user directory -# - site/ directory under the OpenFOAM project dir, not its parent dir -# -# etc/config.*/mpi -# - added USERMPI as place for spack mpi information -# -# mgridgen, zoltan: -# - make location configurable -# -# metis, scotch: -# - also check lib path (not just lib64) -# -# All issues patched here are addressed in OpenFOAM-1706 and later. -# -# ESI-OpenCFD www.openfoam.com -# -############################################################################# ---- OpenFOAM-v1612+.orig/bin/foamEtcFile 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-plus/bin/foamEtcFile 2017-12-18 17:48:35.043291205 +0100 -@@ -4,164 +4,235 @@ - # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - # \\ / O peration | - # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation --# \\/ M anipulation | -+# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. - #------------------------------------------------------------------------------- - # License --# This file is part of OpenFOAM. --# --# OpenFOAM is free software: you can redistribute it and/or modify it --# under the terms of the GNU General Public License as published by --# the Free Software Foundation, either version 3 of the License, or --# (at your option) any later version. --# --# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT --# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or --# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --# for more details. --# --# You should have received a copy of the GNU General Public License --# along with OpenFOAM. If not, see . -+# This file is part of OpenFOAM, licensed under GNU General Public License -+# . - # - # Script - # foamEtcFile - # - # Description --# Locate user/group/shipped file with semantics similar to the --# ~OpenFOAM/fileName expansion. -+# Locate user/group/other file as per '#includeEtc'. -+# -+# The -mode option can be used to allow chaining from personal settings -+# to site-wide settings. - # --# The -mode option can be used to allow chaining from --# personal settings to site-wide settings. -+# For example, within the user ~/.OpenFOAM//config.sh/compiler: -+# \code -+# eval $(foamEtcFile -sh -mode=go config.sh/compiler) -+# \endcode - # --# For example, within the user ~/.OpenFOAM//prefs.sh: -+# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure -+# that system prefs are respected: - # \code --# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ --# && _foamSource $foamPrefs -+# eval $(foamEtcFile -sh -mode=o prefs.sh) -+# eval $(foamEtcFile -sh -mode=ug prefs.sh) - # \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) -+# - # Note --# This script must exist in $FOAM_INST_DIR/OpenFOAM-/bin/ --# or $FOAM_INST_DIR/openfoam/bin/ (for the debian version) -+# This script must exist in one of these locations: -+# - $WM_PROJECT_INST_DIR/OpenFOAM-/bin -+# - $WM_PROJECT_INST_DIR/openfoam-/bin -+# - $WM_PROJECT_INST_DIR/openfoam/bin (debian version) - # - #------------------------------------------------------------------------------- --usage() { -- [ "${optQuiet:-$optSilent}" = true ] && exit 1 -- -- exec 1>&2 -- while [ "$#" -ge 1 ]; do echo "$1"; shift; done -+printHelp() { - cat< any combination of u(user), g(group), o(other) -- -prefix specify an alternative installation prefix -- -quiet suppress all normal output -- -silent suppress all stderr output -- -version specify an alternative OpenFOAM version -- in the form Maj.Min.Rev (eg, 1.7.0) -- -help print the usage -- -- Locate user/group/shipped file with semantics similar to the -- ~OpenFOAM/fileName expansion. -- -- The options can also be specified as a single character -- (eg, '-q' instead of '-quiet'), but must not be grouped. -- -- Exit status -- 0 when the file is found. Print resolved path to stdout. -- 1 for miscellaneous errors. -- 2 when the file is not found. -+ -all (-a) Return all files (otherwise stop after the first match) -+ -list (-l) List directories or files to be checked -+ -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, ...) -+ -csh Produce output suitable for a csh or sh 'eval' -+ -csh-verbose As per -csh with additional verbosity -+ -sh Produce output suitable for a csh or sh 'eval' -+ -sh-verbose As per -sh with additional verbosity -+ -quiet (-q) Suppress all normal output -+ -silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output -+ -help Print the usage -+ -+Locate user/group/other file as per '#includeEtc' -+ -+Do not group single character options. -+Equivalent options: -+ | -mode=MODE | -mode MODE | -m MODE -+ | -prefix=DIR | -prefix DIR | -p DIR -+ | -version=VER | -version VER | -v VER -+ -+Exit status -+ 0 when the file is found. Print resolved path to stdout. -+ 1 for miscellaneous errors. -+ 2 when the file is not found. - - USAGE -- exit 1 -+ exit 0 # A clean exit - } - --#------------------------------------------------------------------------------- - --# the bin dir: --binDir="${0%/*}" -+unset optQuiet optSilent -+# Report error and exit -+die() -+{ -+ [ "${optQuiet:-$optSilent}" = true ] && exit 1 -+ exec 1>&2 -+ echo -+ echo "Error encountered:" -+ while [ "$#" -ge 1 ]; do echo " $1"; shift; done -+ echo -+ echo "See 'foamEtcFile -help' for usage" -+ echo -+ exit 1 -+} - --# the project dir: --projectDir="${binDir%/bin}" -+#------------------------------------------------------------------------------- -+binDir="${0%/*}" # The bin dir -+projectDir="${binDir%/bin}" # The project dir -+prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR) - --# the prefix dir (same as $FOAM_INST_DIR): --prefixDir="${projectDir%/*}" -+# Could not resolve projectDir, prefixDir? (eg, called as ./bin/foamEtcFile) -+if [ "$prefixDir" = "$projectDir" ] -+then -+ binDir="$(cd $binDir && pwd -L)" -+ projectDir="${binDir%/bin}" -+ prefixDir="${projectDir%/*}" -+fi -+projectDirName="${projectDir##*/}" # The project directory name - --# the name used for the project directory --projectDirName="${projectDir##*/}" -+projectVersion="$WM_PROJECT_VERSION" # Empty? - will be treated later -+userDir="$HOME/.OpenFOAM" # Hard-coded as per foamVersion.H - --# version number used for debian packaging --unset versionNum -+#------------------------------------------------------------------------------- - -+# Guess project version or simply get the stem part of the projectDirName. -+# Handle standard and debian naming conventions. - # --# handle standard and debian naming convention -+# - projectVersion: update unless already set - # --case "$projectDirName" in --OpenFOAM-*) # standard naming convention OpenFOAM- -- version="${projectDirName##OpenFOAM-}" -- ;; -+# Helper variables: -+# - dirBase (for reassembling name) == projectDirName without the version -+# - versionNum (debian packaging) -+unset dirBase versionNum -+guessVersion() -+{ -+ local version -+ -+ case "$projectDirName" in -+ (OpenFOAM-* | openfoam-*) -+ # Standard naming: OpenFOAM- or openfoam- -+ dirBase="${projectDirName%%-*}-" -+ version="${projectDirName#*-}" -+ version="${version%%*-}" # Extra safety, eg openfoam-version-packager -+ ;; -+ -+ (openfoam[0-9]*) -+ # Debian naming: openfoam -+ 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 - --openfoam[0-9]* | openfoam-dev) # debian naming convention 'openfoam' -- versionNum="${projectDirName##openfoam}" -- case "$versionNum" in -- ??) # convert 2 digit version number to decimal delineated -- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@') -- ;; -- ???) # convert 3 digit version number to decimal delineated -- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@') -+ # Ignore special treatment if no decimals were inserted. -+ [ "${#version}" -gt "${#versionNum}" ] || unset versionNum - ;; -- ????) # convert 4 digit version number to decimal delineated -- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@') -- ;; -- *) # failback - use current environment setting -- version="$WM_PROJECT_VERSION" -+ -+ (*) -+ die "unknown/unsupported naming convention for '$projectDirName'" - ;; - esac -- ;; - --*) -- echo "Error : unknown/unsupported naming convention" -- exit 1 -- ;; --esac -+ # Set projectVersion if required -+ : ${projectVersion:=$version} -+} - - --# default mode is 'ugo' --mode=ugo --unset optAll optList optQuiet optSilent -+# Set projectVersion and update versionNum, projectDirName accordingly -+setVersion() -+{ -+ projectVersion="$1" - --# parse options -+ # 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}" -+} -+ -+ -+optMode=ugo # Default mode is always 'ugo' -+unset optAll optList optShell optVersion -+ -+# Parse options - while [ "$#" -gt 0 ] - do - case "$1" in -- -h | -help) -- usage -+ -h | -help*) -+ printHelp - ;; - -a | -all) - optAll=true -+ unset optShell - ;; - -l | -list) - optList=true -+ unset optShell -+ ;; -+ -list-test) -+ optList='test' -+ unset optShell -+ ;; -+ -csh | -sh | -csh-verbose | -sh-verbose) -+ optShell="${1#-}" -+ unset optAll -+ ;; -+ -mode=[ugo]*) -+ optMode="${1#*=}" -+ ;; -+ -prefix=/*) -+ prefixDir="${1#*=}" -+ prefixDir="${prefixDir%/}" -+ ;; -+ -version=*) -+ optVersion="${1#*=}" - ;; - -m | -mode) -- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" -- mode="$2" -- -- # sanity check: -- case "$mode" in -- *u* | *g* | *o* ) -- ;; -- *) -- usage "'$1' option with invalid mode '$mode'" -- ;; -- esac -+ optMode="$2" - shift -+ # Sanity check. Handles missing argument too. -+ case "$optMode" in -+ ([ugo]*) -+ ;; -+ (*) -+ die "invalid mode '$optMode'" -+ ;; -+ esac - ;; - -p | -prefix) -- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" -- prefixDir="$2" -+ [ "$#" -ge 2 ] || die "'$1' option requires an argument" -+ prefixDir="${2%/}" - shift - ;; - -q | -quiet) -@@ -171,13 +242,8 @@ - optSilent=true - ;; - -v | -version) -- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" -- version="$2" -- # convert x.y.z -> xyz version (if installation looked like debian) -- if [ -n "$versionNum" ] -- then -- versionNum=$(echo "$version" | sed -e 's@\.@@g') -- fi -+ [ "$#" -ge 2 ] || die "'$1' option requires an argument" -+ optVersion="$2" - shift - ;; - --) -@@ -185,7 +251,7 @@ - break - ;; - -*) -- usage "unknown option: '$*'" -+ die "unknown option: '$1'" - ;; - *) - break -@@ -195,11 +261,28 @@ - done - - --# debugging: --# echo "Installed locations:" --# for i in projectDir prefixDir projectDirName version versionNum -+#------------------------------------------------------------------------------- -+ -+if [ -n "$optVersion" ] -+then -+ setVersion $optVersion -+elif [ -z "$projectVersion" ] -+then -+ guessVersion -+fi -+ -+# Updates: -+# - projectDir for changes via -prefix or -version -+# - groupDir for changes via -prefix -+projectDir="$prefixDir/$projectDirName" -+groupDir="${WM_PROJECT_SITE:-$prefixDir/site}" -+ -+ -+# Debugging: -+# echo "Installed locations:" 1>&2 -+# for i in projectDir prefixDir projectDirName projectVersion - # do --# eval echo "$i=\$$i" -+# eval echo "$i=\$$i" 1>&2 - # done - - -@@ -210,30 +293,18 @@ - - # Define the various places to be searched: - unset dirList --case "$mode" in --*u*) # user -- userDir="$HOME/.${WM_PROJECT:-OpenFOAM}" -- dirList="$dirList $userDir/$version $userDir" -+case "$optMode" in (*u*) # (U)ser -+ dirList="$dirList $userDir/$projectVersion $userDir" - ;; - esac - --case "$mode" in --*g*) # group (site) -- siteDir="${WM_PROJECT_SITE:-$prefixDir/site}" -- dirList="$dirList $siteDir/$version $siteDir" -+case "$optMode" in (*g*) # (G)roup == site -+ dirList="$dirList $groupDir/$projectVersion $groupDir" - ;; - esac - --case "$mode" in --*o*) # other (shipped) -- if [ -n "$versionNum" ] -- then -- # debian packaging -- dirList="$dirList $prefixDir/openfoam$versionNum/etc" -- else -- # standard packaging -- dirList="$dirList $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc" -- fi -+case "$optMode" in (*o*) # (O)ther == shipped -+ dirList="$dirList $projectDir/etc" - ;; - esac - set -- $dirList -@@ -244,50 +315,87 @@ - # - - exitCode=0 --if [ "$optList" = true ] -+if [ -n "$optList" ] - then - -- # list directories, or potential file locations -- [ "$nArgs" -le 1 ] || usage -+ # List directories, or potential file locations -+ [ "$nArgs" -le 1 ] || \ -+ die "-list expects 0 or 1 filename, but $nArgs provided" - -- # a silly combination, but -quiet does have precedence -- [ "$optQuiet" = true ] && exit 0 -+ # A silly combination, but -quiet does have precedence -+ [ -n "$optQuiet" ] && exit 0 -+ -+ # Test for directory or file too? -+ if [ "$optList" = "test" ] -+ then -+ exitCode=2 # Fallback to a general error (file not found) - -- for dir -- do - if [ "$nArgs" -eq 1 ] - then -- echo "$dir/$fileName" -+ for dir -+ do -+ resolved="$dir/$fileName" -+ if [ -f "$resolved" ] -+ then -+ echo "$resolved" -+ exitCode=0 # OK -+ fi -+ done - else -- echo "$dir" -+ for dir -+ do -+ if [ -d "$dir" ] -+ then -+ echo "$dir" -+ exitCode=0 # OK -+ fi -+ done - fi -- done -+ else -+ for dir -+ do -+ echo "$dir${fileName:+/}$fileName" -+ done -+ fi - - else - -- [ "$nArgs" -eq 1 ] || usage -+ [ "$nArgs" -eq 1 ] || die "One filename expected - $nArgs provided" - -- # general error, eg file not found -- exitCode=2 -+ exitCode=2 # Fallback to a general error (file not found) - - for dir - do - if [ -f "$dir/$fileName" ] - then - exitCode=0 -- if [ "$optQuiet" = true ] -- then -+ [ -n "$optQuiet" ] && break -+ -+ case "$optShell" in -+ (*verbose) -+ echo "Using: $dir/$fileName" 1>&2 -+ ;; -+ esac -+ -+ case "$optShell" in -+ csh*) -+ echo "source $dir/$fileName" - break -- else -+ ;; -+ sh*) -+ echo ". $dir/$fileName" -+ break -+ ;; -+ *) - echo "$dir/$fileName" -- [ "$optAll" = true ] || break -- fi -+ [ -n "$optAll" ] || break -+ ;; -+ esac - fi - done - - fi - -- - exit $exitCode - - #------------------------------------------------------------------------------ ---- OpenFOAM-v1612+.orig/etc/bashrc 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/bashrc 2017-03-22 16:05:05.751237072 +0100 -@@ -42,7 +42,8 @@ - # - # Please set to the appropriate path if the default is not correct. - # --[ $BASH_SOURCE ] && FOAM_INST_DIR=$(\cd ${BASH_SOURCE%/*/*/*} && \pwd -P) || \ -+rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}" -+[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \ - FOAM_INST_DIR=$HOME/$WM_PROJECT - # FOAM_INST_DIR=~$WM_PROJECT - # FOAM_INST_DIR=/opt/$WM_PROJECT -@@ -135,8 +136,10 @@ - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - . $WM_PROJECT_DIR/etc/config.sh/functions - --# Add in preset user or site preferences: --_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` -+# Override definitions via prefs, with 'other' first so the sys-admin -+# can provide base values independent of WM_PROJECT_SITE -+_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.sh` -+_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.sh` - - # Evaluate command-line parameters and record settings for later - # these can be used to set/unset values, or specify alternative pref files -diff -uw OpenFOAM-v1612+.orig/etc/cshrc OpenFOAM-v1612+/etc/cshrc ---- OpenFOAM-v1612+.orig/etc/cshrc 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/cshrc 2017-03-22 16:04:51.839291067 +0100 -@@ -148,8 +148,10 @@ - # Source files, possibly with some verbosity - alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*' - --# Add in preset user or site preferences: --_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh` -+# Override definitions via prefs, with 'other' first so the sys-admin -+# can provide base values independent of WM_PROJECT_SITE -+_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.csh` -+_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.csh` - - # Evaluate command-line parameters and record settings for later - # these can be used to set/unset values, or specify alternative pref files ---- OpenFOAM-v1612+.orig/etc/config.sh/settings 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/config.sh/settings 2017-12-21 20:40:50.109036445 +0100 -@@ -141,7 +141,7 @@ - #------------------------------------------------------------------------------ - - # Location of the jobControl directory --export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl -+export FOAM_JOB_DIR="$HOME/.OpenFOAM/jobControl" - - # wmake configuration - export WM_DIR=$WM_PROJECT_DIR/wmake -@@ -198,8 +198,12 @@ - unset siteDir - - _foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN --# Make sure to pick up dummy versions of external libraries last --_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy -+_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last -+if [ -n "$FOAM_EXT_LIBBIN" ] # External libraries (allowed to be unset) -+then -+ _foamAddLib $FOAM_EXT_LIBBIN -+fi -+_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN - - # Compiler settings - # ~~~~~~~~~~~~~~~~~ ---- OpenFOAM-v1612+.orig/etc/config.csh/settings 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/config.csh/settings 2017-12-21 20:37:24.301773802 +0100 -@@ -137,7 +137,7 @@ - #------------------------------------------------------------------------------ - - # Location of the jobControl directory --setenv FOAM_JOB_DIR $WM_PROJECT_INST_DIR/jobControl -+setenv FOAM_JOB_DIR "$HOME/.OpenFOAM/jobControl" - - # wmake configuration - setenv WM_DIR $WM_PROJECT_DIR/wmake -@@ -196,8 +196,11 @@ - unset siteDir - - _foamAddPath ${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN} --# Make sure to pick up dummy versions of external libraries last --_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}:${FOAM_EXT_LIBBIN}:${FOAM_LIBBIN}/dummy -+_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last -+if ( $?FOAM_EXT_LIBBIN ) then # External libraries (allowed to be unset) -+ _foamAddLib $FOAM_EXT_LIBBIN -+endif -+_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN} - - # Compiler settings - # ~~~~~~~~~~~~~~~~~ ---- OpenFOAM-v1612+.orig/etc/config.sh/mpi 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/config.sh/mpi 2017-03-29 13:55:57.507980699 +0200 -@@ -75,8 +75,15 @@ - _foamAddMan $MPI_ARCH_PATH/share/man - ;; - -+USERMPI) -+ # Use an arbitrary, user-specified mpi implementation -+ export FOAM_MPI=mpi-user -+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-user` -+ ;; -+ - SYSTEMMPI) - export FOAM_MPI=mpi-system -+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-system` - - if [ -z "$MPI_ROOT" ] - then ---- OpenFOAM-v1612+.orig/etc/config.csh/mpi 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/etc/config.csh/mpi 2017-03-29 13:56:36.347835938 +0200 -@@ -71,8 +71,15 @@ - _foamAddMan $MPI_ARCH_PATH/share/man - breaksw - -+case USERMPI: -+ # Use an arbitrary, user-specified mpi implementation -+ setenv FOAM_MPI mpi-user -+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-user` -+ breaksw -+ - case SYSTEMMPI: - setenv FOAM_MPI mpi-system -+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-system` - - if ( ! ($?MPI_ROOT) ) then - echo ---- OpenFOAM-v1612+.orig/src/fvAgglomerationMethods/Allwmake 2017-01-02 09:56:17.578558265 +0100 -+++ OpenFOAM-v1612+/src/fvAgglomerationMethods/Allwmake 2017-04-18 18:58:38.236795902 +0200 -@@ -4,9 +4,13 @@ - # Parse arguments for library compilation - . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments - --export ParMGridGen=$WM_THIRD_PARTY_DIR/ParMGridGen-1.0 -+unset MGRIDGEN_ARCH_PATH -+if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mgridgen) -+then -+ . $settings -+fi - --if [ -e "$FOAM_LIBBIN/libMGridGen.so" ] -+if [ -e "$MGRIDGEN_ARCH_PATH/include/mgridgen.h" ] - then - wmake $targetType MGridGenGamgAgglomeration - fi ---- OpenFOAM-v1612+.orig/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options 2017-01-02 09:56:17.578558265 +0100 -+++ OpenFOAM-v1612+/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options 2017-04-18 18:59:16.860662811 +0200 -@@ -1,15 +1,9 @@ --/* Needs ParMGridGen environment variable set. (see Allwmake script) */ -- --TYPE_REAL= --#if defined(WM_SP) --TYPE_REAL=-DTYPE_REAL --#endif -- - EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ -- -I$(ParMGridGen)/MGridGen/Lib/lnInclude \ -- -I$(ParMGridGen)/MGridGen/IMlib/lnInclude \ -- $(TYPE_REAL) -+ -I$(MGRIDGEN_ARCH_PATH)/include - - LIB_LIBS = \ -- -L$(FOAM_EXT_LIBBIN) -lMGridGen -+ -L$(FOAM_EXT_LIBBIN) \ -+ -L$(MGRIDGEN_ARCH_PATH)/lib \ -+ -L$(MGRIDGEN_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ -+ -lmgrid ---- OpenFOAM-v1612+.orig/src/parallel/decompose/Allwmake 2017-03-21 16:34:44.599021283 +0100 -+++ OpenFOAM-v1612+/src/parallel/decompose/Allwmake 2017-03-21 16:28:57.243969660 +0100 -@@ -36,6 +36,7 @@ - - # Library - [ -r $FOAM_EXT_LIBBIN/libmetis.so ] || \ -+ [ -r $METIS_ARCH_PATH/lib/libmetis.so ] || \ - [ -r $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so ] || \ - [ "${METIS_ARCH_PATH##*-}" = system ] || { - echo "$warning (missing library)" -@@ -90,6 +91,7 @@ - - # Library - [ -r $FOAM_EXT_LIBBIN/libscotch.so ] || \ -+ [ -r $SCOTCH_ARCH_PATH/lib/libscotch.so ] || \ - [ -r $SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so ] || \ - [ "${SCOTCH_ARCH_PATH##*-}" = system ] || { - echo "$warning (missing library)" ---- OpenFOAM-v1612+.orig/src/parallel/decompose/metisDecomp/Make/options 2017-03-21 16:34:25.383075328 +0100 -+++ OpenFOAM-v1612+/src/parallel/decompose/metisDecomp/Make/options 2017-03-21 16:30:15.727758338 +0100 -@@ -8,6 +8,7 @@ - * to support central, non-thirdparty installations - */ - LIB_LIBS = \ -+ -L$(METIS_ARCH_PATH)/lib \ - -L$(METIS_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ - -L$(FOAM_EXT_LIBBIN) \ - -lmetis ---- OpenFOAM-v1612+.orig/src/parallel/decompose/ptscotchDecomp/Make/options 2017-03-21 16:34:34.607049385 +0100 -+++ OpenFOAM-v1612+/src/parallel/decompose/ptscotchDecomp/Make/options 2017-03-21 16:30:00.479799399 +0100 -@@ -16,6 +16,7 @@ - * to support central, non-thirdparty installations - */ - LIB_LIBS = \ -+ -L$(SCOTCH_ARCH_PATH)/lib \ - -L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ - -L$(FOAM_EXT_LIBBIN) \ - -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \ ---- OpenFOAM-v1612+.orig/src/parallel/decompose/scotchDecomp/Make/options 2017-03-21 16:34:39.159036582 +0100 -+++ OpenFOAM-v1612+/src/parallel/decompose/scotchDecomp/Make/options 2017-03-21 16:29:46.719836452 +0100 -@@ -16,6 +16,7 @@ - * to support central, non-thirdparty installations - */ - LIB_LIBS = \ -+ -L$(SCOTCH_ARCH_PATH)/lib \ - -L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ - -L$(FOAM_EXT_LIBBIN) \ - -lscotch \ ---- OpenFOAM-v1612+.orig/applications/utilities/mesh/manipulation/renumberMesh/Allwmake 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/applications/utilities/mesh/manipulation/renumberMesh/Allwmake 2017-03-28 11:13:35.222727218 +0200 -@@ -4,20 +4,35 @@ - # Parse arguments for compilation (at least for error catching) - . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments - --export COMPILE_FLAGS='' --export LINK_FLAGS='' -+unset COMP_FLAGS LINK_FLAGS - - if [ -f "${FOAM_LIBBIN}/libSloanRenumber.so" ] - then -- echo "Found libSloanRenumber.so -- enabling Sloan renumbering support." -+ echo " found libSloanRenumber -- enabling sloan renumbering support." - export LINK_FLAGS="${LINK_FLAGS} -lSloanRenumber" - fi - --if [ -f "${ZOLTAN_ARCH_PATH}/lib/libzoltan.a" -a -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ] -+if [ -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ] - then -- echo "Found libzoltanRenumber.so -- enabling zoltan renumbering support." -- export COMPILE_FLAGS="-DFOAM_USE_ZOLTAN" -- export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan" -+ if [ -z "$ZOLTAN_ARCH_PATH" ] -+ then -+ # Optional: get ZOLTAN_ARCH_PATH -+ if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) -+ then -+ . $settings -+ fi -+ fi -+ -+ for libdir in lib "lib${WM_COMPILER_LIB_ARCH}" -+ do -+ if [ -f "$ZOLTAN_ARCH_PATH/$libdir/libzoltan.a" ] -+ then -+ echo " found libzoltanRenumber -- enabling zoltan renumbering support." -+ export COMP_FLAGS="-DFOAM_USE_ZOLTAN" -+ export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L$ZOLTAN_ARCH_PATH/$libdir -lzoltan" -+ break -+ fi -+ done - fi - - wmake $targetType ---- OpenFOAM-v1612+.orig/src/renumber/Allwmake 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/src/renumber/Allwmake 2017-03-28 11:10:22.195543610 +0200 -@@ -5,14 +5,11 @@ - targetType=libso - . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments - --## Get ZOLTAN_ARCH_PATH --#if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) --#then --# . $settings --# echo "using ZOLTAN_ARCH_PATH=$ZOLTAN_ARCH_PATH" --#else --# echo "Error: no config.sh/zoltan settings" --#fi -+# Optional: get ZOLTAN_ARCH_PATH -+if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) -+then -+ . $settings -+fi - - wmake $targetType renumberMethods - ---- OpenFOAM-v1612+.orig/src/renumber/zoltanRenumber/Make/options 2016-12-23 15:22:59.000000000 +0100 -+++ OpenFOAM-v1612+/src/renumber/zoltanRenumber/Make/options 2017-03-28 11:50:46.484343848 +0200 -@@ -4,10 +4,13 @@ - EXE_INC = \ - /* -DFULLDEBUG -g -O0 */ \ - $(PFLAGS) $(PINC) \ -+ ${c++LESSWARN} \ - -I$(FOAM_SRC)/renumber/renumberMethods/lnInclude \ - -I$(ZOLTAN_ARCH_PATH)/include/ \ - -I$(LIB_SRC)/meshTools/lnInclude - - LIB_LIBS = \ -- /* -L$(ZOLTAN_ARCH_PATH)/lib -lzoltan */ \ -+ -L$(ZOLTAN_ARCH_PATH)/lib \ -+ -L$(ZOLTAN_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ -+ -lzoltan \ - -lmeshTools diff --git a/var/spack/repos/builtin/packages/openfoam-com/1806-have-kahip.patch b/var/spack/repos/builtin/packages/openfoam-com/1806-have-kahip.patch deleted file mode 100644 index 3e10a44145..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/1806-have-kahip.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- OpenFOAM-v1806/wmake/scripts/have_kahip-ORIG 2018-06-28 16:39:32.000000000 +0200 -+++ OpenFOAM-v1806/wmake/scripts/have_kahip 2018-08-11 13:37:18.250219013 +0200 -@@ -83,10 +83,10 @@ - # FOAM_EXT_LIBBIN is allowed to be unset - library=$(findFirstFile \ - $FOAM_EXT_LIBBIN/$library \ -- $METIS_ARCH_PATH/lib/$static \ -- $METIS_ARCH_PATH/lib/$library \ -- $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \ -- $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ -+ $KAHIP_ARCH_PATH/lib/$static \ -+ $KAHIP_ARCH_PATH/lib/$library \ -+ $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \ -+ $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ - ) - elif isSystem "$KAHIP_ARCH_PATH" - then diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/README b/var/spack/repos/builtin/packages/openfoam-com/common/README deleted file mode 100644 index d116bbaa23..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/README +++ /dev/null @@ -1,2 +0,0 @@ -Some helper tools for packaging applications/libraries dependent on an -openfoam provider. diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/README-spack b/var/spack/repos/builtin/packages/openfoam-com/common/README-spack deleted file mode 100644 index 83b606dda1..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/README-spack +++ /dev/null @@ -1,15 +0,0 @@ -Additional notes for spack --------------------------- - -OpenFOAM largely manages its own PATH and LD_LIBRARY_PATH settings. -The spack build currently also follows this and only provides -a minimum modules environment. - -The variable FOAM_PROJECT_DIR points to the location of the OpenFOAM project -and shall contain a $FOAM_PROJECT_DIR/etc/bashrc file for OpenFOAM. -The variable FOAM_INST_DIR may also be provided for older OpenFOAM versions. - -It is the aim for the future to use spack to provide the environment directly, -but this still needs more work. - -2017-04-18 diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/change-sitedir.sh b/var/spack/repos/builtin/packages/openfoam-com/common/change-sitedir.sh deleted file mode 100644 index 61d9c3ea8b..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/change-sitedir.sh +++ /dev/null @@ -1,94 +0,0 @@ -#----------------------------------*-sh-*-------------------------------------- -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. -# \\/ M anipulation | -#------------------------------------------------------------------------------ -# License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . -# -# Script -# . change-sitedir.sh PREFIX [SUFFIX] -# -# Shortcuts (prefix) -# -prefix "$WM_PROJECT_INST_DIR/site" -# -project "$WM_PROJECT_DIR/site" -# -none remove from environment -# -# Shortcuts (suffix) -# -platforms "platforms/$WM_OPTIONS" -# -# Description -# Change WM_PROJECT_SITE, FOAM_SITE_APPBIN, FOAM_SITE_LIBBIN -# and the respective entries in PATH, LD_LIBRARY_PATH. -# -# This can be useful when temporarily reassigning the site directory -# when packaging OpenFOAM. -# -# The suffix value should normally include "platforms/$WM_OPTIONS" -# -# Example -# . /path/change-sitedir.sh -prefix -platforms -# -# corresponds to the standard site location: -# -# $WM_PROJECT_INST_DIR/site{/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS} -# -#------------------------------------------------------------------------------ - -if [ "$#" -ge 1 ] -then - prefix="$1" - suffix="$2" - - foamOldDirs="$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN \ - $WM_PROJECT_SITE $WM_PROJECT_INST_DIR/site $WM_PROJECT_DIR/site" - foamClean=$WM_PROJECT_DIR/bin/foamCleanPath - if [ -x "$foamClean" ] - then - cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" - cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ - && LD_LIBRARY_PATH="$cleaned" - fi - - case "$suffix" in - -plat*) suffix="platforms/$WM_OPTIONS" ;; - esac - case "$prefix" in - -prefix) prefix="$WM_PROJECT_INST_DIR/site" ;; - -project) prefix="$WM_PROJECT_DIR/site" ;; - -none) unset prefix ;; - esac - - if [ -n "$prefix" ] - then - export WM_PROJECT_SITE="$prefix" - - prefix="$prefix/${WM_PROJECT_VERSION:-unknown}${suffix:+/}${suffix}" - - export FOAM_SITE_APPBIN="$prefix/bin" - export FOAM_SITE_LIBBIN="$prefix/lib" - PATH="$FOAM_SITE_APPBIN:$PATH" - LD_LIBRARY_PATH="$FOAM_SITE_LIBBIN:$LD_LIBRARY_PATH" - else - unset WM_PROJECT_SITE FOAM_SITE_APPBIN FOAM_SITE_LIBBIN - fi -fi - -unset foamClean foamOldDirs cleaned prefix suffix - -#------------------------------------------------------------------------------ diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/change-userdir.sh b/var/spack/repos/builtin/packages/openfoam-com/common/change-userdir.sh deleted file mode 100644 index d126fcfe5d..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/change-userdir.sh +++ /dev/null @@ -1,94 +0,0 @@ -#----------------------------------*-sh-*-------------------------------------- -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. -# \\/ M anipulation | -#------------------------------------------------------------------------------ -# License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . -# -# Script -# . change-userdir.sh PREFIX [SUFFIX] -# -# Shortcuts (prefix) -# -home "$HOME/OpenFOAM/$USER-$WM_PROJECT_VERSION" -# -none remove from environment -# -# Shortcuts (suffix) -# -platforms "platforms/$WM_OPTIONS" -# -# Description -# Change WM_PROJECT_USER_DIR, FOAM_USER_APPBIN, FOAM_USER_LIBBIN -# and the respective entries in PATH, LD_LIBRARY_PATH. -# Also adjusts FOAM_RUN. -# -# This can be useful with compiling additional OpenFOAM programs -# (that use FOAM_USER_APPBIN, FOAM_USER_LIBBIN for their build), -# to avoid conflicts with the normal user bin/lib files. -# -# The suffix value should normally include "platforms/$WM_OPTIONS" -# -# Example -# . /path/change-userdir.sh -home -platforms -# -# corresponds to the standard user location: -# -# $HOME/OpenFOAM/$USER-$WM_PROJECT_VERSION/platforms/$WM_OPTIONS -# -#------------------------------------------------------------------------------ - -if [ "$#" -ge 1 ] -then - prefix="$1" - suffix="$2" - - foamOldDirs="$FOAM_USER_APPBIN $FOAM_USER_LIBBIN" - foamClean=$WM_PROJECT_DIR/bin/foamCleanPath - if [ -x "$foamClean" ] - then - cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" - cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ - && LD_LIBRARY_PATH="$cleaned" - fi - - case "$suffix" in - -plat*) suffix="platforms/$WM_OPTIONS" ;; - esac - case "$prefix" in - -home) prefix="$HOME/OpenFOAM/$USER-${WM_PROJECT_VERSION:-unknown}" ;; - -none) unset prefix ;; - esac - - if [ -n "$prefix" ] - then - export WM_PROJECT_USER_DIR="$prefix" - export FOAM_RUN="$prefix/run" - - prefix="$prefix${suffix:+/}${suffix}" - export FOAM_USER_APPBIN="$prefix/bin" - export FOAM_USER_LIBBIN="$prefix/lib" - - PATH="$FOAM_USER_APPBIN:$PATH" - LD_LIBRARY_PATH="$FOAM_USER_LIBBIN:$LD_LIBRARY_PATH" - else - unset WM_PROJECT_USER_DIR FOAM_RUN FOAM_USER_APPBIN FOAM_USER_LIBBIN - fi -fi - -unset foamClean foamOldDirs cleaned prefix suffix - -#------------------------------------------------------------------------------ diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake b/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake deleted file mode 100755 index eb2d097c4e..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Build wrapper script - FOAM_INST_DIR is only required by foam-extend -export FOAM_INST_DIR=$(cd .. && pwd -L) -. $PWD/etc/bashrc '' # No arguments -mkdir -p $FOAM_APPBIN $FOAM_LIBBIN 2>/dev/null # Allow interrupt -echo "Build openfoam with SPACK ($@)" -echo WM_PROJECT_DIR = $WM_PROJECT_DIR - -# Prefer spack-specific Allwmake if it exists -if [ -f Allwmake-spack ] -then - ./Allwmake-spack $@ # Pass arguments -else - ./Allwmake $@ # Pass arguments - - # Generate manpages - if [ -x bin/tools/foamCreateManpage ] - then - bin/tools/foamCreateManpage -gzip || \ - echo "ignore problems generating manpages" - fi -fi - - -# Link non-dummy MPI_FOAM type to parent-dir, where rpath can find it -if [ "${FOAM_MPI:=dummy}" != dummy -a -d "$FOAM_LIBBIN/$FOAM_MPI" ] -then -( - cd "$FOAM_LIBBIN" || exit 1 - for i in $FOAM_MPI/lib*.so - do - [ -f $i ] && ln -sf $i "${i##*/}" - done -) -fi - -# ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake b/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake deleted file mode 100755 index 02741f1d13..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# The openfoam providers must export 'FOAM_PROJECT_DIR' -# The derived package is expected to supply an appropriate -# or file. - -[ -d "$FOAM_PROJECT_DIR" -a -f "$FOAM_PROJECT_DIR/etc/bashrc" ] || { - echo "Error: no PROJECT=$FOAM_PROJECT_DIR" 1>&2 - echo " or no etc/bashrc found" 1>&2 - exit 1 -} - -export FOAM_INST_DIR=$(cd $FOAM_PROJECT_DIR/.. && pwd -L) # Needed by foam-extend -. $FOAM_PROJECT_DIR/etc/bashrc '' # No arguments - -# Package-specific adjustments -[ -f spack-config.sh ] && . ./spack-config.sh '' # No arguments - -echo "========================================" -date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown" -echo "Build with ${WM_PROJECT}-${WM_PROJECT_VERSION}" -echo " WM_PROJECT_DIR = $WM_PROJECT_DIR" -echo " $WM_COMPILER $WM_COMPILER_TYPE compiler" -echo " $WM_OPTIONS - with $WM_MPLIB $FOAM_MPI" -echo - -# Prefer spack-specific Allwmake if it exists -if [ -f Allwmake-spack ] -then - ./Allwmake-spack $@ # Pass arguments -else - ./Allwmake $@ # Pass arguments -fi - -# ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam-com/package.py b/var/spack/repos/builtin/packages/openfoam-com/package.py deleted file mode 100644 index 318b2cb5b1..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-com/package.py +++ /dev/null @@ -1,934 +0,0 @@ -# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) - -# -# Author: Mark Olesen -# -# Legal Notice -# ------------ -# OPENFOAM is a trademark owned by OpenCFD Ltd -# (producer and distributor of the OpenFOAM software via www.openfoam.com). -# The trademark information must remain visible and unadulterated in this -# file and via the "spack info" and comply with the term set by -# http://openfoam.com/legal/trademark-policy.php -# -# This file is not part of OpenFOAM, nor does it constitute a component of an -# OpenFOAM distribution. -# -############################################################################## -# -# Notes -# - mpi handling: WM_MPLIB=USERMPI and use spack to populate an appropriate -# configuration and generate wmake rules for 'USER' and 'USERMPI' -# mpi implementations. -# -# - Resolution of flex, zlib needs more attention (within OpenFOAM) -# - +paraview: -# depends_on should just be 'paraview+plugins' but that resolves poorly. -# Workaround: use preferred variants "+plugins +qt" -# packages: -# paraview: -# variants: +plugins +qt -# in ~/.spack/packages.yaml -# -# Known issues -# - Combining +zoltan with +int64 has not been tested, but probably won't work. -# - Combining +mgridgen with +int64 or +float32 probably won't work. -# -# The spack 'develop' version of openfoam-com retains the upstream -# WM_PROJECT_VERSION=plus naming internally. -# -############################################################################## -import glob -import re -import os - -from spack import * -from spack.util.environment import EnvironmentModifications -import llnl.util.tty as tty - - -# Not the nice way of doing things, but is a start for refactoring -__all__ = [ - 'add_extra_files', - 'write_environ', - 'rewrite_environ_files', - 'mplib_content', - 'foam_add_path', - 'foam_add_lib', - 'OpenfoamArch', -] - - -def add_extra_files(foam_pkg, common, local, **kwargs): - """Copy additional common and local files into the stage.source_path - from the openfoam-com/common and the package/assets directories, - respectively - """ - outdir = foam_pkg.stage.source_path - - indir = join_path(os.path.dirname(__file__), 'common') - for f in common: - tty.info('Added file {0}'.format(f)) - install(join_path(indir, f), join_path(outdir, f)) - - indir = join_path(foam_pkg.package_dir, 'assets') - for f in local: - tty.info('Added file {0}'.format(f)) - install(join_path(indir, f), join_path(outdir, f)) - - -def format_export(key, value): - """Format key,value pair as 'export' with newline for POSIX shell. - A leading '#' for key adds a comment character to the entire line. - A value of 'None' corresponds to 'unset'. - """ - if key.startswith('#'): - return '## export {0}={1}\n'.format(re.sub(r'^#+\s*', '', key), value) - elif value is None: - return 'unset {0}\n'.format(key) - else: - return 'export {0}={1}\n'.format(key, value) - - -def format_setenv(key, value): - """Format key,value pair as 'setenv' with newline for C-shell. - A leading '#' for key adds a comment character to the entire line. - A value of 'None' corresponds to 'unsetenv'. - """ - if key.startswith('#'): - return '## setenv {0} {1}\n'.format(re.sub(r'^#+\s*', '', key), value) - elif value is None: - return 'unsetenv {0}\n'.format(key) - else: - return 'setenv {0} {1}\n'.format(key, value) - - -def _write_environ_entries(outfile, environ, formatter): - """Write environment settings as 'export' or 'setenv'. - If environ is a dict, write in sorted order. - If environ is a list, write pair-wise. - Also descends into sub-dict and sub-list, but drops the key. - """ - if isinstance(environ, dict): - for key in sorted(environ): - entry = environ[key] - if isinstance(entry, dict): - _write_environ_entries(outfile, entry, formatter) - elif isinstance(entry, list): - _write_environ_entries(outfile, entry, formatter) - else: - outfile.write(formatter(key, entry)) - elif isinstance(environ, list): - for item in environ: - outfile.write(formatter(item[0], item[1])) - - -def _write_environ_file(output, environ, formatter): - """Write environment settings as 'export' or 'setenv'. - If environ is a dict, write in sorted order. - If environ is a list, write pair-wise. - Also descends into sub-dict and sub-list, but drops the key. - """ - with open(output, 'w') as outfile: - outfile.write('# spack generated\n') - _write_environ_entries(outfile, environ, formatter) - outfile.write('# spack\n') - - -def write_environ(environ, **kwargs): - """Write environment settings as 'export' or 'setenv'. - If environ is a dict, write in sorted order. - If environ is a list, write pair-wise. - - Keyword Options: - posix[=None] If set, the name of the POSIX file to rewrite. - cshell[=None] If set, the name of the C-shell file to rewrite. - """ - rcfile = kwargs.get('posix', None) - if rcfile: - _write_environ_file(rcfile, environ, format_export) - rcfile = kwargs.get('cshell', None) - if rcfile: - _write_environ_file(rcfile, environ, format_setenv) - - -def rewrite_environ_files(environ, **kwargs): - """Use filter_file to rewrite (existing) POSIX shell or C-shell files. - Keyword Options: - posix[=None] If set, the name of the POSIX file to rewrite. - cshell[=None] If set, the name of the C-shell file to rewrite. - """ - rcfile = kwargs.get('posix', None) - if rcfile and os.path.isfile(rcfile): - for k, v in environ.items(): - regex = r'^(\s*export\s+{0})=.*$'.format(k) - if not v: - replace = r'unset {0} #SPACK: unset'.format(k) - elif v.startswith('#'): - replace = r'unset {0} {1}'.format(k, v) - else: - replace = r'\1={0}'.format(v) - filter_file(regex, replace, rcfile, backup=False) - - rcfile = kwargs.get('cshell', None) - if rcfile and os.path.isfile(rcfile): - for k, v in environ.items(): - regex = r'^(\s*setenv\s+{0})\s+.*$'.format(k) - if not v: - replace = r'unsetenv {0} #SPACK: unset'.format(k) - elif v.startswith('#'): - replace = r'unsetenv {0} {1}'.format(k, v) - else: - replace = r'\1 {0}'.format(v) - filter_file(regex, replace, rcfile, backup=False) - - -def foam_add_path(*args): - """A string with args prepended to 'PATH'""" - return '"' + ':'.join(args) + ':${PATH}"' - - -def foam_add_lib(*args): - """A string with args prepended to 'LD_LIBRARY_PATH'""" - return '"' + ':'.join(args) + ':${LD_LIBRARY_PATH}"' - - -def pkglib(package, pre=None): - """Get lib64 or lib from package prefix. - - Optional parameter 'pre' to provide alternative prefix - """ - libdir = package.prefix.lib64 - if not os.path.isdir(libdir): - libdir = package.prefix.lib - if pre: - return join_path(pre, os.path.basename(libdir)) - else: - return libdir - - -def mplib_content(spec, pre=None): - """The mpi settings (from spack) for the OpenFOAM wmake includes, which - allows later reuse within OpenFOAM. - - Optional parameter 'pre' to provide alternative prefix - """ - mpi_spec = spec['mpi'] - bin = mpi_spec.prefix.bin - inc = mpi_spec.prefix.include - lib = pkglib(mpi_spec) - - libname = 'mpi' - if 'mpich' in mpi_spec.name: - libname = 'mpich' - - if pre: - bin = join_path(pre, os.path.basename(bin)) - inc = join_path(pre, os.path.basename(inc)) - lib = join_path(pre, os.path.basename(lib)) - else: - pre = mpi_spec.prefix - - info = { - 'name': '{0}-{1}'.format(mpi_spec.name, mpi_spec.version), - 'prefix': pre, - 'include': inc, - 'bindir': bin, - 'libdir': lib, - 'FLAGS': '-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX', - 'PINC': '-I{0}'.format(inc), - 'PLIBS': '-L{0} -l{1}'.format(lib, libname), - } - return info - - -# ----------------------------------------------------------------------------- - -class OpenfoamCom(Package): - """OpenFOAM is a GPL-opensource C++ CFD-toolbox. - This offering is supported by OpenCFD Ltd, - producer and distributor of the OpenFOAM software via www.openfoam.com, - and owner of the OPENFOAM trademark. - OpenCFD Ltd has been developing and releasing OpenFOAM since its debut - in 2004. - """ - - maintainers = ['olesenm'] - homepage = "http://www.openfoam.com/" - url = "https://sourceforge.net/projects/openfoamplus/files/v1706/OpenFOAM-v1706.tgz" - git = "https://develop.openfoam.com/Development/OpenFOAM-plus.git" - list_url = "https://sourceforge.net/projects/openfoamplus/files/" - list_depth = 2 - - version('develop', branch='develop', submodules='True') # Needs credentials - version('1906', 'ab7017e262c0c0fceec55c31e2153180') - version('1812_190531', 'a4b416838a8a76fdec22706a33c96de3') - version('1812', '6a315687b3601eeece7ff7c7aed3d9a5') - version('1806', 'bb244a3bde7048a03edfccffc46c763f') - version('1712', '6ad92df051f4d52c7d0ec34f4b8eb3bc') - version('1706', '630d30770f7b54d6809efbf94b7d7c8f') - version('1612', 'ca02c491369150ab127cbb88ec60fbdf') - - variant('float32', default=False, - description='Use single-precision') - variant('int64', default=False, - description='With 64-bit labels') - variant('knl', default=False, - description='Use KNL compiler settings') - variant('kahip', default=False, - description='With kahip decomposition') - variant('metis', default=False, - description='With metis decomposition') - variant('scotch', default=True, - description='With scotch/ptscotch decomposition') - variant('zoltan', default=False, - description='With zoltan renumbering') - # TODO?# variant('scalasca', default=False, - # TODO?# description='With scalasca profiling') - variant('mgridgen', default=False, description='With mgridgen support') - variant('paraview', default=False, - description='Build paraview plugins and runtime post-processing') - variant('vtk', default=False, - description='With VTK runTimePostProcessing') - variant('source', default=True, - description='Install library/application sources and tutorials') - - provides('openfoam') - depends_on('mpi') - - # After 1712, could suggest openmpi+thread_multiple for collated output - # but particular mixes of mpi versions and InfiniBand may not work so well - # conflicts('^openmpi~thread_multiple', when='@1712:') - - depends_on('zlib') - depends_on('fftw') - depends_on('boost') - depends_on('cgal') - # The flex restriction is ONLY to deal with a spec resolution clash - # introduced by the restriction within scotch! - depends_on('flex@:2.6.1,2.6.4:') - depends_on('cmake', type='build') - - # Require scotch with ptscotch - corresponds to standard OpenFOAM setup - depends_on('scotch~metis+mpi~int64', when='+scotch~int64') - depends_on('scotch~metis+mpi+int64', when='+scotch+int64') - depends_on('kahip', when='+kahip') - depends_on('metis@5:', when='+metis') - depends_on('metis+int64', when='+metis+int64') - # mgridgen is statically linked - depends_on('parmgridgen', when='+mgridgen', type='build') - depends_on('zoltan', when='+zoltan') - depends_on('vtk', when='+vtk') - - # TODO?# depends_on('scalasca', when='+scalasca') - - # For OpenFOAM plugins and run-time post-processing this should just be - # 'paraview+plugins' but that resolves poorly. - # Workaround: use preferred variants "+plugins +qt" in - # ~/.spack/packages.yaml - - # 1706 ok with newer paraview but avoid pv-5.2, pv-5.3 readers - depends_on('paraview@5.4:', when='@1706:+paraview') - # 1612 plugins need older paraview - depends_on('paraview@:5.0.1', when='@1612+paraview') - - # General patches - common = ['spack-Allwmake', 'README-spack'] - assets = [] - - # Version-specific patches - patch('1612-spack-patches.patch', when='@1612') - patch('1806-have-kahip.patch', when='@1806') - - # Some user config settings - # default: 'compile-option': 'RpathOpt', - # default: 'mplib': 'USERMPI', # Use user mpi for spack - config = { - # Add links into bin/, lib/ (eg, for other applications) - 'link': False - } - - # The openfoam architecture, compiler information etc - _foam_arch = None - - # Content for etc/prefs.{csh,sh} - etc_prefs = {} - - # Content for etc/config.{csh,sh}/ files - etc_config = {} - - phases = ['configure', 'build', 'install'] - build_script = './spack-Allwmake' # From patch() method. - - # - # - End of definitions / setup - - # - - def url_for_version(self, version): - # Prior to 'v1706' and additional '+' in the naming - fmt = self.list_url - if version <= Version('1612'): - fmt += 'v{0}+/OpenFOAM-v{0}+.tgz' - else: - fmt += 'v{0}/OpenFOAM-v{0}.tgz' - return fmt.format(version, version) - - def setup_environment(self, spack_env, run_env): - """Add environment variables to the generated module file. - These environment variables come from running: - - .. code-block:: console - - $ . $WM_PROJECT_DIR/etc/bashrc - """ - - # NOTE: Spack runs setup_environment twice. - # 1) pre-build to set up the build environment - # 2) post-install to determine runtime environment variables - # The etc/bashrc is only available (with corrrect content) - # post-installation. - - bashrc = join_path(self.projectdir, 'etc', 'bashrc') - minimal = True - if os.path.isfile(bashrc): - # post-install: source the installed bashrc - try: - mods = EnvironmentModifications.from_sourcing_file( - bashrc, - clean=True, # Remove duplicate entries - blacklist=[ # Blacklist these - # Inadvertent changes - # ------------------- - 'PS1', # Leave unaffected - 'MANPATH', # Leave unaffected - - # Unneeded bits - # ------------- - # 'FOAM_SETTINGS', # Do not use with modules - # 'FOAM_INST_DIR', # Old - # 'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)', - # 'FOAM_TUTORIALS', # can be useful - # 'WM_OSTYPE', # Purely optional value - - # Third-party cruft - only used for orig compilation - # ----------------- - '[A-Z].*_ARCH_PATH', - # '(KAHIP|METIS|SCOTCH)_VERSION', - - # User-specific - # ------------- - 'FOAM_RUN', - '(FOAM|WM)_.*USER_.*', - ], - whitelist=[ # Whitelist these - 'MPI_ARCH_PATH', # Can be needed for compilation - ]) - - run_env.extend(mods) - spack_env.extend(mods) - minimal = False - tty.info('OpenFOAM bashrc env: {0}'.format(bashrc)) - except Exception: - minimal = True - - if minimal: - # pre-build or minimal environment - tty.info('OpenFOAM minimal env {0}'.format(self.prefix)) - run_env.set('FOAM_PROJECT_DIR', self.projectdir) - run_env.set('WM_PROJECT_DIR', self.projectdir) - spack_env.set('FOAM_PROJECT_DIR', self.projectdir) - spack_env.set('WM_PROJECT_DIR', self.projectdir) - for d in ['wmake', self.archbin]: # bin added automatically - run_env.prepend_path('PATH', join_path(self.projectdir, d)) - spack_env.prepend_path('PATH', join_path(self.projectdir, d)) - - def setup_dependent_environment(self, spack_env, run_env, dependent_spec): - """Location of the OpenFOAM project directory. - This is identical to the WM_PROJECT_DIR value, but we avoid that - variable since it would mask the normal OpenFOAM cleanup of - previous versions. - """ - self.setup_environment(spack_env, run_env) - - @property - def projectdir(self): - """Absolute location of project directory: WM_PROJECT_DIR/""" - return self.prefix # <- install directly under prefix - - @property - def foam_arch(self): - if not self._foam_arch: - self._foam_arch = OpenfoamArch(self.spec, **self.config) - return self._foam_arch - - @property - def archbin(self): - """Relative location of architecture-specific executables""" - return join_path('platforms', self.foam_arch, 'bin') - - @property - def archlib(self): - """Relative location of architecture-specific libraries""" - return join_path('platforms', self.foam_arch, 'lib') - - def patch(self): - """Adjust OpenFOAM build for spack. - Where needed, apply filter as an alternative to normal patching.""" - add_extra_files(self, self.common, self.assets) - - @when('@:1806') - def patch(self): - """Adjust OpenFOAM build for spack. - Where needed, apply filter as an alternative to normal patching.""" - add_extra_files(self, self.common, self.assets) - - # Avoid WM_PROJECT_INST_DIR for ThirdParty - # This modification is non-critical - edits = { - 'WM_THIRD_PARTY_DIR': - r'$WM_PROJECT_DIR/ThirdParty #SPACK: No separate third-party', - } - rewrite_environ_files( # etc/{bashrc,cshrc} - edits, - posix=join_path('etc', 'bashrc'), - cshell=join_path('etc', 'cshrc')) - - # The following filtering is non-critical. - # It simply prevents 'site' dirs at the wrong level - # (likely non-existent anyhow) from being added to - # PATH, LD_LIBRARY_PATH. - for rcdir in ['config.sh', 'config.csh']: - rcfile = join_path('etc', rcdir, 'settings') - if os.path.isfile(rcfile): - filter_file( - 'WM_PROJECT_INST_DIR/', - 'WM_PROJECT_DIR/', - rcfile, - backup=False) - - def configure(self, spec, prefix): - """Make adjustments to the OpenFOAM configuration files in their various - locations: etc/bashrc, etc/config.sh/FEATURE and customizations that - don't properly fit get placed in the etc/prefs.sh file (similiarly for - csh). - """ - # Filtering bashrc, cshrc - edits = {} - edits.update(self.foam_arch.foam_dict()) - rewrite_environ_files( # etc/{bashrc,cshrc} - edits, - posix=join_path('etc', 'bashrc'), - cshell=join_path('etc', 'cshrc')) - - # Content for etc/prefs.{csh,sh} - self.etc_prefs = { - # TODO - # 'CMAKE_ARCH_PATH': spec['cmake'].prefix, - # 'FLEX_ARCH_PATH': spec['flex'].prefix, - # 'ZLIB_ARCH_PATH': spec['zlib'].prefix, - } - - # MPI content, using MPI_ARCH_PATH - user_mpi = mplib_content(spec, '${MPI_ARCH_PATH}') - - # Content for etc/config.{csh,sh}/ files - self.etc_config = { - 'CGAL': [ - ('BOOST_ARCH_PATH', spec['boost'].prefix), - ('CGAL_ARCH_PATH', spec['cgal'].prefix), - ('LD_LIBRARY_PATH', - foam_add_lib( - pkglib(spec['boost'], '${BOOST_ARCH_PATH}'), - pkglib(spec['cgal'], '${CGAL_ARCH_PATH}'))), - ], - 'FFTW': [ - ('FFTW_ARCH_PATH', spec['fftw'].prefix), # Absolute - ('LD_LIBRARY_PATH', - foam_add_lib( - pkglib(spec['fftw'], '${BOOST_ARCH_PATH}'))), - ], - # User-defined MPI - 'mpi-user': [ - ('MPI_ARCH_PATH', spec['mpi'].prefix), # Absolute - ('LD_LIBRARY_PATH', foam_add_lib(user_mpi['libdir'])), - ('PATH', foam_add_path(user_mpi['bindir'])), - ], - 'scotch': {}, - 'kahip': {}, - 'metis': {}, - 'ensight': {}, # Disable settings - 'paraview': [], - 'gperftools': [], # Currently unused - 'vtk': [], - } - - if '+scotch' in spec: - self.etc_config['scotch'] = { - 'SCOTCH_ARCH_PATH': spec['scotch'].prefix, - # For src/parallel/decompose/Allwmake - 'SCOTCH_VERSION': 'scotch-{0}'.format(spec['scotch'].version), - } - - if '+kahip' in spec: - self.etc_config['kahip'] = { - 'KAHIP_ARCH_PATH': spec['kahip'].prefix, - } - - if '+metis' in spec: - self.etc_config['metis'] = { - 'METIS_ARCH_PATH': spec['metis'].prefix, - } - - # ParaView_INCLUDE_DIR is not used in 1812, but has no ill-effect - if '+paraview' in spec: - pvmajor = 'paraview-{0}'.format(spec['paraview'].version.up_to(2)) - self.etc_config['paraview'] = [ - ('ParaView_DIR', spec['paraview'].prefix), - ('ParaView_INCLUDE_DIR', '${ParaView_DIR}/include/' + pvmajor), - ('PV_PLUGIN_PATH', '$FOAM_LIBBIN/' + pvmajor), - ('PATH', foam_add_path('${ParaView_DIR}/bin')), - ] - - if '+vtk' in spec: - self.etc_config['vtk'] = [ - ('VTK_DIR', spec['vtk'].prefix), - ('LD_LIBRARY_PATH', - foam_add_lib(pkglib(spec['vtk'], '${VTK_DIR}'))), - ] - - # Optional - if '+mgridgen' in spec: - self.etc_config['mgridgen'] = { - 'MGRIDGEN_ARCH_PATH': spec['parmgridgen'].prefix - } - - # Optional - if '+zoltan' in spec: - self.etc_config['zoltan'] = { - 'ZOLTAN_ARCH_PATH': spec['zoltan'].prefix - } - - # Write prefs files according to the configuration. - # Only need prefs.sh for building, but install both for end-users - if self.etc_prefs: - write_environ( - self.etc_prefs, - posix=join_path('etc', 'prefs.sh'), - cshell=join_path('etc', 'prefs.csh')) - - # Adjust components to use SPACK variants - for component, subdict in self.etc_config.items(): - write_environ( - subdict, - posix=join_path('etc', 'config.sh', component), - cshell=join_path('etc', 'config.csh', component)) - - def build(self, spec, prefix): - """Build using the OpenFOAM Allwmake script, with a wrapper to source - its environment first. - Only build if the compiler is known to be supported. - """ - self.foam_arch.has_rule(self.stage.source_path) - self.foam_arch.create_rules(self.stage.source_path, self) - - args = ['-silent'] - if self.parallel: # Build in parallel? - pass as an argument - args.append('-j{0}'.format(make_jobs)) - builder = Executable(self.build_script) - builder(*args) - - def install_write_location(self): - """Set the installation location (projectdir) in bashrc,cshrc.""" - mkdirp(self.projectdir) - - # Filtering: bashrc, cshrc - edits = { - 'WM_PROJECT_DIR': self.projectdir, - } - etc_dir = join_path(self.projectdir, 'etc') - rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc - edits, - posix=join_path(etc_dir, 'bashrc'), - cshell=join_path(etc_dir, 'cshrc')) - - @when('@:1806') - def install_write_location(self): - """Set the installation location (projectdir) in bashrc,cshrc. - In 1806 and earlier, had WM_PROJECT_INST_DIR as the prefix - directory where WM_PROJECT_DIR was installed. - """ - mkdirp(self.projectdir) - projdir = os.path.basename(self.projectdir) - - # Filtering: bashrc, cshrc - edits = { - 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), - 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), - } - etc_dir = join_path(self.projectdir, 'etc') - rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc - edits, - posix=join_path(etc_dir, 'bashrc'), - cshell=join_path(etc_dir, 'cshrc')) - - def install(self, spec, prefix): - """Install under the projectdir""" - mkdirp(self.projectdir) - - # All top-level files, except spack build info and possibly Allwmake - if '+source' in spec: - ignored = re.compile(r'^spack-.*') - else: - ignored = re.compile(r'^(Allwmake|spack-).*') - - files = [ - f for f in glob.glob("*") - if os.path.isfile(f) and not ignored.search(f) - ] - for f in files: - install(f, self.projectdir) - - # Having wmake and ~source is actually somewhat pointless... - # Install 'etc' before 'bin' (for symlinks) - dirs = ['etc', 'bin', 'wmake'] - if '+source' in spec: - dirs.extend(['applications', 'src', 'tutorials']) - - for d in dirs: - install_tree( - d, - join_path(self.projectdir, d), - symlinks=True) - - dirs = ['platforms'] - if '+source' in spec: - dirs.extend(['doc']) - - # Install platforms (and doc) skipping intermediate targets - relative_ignore_paths = ['src', 'applications', 'html', 'Guides'] - ignore = lambda p: p in relative_ignore_paths - for d in dirs: - install_tree( - d, - join_path(self.projectdir, d), - ignore=ignore, - symlinks=True) - - self.install_write_location() - self.install_links() - - def install_links(self): - """Add symlinks into bin/, lib/ (eg, for other applications)""" - # Make build log visible - it contains OpenFOAM-specific information - with working_dir(self.projectdir): - os.symlink( - join_path('.spack', 'build.out'), - join_path('log.' + str(self.foam_arch))) - - if not self.config['link']: - return - - # ln -s platforms/linux64GccXXX/lib lib - with working_dir(self.projectdir): - if os.path.isdir(self.archlib): - os.symlink(self.archlib, 'lib') - - # (cd bin && ln -s ../platforms/linux64GccXXX/bin/* .) - with working_dir(join_path(self.projectdir, 'bin')): - for f in [ - f for f in glob.glob(join_path('..', self.archbin, "*")) - if os.path.isfile(f) - ]: - os.symlink(f, os.path.basename(f)) - - -# ----------------------------------------------------------------------------- - -class OpenfoamArch(object): - """OpenfoamArch represents architecture/compiler settings for OpenFOAM. - The string representation is WM_OPTIONS. - - Keywords - label-size=[True] supports int32/int64 - compile-option[=RpathOpt] - mplib[=USERMPI] - """ - - #: Map spack compiler names to OpenFOAM compiler names - # By default, simply capitalize the first letter - compiler_mapping = {'intel': 'icc'} - - def __init__(self, spec, **kwargs): - # Some user settings, to be adjusted manually or via variants - self.compiler = None # <- %compiler - self.arch_option = '' # Eg, -march=knl - self.label_size = None # <- +int64 - self.precision_option = 'DP' # <- +float32 - self.compile_option = kwargs.get('compile-option', 'RpathOpt') - self.arch = None - self.options = None - self.rule = None - self.mplib = kwargs.get('mplib', 'USERMPI') - - # Normally support WM_LABEL_OPTION, but not yet for foam-extend - if '+int64' in spec: - self.label_size = '64' - elif kwargs.get('label-size', True): - self.label_size = '32' - - if '+float32' in spec: - self.precision_option = 'SP' - - # Processor/architecture-specific optimizations - if '+knl' in spec: - self.arch_option = '-march=knl' - - # spec.architecture.platform is like `uname -s`, but lower-case - platform = spec.architecture.platform - - # spec.architecture.target is like `uname -m` - target = spec.architecture.target - - if platform == 'linux': - if target == 'x86_64': - platform += '64' - elif target == 'ia64': - platform += 'IA64' - elif target == 'armv7l': - platform += 'ARM7' - elif target == 'aarch64': - platform += 'ARM64' - elif target == 'ppc64': - platform += 'PPC64' - elif target == 'ppc64le': - platform += 'PPC64le' - elif platform == 'darwin': - if target == 'x86_64': - platform += '64' - # ... and others? - - self.arch = platform - - # Capitalized version of the compiler name, which usually corresponds - # to how OpenFOAM will camel-case things. - # Use compiler_mapping to handing special cases. - # Also handle special compiler options (eg, KNL) - comp = spec.compiler.name - - if comp in self.compiler_mapping: - comp = self.compiler_mapping[comp] - comp = comp.capitalize() - - self.compiler = comp - self.rule = self.arch + self.compiler - - # Build WM_OPTIONS - # ---- - # WM_LABEL_OPTION=Int$WM_LABEL_SIZE - # WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION - # or - # WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION - # ---- - self.options = ''.join([ - self.rule, - self.precision_option, - ('Int' + self.label_size if self.label_size else ''), - self.compile_option]) - - def __str__(self): - return self.options - - def __repr__(self): - return str(self) - - def foam_dict(self): - """Returns a dictionary for OpenFOAM prefs, bashrc, cshrc.""" - return dict([ - ('WM_COMPILER', self.compiler), - ('WM_LABEL_SIZE', self.label_size), - ('WM_PRECISION_OPTION', self.precision_option), - ('WM_COMPILE_OPTION', self.compile_option), - ('WM_MPLIB', self.mplib), - ]) - - def _rule_directory(self, projdir=None, general=False): - """The wmake/rules/ compiler directory""" - if general: - relative = os.path.join('wmake', 'rules', 'General') - else: - relative = os.path.join('wmake', 'rules', self.rule) - if projdir: - return os.path.join(projdir, relative) - else: - return relative - - def has_rule(self, projdir): - """Verify that a wmake/rules/ compiler rule exists in the project - directory. - """ - # Insist on a wmake rule for this architecture/compiler combination - rule_dir = self._rule_directory(projdir) - - if not os.path.isdir(rule_dir): - raise InstallError( - 'No wmake rule for {0}'.format(self.rule)) - if not re.match(r'.+Opt$', self.compile_option): - raise InstallError( - "WM_COMPILE_OPTION={0} is not type '*Opt'" - .format(self.compile_option)) - return True - - def create_rules(self, projdir, foam_pkg): - """ Create cRpathOpt,c++RpathOpt and mplibUSER,mplibUSERMPI - rules in the specified project directory. - The compiler rules are based on the respective cOpt,c++Opt rules - but with additional rpath information for the OpenFOAM libraries. - - The rpath rules allow wmake to use spack information with minimal - modification to OpenFOAM. - The rpath is used for the installed libpath (continue to use - LD_LIBRARY_PATH for values during the build). - """ - # Note: the 'c' rules normally don't need rpath, since they are just - # used for statically linked wmake utilities, but left in anyhow. - - # rpath for installed OpenFOAM libraries - rpath = '{0}{1}'.format( - foam_pkg.compiler.cxx_rpath_arg, - join_path(foam_pkg.projectdir, foam_pkg.archlib)) - - user_mpi = mplib_content(foam_pkg.spec) - rule_dir = self._rule_directory(projdir) - - with working_dir(rule_dir): - # Compiler: copy existing cOpt,c++Opt and modify '*DBUG' value - for lang in ['c', 'c++']: - src = '{0}Opt'.format(lang) - dst = '{0}{1}'.format(lang, self.compile_option) - with open(src, 'r') as infile: - with open(dst, 'w') as outfile: - for line in infile: - line = line.rstrip() - outfile.write(line) - if re.match(r'^\S+DBUG\s*=', line): - outfile.write(' ') - outfile.write(rpath) - elif re.match(r'^\S+OPT\s*=', line): - if self.arch_option: - outfile.write(' ') - outfile.write(self.arch_option) - outfile.write('\n') - - # MPI rules - for mplib in ['mplibUSER', 'mplibUSERMPI']: - with open(mplib, 'w') as out: - out.write("""# Use mpi from spack ({name})\n -PFLAGS = {FLAGS} -PINC = {PINC} -PLIBS = {PLIBS} -""".format(**user_mpi)) - -# ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam-org/package.py b/var/spack/repos/builtin/packages/openfoam-org/package.py index 4b017096cc..7f26bd87d9 100644 --- a/var/spack/repos/builtin/packages/openfoam-org/package.py +++ b/var/spack/repos/builtin/packages/openfoam-org/package.py @@ -17,7 +17,7 @@ ############################################################################## # # Notes -# - The openfoam-org package is a modified version of the openfoam-com package. +# - The openfoam-org package is a modified version of the openfoam package. # If changes are needed here, consider if they should also be applied there. # # - Building with boost/cgal is not included, since some of the logic is not @@ -40,11 +40,11 @@ import os import llnl.util.tty as tty from spack import * -from spack.pkg.builtin.openfoam_com import add_extra_files -from spack.pkg.builtin.openfoam_com import write_environ -from spack.pkg.builtin.openfoam_com import rewrite_environ_files -from spack.pkg.builtin.openfoam_com import mplib_content -from spack.pkg.builtin.openfoam_com import OpenfoamArch +from spack.pkg.builtin.openfoam import add_extra_files +from spack.pkg.builtin.openfoam import write_environ +from spack.pkg.builtin.openfoam import rewrite_environ_files +from spack.pkg.builtin.openfoam import mplib_content +from spack.pkg.builtin.openfoam import OpenfoamArch class OpenfoamOrg(Package): @@ -76,7 +76,6 @@ class OpenfoamOrg(Package): variant('source', default=True, description='Install library/application sources and tutorials') - provides('openfoam') depends_on('mpi') depends_on('zlib') depends_on('flex', type='build') @@ -128,7 +127,7 @@ class OpenfoamOrg(Package): return settings def setup_environment(self, spack_env, run_env): - # This should be similar to the openfoam-com package, + # This should be similar to the openfoam package, # but sourcing the etc/bashrc here seems to exit with an error. # ... this needs to be examined in more detail. # diff --git a/var/spack/repos/builtin/packages/openfoam/1612-spack-patches.patch b/var/spack/repos/builtin/packages/openfoam/1612-spack-patches.patch new file mode 100644 index 0000000000..00679c4c1d --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/1612-spack-patches.patch @@ -0,0 +1,876 @@ +############################################################################# +# This patch for OpenFOAM-1612 comprises the following changes: +# +# bin/foamEtcFile +# - Adjust to cope with spack naming (eg, openfoam-com-1612-abcxzy). +# Lets us avoid a needless directory layer. +# +# etc/bashrc +# - improved robustness when sourcing. +# - source top-level prefs.sh first (for sysadmin changes) +# +# etc/config.*/settings +# - write job control information to the user directory +# - site/ directory under the OpenFOAM project dir, not its parent dir +# +# etc/config.*/mpi +# - added USERMPI as place for spack mpi information +# +# mgridgen, zoltan: +# - make location configurable +# +# metis, scotch: +# - also check lib path (not just lib64) +# +# All issues patched here are addressed in OpenFOAM-1706 and later. +# +# ESI-OpenCFD www.openfoam.com +# +############################################################################# +--- OpenFOAM-v1612+.orig/bin/foamEtcFile 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-plus/bin/foamEtcFile 2017-12-18 17:48:35.043291205 +0100 +@@ -4,164 +4,235 @@ + # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + # \\ / O peration | + # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +-# \\/ M anipulation | ++# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + #------------------------------------------------------------------------------- + # License +-# This file is part of OpenFOAM. +-# +-# OpenFOAM is free software: you can redistribute it and/or modify it +-# under the terms of the GNU General Public License as published by +-# the Free Software Foundation, either version 3 of the License, or +-# (at your option) any later version. +-# +-# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-# for more details. +-# +-# You should have received a copy of the GNU General Public License +-# along with OpenFOAM. If not, see . ++# This file is part of OpenFOAM, licensed under GNU General Public License ++# . + # + # Script + # foamEtcFile + # + # Description +-# Locate user/group/shipped file with semantics similar to the +-# ~OpenFOAM/fileName expansion. ++# Locate user/group/other file as per '#includeEtc'. ++# ++# The -mode option can be used to allow chaining from personal settings ++# to site-wide settings. + # +-# The -mode option can be used to allow chaining from +-# personal settings to site-wide settings. ++# For example, within the user ~/.OpenFOAM//config.sh/compiler: ++# \code ++# eval $(foamEtcFile -sh -mode=go config.sh/compiler) ++# \endcode + # +-# For example, within the user ~/.OpenFOAM//prefs.sh: ++# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure ++# that system prefs are respected: + # \code +-# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ +-# && _foamSource $foamPrefs ++# eval $(foamEtcFile -sh -mode=o prefs.sh) ++# eval $(foamEtcFile -sh -mode=ug prefs.sh) + # \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) ++# + # Note +-# This script must exist in $FOAM_INST_DIR/OpenFOAM-/bin/ +-# or $FOAM_INST_DIR/openfoam/bin/ (for the debian version) ++# This script must exist in one of these locations: ++# - $WM_PROJECT_INST_DIR/OpenFOAM-/bin ++# - $WM_PROJECT_INST_DIR/openfoam-/bin ++# - $WM_PROJECT_INST_DIR/openfoam/bin (debian version) + # + #------------------------------------------------------------------------------- +-usage() { +- [ "${optQuiet:-$optSilent}" = true ] && exit 1 +- +- exec 1>&2 +- while [ "$#" -ge 1 ]; do echo "$1"; shift; done ++printHelp() { + cat< any combination of u(user), g(group), o(other) +- -prefix specify an alternative installation prefix +- -quiet suppress all normal output +- -silent suppress all stderr output +- -version specify an alternative OpenFOAM version +- in the form Maj.Min.Rev (eg, 1.7.0) +- -help print the usage +- +- Locate user/group/shipped file with semantics similar to the +- ~OpenFOAM/fileName expansion. +- +- The options can also be specified as a single character +- (eg, '-q' instead of '-quiet'), but must not be grouped. +- +- Exit status +- 0 when the file is found. Print resolved path to stdout. +- 1 for miscellaneous errors. +- 2 when the file is not found. ++ -all (-a) Return all files (otherwise stop after the first match) ++ -list (-l) List directories or files to be checked ++ -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, ...) ++ -csh Produce output suitable for a csh or sh 'eval' ++ -csh-verbose As per -csh with additional verbosity ++ -sh Produce output suitable for a csh or sh 'eval' ++ -sh-verbose As per -sh with additional verbosity ++ -quiet (-q) Suppress all normal output ++ -silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output ++ -help Print the usage ++ ++Locate user/group/other file as per '#includeEtc' ++ ++Do not group single character options. ++Equivalent options: ++ | -mode=MODE | -mode MODE | -m MODE ++ | -prefix=DIR | -prefix DIR | -p DIR ++ | -version=VER | -version VER | -v VER ++ ++Exit status ++ 0 when the file is found. Print resolved path to stdout. ++ 1 for miscellaneous errors. ++ 2 when the file is not found. + + USAGE +- exit 1 ++ exit 0 # A clean exit + } + +-#------------------------------------------------------------------------------- + +-# the bin dir: +-binDir="${0%/*}" ++unset optQuiet optSilent ++# Report error and exit ++die() ++{ ++ [ "${optQuiet:-$optSilent}" = true ] && exit 1 ++ exec 1>&2 ++ echo ++ echo "Error encountered:" ++ while [ "$#" -ge 1 ]; do echo " $1"; shift; done ++ echo ++ echo "See 'foamEtcFile -help' for usage" ++ echo ++ exit 1 ++} + +-# the project dir: +-projectDir="${binDir%/bin}" ++#------------------------------------------------------------------------------- ++binDir="${0%/*}" # The bin dir ++projectDir="${binDir%/bin}" # The project dir ++prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR) + +-# the prefix dir (same as $FOAM_INST_DIR): +-prefixDir="${projectDir%/*}" ++# Could not resolve projectDir, prefixDir? (eg, called as ./bin/foamEtcFile) ++if [ "$prefixDir" = "$projectDir" ] ++then ++ binDir="$(cd $binDir && pwd -L)" ++ projectDir="${binDir%/bin}" ++ prefixDir="${projectDir%/*}" ++fi ++projectDirName="${projectDir##*/}" # The project directory name + +-# the name used for the project directory +-projectDirName="${projectDir##*/}" ++projectVersion="$WM_PROJECT_VERSION" # Empty? - will be treated later ++userDir="$HOME/.OpenFOAM" # Hard-coded as per foamVersion.H + +-# version number used for debian packaging +-unset versionNum ++#------------------------------------------------------------------------------- + ++# Guess project version or simply get the stem part of the projectDirName. ++# Handle standard and debian naming conventions. + # +-# handle standard and debian naming convention ++# - projectVersion: update unless already set + # +-case "$projectDirName" in +-OpenFOAM-*) # standard naming convention OpenFOAM- +- version="${projectDirName##OpenFOAM-}" +- ;; ++# Helper variables: ++# - dirBase (for reassembling name) == projectDirName without the version ++# - versionNum (debian packaging) ++unset dirBase versionNum ++guessVersion() ++{ ++ local version ++ ++ case "$projectDirName" in ++ (OpenFOAM-* | openfoam-*) ++ # Standard naming: OpenFOAM- or openfoam- ++ dirBase="${projectDirName%%-*}-" ++ version="${projectDirName#*-}" ++ version="${version%%*-}" # Extra safety, eg openfoam-version-packager ++ ;; ++ ++ (openfoam[0-9]*) ++ # Debian naming: openfoam ++ 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 + +-openfoam[0-9]* | openfoam-dev) # debian naming convention 'openfoam' +- versionNum="${projectDirName##openfoam}" +- case "$versionNum" in +- ??) # convert 2 digit version number to decimal delineated +- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@') +- ;; +- ???) # convert 3 digit version number to decimal delineated +- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@') ++ # Ignore special treatment if no decimals were inserted. ++ [ "${#version}" -gt "${#versionNum}" ] || unset versionNum + ;; +- ????) # convert 4 digit version number to decimal delineated +- version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@') +- ;; +- *) # failback - use current environment setting +- version="$WM_PROJECT_VERSION" ++ ++ (*) ++ die "unknown/unsupported naming convention for '$projectDirName'" + ;; + esac +- ;; + +-*) +- echo "Error : unknown/unsupported naming convention" +- exit 1 +- ;; +-esac ++ # Set projectVersion if required ++ : ${projectVersion:=$version} ++} + + +-# default mode is 'ugo' +-mode=ugo +-unset optAll optList optQuiet optSilent ++# Set projectVersion and update versionNum, projectDirName accordingly ++setVersion() ++{ ++ projectVersion="$1" + +-# parse options ++ # 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}" ++} ++ ++ ++optMode=ugo # Default mode is always 'ugo' ++unset optAll optList optShell optVersion ++ ++# Parse options + while [ "$#" -gt 0 ] + do + case "$1" in +- -h | -help) +- usage ++ -h | -help*) ++ printHelp + ;; + -a | -all) + optAll=true ++ unset optShell + ;; + -l | -list) + optList=true ++ unset optShell ++ ;; ++ -list-test) ++ optList='test' ++ unset optShell ++ ;; ++ -csh | -sh | -csh-verbose | -sh-verbose) ++ optShell="${1#-}" ++ unset optAll ++ ;; ++ -mode=[ugo]*) ++ optMode="${1#*=}" ++ ;; ++ -prefix=/*) ++ prefixDir="${1#*=}" ++ prefixDir="${prefixDir%/}" ++ ;; ++ -version=*) ++ optVersion="${1#*=}" + ;; + -m | -mode) +- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" +- mode="$2" +- +- # sanity check: +- case "$mode" in +- *u* | *g* | *o* ) +- ;; +- *) +- usage "'$1' option with invalid mode '$mode'" +- ;; +- esac ++ optMode="$2" + shift ++ # Sanity check. Handles missing argument too. ++ case "$optMode" in ++ ([ugo]*) ++ ;; ++ (*) ++ die "invalid mode '$optMode'" ++ ;; ++ esac + ;; + -p | -prefix) +- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" +- prefixDir="$2" ++ [ "$#" -ge 2 ] || die "'$1' option requires an argument" ++ prefixDir="${2%/}" + shift + ;; + -q | -quiet) +@@ -171,13 +242,8 @@ + optSilent=true + ;; + -v | -version) +- [ "$#" -ge 2 ] || usage "'$1' option requires an argument" +- version="$2" +- # convert x.y.z -> xyz version (if installation looked like debian) +- if [ -n "$versionNum" ] +- then +- versionNum=$(echo "$version" | sed -e 's@\.@@g') +- fi ++ [ "$#" -ge 2 ] || die "'$1' option requires an argument" ++ optVersion="$2" + shift + ;; + --) +@@ -185,7 +251,7 @@ + break + ;; + -*) +- usage "unknown option: '$*'" ++ die "unknown option: '$1'" + ;; + *) + break +@@ -195,11 +261,28 @@ + done + + +-# debugging: +-# echo "Installed locations:" +-# for i in projectDir prefixDir projectDirName version versionNum ++#------------------------------------------------------------------------------- ++ ++if [ -n "$optVersion" ] ++then ++ setVersion $optVersion ++elif [ -z "$projectVersion" ] ++then ++ guessVersion ++fi ++ ++# Updates: ++# - projectDir for changes via -prefix or -version ++# - groupDir for changes via -prefix ++projectDir="$prefixDir/$projectDirName" ++groupDir="${WM_PROJECT_SITE:-$prefixDir/site}" ++ ++ ++# Debugging: ++# echo "Installed locations:" 1>&2 ++# for i in projectDir prefixDir projectDirName projectVersion + # do +-# eval echo "$i=\$$i" ++# eval echo "$i=\$$i" 1>&2 + # done + + +@@ -210,30 +293,18 @@ + + # Define the various places to be searched: + unset dirList +-case "$mode" in +-*u*) # user +- userDir="$HOME/.${WM_PROJECT:-OpenFOAM}" +- dirList="$dirList $userDir/$version $userDir" ++case "$optMode" in (*u*) # (U)ser ++ dirList="$dirList $userDir/$projectVersion $userDir" + ;; + esac + +-case "$mode" in +-*g*) # group (site) +- siteDir="${WM_PROJECT_SITE:-$prefixDir/site}" +- dirList="$dirList $siteDir/$version $siteDir" ++case "$optMode" in (*g*) # (G)roup == site ++ dirList="$dirList $groupDir/$projectVersion $groupDir" + ;; + esac + +-case "$mode" in +-*o*) # other (shipped) +- if [ -n "$versionNum" ] +- then +- # debian packaging +- dirList="$dirList $prefixDir/openfoam$versionNum/etc" +- else +- # standard packaging +- dirList="$dirList $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc" +- fi ++case "$optMode" in (*o*) # (O)ther == shipped ++ dirList="$dirList $projectDir/etc" + ;; + esac + set -- $dirList +@@ -244,50 +315,87 @@ + # + + exitCode=0 +-if [ "$optList" = true ] ++if [ -n "$optList" ] + then + +- # list directories, or potential file locations +- [ "$nArgs" -le 1 ] || usage ++ # List directories, or potential file locations ++ [ "$nArgs" -le 1 ] || \ ++ die "-list expects 0 or 1 filename, but $nArgs provided" + +- # a silly combination, but -quiet does have precedence +- [ "$optQuiet" = true ] && exit 0 ++ # A silly combination, but -quiet does have precedence ++ [ -n "$optQuiet" ] && exit 0 ++ ++ # Test for directory or file too? ++ if [ "$optList" = "test" ] ++ then ++ exitCode=2 # Fallback to a general error (file not found) + +- for dir +- do + if [ "$nArgs" -eq 1 ] + then +- echo "$dir/$fileName" ++ for dir ++ do ++ resolved="$dir/$fileName" ++ if [ -f "$resolved" ] ++ then ++ echo "$resolved" ++ exitCode=0 # OK ++ fi ++ done + else +- echo "$dir" ++ for dir ++ do ++ if [ -d "$dir" ] ++ then ++ echo "$dir" ++ exitCode=0 # OK ++ fi ++ done + fi +- done ++ else ++ for dir ++ do ++ echo "$dir${fileName:+/}$fileName" ++ done ++ fi + + else + +- [ "$nArgs" -eq 1 ] || usage ++ [ "$nArgs" -eq 1 ] || die "One filename expected - $nArgs provided" + +- # general error, eg file not found +- exitCode=2 ++ exitCode=2 # Fallback to a general error (file not found) + + for dir + do + if [ -f "$dir/$fileName" ] + then + exitCode=0 +- if [ "$optQuiet" = true ] +- then ++ [ -n "$optQuiet" ] && break ++ ++ case "$optShell" in ++ (*verbose) ++ echo "Using: $dir/$fileName" 1>&2 ++ ;; ++ esac ++ ++ case "$optShell" in ++ csh*) ++ echo "source $dir/$fileName" + break +- else ++ ;; ++ sh*) ++ echo ". $dir/$fileName" ++ break ++ ;; ++ *) + echo "$dir/$fileName" +- [ "$optAll" = true ] || break +- fi ++ [ -n "$optAll" ] || break ++ ;; ++ esac + fi + done + + fi + +- + exit $exitCode + + #------------------------------------------------------------------------------ +--- OpenFOAM-v1612+.orig/etc/bashrc 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/bashrc 2017-03-22 16:05:05.751237072 +0100 +@@ -42,7 +42,8 @@ + # + # Please set to the appropriate path if the default is not correct. + # +-[ $BASH_SOURCE ] && FOAM_INST_DIR=$(\cd ${BASH_SOURCE%/*/*/*} && \pwd -P) || \ ++rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}" ++[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \ + FOAM_INST_DIR=$HOME/$WM_PROJECT + # FOAM_INST_DIR=~$WM_PROJECT + # FOAM_INST_DIR=/opt/$WM_PROJECT +@@ -135,8 +136,10 @@ + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + . $WM_PROJECT_DIR/etc/config.sh/functions + +-# Add in preset user or site preferences: +-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` ++# Override definitions via prefs, with 'other' first so the sys-admin ++# can provide base values independent of WM_PROJECT_SITE ++_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.sh` ++_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.sh` + + # Evaluate command-line parameters and record settings for later + # these can be used to set/unset values, or specify alternative pref files +diff -uw OpenFOAM-v1612+.orig/etc/cshrc OpenFOAM-v1612+/etc/cshrc +--- OpenFOAM-v1612+.orig/etc/cshrc 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/cshrc 2017-03-22 16:04:51.839291067 +0100 +@@ -148,8 +148,10 @@ + # Source files, possibly with some verbosity + alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*' + +-# Add in preset user or site preferences: +-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh` ++# Override definitions via prefs, with 'other' first so the sys-admin ++# can provide base values independent of WM_PROJECT_SITE ++_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.csh` ++_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.csh` + + # Evaluate command-line parameters and record settings for later + # these can be used to set/unset values, or specify alternative pref files +--- OpenFOAM-v1612+.orig/etc/config.sh/settings 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/config.sh/settings 2017-12-21 20:40:50.109036445 +0100 +@@ -141,7 +141,7 @@ + #------------------------------------------------------------------------------ + + # Location of the jobControl directory +-export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl ++export FOAM_JOB_DIR="$HOME/.OpenFOAM/jobControl" + + # wmake configuration + export WM_DIR=$WM_PROJECT_DIR/wmake +@@ -198,8 +198,12 @@ + unset siteDir + + _foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN +-# Make sure to pick up dummy versions of external libraries last +-_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy ++_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last ++if [ -n "$FOAM_EXT_LIBBIN" ] # External libraries (allowed to be unset) ++then ++ _foamAddLib $FOAM_EXT_LIBBIN ++fi ++_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN + + # Compiler settings + # ~~~~~~~~~~~~~~~~~ +--- OpenFOAM-v1612+.orig/etc/config.csh/settings 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/config.csh/settings 2017-12-21 20:37:24.301773802 +0100 +@@ -137,7 +137,7 @@ + #------------------------------------------------------------------------------ + + # Location of the jobControl directory +-setenv FOAM_JOB_DIR $WM_PROJECT_INST_DIR/jobControl ++setenv FOAM_JOB_DIR "$HOME/.OpenFOAM/jobControl" + + # wmake configuration + setenv WM_DIR $WM_PROJECT_DIR/wmake +@@ -196,8 +196,11 @@ + unset siteDir + + _foamAddPath ${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN} +-# Make sure to pick up dummy versions of external libraries last +-_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}:${FOAM_EXT_LIBBIN}:${FOAM_LIBBIN}/dummy ++_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last ++if ( $?FOAM_EXT_LIBBIN ) then # External libraries (allowed to be unset) ++ _foamAddLib $FOAM_EXT_LIBBIN ++endif ++_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN} + + # Compiler settings + # ~~~~~~~~~~~~~~~~~ +--- OpenFOAM-v1612+.orig/etc/config.sh/mpi 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/config.sh/mpi 2017-03-29 13:55:57.507980699 +0200 +@@ -75,8 +75,15 @@ + _foamAddMan $MPI_ARCH_PATH/share/man + ;; + ++USERMPI) ++ # Use an arbitrary, user-specified mpi implementation ++ export FOAM_MPI=mpi-user ++ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-user` ++ ;; ++ + SYSTEMMPI) + export FOAM_MPI=mpi-system ++ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-system` + + if [ -z "$MPI_ROOT" ] + then +--- OpenFOAM-v1612+.orig/etc/config.csh/mpi 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/etc/config.csh/mpi 2017-03-29 13:56:36.347835938 +0200 +@@ -71,8 +71,15 @@ + _foamAddMan $MPI_ARCH_PATH/share/man + breaksw + ++case USERMPI: ++ # Use an arbitrary, user-specified mpi implementation ++ setenv FOAM_MPI mpi-user ++ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-user` ++ breaksw ++ + case SYSTEMMPI: + setenv FOAM_MPI mpi-system ++ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-system` + + if ( ! ($?MPI_ROOT) ) then + echo +--- OpenFOAM-v1612+.orig/src/fvAgglomerationMethods/Allwmake 2017-01-02 09:56:17.578558265 +0100 ++++ OpenFOAM-v1612+/src/fvAgglomerationMethods/Allwmake 2017-04-18 18:58:38.236795902 +0200 +@@ -4,9 +4,13 @@ + # Parse arguments for library compilation + . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments + +-export ParMGridGen=$WM_THIRD_PARTY_DIR/ParMGridGen-1.0 ++unset MGRIDGEN_ARCH_PATH ++if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mgridgen) ++then ++ . $settings ++fi + +-if [ -e "$FOAM_LIBBIN/libMGridGen.so" ] ++if [ -e "$MGRIDGEN_ARCH_PATH/include/mgridgen.h" ] + then + wmake $targetType MGridGenGamgAgglomeration + fi +--- OpenFOAM-v1612+.orig/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options 2017-01-02 09:56:17.578558265 +0100 ++++ OpenFOAM-v1612+/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options 2017-04-18 18:59:16.860662811 +0200 +@@ -1,15 +1,9 @@ +-/* Needs ParMGridGen environment variable set. (see Allwmake script) */ +- +-TYPE_REAL= +-#if defined(WM_SP) +-TYPE_REAL=-DTYPE_REAL +-#endif +- + EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ +- -I$(ParMGridGen)/MGridGen/Lib/lnInclude \ +- -I$(ParMGridGen)/MGridGen/IMlib/lnInclude \ +- $(TYPE_REAL) ++ -I$(MGRIDGEN_ARCH_PATH)/include + + LIB_LIBS = \ +- -L$(FOAM_EXT_LIBBIN) -lMGridGen ++ -L$(FOAM_EXT_LIBBIN) \ ++ -L$(MGRIDGEN_ARCH_PATH)/lib \ ++ -L$(MGRIDGEN_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ ++ -lmgrid +--- OpenFOAM-v1612+.orig/src/parallel/decompose/Allwmake 2017-03-21 16:34:44.599021283 +0100 ++++ OpenFOAM-v1612+/src/parallel/decompose/Allwmake 2017-03-21 16:28:57.243969660 +0100 +@@ -36,6 +36,7 @@ + + # Library + [ -r $FOAM_EXT_LIBBIN/libmetis.so ] || \ ++ [ -r $METIS_ARCH_PATH/lib/libmetis.so ] || \ + [ -r $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so ] || \ + [ "${METIS_ARCH_PATH##*-}" = system ] || { + echo "$warning (missing library)" +@@ -90,6 +91,7 @@ + + # Library + [ -r $FOAM_EXT_LIBBIN/libscotch.so ] || \ ++ [ -r $SCOTCH_ARCH_PATH/lib/libscotch.so ] || \ + [ -r $SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so ] || \ + [ "${SCOTCH_ARCH_PATH##*-}" = system ] || { + echo "$warning (missing library)" +--- OpenFOAM-v1612+.orig/src/parallel/decompose/metisDecomp/Make/options 2017-03-21 16:34:25.383075328 +0100 ++++ OpenFOAM-v1612+/src/parallel/decompose/metisDecomp/Make/options 2017-03-21 16:30:15.727758338 +0100 +@@ -8,6 +8,7 @@ + * to support central, non-thirdparty installations + */ + LIB_LIBS = \ ++ -L$(METIS_ARCH_PATH)/lib \ + -L$(METIS_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(FOAM_EXT_LIBBIN) \ + -lmetis +--- OpenFOAM-v1612+.orig/src/parallel/decompose/ptscotchDecomp/Make/options 2017-03-21 16:34:34.607049385 +0100 ++++ OpenFOAM-v1612+/src/parallel/decompose/ptscotchDecomp/Make/options 2017-03-21 16:30:00.479799399 +0100 +@@ -16,6 +16,7 @@ + * to support central, non-thirdparty installations + */ + LIB_LIBS = \ ++ -L$(SCOTCH_ARCH_PATH)/lib \ + -L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(FOAM_EXT_LIBBIN) \ + -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \ +--- OpenFOAM-v1612+.orig/src/parallel/decompose/scotchDecomp/Make/options 2017-03-21 16:34:39.159036582 +0100 ++++ OpenFOAM-v1612+/src/parallel/decompose/scotchDecomp/Make/options 2017-03-21 16:29:46.719836452 +0100 +@@ -16,6 +16,7 @@ + * to support central, non-thirdparty installations + */ + LIB_LIBS = \ ++ -L$(SCOTCH_ARCH_PATH)/lib \ + -L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(FOAM_EXT_LIBBIN) \ + -lscotch \ +--- OpenFOAM-v1612+.orig/applications/utilities/mesh/manipulation/renumberMesh/Allwmake 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/applications/utilities/mesh/manipulation/renumberMesh/Allwmake 2017-03-28 11:13:35.222727218 +0200 +@@ -4,20 +4,35 @@ + # Parse arguments for compilation (at least for error catching) + . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments + +-export COMPILE_FLAGS='' +-export LINK_FLAGS='' ++unset COMP_FLAGS LINK_FLAGS + + if [ -f "${FOAM_LIBBIN}/libSloanRenumber.so" ] + then +- echo "Found libSloanRenumber.so -- enabling Sloan renumbering support." ++ echo " found libSloanRenumber -- enabling sloan renumbering support." + export LINK_FLAGS="${LINK_FLAGS} -lSloanRenumber" + fi + +-if [ -f "${ZOLTAN_ARCH_PATH}/lib/libzoltan.a" -a -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ] ++if [ -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ] + then +- echo "Found libzoltanRenumber.so -- enabling zoltan renumbering support." +- export COMPILE_FLAGS="-DFOAM_USE_ZOLTAN" +- export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan" ++ if [ -z "$ZOLTAN_ARCH_PATH" ] ++ then ++ # Optional: get ZOLTAN_ARCH_PATH ++ if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) ++ then ++ . $settings ++ fi ++ fi ++ ++ for libdir in lib "lib${WM_COMPILER_LIB_ARCH}" ++ do ++ if [ -f "$ZOLTAN_ARCH_PATH/$libdir/libzoltan.a" ] ++ then ++ echo " found libzoltanRenumber -- enabling zoltan renumbering support." ++ export COMP_FLAGS="-DFOAM_USE_ZOLTAN" ++ export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L$ZOLTAN_ARCH_PATH/$libdir -lzoltan" ++ break ++ fi ++ done + fi + + wmake $targetType +--- OpenFOAM-v1612+.orig/src/renumber/Allwmake 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/src/renumber/Allwmake 2017-03-28 11:10:22.195543610 +0200 +@@ -5,14 +5,11 @@ + targetType=libso + . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments + +-## Get ZOLTAN_ARCH_PATH +-#if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) +-#then +-# . $settings +-# echo "using ZOLTAN_ARCH_PATH=$ZOLTAN_ARCH_PATH" +-#else +-# echo "Error: no config.sh/zoltan settings" +-#fi ++# Optional: get ZOLTAN_ARCH_PATH ++if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) ++then ++ . $settings ++fi + + wmake $targetType renumberMethods + +--- OpenFOAM-v1612+.orig/src/renumber/zoltanRenumber/Make/options 2016-12-23 15:22:59.000000000 +0100 ++++ OpenFOAM-v1612+/src/renumber/zoltanRenumber/Make/options 2017-03-28 11:50:46.484343848 +0200 +@@ -4,10 +4,13 @@ + EXE_INC = \ + /* -DFULLDEBUG -g -O0 */ \ + $(PFLAGS) $(PINC) \ ++ ${c++LESSWARN} \ + -I$(FOAM_SRC)/renumber/renumberMethods/lnInclude \ + -I$(ZOLTAN_ARCH_PATH)/include/ \ + -I$(LIB_SRC)/meshTools/lnInclude + + LIB_LIBS = \ +- /* -L$(ZOLTAN_ARCH_PATH)/lib -lzoltan */ \ ++ -L$(ZOLTAN_ARCH_PATH)/lib \ ++ -L$(ZOLTAN_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ ++ -lzoltan \ + -lmeshTools diff --git a/var/spack/repos/builtin/packages/openfoam/1806-have-kahip.patch b/var/spack/repos/builtin/packages/openfoam/1806-have-kahip.patch new file mode 100644 index 0000000000..3e10a44145 --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/1806-have-kahip.patch @@ -0,0 +1,17 @@ +--- OpenFOAM-v1806/wmake/scripts/have_kahip-ORIG 2018-06-28 16:39:32.000000000 +0200 ++++ OpenFOAM-v1806/wmake/scripts/have_kahip 2018-08-11 13:37:18.250219013 +0200 +@@ -83,10 +83,10 @@ + # FOAM_EXT_LIBBIN is allowed to be unset + library=$(findFirstFile \ + $FOAM_EXT_LIBBIN/$library \ +- $METIS_ARCH_PATH/lib/$static \ +- $METIS_ARCH_PATH/lib/$library \ +- $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \ +- $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ ++ $KAHIP_ARCH_PATH/lib/$static \ ++ $KAHIP_ARCH_PATH/lib/$library \ ++ $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \ ++ $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + elif isSystem "$KAHIP_ARCH_PATH" + then diff --git a/var/spack/repos/builtin/packages/openfoam/common/README b/var/spack/repos/builtin/packages/openfoam/common/README new file mode 100644 index 0000000000..c4ba87b5cc --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/README @@ -0,0 +1 @@ +Helper tools for packaging applications/libraries dependent on OpenFOAM. diff --git a/var/spack/repos/builtin/packages/openfoam/common/README-spack b/var/spack/repos/builtin/packages/openfoam/common/README-spack new file mode 100644 index 0000000000..83b606dda1 --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/README-spack @@ -0,0 +1,15 @@ +Additional notes for spack +-------------------------- + +OpenFOAM largely manages its own PATH and LD_LIBRARY_PATH settings. +The spack build currently also follows this and only provides +a minimum modules environment. + +The variable FOAM_PROJECT_DIR points to the location of the OpenFOAM project +and shall contain a $FOAM_PROJECT_DIR/etc/bashrc file for OpenFOAM. +The variable FOAM_INST_DIR may also be provided for older OpenFOAM versions. + +It is the aim for the future to use spack to provide the environment directly, +but this still needs more work. + +2017-04-18 diff --git a/var/spack/repos/builtin/packages/openfoam/common/change-sitedir.sh b/var/spack/repos/builtin/packages/openfoam/common/change-sitedir.sh new file mode 100644 index 0000000000..61d9c3ea8b --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/change-sitedir.sh @@ -0,0 +1,94 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see . +# +# Script +# . change-sitedir.sh PREFIX [SUFFIX] +# +# Shortcuts (prefix) +# -prefix "$WM_PROJECT_INST_DIR/site" +# -project "$WM_PROJECT_DIR/site" +# -none remove from environment +# +# Shortcuts (suffix) +# -platforms "platforms/$WM_OPTIONS" +# +# Description +# Change WM_PROJECT_SITE, FOAM_SITE_APPBIN, FOAM_SITE_LIBBIN +# and the respective entries in PATH, LD_LIBRARY_PATH. +# +# This can be useful when temporarily reassigning the site directory +# when packaging OpenFOAM. +# +# The suffix value should normally include "platforms/$WM_OPTIONS" +# +# Example +# . /path/change-sitedir.sh -prefix -platforms +# +# corresponds to the standard site location: +# +# $WM_PROJECT_INST_DIR/site{/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS} +# +#------------------------------------------------------------------------------ + +if [ "$#" -ge 1 ] +then + prefix="$1" + suffix="$2" + + foamOldDirs="$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN \ + $WM_PROJECT_SITE $WM_PROJECT_INST_DIR/site $WM_PROJECT_DIR/site" + foamClean=$WM_PROJECT_DIR/bin/foamCleanPath + if [ -x "$foamClean" ] + then + cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" + cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ + && LD_LIBRARY_PATH="$cleaned" + fi + + case "$suffix" in + -plat*) suffix="platforms/$WM_OPTIONS" ;; + esac + case "$prefix" in + -prefix) prefix="$WM_PROJECT_INST_DIR/site" ;; + -project) prefix="$WM_PROJECT_DIR/site" ;; + -none) unset prefix ;; + esac + + if [ -n "$prefix" ] + then + export WM_PROJECT_SITE="$prefix" + + prefix="$prefix/${WM_PROJECT_VERSION:-unknown}${suffix:+/}${suffix}" + + export FOAM_SITE_APPBIN="$prefix/bin" + export FOAM_SITE_LIBBIN="$prefix/lib" + PATH="$FOAM_SITE_APPBIN:$PATH" + LD_LIBRARY_PATH="$FOAM_SITE_LIBBIN:$LD_LIBRARY_PATH" + else + unset WM_PROJECT_SITE FOAM_SITE_APPBIN FOAM_SITE_LIBBIN + fi +fi + +unset foamClean foamOldDirs cleaned prefix suffix + +#------------------------------------------------------------------------------ diff --git a/var/spack/repos/builtin/packages/openfoam/common/change-userdir.sh b/var/spack/repos/builtin/packages/openfoam/common/change-userdir.sh new file mode 100644 index 0000000000..d126fcfe5d --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/change-userdir.sh @@ -0,0 +1,94 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see . +# +# Script +# . change-userdir.sh PREFIX [SUFFIX] +# +# Shortcuts (prefix) +# -home "$HOME/OpenFOAM/$USER-$WM_PROJECT_VERSION" +# -none remove from environment +# +# Shortcuts (suffix) +# -platforms "platforms/$WM_OPTIONS" +# +# Description +# Change WM_PROJECT_USER_DIR, FOAM_USER_APPBIN, FOAM_USER_LIBBIN +# and the respective entries in PATH, LD_LIBRARY_PATH. +# Also adjusts FOAM_RUN. +# +# This can be useful with compiling additional OpenFOAM programs +# (that use FOAM_USER_APPBIN, FOAM_USER_LIBBIN for their build), +# to avoid conflicts with the normal user bin/lib files. +# +# The suffix value should normally include "platforms/$WM_OPTIONS" +# +# Example +# . /path/change-userdir.sh -home -platforms +# +# corresponds to the standard user location: +# +# $HOME/OpenFOAM/$USER-$WM_PROJECT_VERSION/platforms/$WM_OPTIONS +# +#------------------------------------------------------------------------------ + +if [ "$#" -ge 1 ] +then + prefix="$1" + suffix="$2" + + foamOldDirs="$FOAM_USER_APPBIN $FOAM_USER_LIBBIN" + foamClean=$WM_PROJECT_DIR/bin/foamCleanPath + if [ -x "$foamClean" ] + then + cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" + cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ + && LD_LIBRARY_PATH="$cleaned" + fi + + case "$suffix" in + -plat*) suffix="platforms/$WM_OPTIONS" ;; + esac + case "$prefix" in + -home) prefix="$HOME/OpenFOAM/$USER-${WM_PROJECT_VERSION:-unknown}" ;; + -none) unset prefix ;; + esac + + if [ -n "$prefix" ] + then + export WM_PROJECT_USER_DIR="$prefix" + export FOAM_RUN="$prefix/run" + + prefix="$prefix${suffix:+/}${suffix}" + export FOAM_USER_APPBIN="$prefix/bin" + export FOAM_USER_LIBBIN="$prefix/lib" + + PATH="$FOAM_USER_APPBIN:$PATH" + LD_LIBRARY_PATH="$FOAM_USER_LIBBIN:$LD_LIBRARY_PATH" + else + unset WM_PROJECT_USER_DIR FOAM_RUN FOAM_USER_APPBIN FOAM_USER_LIBBIN + fi +fi + +unset foamClean foamOldDirs cleaned prefix suffix + +#------------------------------------------------------------------------------ diff --git a/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake b/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake new file mode 100755 index 0000000000..a98d7d0db2 --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake @@ -0,0 +1,37 @@ +#!/bin/bash +# Build wrapper script - FOAM_INST_DIR is only required by foam-extend +export FOAM_INST_DIR=$(cd .. && pwd -L) +. $PWD/etc/bashrc '' # No arguments +mkdir -p $FOAM_APPBIN $FOAM_LIBBIN 2>/dev/null # Allow interrupt +echo "Build openfoam with SPACK ($@)" +echo "WM_PROJECT_DIR = $WM_PROJECT_DIR" + +# Prefer spack-specific Allwmake if it exists +if [ -f Allwmake-spack ] +then + ./Allwmake-spack $@ # Pass arguments +else + ./Allwmake $@ # Pass arguments + + # Generate manpages + if [ -x bin/tools/foamCreateManpage ] + then + bin/tools/foamCreateManpage -gzip || \ + echo "ignore problems generating manpages" + fi +fi + + +# Link non-dummy MPI_FOAM type to parent-dir, where rpath can find it +if [ "${FOAM_MPI:=dummy}" != dummy -a -d "$FOAM_LIBBIN/$FOAM_MPI" ] +then +( + cd "$FOAM_LIBBIN" || exit 1 + for i in $FOAM_MPI/lib*.so + do + [ -f $i ] && ln -sf $i "${i##*/}" + done +) +fi + +# ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam/common/spack-derived-Allwmake b/var/spack/repos/builtin/packages/openfoam/common/spack-derived-Allwmake new file mode 100755 index 0000000000..02741f1d13 --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/common/spack-derived-Allwmake @@ -0,0 +1,34 @@ +#!/bin/bash +# The openfoam providers must export 'FOAM_PROJECT_DIR' +# The derived package is expected to supply an appropriate +# or file. + +[ -d "$FOAM_PROJECT_DIR" -a -f "$FOAM_PROJECT_DIR/etc/bashrc" ] || { + echo "Error: no PROJECT=$FOAM_PROJECT_DIR" 1>&2 + echo " or no etc/bashrc found" 1>&2 + exit 1 +} + +export FOAM_INST_DIR=$(cd $FOAM_PROJECT_DIR/.. && pwd -L) # Needed by foam-extend +. $FOAM_PROJECT_DIR/etc/bashrc '' # No arguments + +# Package-specific adjustments +[ -f spack-config.sh ] && . ./spack-config.sh '' # No arguments + +echo "========================================" +date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown" +echo "Build with ${WM_PROJECT}-${WM_PROJECT_VERSION}" +echo " WM_PROJECT_DIR = $WM_PROJECT_DIR" +echo " $WM_COMPILER $WM_COMPILER_TYPE compiler" +echo " $WM_OPTIONS - with $WM_MPLIB $FOAM_MPI" +echo + +# Prefer spack-specific Allwmake if it exists +if [ -f Allwmake-spack ] +then + ./Allwmake-spack $@ # Pass arguments +else + ./Allwmake $@ # Pass arguments +fi + +# ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam/package.py b/var/spack/repos/builtin/packages/openfoam/package.py new file mode 100644 index 0000000000..4cf12a19b1 --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam/package.py @@ -0,0 +1,933 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +# +# Author: Mark Olesen +# +# Legal Notice +# ------------ +# OPENFOAM is a trademark owned by OpenCFD Ltd +# (producer and distributor of the OpenFOAM software via www.openfoam.com). +# The trademark information must remain visible and unadulterated in this +# file and via the "spack info" and comply with the term set by +# http://openfoam.com/legal/trademark-policy.php +# +# This file is not part of OpenFOAM, nor does it constitute a component of an +# OpenFOAM distribution. +# +############################################################################## +# +# Notes +# - mpi handling: WM_MPLIB=USERMPI and use spack to populate an appropriate +# configuration and generate wmake rules for 'USER' and 'USERMPI' +# mpi implementations. +# +# - Resolution of flex, zlib needs more attention (within OpenFOAM) +# - +paraview: +# depends_on should just be 'paraview+plugins' but that resolves poorly. +# Workaround: use preferred variants "+plugins +qt" +# packages: +# paraview: +# variants: +plugins +qt +# in ~/.spack/packages.yaml +# +# Known issues +# - Combining +zoltan with +int64 has not been tested, but probably won't work. +# - Combining +mgridgen with +int64 or +float32 probably won't work. +# +# The spack 'develop' version of openfoam retains the upstream +# WM_PROJECT_VERSION=plus naming internally. +# +############################################################################## +import glob +import re +import os + +from spack import * +from spack.util.environment import EnvironmentModifications +import llnl.util.tty as tty + + +# Not the nice way of doing things, but is a start for refactoring +__all__ = [ + 'add_extra_files', + 'write_environ', + 'rewrite_environ_files', + 'mplib_content', + 'foam_add_path', + 'foam_add_lib', + 'OpenfoamArch', +] + + +def add_extra_files(foam_pkg, common, local, **kwargs): + """Copy additional common and local files into the stage.source_path + from the openfoam/common and the package/assets directories, + respectively + """ + outdir = foam_pkg.stage.source_path + + indir = join_path(os.path.dirname(__file__), 'common') + for f in common: + tty.info('Added file {0}'.format(f)) + install(join_path(indir, f), join_path(outdir, f)) + + indir = join_path(foam_pkg.package_dir, 'assets') + for f in local: + tty.info('Added file {0}'.format(f)) + install(join_path(indir, f), join_path(outdir, f)) + + +def format_export(key, value): + """Format key,value pair as 'export' with newline for POSIX shell. + A leading '#' for key adds a comment character to the entire line. + A value of 'None' corresponds to 'unset'. + """ + if key.startswith('#'): + return '## export {0}={1}\n'.format(re.sub(r'^#+\s*', '', key), value) + elif value is None: + return 'unset {0}\n'.format(key) + else: + return 'export {0}={1}\n'.format(key, value) + + +def format_setenv(key, value): + """Format key,value pair as 'setenv' with newline for C-shell. + A leading '#' for key adds a comment character to the entire line. + A value of 'None' corresponds to 'unsetenv'. + """ + if key.startswith('#'): + return '## setenv {0} {1}\n'.format(re.sub(r'^#+\s*', '', key), value) + elif value is None: + return 'unsetenv {0}\n'.format(key) + else: + return 'setenv {0} {1}\n'.format(key, value) + + +def _write_environ_entries(outfile, environ, formatter): + """Write environment settings as 'export' or 'setenv'. + If environ is a dict, write in sorted order. + If environ is a list, write pair-wise. + Also descends into sub-dict and sub-list, but drops the key. + """ + if isinstance(environ, dict): + for key in sorted(environ): + entry = environ[key] + if isinstance(entry, dict): + _write_environ_entries(outfile, entry, formatter) + elif isinstance(entry, list): + _write_environ_entries(outfile, entry, formatter) + else: + outfile.write(formatter(key, entry)) + elif isinstance(environ, list): + for item in environ: + outfile.write(formatter(item[0], item[1])) + + +def _write_environ_file(output, environ, formatter): + """Write environment settings as 'export' or 'setenv'. + If environ is a dict, write in sorted order. + If environ is a list, write pair-wise. + Also descends into sub-dict and sub-list, but drops the key. + """ + with open(output, 'w') as outfile: + outfile.write('# spack generated\n') + _write_environ_entries(outfile, environ, formatter) + outfile.write('# spack\n') + + +def write_environ(environ, **kwargs): + """Write environment settings as 'export' or 'setenv'. + If environ is a dict, write in sorted order. + If environ is a list, write pair-wise. + + Keyword Options: + posix[=None] If set, the name of the POSIX file to rewrite. + cshell[=None] If set, the name of the C-shell file to rewrite. + """ + rcfile = kwargs.get('posix', None) + if rcfile: + _write_environ_file(rcfile, environ, format_export) + rcfile = kwargs.get('cshell', None) + if rcfile: + _write_environ_file(rcfile, environ, format_setenv) + + +def rewrite_environ_files(environ, **kwargs): + """Use filter_file to rewrite (existing) POSIX shell or C-shell files. + Keyword Options: + posix[=None] If set, the name of the POSIX file to rewrite. + cshell[=None] If set, the name of the C-shell file to rewrite. + """ + rcfile = kwargs.get('posix', None) + if rcfile and os.path.isfile(rcfile): + for k, v in environ.items(): + regex = r'^(\s*export\s+{0})=.*$'.format(k) + if not v: + replace = r'unset {0} #SPACK: unset'.format(k) + elif v.startswith('#'): + replace = r'unset {0} {1}'.format(k, v) + else: + replace = r'\1={0}'.format(v) + filter_file(regex, replace, rcfile, backup=False) + + rcfile = kwargs.get('cshell', None) + if rcfile and os.path.isfile(rcfile): + for k, v in environ.items(): + regex = r'^(\s*setenv\s+{0})\s+.*$'.format(k) + if not v: + replace = r'unsetenv {0} #SPACK: unset'.format(k) + elif v.startswith('#'): + replace = r'unsetenv {0} {1}'.format(k, v) + else: + replace = r'\1 {0}'.format(v) + filter_file(regex, replace, rcfile, backup=False) + + +def foam_add_path(*args): + """A string with args prepended to 'PATH'""" + return '"' + ':'.join(args) + ':${PATH}"' + + +def foam_add_lib(*args): + """A string with args prepended to 'LD_LIBRARY_PATH'""" + return '"' + ':'.join(args) + ':${LD_LIBRARY_PATH}"' + + +def pkglib(package, pre=None): + """Get lib64 or lib from package prefix. + + Optional parameter 'pre' to provide alternative prefix + """ + libdir = package.prefix.lib64 + if not os.path.isdir(libdir): + libdir = package.prefix.lib + if pre: + return join_path(pre, os.path.basename(libdir)) + else: + return libdir + + +def mplib_content(spec, pre=None): + """The mpi settings (from spack) for the OpenFOAM wmake includes, which + allows later reuse within OpenFOAM. + + Optional parameter 'pre' to provide alternative prefix + """ + mpi_spec = spec['mpi'] + bin = mpi_spec.prefix.bin + inc = mpi_spec.prefix.include + lib = pkglib(mpi_spec) + + libname = 'mpi' + if 'mpich' in mpi_spec.name: + libname = 'mpich' + + if pre: + bin = join_path(pre, os.path.basename(bin)) + inc = join_path(pre, os.path.basename(inc)) + lib = join_path(pre, os.path.basename(lib)) + else: + pre = mpi_spec.prefix + + info = { + 'name': '{0}-{1}'.format(mpi_spec.name, mpi_spec.version), + 'prefix': pre, + 'include': inc, + 'bindir': bin, + 'libdir': lib, + 'FLAGS': '-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX', + 'PINC': '-I{0}'.format(inc), + 'PLIBS': '-L{0} -l{1}'.format(lib, libname), + } + return info + + +# ----------------------------------------------------------------------------- + +class Openfoam(Package): + """OpenFOAM is a GPL-opensource C++ CFD-toolbox. + This offering is supported by OpenCFD Ltd, + producer and distributor of the OpenFOAM software via www.openfoam.com, + and owner of the OPENFOAM trademark. + OpenCFD Ltd has been developing and releasing OpenFOAM since its debut + in 2004. + """ + + maintainers = ['olesenm'] + homepage = "http://www.openfoam.com/" + url = "https://sourceforge.net/projects/openfoamplus/files/v1706/OpenFOAM-v1706.tgz" + git = "https://develop.openfoam.com/Development/OpenFOAM-plus.git" + list_url = "https://sourceforge.net/projects/openfoamplus/files/" + list_depth = 2 + + version('develop', branch='develop', submodules='True') + version('1906', 'ab7017e262c0c0fceec55c31e2153180') + version('1812_190531', 'a4b416838a8a76fdec22706a33c96de3') + version('1812', '6a315687b3601eeece7ff7c7aed3d9a5') + version('1806', 'bb244a3bde7048a03edfccffc46c763f') + version('1712', '6ad92df051f4d52c7d0ec34f4b8eb3bc') + version('1706', '630d30770f7b54d6809efbf94b7d7c8f') + version('1612', 'ca02c491369150ab127cbb88ec60fbdf') + + variant('float32', default=False, + description='Use single-precision') + variant('int64', default=False, + description='With 64-bit labels') + variant('knl', default=False, + description='Use KNL compiler settings') + variant('kahip', default=False, + description='With kahip decomposition') + variant('metis', default=False, + description='With metis decomposition') + variant('scotch', default=True, + description='With scotch/ptscotch decomposition') + variant('zoltan', default=False, + description='With zoltan renumbering') + # TODO?# variant('scalasca', default=False, + # TODO?# description='With scalasca profiling') + variant('mgridgen', default=False, description='With mgridgen support') + variant('paraview', default=False, + description='Build paraview plugins and runtime post-processing') + variant('vtk', default=False, + description='With VTK runTimePostProcessing') + variant('source', default=True, + description='Install library/application sources and tutorials') + + depends_on('mpi') + + # After 1712, could suggest openmpi+thread_multiple for collated output + # but particular mixes of mpi versions and InfiniBand may not work so well + # conflicts('^openmpi~thread_multiple', when='@1712:') + + depends_on('zlib') + depends_on('fftw') + depends_on('boost') + depends_on('cgal') + # The flex restriction is ONLY to deal with a spec resolution clash + # introduced by the restriction within scotch! + depends_on('flex@:2.6.1,2.6.4:') + depends_on('cmake', type='build') + + # Require scotch with ptscotch - corresponds to standard OpenFOAM setup + depends_on('scotch~metis+mpi~int64', when='+scotch~int64') + depends_on('scotch~metis+mpi+int64', when='+scotch+int64') + depends_on('kahip', when='+kahip') + depends_on('metis@5:', when='+metis') + depends_on('metis+int64', when='+metis+int64') + # mgridgen is statically linked + depends_on('parmgridgen', when='+mgridgen', type='build') + depends_on('zoltan', when='+zoltan') + depends_on('vtk', when='+vtk') + + # TODO?# depends_on('scalasca', when='+scalasca') + + # For OpenFOAM plugins and run-time post-processing this should just be + # 'paraview+plugins' but that resolves poorly. + # Workaround: use preferred variants "+plugins +qt" in + # ~/.spack/packages.yaml + + # 1706 ok with newer paraview but avoid pv-5.2, pv-5.3 readers + depends_on('paraview@5.4:', when='@1706:+paraview') + # 1612 plugins need older paraview + depends_on('paraview@:5.0.1', when='@1612+paraview') + + # General patches + common = ['spack-Allwmake', 'README-spack'] + assets = [] + + # Version-specific patches + patch('1612-spack-patches.patch', when='@1612') + patch('1806-have-kahip.patch', when='@1806') + + # Some user config settings + # default: 'compile-option': 'RpathOpt', + # default: 'mplib': 'USERMPI', # Use user mpi for spack + config = { + # Add links into bin/, lib/ (eg, for other applications) + 'link': False + } + + # The openfoam architecture, compiler information etc + _foam_arch = None + + # Content for etc/prefs.{csh,sh} + etc_prefs = {} + + # Content for etc/config.{csh,sh}/ files + etc_config = {} + + phases = ['configure', 'build', 'install'] + build_script = './spack-Allwmake' # From patch() method. + + # + # - End of definitions / setup - + # + + def url_for_version(self, version): + # Prior to 'v1706' and additional '+' in the naming + fmt = self.list_url + if version <= Version('1612'): + fmt += 'v{0}+/OpenFOAM-v{0}+.tgz' + else: + fmt += 'v{0}/OpenFOAM-v{0}.tgz' + return fmt.format(version, version) + + def setup_environment(self, spack_env, run_env): + """Add environment variables to the generated module file. + These environment variables come from running: + + .. code-block:: console + + $ . $WM_PROJECT_DIR/etc/bashrc + """ + + # NOTE: Spack runs setup_environment twice. + # 1) pre-build to set up the build environment + # 2) post-install to determine runtime environment variables + # The etc/bashrc is only available (with corrrect content) + # post-installation. + + bashrc = join_path(self.projectdir, 'etc', 'bashrc') + minimal = True + if os.path.isfile(bashrc): + # post-install: source the installed bashrc + try: + mods = EnvironmentModifications.from_sourcing_file( + bashrc, + clean=True, # Remove duplicate entries + blacklist=[ # Blacklist these + # Inadvertent changes + # ------------------- + 'PS1', # Leave unaffected + 'MANPATH', # Leave unaffected + + # Unneeded bits + # ------------- + # 'FOAM_SETTINGS', # Do not use with modules + # 'FOAM_INST_DIR', # Old + # 'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)', + # 'FOAM_TUTORIALS', # can be useful + # 'WM_OSTYPE', # Purely optional value + + # Third-party cruft - only used for orig compilation + # ----------------- + '[A-Z].*_ARCH_PATH', + # '(KAHIP|METIS|SCOTCH)_VERSION', + + # User-specific + # ------------- + 'FOAM_RUN', + '(FOAM|WM)_.*USER_.*', + ], + whitelist=[ # Whitelist these + 'MPI_ARCH_PATH', # Can be needed for compilation + ]) + + run_env.extend(mods) + spack_env.extend(mods) + minimal = False + tty.info('OpenFOAM bashrc env: {0}'.format(bashrc)) + except Exception: + minimal = True + + if minimal: + # pre-build or minimal environment + tty.info('OpenFOAM minimal env {0}'.format(self.prefix)) + run_env.set('FOAM_PROJECT_DIR', self.projectdir) + run_env.set('WM_PROJECT_DIR', self.projectdir) + spack_env.set('FOAM_PROJECT_DIR', self.projectdir) + spack_env.set('WM_PROJECT_DIR', self.projectdir) + for d in ['wmake', self.archbin]: # bin added automatically + run_env.prepend_path('PATH', join_path(self.projectdir, d)) + spack_env.prepend_path('PATH', join_path(self.projectdir, d)) + + def setup_dependent_environment(self, spack_env, run_env, dependent_spec): + """Location of the OpenFOAM project directory. + This is identical to the WM_PROJECT_DIR value, but we avoid that + variable since it would mask the normal OpenFOAM cleanup of + previous versions. + """ + self.setup_environment(spack_env, run_env) + + @property + def projectdir(self): + """Absolute location of project directory: WM_PROJECT_DIR/""" + return self.prefix # <- install directly under prefix + + @property + def foam_arch(self): + if not self._foam_arch: + self._foam_arch = OpenfoamArch(self.spec, **self.config) + return self._foam_arch + + @property + def archbin(self): + """Relative location of architecture-specific executables""" + return join_path('platforms', self.foam_arch, 'bin') + + @property + def archlib(self): + """Relative location of architecture-specific libraries""" + return join_path('platforms', self.foam_arch, 'lib') + + def patch(self): + """Adjust OpenFOAM build for spack. + Where needed, apply filter as an alternative to normal patching.""" + add_extra_files(self, self.common, self.assets) + + @when('@:1806') + def patch(self): + """Adjust OpenFOAM build for spack. + Where needed, apply filter as an alternative to normal patching.""" + add_extra_files(self, self.common, self.assets) + + # Avoid WM_PROJECT_INST_DIR for ThirdParty + # This modification is non-critical + edits = { + 'WM_THIRD_PARTY_DIR': + r'$WM_PROJECT_DIR/ThirdParty #SPACK: No separate third-party', + } + rewrite_environ_files( # etc/{bashrc,cshrc} + edits, + posix=join_path('etc', 'bashrc'), + cshell=join_path('etc', 'cshrc')) + + # The following filtering is non-critical. + # It simply prevents 'site' dirs at the wrong level + # (likely non-existent anyhow) from being added to + # PATH, LD_LIBRARY_PATH. + for rcdir in ['config.sh', 'config.csh']: + rcfile = join_path('etc', rcdir, 'settings') + if os.path.isfile(rcfile): + filter_file( + 'WM_PROJECT_INST_DIR/', + 'WM_PROJECT_DIR/', + rcfile, + backup=False) + + def configure(self, spec, prefix): + """Make adjustments to the OpenFOAM configuration files in their various + locations: etc/bashrc, etc/config.sh/FEATURE and customizations that + don't properly fit get placed in the etc/prefs.sh file (similiarly for + csh). + """ + # Filtering bashrc, cshrc + edits = {} + edits.update(self.foam_arch.foam_dict()) + rewrite_environ_files( # etc/{bashrc,cshrc} + edits, + posix=join_path('etc', 'bashrc'), + cshell=join_path('etc', 'cshrc')) + + # Content for etc/prefs.{csh,sh} + self.etc_prefs = { + # TODO + # 'CMAKE_ARCH_PATH': spec['cmake'].prefix, + # 'FLEX_ARCH_PATH': spec['flex'].prefix, + # 'ZLIB_ARCH_PATH': spec['zlib'].prefix, + } + + # MPI content, using MPI_ARCH_PATH + user_mpi = mplib_content(spec, '${MPI_ARCH_PATH}') + + # Content for etc/config.{csh,sh}/ files + self.etc_config = { + 'CGAL': [ + ('BOOST_ARCH_PATH', spec['boost'].prefix), + ('CGAL_ARCH_PATH', spec['cgal'].prefix), + ('LD_LIBRARY_PATH', + foam_add_lib( + pkglib(spec['boost'], '${BOOST_ARCH_PATH}'), + pkglib(spec['cgal'], '${CGAL_ARCH_PATH}'))), + ], + 'FFTW': [ + ('FFTW_ARCH_PATH', spec['fftw'].prefix), # Absolute + ('LD_LIBRARY_PATH', + foam_add_lib( + pkglib(spec['fftw'], '${BOOST_ARCH_PATH}'))), + ], + # User-defined MPI + 'mpi-user': [ + ('MPI_ARCH_PATH', spec['mpi'].prefix), # Absolute + ('LD_LIBRARY_PATH', foam_add_lib(user_mpi['libdir'])), + ('PATH', foam_add_path(user_mpi['bindir'])), + ], + 'scotch': {}, + 'kahip': {}, + 'metis': {}, + 'ensight': {}, # Disable settings + 'paraview': [], + 'gperftools': [], # Currently unused + 'vtk': [], + } + + if '+scotch' in spec: + self.etc_config['scotch'] = { + 'SCOTCH_ARCH_PATH': spec['scotch'].prefix, + # For src/parallel/decompose/Allwmake + 'SCOTCH_VERSION': 'scotch-{0}'.format(spec['scotch'].version), + } + + if '+kahip' in spec: + self.etc_config['kahip'] = { + 'KAHIP_ARCH_PATH': spec['kahip'].prefix, + } + + if '+metis' in spec: + self.etc_config['metis'] = { + 'METIS_ARCH_PATH': spec['metis'].prefix, + } + + # ParaView_INCLUDE_DIR is not used in 1812, but has no ill-effect + if '+paraview' in spec: + pvmajor = 'paraview-{0}'.format(spec['paraview'].version.up_to(2)) + self.etc_config['paraview'] = [ + ('ParaView_DIR', spec['paraview'].prefix), + ('ParaView_INCLUDE_DIR', '${ParaView_DIR}/include/' + pvmajor), + ('PV_PLUGIN_PATH', '$FOAM_LIBBIN/' + pvmajor), + ('PATH', foam_add_path('${ParaView_DIR}/bin')), + ] + + if '+vtk' in spec: + self.etc_config['vtk'] = [ + ('VTK_DIR', spec['vtk'].prefix), + ('LD_LIBRARY_PATH', + foam_add_lib(pkglib(spec['vtk'], '${VTK_DIR}'))), + ] + + # Optional + if '+mgridgen' in spec: + self.etc_config['mgridgen'] = { + 'MGRIDGEN_ARCH_PATH': spec['parmgridgen'].prefix + } + + # Optional + if '+zoltan' in spec: + self.etc_config['zoltan'] = { + 'ZOLTAN_ARCH_PATH': spec['zoltan'].prefix + } + + # Write prefs files according to the configuration. + # Only need prefs.sh for building, but install both for end-users + if self.etc_prefs: + write_environ( + self.etc_prefs, + posix=join_path('etc', 'prefs.sh'), + cshell=join_path('etc', 'prefs.csh')) + + # Adjust components to use SPACK variants + for component, subdict in self.etc_config.items(): + write_environ( + subdict, + posix=join_path('etc', 'config.sh', component), + cshell=join_path('etc', 'config.csh', component)) + + def build(self, spec, prefix): + """Build using the OpenFOAM Allwmake script, with a wrapper to source + its environment first. + Only build if the compiler is known to be supported. + """ + self.foam_arch.has_rule(self.stage.source_path) + self.foam_arch.create_rules(self.stage.source_path, self) + + args = ['-silent'] + if self.parallel: # Build in parallel? - pass as an argument + args.append('-j{0}'.format(make_jobs)) + builder = Executable(self.build_script) + builder(*args) + + def install_write_location(self): + """Set the installation location (projectdir) in bashrc,cshrc.""" + mkdirp(self.projectdir) + + # Filtering: bashrc, cshrc + edits = { + 'WM_PROJECT_DIR': self.projectdir, + } + etc_dir = join_path(self.projectdir, 'etc') + rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc + edits, + posix=join_path(etc_dir, 'bashrc'), + cshell=join_path(etc_dir, 'cshrc')) + + @when('@:1806') + def install_write_location(self): + """Set the installation location (projectdir) in bashrc,cshrc. + In 1806 and earlier, had WM_PROJECT_INST_DIR as the prefix + directory where WM_PROJECT_DIR was installed. + """ + mkdirp(self.projectdir) + projdir = os.path.basename(self.projectdir) + + # Filtering: bashrc, cshrc + edits = { + 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), + 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), + } + etc_dir = join_path(self.projectdir, 'etc') + rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc + edits, + posix=join_path(etc_dir, 'bashrc'), + cshell=join_path(etc_dir, 'cshrc')) + + def install(self, spec, prefix): + """Install under the projectdir""" + mkdirp(self.projectdir) + + # All top-level files, except spack build info and possibly Allwmake + if '+source' in spec: + ignored = re.compile(r'^spack-.*') + else: + ignored = re.compile(r'^(Allwmake|spack-).*') + + files = [ + f for f in glob.glob("*") + if os.path.isfile(f) and not ignored.search(f) + ] + for f in files: + install(f, self.projectdir) + + # Having wmake and ~source is actually somewhat pointless... + # Install 'etc' before 'bin' (for symlinks) + dirs = ['etc', 'bin', 'wmake'] + if '+source' in spec: + dirs.extend(['applications', 'src', 'tutorials']) + + for d in dirs: + install_tree( + d, + join_path(self.projectdir, d), + symlinks=True) + + dirs = ['platforms'] + if '+source' in spec: + dirs.extend(['doc']) + + # Install platforms (and doc) skipping intermediate targets + relative_ignore_paths = ['src', 'applications', 'html', 'Guides'] + ignore = lambda p: p in relative_ignore_paths + for d in dirs: + install_tree( + d, + join_path(self.projectdir, d), + ignore=ignore, + symlinks=True) + + self.install_write_location() + self.install_links() + + def install_links(self): + """Add symlinks into bin/, lib/ (eg, for other applications)""" + # Make build log visible - it contains OpenFOAM-specific information + with working_dir(self.projectdir): + os.symlink( + join_path('.spack', 'build.out'), + join_path('log.' + str(self.foam_arch))) + + if not self.config['link']: + return + + # ln -s platforms/linux64GccXXX/lib lib + with working_dir(self.projectdir): + if os.path.isdir(self.archlib): + os.symlink(self.archlib, 'lib') + + # (cd bin && ln -s ../platforms/linux64GccXXX/bin/* .) + with working_dir(join_path(self.projectdir, 'bin')): + for f in [ + f for f in glob.glob(join_path('..', self.archbin, "*")) + if os.path.isfile(f) + ]: + os.symlink(f, os.path.basename(f)) + + +# ----------------------------------------------------------------------------- + +class OpenfoamArch(object): + """OpenfoamArch represents architecture/compiler settings for OpenFOAM. + The string representation is WM_OPTIONS. + + Keywords + label-size=[True] supports int32/int64 + compile-option[=RpathOpt] + mplib[=USERMPI] + """ + + #: Map spack compiler names to OpenFOAM compiler names + # By default, simply capitalize the first letter + compiler_mapping = {'intel': 'icc'} + + def __init__(self, spec, **kwargs): + # Some user settings, to be adjusted manually or via variants + self.compiler = None # <- %compiler + self.arch_option = '' # Eg, -march=knl + self.label_size = None # <- +int64 + self.precision_option = 'DP' # <- +float32 + self.compile_option = kwargs.get('compile-option', 'RpathOpt') + self.arch = None + self.options = None + self.rule = None + self.mplib = kwargs.get('mplib', 'USERMPI') + + # Normally support WM_LABEL_OPTION, but not yet for foam-extend + if '+int64' in spec: + self.label_size = '64' + elif kwargs.get('label-size', True): + self.label_size = '32' + + if '+float32' in spec: + self.precision_option = 'SP' + + # Processor/architecture-specific optimizations + if '+knl' in spec: + self.arch_option = '-march=knl' + + # spec.architecture.platform is like `uname -s`, but lower-case + platform = spec.architecture.platform + + # spec.architecture.target is like `uname -m` + target = spec.architecture.target + + if platform == 'linux': + if target == 'x86_64': + platform += '64' + elif target == 'ia64': + platform += 'IA64' + elif target == 'armv7l': + platform += 'ARM7' + elif target == 'aarch64': + platform += 'ARM64' + elif target == 'ppc64': + platform += 'PPC64' + elif target == 'ppc64le': + platform += 'PPC64le' + elif platform == 'darwin': + if target == 'x86_64': + platform += '64' + # ... and others? + + self.arch = platform + + # Capitalized version of the compiler name, which usually corresponds + # to how OpenFOAM will camel-case things. + # Use compiler_mapping to handing special cases. + # Also handle special compiler options (eg, KNL) + comp = spec.compiler.name + + if comp in self.compiler_mapping: + comp = self.compiler_mapping[comp] + comp = comp.capitalize() + + self.compiler = comp + self.rule = self.arch + self.compiler + + # Build WM_OPTIONS + # ---- + # WM_LABEL_OPTION=Int$WM_LABEL_SIZE + # WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION + # or + # WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION + # ---- + self.options = ''.join([ + self.rule, + self.precision_option, + ('Int' + self.label_size if self.label_size else ''), + self.compile_option]) + + def __str__(self): + return self.options + + def __repr__(self): + return str(self) + + def foam_dict(self): + """Returns a dictionary for OpenFOAM prefs, bashrc, cshrc.""" + return dict([ + ('WM_COMPILER', self.compiler), + ('WM_LABEL_SIZE', self.label_size), + ('WM_PRECISION_OPTION', self.precision_option), + ('WM_COMPILE_OPTION', self.compile_option), + ('WM_MPLIB', self.mplib), + ]) + + def _rule_directory(self, projdir=None, general=False): + """The wmake/rules/ compiler directory""" + if general: + relative = os.path.join('wmake', 'rules', 'General') + else: + relative = os.path.join('wmake', 'rules', self.rule) + if projdir: + return os.path.join(projdir, relative) + else: + return relative + + def has_rule(self, projdir): + """Verify that a wmake/rules/ compiler rule exists in the project + directory. + """ + # Insist on a wmake rule for this architecture/compiler combination + rule_dir = self._rule_directory(projdir) + + if not os.path.isdir(rule_dir): + raise InstallError( + 'No wmake rule for {0}'.format(self.rule)) + if not re.match(r'.+Opt$', self.compile_option): + raise InstallError( + "WM_COMPILE_OPTION={0} is not type '*Opt'" + .format(self.compile_option)) + return True + + def create_rules(self, projdir, foam_pkg): + """ Create cRpathOpt,c++RpathOpt and mplibUSER,mplibUSERMPI + rules in the specified project directory. + The compiler rules are based on the respective cOpt,c++Opt rules + but with additional rpath information for the OpenFOAM libraries. + + The rpath rules allow wmake to use spack information with minimal + modification to OpenFOAM. + The rpath is used for the installed libpath (continue to use + LD_LIBRARY_PATH for values during the build). + """ + # Note: the 'c' rules normally don't need rpath, since they are just + # used for statically linked wmake utilities, but left in anyhow. + + # rpath for installed OpenFOAM libraries + rpath = '{0}{1}'.format( + foam_pkg.compiler.cxx_rpath_arg, + join_path(foam_pkg.projectdir, foam_pkg.archlib)) + + user_mpi = mplib_content(foam_pkg.spec) + rule_dir = self._rule_directory(projdir) + + with working_dir(rule_dir): + # Compiler: copy existing cOpt,c++Opt and modify '*DBUG' value + for lang in ['c', 'c++']: + src = '{0}Opt'.format(lang) + dst = '{0}{1}'.format(lang, self.compile_option) + with open(src, 'r') as infile: + with open(dst, 'w') as outfile: + for line in infile: + line = line.rstrip() + outfile.write(line) + if re.match(r'^\S+DBUG\s*=', line): + outfile.write(' ') + outfile.write(rpath) + elif re.match(r'^\S+OPT\s*=', line): + if self.arch_option: + outfile.write(' ') + outfile.write(self.arch_option) + outfile.write('\n') + + # MPI rules + for mplib in ['mplibUSER', 'mplibUSERMPI']: + with open(mplib, 'w') as out: + out.write("""# Use mpi from spack ({name})\n +PFLAGS = {FLAGS} +PINC = {PINC} +PLIBS = {PLIBS} +""".format(**user_mpi)) + +# ----------------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2