[elbe-devel] [PATCH 5/6] Add xmlpreprocessor for PGP Key URL

Torben Hohn torben.hohn at linutronix.de
Mon May 27 15:37:25 CEST 2019


On Tue, May 21, 2019 at 10:49:00AM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> 'mirror/url-list/url/key' is now deprecated.  It should be remove from
> schema.  The preprocessor will get the PGP key and replace the 'key'
> tag with a 'raw-key' tag.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>


print is ok. remove the comment,
andd add:

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/xmlpreprocess.py | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
> index dd941d41..971bc819 100644
> --- a/elbepack/xmlpreprocess.py
> +++ b/elbepack/xmlpreprocess.py
> @@ -29,6 +29,18 @@ mergepaths = ['//target/finetuning',
>  class XMLPreprocessError(Exception):
>      pass
>  
> +def preprocess_pgp_key(xml):
> +
> +    for key in xml.iterfind('project/mirror/url-list/url/key'):
> +        # Maybe not print?

its ok. remove the comment, please

> +        print("[WARN] <key>%s</key> is deprecated.  You should use raw-key instead." % key.text)
> +        try:
> +            keyurl = key.text.strip().replace('LOCALMACHINE', '10.0.2.2')
> +            myKey = urllib2.urlopen(keyurl).read()
> +            key.tag = "raw-key"
> +            key.text = "\n%s\n" % myKey
> +        except urllib2.HTTPError as E:
> +            raise XMLPreprocessError("Invalid PGP Key URL in <key> tag: %s" % keyurl)
>  
>  def xmlpreprocess(fname, output, variants=None):
>  
> @@ -97,6 +109,9 @@ def xmlpreprocess(fname, output, variants=None):
>          # handle archivedir elements
>          xml = combinearchivedir(xml)
>  
> +        # Change public PGP url key to raw key
> +        preprocess_pgp_key(xml)
> +
>          if schema.validate(xml):
>              # if validation succedes write xml file
>              xml.write(
> -- 
> 2.21.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list