diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/test/url_parse.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/url.py | 17 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py index 1466698dbf..c4718d56b8 100644 --- a/lib/spack/spack/test/url_parse.py +++ b/lib/spack/spack/test/url_parse.py @@ -154,6 +154,20 @@ class UrlParseTest(unittest.TestCase): 'foo-bar', '1.21', 'http://example.com/foo_bar-1.21.tar.gz') + def test_version_gitlab(self): + self.check( + 'vtk', '7.0.0', + 'https://gitlab.kitware.com/vtk/vtk/repository/' + 'archive.tar.bz2?ref=v7.0.0') + self.check( + 'icet', '1.2.3', + 'https://gitlab.kitware.com/icet/icet/repository/' + 'archive.tar.gz?ref=IceT-1.2.3') + self.check( + 'foo', '42.1337', + 'http://example.com/org/foo/repository/' + 'archive.zip?ref=42.1337bar') + def test_version_github(self): self.check( 'yajl', '1.0.5', diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py index 85311ba64c..a1eec6067e 100644 --- a/lib/spack/spack/url.py +++ b/lib/spack/spack/url.py @@ -106,19 +106,22 @@ def split_url_extension(path): 1. https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7.tgz?raw=true 2. http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz + 3. https://gitlab.kitware.com/vtk/vtk/repository/archive.tar.bz2?ref=v7.0.0 In (1), the query string needs to be stripped to get at the - extension, but in (2), the filename is IN a single final query + extension, but in (2) & (3), the filename is IN a single final query argument. This strips the URL into three pieces: prefix, ext, and suffix. The suffix contains anything that was stripped off the URL to get at the file extension. In (1), it will be '?raw=true', but - in (2), it will be empty. e.g.: + in (2), it will be empty. In (3) the suffix is a parameter that follows + after the file extension, e.g.: 1. ('https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7', '.tgz', '?raw=true') 2. ('http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin', '.tar.gz', None) + 3. ('https://gitlab.kitware.com/vtk/vtk/repository/archive', '.tar.bz2', '?ref=v7.0.0') """ prefix, ext, suffix = path, '', '' @@ -203,6 +206,15 @@ def parse_version_offset(path, debug=False): # https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz (r'github.com/[^/]+/[^/]+/releases/download/v?([^/]+)/.*$', path), + # GitLab syntax: + # {baseUrl}{/organization}{/projectName}/repository/archive.{fileEnding}?ref={gitTag} + # as with github releases, we hope a version can be found in the + # git tag + # Search dotted versions: + # e.g., https://gitlab.kitware.com/vtk/vtk/repository/archive.tar.bz2?ref=v7.0.0 + # e.g., https://example.com/org/repo/repository/archive.tar.bz2?ref=SomePrefix-2.1.1 + (r'\?ref=(?:.*-|v)*((\d+\.)+\d+).*$', suffix), + # e.g. boost_1_39_0 (r'((\d+_)+\d+)$', stem), @@ -291,6 +303,7 @@ def parse_name_offset(path, v=None, debug=False): (r'/([^/]+)/(tarball|zipball)/', path), (r'/([^/]+)[_.-](bin|dist|stable|src|sources)[_.-]%s' % v, path), (r'github.com/[^/]+/([^/]+)/archive', path), + (r'[^/]+/([^/]+)/repository/archive', path), # gitlab (r'([^/]+)[_.-]v?%s' % v, stem), # prefer the stem (r'([^/]+)%s' % v, stem), |