From 0f1a1ae94e9b5f6e147bf13dae44a3af8d46c8fa Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 12 Jun 2018 12:33:47 -0500 Subject: Add trailing slash when spidering URLs for versions (#8429) By default, if a package does not specify a list_url and does not download from a common repository, Spack runs dirname on the package URL. Given a URL like https://root.cern.ch/download/root_v6.09.02.source.tar.gz, this returns https://root.cern.ch/download. However, https://root.cern.ch/download gives a 404, while https://root.cern.ch/download/ works just fine. Note that some servers *don't* work with a trailing slash, so this tries with and without the slash. This will double the number of URLs searched but the slowdown should only affect the "spack versions" command. --- lib/spack/spack/util/web.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py index f694b49e7a..b9f94fcc35 100644 --- a/lib/spack/spack/util/web.py +++ b/lib/spack/spack/util/web.py @@ -286,6 +286,13 @@ def find_versions_of_archive(archive_urls, list_url=None, list_depth=0): for aurl in archive_urls: list_urls.add(spack.url.find_list_url(aurl)) + # Add '/' to the end of the URL. Some web servers require this. + additional_list_urls = set() + for lurl in list_urls: + if not lurl.endswith('/'): + additional_list_urls.add(lurl + '/') + list_urls.update(additional_list_urls) + # Grab some web pages to scrape. pages = {} links = set() -- cgit v1.2.3-60-g2f50