[elbe-devel] [PATCH 5/6] Add xmlpreprocessor for PGP Key URL
dion at linutronix.de
dion at linutronix.de
Tue May 21 10:49:00 CEST 2019
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>
---
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?
+ 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
More information about the elbe-devel
mailing list