def test_get_kojiroot_base_url(self, m_config): m_config.kojiroot_url = "http://kojiroot.com" build_info = dict( package_name="kernel", version="3.10.0", release="123.20.1", ) result = packaging.get_kojiroot_base_url(build_info) expected = "http://kojiroot.com/kernel/3.10.0/123.20.1/x86_64/" assert result == expected
def download_kernel(ctx, config): """ Supply each remote with a kernel package: - local kernels are copied over - gitbuilder kernels are downloaded - nothing is done for distro kernels :param ctx: Context :param config: Configuration """ procs = {} for role, src in config.items(): needs_download = False if src == 'distro': # don't need to download distro kernels log.debug("src is distro, skipping download") continue (role_remote, ) = ctx.cluster.only(role).remotes.keys() if isinstance(src, dict): # we're downloading a kernel from koji, the src dict here # is the build_info retrieved from koji using get_koji_build_info if src.get("id"): build_id = src["id"] log.info( "Downloading kernel with build_id {build_id} on {role}...". format(build_id=build_id, role=role)) needs_download = True baseurl = get_kojiroot_base_url(src) pkg_name = get_koji_package_name("kernel", src) elif src.get("task_id"): needs_download = True log.info( "Downloading kernel with task_id {task_id} on {role}...". format(task_id=src["task_id"], role=role)) baseurl = src["base_url"] # this var is also poorly named as it's not the package name, # but the full name of the rpm file to download. pkg_name = src["rpm_name"] elif src.find('/') >= 0: # local package - src is path log.info('Copying kernel package {path} to {role}...'.format( path=src, role=role)) role_remote.put_file(src, remote_pkg_path(role_remote)) else: # gitbuilder package - src is sha1 log.info('Downloading kernel {sha1} on {role}...'.format( sha1=src, role=role, )) needs_download = True builder = get_builder_project()( 'kernel', { 'sha1': src }, ctx=ctx, remote=role_remote, ) if teuth_config.use_shaman: if role_remote.os.package_type == 'rpm': arch = builder.arch baseurl = urlparse.urljoin(builder.base_url, '/'.join([arch, ''])) pkg_name = "kernel-%s.%s.rpm" % ( builder.version, arch, ) elif role_remote.os.package_type == 'deb': arch = 'amd64' # FIXME baseurl = urlparse.urljoin( builder.base_url, '/'.join([ 'pool', 'main', 'l', 'linux-%s' % builder.scm_version, '' ])) pkg_name = 'linux-image-%s_%s_%s.deb' % ( builder.scm_version, builder.version, arch, ) else: baseurl = builder.base_url + "/" pkg_name = gitbuilder_pkg_name(role_remote) log.info("fetching, builder baseurl is %s", baseurl) if needs_download: proc = role_remote.run(args=[ 'rm', '-f', remote_pkg_path(role_remote), run.Raw('&&'), 'echo', pkg_name, run.Raw('|'), 'wget', '-nv', '-O', remote_pkg_path(role_remote), '--base={url}'.format(url=baseurl), '--input-file=-', ], wait=False) procs[role_remote.name] = proc for name, proc in procs.items(): log.debug('Waiting for download/copy to %s to complete...', name) proc.wait()