[elbe-devel] [PATCH v2] Add includepkgs as debootstrapvariant attribute
bage at linutronix.de
bage at linutronix.de
Mon Mar 4 12:58:37 CET 2019
From: Bastian Germann <bage at linutronix.de>
In some situations, you need additional packages during debootstrap.
Add an attribute includepkgs to the debootstrapvariant element and apply its
contents as debootstrap --include="...".
Add checks and user errors for the following cases:
With debootstrapvariant minbase and additional repository keys gnupg is needed.
With HTTPS mirrors (not primary) apt-transport-https is needed.
Closes issue #200.
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
elbepack/rfs.py | 14 +++++++++++---
elbepack/validate.py | 32 +++++++++++++++++++++++++++++++-
schema/dbsfed.xsd | 8 +++++++-
3 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index eec4e6a0..cb72aba0 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -124,9 +124,17 @@ class BuildEnv (object):
if self.xml.has("target/debootstrapvariant"):
bootstrapvariant = self.xml.text("target/debootstrapvariant")
- self.log.printo('NOTE: use bootstrap variant "%s".' % (
- bootstrapvariant))
- strapcmd = 'debootstrap --variant="%s"' % (bootstrapvariant)
+ includepkgs = self.xml.node("target/debootstrapvariant").et.get("includepkgs")
+ if includepkgs:
+ self.log.printo('NOTE: use bootstrap variant '
+ '"%s" with additional includes: "%s".' % (
+ bootstrapvariant, includepkgs))
+ strapcmd = 'debootstrap --variant="%s" --include="%s"' % (
+ bootstrapvariant, includepkgs)
+ else:
+ self.log.printo('NOTE: use bootstrap variant "%s".' % (
+ bootstrapvariant))
+ strapcmd = 'debootstrap --variant="%s"' % (bootstrapvariant)
else:
self.log.printo('use bootstrap no variant.')
strapcmd = 'debootstrap'
diff --git a/elbepack/validate.py b/elbepack/validate.py
index c5604372..d03dd7ef 100644
--- a/elbepack/validate.py
+++ b/elbepack/validate.py
@@ -6,6 +6,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
+
from lxml import etree
from lxml.etree import XMLParser, parse
@@ -20,7 +21,7 @@ def validate_xml(fname):
xml = parse(fname, parser=parser)
if schema.validate(xml):
- return []
+ return validate_xml_content(xml)
except etree.XMLSyntaxError:
return ["XML Parse error\n" + str(sys.exc_info()[1])]
except BaseException:
@@ -41,3 +42,32 @@ def validate_xml(fname):
"Run 'elbe preprocess' first!\n")
return errors
+
+def validate_xml_content(xml):
+ errors = []
+
+ dbsv = xml.find("/target/debootstrapvariant")
+
+ if (dbsv is not None and "minbase" in dbsv.text
+ and "gnupg" not in dbsv.get("includepkgs", "")
+ and xml.find("/project/mirror/url-list/url/key") is not None):
+
+ errors.append("\nThe XML contains a custom mirror key. "
+ "Use debootstrapvariant's attribute includepkgs "
+ "to make gnupg available in debootstrap.\n")
+
+ https = xml.findtext("/project/mirror/primary_proto", "").lower() == "https"
+
+ if not https and (dbsv is None
+ or "apt-transport-https" not in dbsv.get("includepkgs", "")):
+ for url in xml.findall("/project/mirror/url-list/url"):
+ b = url.findtext("binary", "")
+ s = url.findtext("source", "")
+ if b.startswith("https") or s.startswith("https"):
+ errors.append("\nThe XML contains an HTTPS mirror. "
+ "Use debootstrapvariant's attribute includepkgs "
+ "to make apt-transport-https available in "
+ "debootstrap.\n")
+ break
+
+ return errors
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 4740a436..ccab23be 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -885,7 +885,13 @@
</annotation>
<simpleContent>
<extension base="rfs:debootstrapvarianttype_restriction">
- <attribute ref="xml:base"/>
+ <attribute name="includepkgs" type="string" use="optional">
+ <annotation>
+ <documentation>
+ A comma-separated list of additional packages at debootstrap runtime.
+ </documentation>
+ </annotation>
+ </attribute>
</extension>
</simpleContent>
</complexType>
--
2.11.0
More information about the elbe-devel
mailing list