[elbe-devel] [PATCH] Add includepkgs as debootstrapvariant attribute

bage at linutronix.de bage at linutronix.de
Wed Feb 27 10:47:40 CET 2019


From: Bastian Germann <bage at linutronix.de>

In some situations, you need additional packages during debootstrap.
E.g., with variant minbase and additional repository keys, gnupg is needed to
add those keys to the trusted key database.

Add an attribute includepkgs to the debootstrapvariant element and apply its
contents as debootstrap --include="...".

Closes issue #200.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/rfs.py   | 23 ++++++++++++++++++-----
 schema/dbsfed.xsd |  8 +++++++-
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index eec4e6a0..d392f41f 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'
@@ -217,8 +225,13 @@ class BuildEnv (object):
                         'echo "%s" > %s' %
                         (myKey, self.rfs.fname("tmp/key.pub")))
                     with self.rfs:
-                        self.log.chroot(
-                            self.rfs.path, 'apt-key add /tmp/key.pub')
+                        try:
+                            self.log.chroot(
+                                self.rfs.path, 'apt-key add /tmp/key.pub')
+                        except CommandError:
+                            self.log.printo("Use debootstrapvariant's attribute includepkgs to "
+                                             "make gnupg available in debootstrap.")
+                            raise
                     self.log.do('rm -f %s' % self.rfs.fname("tmp/key.pub"))
 
     def initialize_dirs(self, build_sources=False):
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