diff --git a/osc/build.py b/osc/build.py index ff3d3155..c47f6b2c 100644 --- a/osc/build.py +++ b/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) diff --git a/osc/conf.py b/osc/conf.py index 07c6c967..09e38f1d 100644 --- a/osc/conf.py +++ b/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