SourceForge: Mirror Mixin (#16112)

* SourceForge: Mirror Mixin

Add a mixing class for direct `CNAME`s to sourceforge mirrors.
Since the main gateway servers are often down, this could reduce
timeouts and fetch errors for sourceforge.net hosted software.

* SourceForge: unspectacular mirror replacement

add mirrors to all sourceforge packages with trivial
download logic.

tested fetch of latest version of each of these packages
with various mirrors before committing.

* SourceForge: xz

the author homepage is chronocially overrun and this is the offical
upload with many mirrors.
This commit is contained in:
Axel Huebl
2020-04-16 21:35:30 -07:00
committed by GitHub
parent e476a9061b
commit abbc47823d
39 changed files with 162 additions and 68 deletions

View File

@@ -0,0 +1,40 @@
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.util.url
import spack.package
class SourceforgePackage(spack.package.PackageBase):
"""Mixin that takes care of setting url and mirrors for Sourceforge
packages."""
#: Path of the package in a Sourceforge mirror
sourceforge_mirror_path = None
#: List of Sourceforge mirrors used by Spack
base_mirrors = [
'https://prdownloads.sourceforge.net/',
'https://freefr.dl.sourceforge.net/',
'https://netcologne.dl.sourceforge.net/',
'https://pilotfiber.dl.sourceforge.net/',
'https://downloads.sourceforge.net/',
'http://kent.dl.sourceforge.net/sourceforge/'
]
@property
def urls(self):
self._ensure_sourceforge_mirror_path_is_set_or_raise()
return [
spack.util.url.join(m, self.sourceforge_mirror_path,
resolve_href=True)
for m in self.base_mirrors
]
def _ensure_sourceforge_mirror_path_is_set_or_raise(self):
if self.sourceforge_mirror_path is None:
cls_name = type(self).__name__
msg = ('{0} must define a `sourceforge_mirror_path` attribute'
' [none defined]')
raise AttributeError(msg.format(cls_name))

View File

@@ -31,6 +31,7 @@
from spack.build_systems.meson import MesonPackage
from spack.build_systems.sip import SIPPackage
from spack.build_systems.gnu import GNUMirrorPackage
from spack.build_systems.sourceforge import SourceforgePackage
from spack.build_systems.sourceware import SourcewarePackage
from spack.build_systems.xorg import XorgPackage

View File

@@ -244,6 +244,29 @@ def test_define(self):
'make/make-4.2.1.tar.gz'
@pytest.mark.usefixtures('config', 'mock_packages')
class TestSourceforgePackage(object):
def test_define(self):
s = Spec('mirror-sourceforge')
s.concretize()
pkg = spack.repo.get(s)
s = Spec('mirror-sourceforge-broken')
s.concretize()
pkg_broken = spack.repo.get(s)
cls_name = type(pkg_broken).__name__
with pytest.raises(AttributeError,
match=r'{0} must define a `sourceforge_mirror_path`'
r' attribute \[none defined\]'
.format(cls_name)):
pkg_broken.urls
assert pkg.urls[0] == 'https://prdownloads.sourceforge.net/' \
'tcl/tcl8.6.5-src.tar.gz'
@pytest.mark.usefixtures('config', 'mock_packages')
class TestSourcewarePackage(object):