Repository: spack/spack

Issue:
llvm and fenics packages are named incorrectly by `spack install`
I tried to install `llvm`, but spack tries to install it as `flang-driver` (one of the resources of the `llvm` package).  A similar thing happens with `fenics`, being installed as `ffc`.  I haven't yet noticed any problems that result from this -- `clang` as provided by `llvm@8.0.0` seems to work fine when used via `spack load` in simple tests.  [I wrote a comment on the PR](https://github.com/spack/spack/pull/11568#issuecomment-501849962) that seems to have introduced it, and I'm copying some of that text inline here:

Trying to install either package (suggest using `--fake` to speed things up if you want to test this) will show `llvm` installing as `flang-driver` and `fenics` installing as `ffc`.  I've tested this out on a Mac laptop, in a Fedora 30 docker container and on a CentOS 7 machine.  `git bisect` led me to 87e6cb9f7 being the commit that changed this.

It seems that in both cases, if you load the package via `Repo.get` in a spack python shell, the `Package.name` path introduced in #11568 is not touched.  The only thing I can see in common between the two package definitions is that they use resources dicts that have keys that match the incorrect name.  I don't think any other packages are affected (tested by comparing `name` and `_name` across all packages in the builtin repo).


### Steps to reproduce the issue

Either command below should reproduce with a fresh spack clone

```console
$ spack install llvm
$ spack install fenics
...
```

### Error Message

I'm not sure if it's considered an error, really.  The relevant output from `spack install llvm` looks something like this:

```console
==> Installing flang-driver
==> Searching for binary cache of flang-driver
==> Warning: No Spack mirrors are currently configured
==> No binary for flang-driver found: installing from source
==> Building flang-driver [CMakePackage]
==> Successfully installed flang-driver
```

### Information on your system

Tested on:
- Fedora 30 docker image with python = 2.7.16 and python3 = 3.7.3
- CentOS7 with python = 2.7.15 and python3 = 3.4.9
- MacOS Mojave python = 2.7.10 and python3 = 3.7.3

most recently at d21bec996


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/fenics/package.py b/var/spack/repos/builtin/packages/fenics/package.py
--- a/var/spack/repos/builtin/packages/fenics/package.py
+++ b/var/spack/repos/builtin/packages/fenics/package.py
@@ -117,13 +117,13 @@ class Fenics(CMakePackage):
     for release in releases:
         version(release['version'], release['md5'], url=base_url.format(
             pkg='dolfin', version=release['version']))
-        for name, md5 in release['resources'].items():
-            resource(name=name,
-                     url=base_url.format(pkg=name, **release),
+        for rname, md5 in release['resources'].items():
+            resource(name=rname,
+                     url=base_url.format(pkg=rname, **release),
                      md5=md5,
                      destination='depends',
                      when='@{version}'.format(**release),
-                     placement=name)
+                     placement=rname)
 
     def cmake_is_on(self, option):
         return 'ON' if option in self.spec else 'OFF'
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -525,32 +525,32 @@ class Llvm(CMakePackage):
         if release['version'] == 'develop':
             version(release['version'], svn=release['repo'])
 
-            for name, repo in release['resources'].items():
-                resource(name=name,
+            for rname, repo in release['resources'].items():
+                resource(name=rname,
                          svn=repo,
-                         destination=resources[name]['destination'],
+                         destination=resources[rname]['destination'],
                          when='@%s%s' % (release['version'],
-                                         resources[name].get('variant', "")),
-                         placement=resources[name].get('placement', None))
+                                         resources[rname].get('variant', "")),
+                         placement=resources[rname].get('placement', None))
         else:
             version(release['version'], release['md5'], url=llvm_url % release)
 
-            for name, md5 in release['resources'].items():
-                resource(name=name,
-                         url=resources[name]['url'] % release,
+            for rname, md5 in release['resources'].items():
+                resource(name=rname,
+                         url=resources[rname]['url'] % release,
                          md5=md5,
-                         destination=resources[name]['destination'],
+                         destination=resources[rname]['destination'],
                          when='@%s%s' % (release['version'],
-                                         resources[name].get('variant', "")),
-                         placement=resources[name].get('placement', None))
+                                         resources[rname].get('variant', "")),
+                         placement=resources[rname].get('placement', None))
 
     for release in flang_releases:
         if release['version'] == 'develop':
             version('flang-' + release['version'], git=flang_llvm_url, branch=release['branch'])
 
-            for name, branch in release['resources'].items():
-                flang_resource = flang_resources[name]
-                resource(name=name,
+            for rname, branch in release['resources'].items():
+                flang_resource = flang_resources[rname]
+                resource(name=rname,
                          git=flang_resource['git'],
                          branch=branch,
                          destination=flang_resource['destination'],
@@ -560,9 +560,9 @@ class Llvm(CMakePackage):
         else:
             version('flang-' + release['version'], git=flang_llvm_url, commit=release['commit'])
 
-            for name, commit in release['resources'].items():
-                flang_resource = flang_resources[name]
-                resource(name=name,
+            for rname, commit in release['resources'].items():
+                flang_resource = flang_resources[rname]
+                resource(name=rname,
                          git=flang_resource['git'],
                          commit=commit,
                          destination=flang_resource['destination'],


Test patch: