diff options
author | Alberto Invernizzi <9337627+albestro@users.noreply.github.com> | 2023-12-05 12:37:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 12:37:57 +0100 |
commit | 3547bcb51714872e4fc735a657b38ecc6eeae30c (patch) | |
tree | 21e85ae9495e076d03db6768d255018b559d5334 | |
parent | 53b528f6494d971bf8f476a8ad30daf34f1eb9e3 (diff) | |
download | spack-3547bcb51714872e4fc735a657b38ecc6eeae30c.tar.gz spack-3547bcb51714872e4fc735a657b38ecc6eeae30c.tar.bz2 spack-3547bcb51714872e4fc735a657b38ecc6eeae30c.tar.xz spack-3547bcb51714872e4fc735a657b38ecc6eeae30c.zip |
openfoam-org: fix for being able to build manually checked out repository (#41000)
* grep WM_PROJECT_VERSION from etc/bashrc
This fixes the problem when building from a manually checked out repo
which might have a different version wrt the one defined in the spack
package (e.g. anything later than 5.0 is known as 5.x by the build
system)
* patch applies to just 5.0, in newer versions it is already addressed
In `5.20171030` there's a commit
https://github.com/OpenFOAM/OpenFOAM-5.x/commit/c66fba323c348012c2d4a75b9091406e1b3bcc31
very similar (almost identical) to what the patch `50-etc.patch` does.
So the patch should not be applied to other than `5.0` otherwise it errors.
References:
- https://github.com/OpenFOAM/OpenFOAM-5.x/commits/20171030/etc/bashrc
- https://github.com/OpenFOAM/OpenFOAM-5.x/blob/197d9d3bf20ac0641a8fe4f57be6a6325ca834b1/etc/bashrc#L45-L47
-rw-r--r-- | var/spack/repos/builtin/packages/openfoam-org/package.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/openfoam-org/package.py b/var/spack/repos/builtin/packages/openfoam-org/package.py index 01d57489ac..e3bf0bfb28 100644 --- a/var/spack/repos/builtin/packages/openfoam-org/package.py +++ b/var/spack/repos/builtin/packages/openfoam-org/package.py @@ -120,7 +120,7 @@ class OpenfoamOrg(Package): sha256="05d17e17f94e6fe8188a9c0b91ed34c9b62259414589d908c152a4c40fe6b7e2", when="@7", ) - patch("50-etc.patch", when="@5.0:5.9") + patch("50-etc.patch", when="@5.0") patch("41-etc.patch", when="@4.1") patch("41-site.patch", when="@4.1:") patch("240-etc.patch", when="@:2.4.0") @@ -236,8 +236,24 @@ class OpenfoamOrg(Package): # to build correctly! parent = os.path.dirname(self.stage.source_path) original = os.path.basename(self.stage.source_path) - target = "OpenFOAM-{0}".format(self.version) - # Could also grep through etc/bashrc for WM_PROJECT_VERSION + + # Grep for WM_PROJECT_VERSION in etc/bashrc + # e.g. "export WM_PROJECT_VERSION=5.x" + # + # note: WM_PROJECT is assumed to be OpenFOAM and the project folder is assumed to + # be "OpenFOAM-${WM_PROJECT_VERSION}" + target = None + with open(join_path(self.stage.source_path, "etc/bashrc"), "r") as bashrc_file: + import re + + for line in bashrc_file.readlines(): + m = re.match("export WM_PROJECT_VERSION=(.*)", line) + if m: + target = f"OpenFOAM-{m.group(1)}" + break + if target is None: + raise InstallError("Failed to infer projet directory name from build script.") + with working_dir(parent): if original != target and not os.path.lexists(target): os.rename(original, target) |