From 820d147e083621db88c744b8c3f73872527303a3 Mon Sep 17 00:00:00 2001
From: Patrick Gartung <gartung@fnal.gov>
Date: Thu, 5 Mar 2020 15:15:40 -0600
Subject: [PATCH] Allow buildcaches keys to find public keys on the e4s mirror
 (#15361)

---
 lib/spack/spack/binary_distribution.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index e985ba75fa..f2a01e6b21 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -802,6 +802,7 @@ def get_specs(force=False, allarch=False):
 def get_keys(install=False, trust=False, force=False):
     """
     Get pgp public keys available on mirror
+    with suffix .key or .pub
     """
     if not spack.mirror.MirrorCollection():
         tty.die("Please add a spack mirror to allow " +
@@ -818,16 +819,18 @@ def get_keys(install=False, trust=False, force=False):
             tty.msg("Finding public keys in %s" % mirror_dir)
             files = os.listdir(mirror_dir)
             for file in files:
-                if re.search(r'\.key', file):
+                if re.search(r'\.key', file) or re.search(r'\.pub', file):
                     link = url_util.join(fetch_url_build_cache, file)
                     keys.add(link)
         else:
             tty.msg("Finding public keys at %s" %
                     url_util.format(fetch_url_build_cache))
-            p, links = web_util.spider(fetch_url_build_cache, depth=1)
+            # For s3 mirror need to request index.html directly
+            p, links = web_util.spider(
+                url_util.join(fetch_url_build_cache, 'index.html'), depth=1)
 
             for link in links:
-                if re.search(r'\.key', link):
+                if re.search(r'\.key', link) or re.search(r'\.pub', link):
                     keys.add(link)
 
         for link in keys:
-- 
GitLab