← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~dbungert/curtin:command-apt-libapt-v4 into curtin:master

 

Review: Approve

Very nice. Just one suggestion, feel free to act on or ignore that and then merge, no further review required.

Diff comments:

> diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
> index e7d84c0..1082c63 100644
> --- a/curtin/commands/apt_config.py
> +++ b/curtin/commands/apt_config.py
> @@ -211,22 +213,39 @@ def rename_apt_lists(new_mirrors, target=None):
>                  LOG.warn("Failed to rename apt list:", exc_info=True)
>  
>  
> -def mirror_to_placeholder(tmpl, mirror, placeholder):
> -    """ mirror_to_placeholder
> -        replace the specified mirror in a template with a placeholder string
> -        Checks for existance of the expected mirror and warns if not found
> -    """
> -    if mirror not in tmpl:
> -        if mirror.endswith("/") and mirror[:-1] in tmpl:
> -            LOG.debug("mirror_to_placeholder: '%s' did not exist in tmpl, "
> -                      "did without a trailing /.  Accomodating.", mirror)
> -            mirror = mirror[:-1]
> -        else:
> -            LOG.warn("Expected mirror '%s' not found in: %s", mirror, tmpl)
> -    return tmpl.replace(mirror, placeholder)
> +def update_default_mirrors(entries, mirrors, target):
> +    """replace existing default repos with the configured mirror"""
> +
> +    defaults = get_default_mirrors(distro.get_architecture(target))
> +    mirrors_replacement = {
> +        defaults['PRIMARY']: mirrors["MIRROR"],
> +        defaults['SECURITY']: mirrors["SECURITY"],
> +    }
> +
> +    # allow original file URIs without the trailing slash to match mirror
> +    # specifications that have it
> +    noslash = {}
> +    for key in mirrors_replacement.keys():
> +        if key[-1] == '/':
> +            noslash[key[:-1]] = mirrors_replacement[key]
> +
> +    mirrors_replacement.update(noslash)
> +
> +    for entry in entries:
> +        if entry.uri in mirrors_replacement:
> +            entry.uri = mirrors_replacement[entry.uri]

these two lines could be entry.uri = mirrors.replacement.get(entry.uri, entry.uri)?

> +    return entries
> +
>  
> +def update_mirrors(entries, mirrors):
> +    """perform template replacement of mirror placeholders with configured
> +       values"""
> +    for entry in entries:
> +        entry.uri = util.render_string(entry.uri, mirrors)
> +    return entries
>  
> -def map_known_suites(suite):
> +
> +def map_known_suites(suite, release):
>      """there are a few default names which will be auto-extended.
>         This comes at the inability to use those names literally as suites,
>         but on the other hand increases readability of the cfg quite a lot"""


-- 
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/408383
Your team curtin developers is subscribed to branch curtin:master.



References