← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~ogayot/curtin:apt-pinning into curtin:master

 


Diff comments:

> diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
> index 9ea2d30..be4a039 100644
> --- a/curtin/commands/apt_config.py
> +++ b/curtin/commands/apt_config.py
> @@ -595,6 +603,36 @@ def apply_apt_proxy_config(cfg, proxy_fname, config_fname):
>          LOG.debug("no apt config configured, removed %s", config_fname)
>  
>  
> +def preference_to_str(preference):
> +    """ Return a textual representation of a given preference as specified in
> +    apt_preferences(5).
> +    """
> +
> +    return """\
> +Package: {package}
> +Pin: {pin}

Related to my subiquity comment, are there Pin strings where we need to quote part of the value?

> +Pin-Priority: {pin_priority}
> +""".format(package=preference["package"],
> +           pin=preference["pin"],
> +           pin_priority=preference["pin-priority"])
> +
> +
> +def apply_apt_preferences(cfg, pref_fname):
> +    """ Apply apt preferences if any is provided.
> +    """
> +
> +    prefs = cfg.get("preferences")
> +    if not prefs:
> +        if os.path.isfile(pref_fname):
> +            util.del_file(pref_fname)
> +            LOG.debug("no apt preferences configured, removed %s", pref_fname)
> +        return
> +    prefs_as_strings = [preference_to_str(pref) for pref in prefs]
> +    print(prefs_as_strings)
> +    LOG.debug("write apt preferences info to %s.", pref_fname)
> +    util.write_file(pref_fname, "\n".join(prefs_as_strings))
> +
> +
>  def apt_command(args):
>      """ Main entry point for curtin apt-config standalone command
>          This does not read the global config as handled by curthooks, but


-- 
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/413788
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:apt-pinning into curtin:master.



References