Repository: spack/spack

Issue:
Installation issue: cp2k and quantum-espresso build failure with the most recent ELPA
### Steps to reproduce the issue

```console
$ spack install cp2k +elpa
$ spack install quantum-espresso +elpa
```


### Error message

<details><summary>Error message</summary>

For `cp2k`
<pre>
     1031    F90-F-0004-Unable to open MODULE file elpa_constants.mod (/local/ningli12/spack-stage/spack-stage-cp2k-2023.1-3iudyyzaijhgqzkdizzh5sacb
             z4jznaq/spack-src/src/fm/cp_fm_elpa.F: 44)
     1032    F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted
</pre>

For `quantum-espresso`
<pre>
     7294    F90-F-0004-Unable to open MODULE file elpa.mod (/local/ningli12/spack-stage/spack-stage-quantum-espresso-7.3-ur5pdnsv3cokvw7cpfrypbt62q
             phsbxr/spack-src/EPW/src/qdabs.f90: 1814)
     7295    F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted
</pre></details>


### Information on your system

* **Spack:** 0.22.0.dev0 (f9e9fab2daa1f43b49f58425f50b6a7e66bd137b)
* **Python:** 3.9.13
* **Platform:** linux-rhel8-zen4
* **Concretizer:** clingo

### Additional information

This bug was introduced by https://github.com/spack/spack/pull/42539. Earlier ELPA versions before 2023.05.001 works fine.

As can be seen both applications suffered from the same error. The newly added ELPA version 2023.11.001-patched had the **patched** suffix as part of the version number - this is the problem.

When both application tried to locate the Fortran module files from ELPA, they expected to find the module files in `elpa-2023.11.001-patched-<hash_id>/include/elpa_openmp-2023.11.001-patched/modules`. But the ELPA build actually install the module files in  `elpa-2023.11.001-patched-<hash_id>/include/elpa_openmp-2023.11.001/modules/` (note the missing **patched** suffix).

I believe this is a packaging issue with ELPA and should be fixed in ELPA's recipe.

@naromero77 May I ask you to have a look at this as you authored https://github.com/spack/spack/pull/42539?  




### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Thanks for reporting this issue and triaging the problem. This patched version has been a source of headaches.

This package does not have a maintainer at the moment. I would recommend that you just use the older version for now until this latest patch can get fixed. I am not able to fix this at the moment. I would prefer not to eliminate this version, but maybe that is something to consider if it is a show stopper for people.



Resolving patch:
diff --git a/var/spack/repos/builtin/packages/elpa/package.py b/var/spack/repos/builtin/packages/elpa/package.py
--- a/var/spack/repos/builtin/packages/elpa/package.py
+++ b/var/spack/repos/builtin/packages/elpa/package.py
@@ -98,7 +98,7 @@ def headers(self):
 
         # upstream sometimes adds tarball suffixes not part of the internal version
         elpa_version = str(self.spec.version)
-        for vsuffix in ("_bugfix",):
+        for vsuffix in ("_bugfix", "-patched"):
             if elpa_version.endswith(vsuffix):  # implementation of py3.9 removesuffix
                 elpa_version = elpa_version[: -len(vsuffix)]
 


Test patch: