Repository: spack/spack

Issue:
Installation issue: hypre@2.14.0 fails due to superlu-dist patch
### Steps to reproduce the issue

```console
$ spack install hypre@2.14.0 % gcc@4.9.4
==> Installing hypre
==> Searching for binary cache of hypre
==> Warning: No Spack mirrors are currently configured
==> No binary for hypre found: installing from source
==> Using cached archive: /home/balos1/.local/src/spack/var/spack/cache/hypre/hypre-2.14.0.tar.gz
==> Staging archive: /home/balos1/.local/src/spack/var/spack/stage/hypre-2.14.0-crfkaqduba4pyg3mjxlyb6yekrdeynum/v2.14.0.tar.gz
==> Created stage in /home/balos1/.local/src/spack/var/spack/stage/hypre-2.14.0-crfkaqduba4pyg3mjxlyb6yekrdeynum
1 out of 1 hunk FAILED -- saving rejects to file src/lib/Makefile.rej
==> Patch /home/balos1/.local/src/spack/var/spack/repos/builtin/packages/hypre/superlu-dist-link.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/usr/bin/patch' '-s' '-p' '1' '-i' '/home/balos1/.local/src/spack/var/spack/repos/builtin/packages/hypre/superlu-dist-link.patch' '-d' '.'
```

### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux tux419 3.10.0-957.5.1.el7.x86_64 #1 SMP Wed Dec 19 10:46:58 EST 2018 x86_64 x86_64 x86_64 GNU/Linux
``` 

### Additional information

```console
$ spack spec --install-status <spec>
Input spec
--------------------------------
 -   hypre@2.14.0

Concretized
--------------------------------
 -   hypre@2.14.0%gcc@4.9.4~debug~int64+internal-superlu+mpi patches=da60725bfecb4595457a78750ac33b2bc67e6155d2adfdbe6125bda53e776796 +shared+superlu-dist arch=linux-rhel7-x86_64 
[+]      ^openblas@0.3.0%gcc@4.9.4 cpu_target=auto ~ilp64 patches=f1b066a4481a50678caeb7656bf3e6764f45619686ac465f257c8017a2dc1ff0 +pic+shared threads=none ~virtual_machine arch=linux-rhel7-x86_64 
[+]      ^openmpi@3.1.3%gcc@4.9.4~cuda+cxx_exceptions fabrics=auto ~java~legacylaunchers~memchecker~pmi schedulers=auto ~sqlite3~thread_multiple+vt arch=linux-rhel7-x86_64 
[+]          ^hwloc@1.11.11%gcc@4.9.4~cairo~cuda~gl+libxml2~nvml+pci+shared arch=linux-rhel7-x86_64 
[+]              ^libpciaccess@0.13.5%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^libtool@2.4.6%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                      ^m4@1.4.18%gcc@4.9.4 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-rhel7-x86_64 
[+]                          ^libsigsegv@2.11%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^pkgconf@1.6.0%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^util-macros@1.19.1%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]              ^libxml2@2.9.8%gcc@4.9.4~python arch=linux-rhel7-x86_64 
[+]                  ^libiconv@1.15%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^xz@5.2.4%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^zlib@1.2.11%gcc@4.9.4+optimize+pic+shared arch=linux-rhel7-x86_64 
[+]              ^numactl@2.0.12%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                  ^autoconf@2.69%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                      ^perl@5.26.2%gcc@4.9.4+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-rhel7-x86_64 
[+]                          ^gdbm@1.18.1%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                              ^readline@7.0%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]                                  ^ncurses@6.1%gcc@4.9.4~symlinks~termlib arch=linux-rhel7-x86_64 
[+]                  ^automake@1.16.1%gcc@4.9.4 arch=linux-rhel7-x86_64 
[+]      ^superlu-dist@6.1.0%gcc@4.9.4 build_type=RelWithDebInfo ~int64+shared arch=linux-rhel7-x86_64 
[+]          ^cmake@3.1.3%gcc@4.9.4~doc+ncurses+openssl~ownlibs~qt arch=linux-rhel7-x86_64 
[+]          ^metis@5.1.0%gcc@4.9.4 build_type=Release ~gdb~int64 patches=4991da938c1d3a1d3dea78e49bbebecba00273f98df2a656e38b83d55b281da1 ~real64+shared arch=linux-rhel7-x86_64 
[+]          ^parmetis@4.0.3%gcc@4.9.4 build_type=RelWithDebInfo ~gdb patches=4f892531eb0a807eb1b82e683a416d3e35154a455274cf9b162fb02054d11a5b,50ed2081bc939269689789942067c58b3e522c269269a430d5d34c00edbc5870,704b84f7c7444d4372cb59cca6e1209df4ef3b033bc4ee3cf50f369bce972a9d +shared arch=linux-rhel7-x86_64 

```

This started happening after #10985 which added the superlu-dist variant to the hypre package. It works fine when installing `hypre@2.15:`. Im guessing the patch for superlu-dist that is applied should be conditionally applied based on the hypre version.

@balay 


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/hypre/package.py b/var/spack/repos/builtin/packages/hypre/package.py
--- a/var/spack/repos/builtin/packages/hypre/package.py
+++ b/var/spack/repos/builtin/packages/hypre/package.py
@@ -52,7 +52,8 @@ class Hypre(Package):
     # Patch to build shared libraries on Darwin
     patch('darwin-shared-libs-for-hypre-2.13.0.patch', when='+shared@2.13.0 platform=darwin')
     patch('darwin-shared-libs-for-hypre-2.14.0.patch', when='+shared@2.14.0 platform=darwin')
-    patch('superlu-dist-link.patch')
+    patch('superlu-dist-link-2.15.0.patch', when='+superlu-dist @2.15:')
+    patch('superlu-dist-link-2.14.0.patch', when='+superlu-dist @:2.14.0')
 
     depends_on("mpi", when='+mpi')
     depends_on("blas")


Test patch: