summaryrefslogtreecommitdiff
path: root/lib/spack/spack/build_systems/sourceforge.py
blob: 602a099c17d1c84406bd8772db502fed1981bef3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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))