def METHOD_NAME(
    *,
    yum_dnf: YumDnf,
    infile: TextIO,
    out_dir: Path,
    install_dir: Path,
    ports: Iterable[int],
) -> None:
    # `yum-dnf-from-snapshot` implicitly depends on this path convention for
    # the main config and for the plugin configs under `<snapshot_dir>/etc`.
    plugin_dir = f"etc/{yum_dnf.value}/plugins"
    cache_dir = f"var/cache/{yum_dnf.value}"  # created via genrule_layer later
    config_path = f"etc/{yum_dnf.value}/{yum_dnf.value}.conf"
    os.makedirs(out_dir / plugin_dir)
    populate_versionlock_conf(
        yum_dnf,
        out_dir=out_dir / plugin_dir,
        install_dir=install_dir / plugin_dir,
    )
    server_urls = [urlparse(f"http://localhost:{p}") for p in ports]
    yc = YumDnfConfParser(yum_dnf, infile)
    isolated_yc = (
        yc.isolate()
        .isolate_repos(
            repo._replace(
                base_url=[
                    urlunparse(url._replace(path=repo.name)) for url in server_urls
                ],
                gpg_key_urls=[
                    urlunparse(
                        # NB: It's be "better" to use `random.choice` but it
                        # makes it harder to write tests, so worse it is.
                        server_urls[0]._replace(
                            path=os.path.join(
                                repo.name,
                                os.path.basename(urlparse(key_url).path),
                            )
                        )
                    )
                    for key_url in repo.gpg_key_urls
                ],
            )
            for repo in yc.gen_repos()
        )
        .isolate_main(
            config_path=(install_dir / config_path).decode(),
            pluginconf_dir=(install_dir / plugin_dir).decode(),
            cache_dir=(install_dir / cache_dir).decode(),
        )
    )
    with create_ro(out_dir / config_path, "w") as conf_out:
        isolated_yc.write(conf_out)