Repository: spack/spack

Issue:
openfoam-org build issue
Summary

Openfoam-org 4.1 and 5.0 fails on fresh centos7 and fails in package.py

### Expected Result

Build openfoam-org 


### Actual Result

openfoam-org@4.1 and @5.0 both fail with same error

### Steps to reproduce the issue

```console
yum -y install gcc gcc-gfortran gcc-c++ file git make which patch bzip2

git clone https://github.com/spack/spack.git

PATH=$PATH:~/spack/bin

#intall helper utilities for spack operation like modules
spack bootstrap

#add mdoule to CLI
source spack/share/spack/setup-env.sh


spack install gcc@6.4.0
<snip console>
spack install  openfoam-org@5.0%gcc@6.4.0
==> Installing openfoam-org
==> Using cached archive: /home/brockp/spack/var/spack/cache/openfoam-org/openfoam-org-5.0.tar.gz
==> Staging archive: /home/brockp/spack/var/spack/stage/openfoam-org-5.0-4j7ddenwnr2vqxpd7fnoigdql3esztmz/version-5.0.tar.gz
==> Created stage in /home/brockp/spack/var/spack/stage/openfoam-org-5.0-4j7ddenwnr2vqxpd7fnoigdql3esztmz
==> Applied patch 50-etc.patch
==> Applied patch 41-site.patch
==> renamed OpenFOAM-5.x-version-5.0 -> OpenFOAM-5.0
==> Added file spack-Allwmake
==> Added file README-spack
==> Added file bin/foamEtcFile
==> Error: AttributeError: 'Version' object has no attribute 'startswith'
AttributeError: AttributeError: 'Version' object has no attribute 'startswith'

/home/brockp/spack/var/spack/repos/builtin/packages/openfoam-org/package.py:216, in patch:
     16            rewrite_environ_files(  # Adjust etc/bashrc and etc/cshrc
     17                edits,
     18                posix=join_path('etc', 'bashrc'),
  >> 19                cshell=join_path('etc', 'cshrc'))
```

### Information on your system

This includes:

 1. which platform you are using
blank centos7  docker image

```
docker pull centos
```

 2. any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.)

-----

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively!

If you want to ask a question about the tool (how to use it, what it can currently do, etc.), try the `#general` channel on our Slack first. We have a welcoming community and chances are you'll get your reply faster and without opening an issue.

Other than that, thanks for taking the time to contribute to Spack!


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openfoam-org/package.py b/var/spack/repos/builtin/packages/openfoam-org/package.py
--- a/var/spack/repos/builtin/packages/openfoam-org/package.py
+++ b/var/spack/repos/builtin/packages/openfoam-org/package.py
@@ -207,8 +207,8 @@ def patch(self):
         edits = {
             'WM_THIRD_PARTY_DIR':
             r'$WM_PROJECT_DIR/ThirdParty #SPACK: No separate third-party',
-            'WM_VERSION': self.version,    # consistency
-            'FOAMY_HEX_MESH': '',          # This is horrible (unset variable?)
+            'WM_VERSION': str(self.version),  # consistency
+            'FOAMY_HEX_MESH': '',  # This is horrible (unset variable?)
         }
         rewrite_environ_files(  # Adjust etc/bashrc and etc/cshrc
             edits,


Test patch: