mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 09:16:14 +01:00
Merge pull request #950 from Firstyear/allow-download-source
Add support to manually override download url locations.
This commit is contained in:
commit
c1bec6901a
19
osc/build.py
19
osc/build.py
@ -144,7 +144,15 @@ class Buildinfo:
|
||||
self.release = root.find('release').text
|
||||
else:
|
||||
self.release = None
|
||||
self.downloadurl = root.get('downloadurl')
|
||||
if config['api_host_options'][apiurl]['downloadurl']:
|
||||
self.enable_cpio = False
|
||||
self.downloadurl = config['api_host_options'][apiurl]['downloadurl'] + "/repositories"
|
||||
if config['http_debug']:
|
||||
print("⚠️ setting dl_url to %s" % config['api_host_options'][apiurl]['downloadurl'])
|
||||
else:
|
||||
self.enable_cpio = True
|
||||
self.downloadurl = root.get('downloadurl')
|
||||
|
||||
self.debuginfo = 0
|
||||
if root.find('debuginfo') != None:
|
||||
try:
|
||||
@ -181,7 +189,12 @@ class Buildinfo:
|
||||
# a hash providing the matching URL for specific repos for newer OBS instances
|
||||
if node.get('url'):
|
||||
url = node.get('url').replace('%', '%%')
|
||||
self.urls[node.get('project')+"/"+node.get('repository')] = url + '/%(arch)s/%(filename)s'
|
||||
if config['api_host_options'][apiurl]['downloadurl']:
|
||||
# Add the path element to the download url override.
|
||||
baseurl = config['api_host_options'][apiurl]['downloadurl'] + urlsplit(node.get('url'))[2]
|
||||
else:
|
||||
baseurl = node.get('url')
|
||||
self.urls[node.get('project')+"/"+node.get('repository')] = baseurl + '/%(arch)s/%(filename)s'
|
||||
|
||||
self.vminstall_list = [ dep.name for dep in self.deps if dep.vminstall ]
|
||||
self.preinstall_list = [ dep.name for dep in self.deps if dep.preinstall ]
|
||||
@ -1062,7 +1075,7 @@ def main(apiurl, opts, argv):
|
||||
offline = opts.noinit or opts.offline,
|
||||
http_debug = config['http_debug'],
|
||||
modules = bi.modules,
|
||||
enable_cpio = not opts.disable_cpio_bulk_download,
|
||||
enable_cpio=not opts.disable_cpio_bulk_download and bi.enable_cpio,
|
||||
cookiejar=cookiejar,
|
||||
download_api_only=opts.download_api_only)
|
||||
|
||||
|
13
osc/conf.py
13
osc/conf.py
@ -221,7 +221,8 @@ boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'tr
|
||||
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail']
|
||||
integer_opts = ['build-jobs']
|
||||
|
||||
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj']
|
||||
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj',
|
||||
'downloadurl']
|
||||
|
||||
new_conf_template = """
|
||||
[general]
|
||||
@ -1024,6 +1025,16 @@ def get_config(override_conffile=None,
|
||||
else:
|
||||
api_host_options[apiurl]['trusted_prj'] = []
|
||||
|
||||
# ⚠️ This option is experimental and may be removed at any time in the future!
|
||||
# This allows overriding the download url for an OBS instance to specify a closer mirror
|
||||
# or proxy system, which can greatly improve download performance, latency and more.
|
||||
# For example, this can use https://github.com/Firstyear/opensuse-proxy-cache in a local
|
||||
# geo to improve performance.
|
||||
if cp.has_option(url, 'downloadurl'):
|
||||
api_host_options[apiurl]['downloadurl'] = cp.get(url, 'downloadurl')
|
||||
else:
|
||||
api_host_options[apiurl]['downloadurl'] = None
|
||||
|
||||
# add the auth data we collected to the config dict
|
||||
config['api_host_options'] = api_host_options
|
||||
config['apiurl_aliases'] = aliases
|
||||
|
Loading…
Reference in New Issue
Block a user