|
|
@@ -1066,6 +1066,11 @@ def action_export(args):
|
|
|
raise SystemExit(1)
|
|
|
|
|
|
|
|
|
+def apply_url_mirrors(args, tool_download_obj):
|
|
|
+ apply_mirror_prefix_map(args, tool_download_obj)
|
|
|
+ apply_github_assets_option(tool_download_obj)
|
|
|
+
|
|
|
+
|
|
|
def apply_mirror_prefix_map(args, tool_download_obj):
|
|
|
"""Rewrite URL for given tool_obj, given tool_version, and current platform,
|
|
|
if --mirror-prefix-map flag or IDF_MIRROR_PREFIX_MAP environment variable is given.
|
|
|
@@ -1093,6 +1098,32 @@ def apply_mirror_prefix_map(args, tool_download_obj):
|
|
|
break
|
|
|
|
|
|
|
|
|
+def apply_github_assets_option(tool_download_obj):
|
|
|
+ """ Rewrite URL for given tool_obj if the download URL is an https://github.com/ URL and the variable
|
|
|
+ IDF_GITHUB_ASSETS is set. The github.com part of the URL will be replaced.
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ github_assets = os.environ["IDF_GITHUB_ASSETS"].strip()
|
|
|
+ except KeyError:
|
|
|
+ return # no IDF_GITHUB_ASSETS
|
|
|
+ if not github_assets: # variable exists but is empty
|
|
|
+ return
|
|
|
+
|
|
|
+ # check no URL qualifier in the mirror URL
|
|
|
+ if '://' in github_assets:
|
|
|
+ fatal("IDF_GITHUB_ASSETS shouldn't include any URL qualifier, https:// is assumed")
|
|
|
+ raise SystemExit(1)
|
|
|
+
|
|
|
+ # Strip any trailing / from the mirror URL
|
|
|
+ github_assets = github_assets.rstrip('/')
|
|
|
+
|
|
|
+ old_url = tool_download_obj.url
|
|
|
+ new_url = re.sub(r'^https://github.com/', 'https://{}/'.format(github_assets), old_url)
|
|
|
+ if new_url != old_url:
|
|
|
+ info('Using GitHub assets mirror for URL: {} => {}'.format(old_url, new_url))
|
|
|
+ tool_download_obj.url = new_url
|
|
|
+
|
|
|
+
|
|
|
def action_download(args):
|
|
|
tools_info = load_tools_info()
|
|
|
tools_spec = args.tools
|
|
|
@@ -1135,7 +1166,7 @@ def action_download(args):
|
|
|
tool_spec = '{}@{}'.format(tool_name, tool_version)
|
|
|
|
|
|
info('Downloading {}'.format(tool_spec))
|
|
|
- apply_mirror_prefix_map(args, tool_obj.versions[tool_version].get_download_for_platform(platform))
|
|
|
+ apply_url_mirrors(args, tool_obj.versions[tool_version].get_download_for_platform(platform))
|
|
|
|
|
|
tool_obj.download(tool_version)
|
|
|
|
|
|
@@ -1176,7 +1207,7 @@ def action_install(args):
|
|
|
continue
|
|
|
|
|
|
info('Installing {}'.format(tool_spec))
|
|
|
- apply_mirror_prefix_map(args, tool_obj.versions[tool_version].get_download_for_platform(PYTHON_PLATFORM))
|
|
|
+ apply_url_mirrors(args, tool_obj.versions[tool_version].get_download_for_platform(PYTHON_PLATFORM))
|
|
|
|
|
|
tool_obj.download(tool_version)
|
|
|
tool_obj.install(tool_version)
|