← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~nacc/curtin:nacc/lp1892494 into curtin:master

 


Diff comments:

> diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
> index e7d84c0..7cb1484 100644
> --- a/curtin/commands/apt_config.py
> +++ b/curtin/commands/apt_config.py
> @@ -343,20 +343,22 @@ def apply_preserve_sources_list(target):
>          raise
>  
>  
> -def add_apt_key_raw(key, target=None):
> +def add_apt_key_raw(filename, key, target=None):
>      """
>      actual adding of a key as defined in key argument
>      to the system
>      """
>      LOG.debug("Adding key:\n'%s'", key)
> -    try:
> -        util.subp(['apt-key', 'add', '-'], data=key.encode(), target=target)
> -    except util.ProcessExecutionError:
> -        LOG.exception("failed to add apt GPG Key to apt keyring")
> -        raise
> +    if '-----BEGIN PGP PUBLIC KEY BLOCK-----' in key:
> +        target_file_ext = '.asc'
> +    else:
> +        target_file_ext = '.gpg'

You should check that the filename does not already end in .gpg or .asc.
What should you do if filename includes .gpg but you think should use end an .asc?

I'm not sure why we're second guessing user's choice of filename.

> +    target_file = paths.target_path(target, filename + target_file_ext)
> +    util.write_file(target_file, key.rstrip(), mode=0o644)
> +    LOG.debug("Added key to '%s'", target_file)

If you move the file extension logic above line 15, then you can combine both items (key and file) into a single log message:

LOG.debug("Adding key to %s:\n%s", filename, key)

>  
>  
> -def add_apt_key(ent, target=None):
> +def add_apt_key(filename, ent, target=None):
>      """
>      Add key to the system as defined in ent (if any).
>      Supports raw keys or keyid's


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


References