aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-02-29 20:21:02 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-02-29 20:34:39 +0300
commit8fe1c6ddcca215458a021239e873df334f7d53a0 (patch)
treec94c0ac241d6c143067b075219c871c95040218c
parentwtf, two empty lines (diff)
downloadcmake-common-8fe1c6ddcca215458a021239e873df334f7d53a0.tar.gz
cmake-common-8fe1c6ddcca215458a021239e873df334f7d53a0.zip
boost/build: try multiple mirrors
-rwxr-xr-xboost/build/build.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/boost/build/build.py b/boost/build/build.py
index c4b008c..0450593 100755
--- a/boost/build/build.py
+++ b/boost/build/build.py
@@ -205,11 +205,19 @@ class BoostVersion:
def archive_name(self):
return f'{self.dir_name}{self.archive_ext}'
- def get_download_url(self):
- if self._impl < _Version(1, 63, 0):
- return f'https://sourceforge.net/projects/boost/files/boost/{self}/{self.archive_name}/download'
+ def _get_bintray_url(self):
return f'https://dl.bintray.com/boostorg/release/{self}/source/{self.archive_name}'
+ def _get_sourceforge_url(self):
+ return f'https://sourceforge.net/projects/boost/files/boost/{self}/{self.archive_name}/download'
+
+ def get_download_urls(self):
+ if self._impl < _Version(1, 63, 0):
+ # For versions older than 1.63.0, SourceForge is the only option:
+ return [self._get_sourceforge_url()]
+ # Otherwise, Bintray is preferred (the official website links to it).
+ return [self._get_bintray_url(), self._get_sourceforge_url()]
+
class BoostArchive:
def __init__(self, version, path):
@@ -238,12 +246,20 @@ class ArchiveStorage(abc.ABC):
yield BoostArchive(version, path)
return
- url = version.get_download_url()
- logging.info('Download URL: %s', url)
+ urls = version.get_download_urls()
- with urllib.request.urlopen(url) as request:
- with self.write_archive(version, request.read()) as path:
- yield BoostArchive(version, path)
+ for url in urls:
+ logging.info('Trying URL: %s', url)
+ try:
+ with urllib.request.urlopen(url) as request:
+ with self.write_archive(version, request.read()) as path:
+ yield BoostArchive(version, path)
+ return
+ except urllib.request.URLError as e:
+ logging.error("Couldn't download from this mirror, an error occured:")
+ logging.exception(e)
+
+ raise RuntimeError("Couldn't download Boost from any of the mirrors")
@abc.abstractmethod
def get_archive(self, version):