[elbe-devel] [PATCH v2 1/8] finetuning: basic implementation of project-finetuning

Torben Hohn torben.hohn at linutronix.de
Wed Dec 5 09:54:05 CET 2018


<project-finetuning> is a set of commands, that run after
image generation.

Add a method FinetuningAction.execute_prj() with additional Parameter builddir.
This method defaults to calling self.execute(). This allows to use all FintuningActions
in project-finetuning as well.

However, this must be allowed by the schema first. And care must be taken, because
not all FinetuningActions make sense to be called after Images heve been generated.
Its espcially not wise to modify target after the images have been created.

Just allow <t2p_mv> for now.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/elbeproject.py |  7 +++++++
 elbepack/finetuning.py  | 19 +++++++++++++++++++
 schema/dbsfed.xsd       | 45 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index bc568e91..8f851562 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -37,6 +37,7 @@ from elbepack.repomanager import ProjectRepo
 from elbepack.config import cfg
 from elbepack.pkgutils import extract_pkg
 from elbepack.templates import write_pack_template
+from elbepack.finetuning import do_prj_finetuning
 
 
 class IncompatibleArchitectureException(Exception):
@@ -578,6 +579,12 @@ class ElbeProject (object):
                 self.xml.text("project/name")),
                 allow_fail=True)
 
+        do_prj_finetuning(self.xml,
+                          self.log,
+                          self.buildenv,
+                          self.targetfs,
+                          self.builddir)
+
         os.system('cat "%s"' % self.validationpath)
 
     def pdebuild_init(self):
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index ddce159e..f08d36b5 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -40,6 +40,10 @@ class FinetuningAction(object):
     def execute(self, _log, _buildenv, _target):
         raise NotImplementedError('execute() not implemented')
 
+    def execute_prj(self, log, buildenv, target, _builddir):
+        self.execute(log, buildenv, target)
+
+
 class RmAction(FinetuningAction):
 
     tag = 'rm'
@@ -481,3 +485,18 @@ def do_finetuning(xml, log, buildenv, target):
             print("Unimplemented finetuning action '%s'" % (i.et.tag))
         except CommandError:
             log.printo("Finetuning Error, trying to continue anyways")
+
+
+def do_prj_finetuning(xml, log, buildenv, target, builddir):
+
+    if not xml.has('target/project-finetuning'):
+        return
+
+    for i in xml.node('target/project-finetuning'):
+        try:
+            action = FinetuningAction(i)
+            action.execute_prj(log, buildenv, target, builddir)
+        except KeyError:
+            print("Unimplemented project-finetuning action '%s'" % (i.et.tag))
+        except CommandError:
+            log.printo("ProjectFinetuning Error, trying to continue anyways")
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index d52b80f6..a7149c37 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -841,6 +841,21 @@
           </documentation>
         </annotation>
       </element>
+      <element name="project-finetuning" type="rfs:project-finetuning" minOccurs="0">
+        <annotation>
+          <documentation>
+	    apply the given commands to the project directory, after images have
+	    been generated. Possible use-cases are:
+
+	    * sign images
+	    * crypt setup
+	    * extract partition from image and mark as build artifact.
+	    * modify images (iE remove some modules from /boot/grub)
+	    * UEFI / secureboot: make_lxtrainer_secureboot.sh
+	    * mark files as build artifacts
+          </documentation>
+        </annotation>
+      </element>
       <element name="pbuilder" type="rfs:pbuilder" minOccurs="0" maxOccurs="1">
         <annotation>
           <documentation>
@@ -1835,6 +1850,36 @@
     </choice>
   </group>
 
+  <complexType name="project-finetuning">
+    <annotation>
+      <documentation>
+         container for project-finetuning commands; these commands are executed in the
+         project directory, after the images have been generated.
+      </documentation>
+    </annotation>
+    <sequence>
+      <group ref="rfs:project-action" minOccurs="0" maxOccurs="unbounded" />
+    </sequence>
+    <attribute ref="xml:base"/>
+  </complexType>
+
+  <group name="project-action">
+    <annotation>
+      <documentation>
+        definition of finetuning commands
+      </documentation>
+    </annotation>
+    <choice>
+      <element name="t2p_mv" type="rfs:cpmv" minOccurs="0">
+        <annotation>
+          <documentation>
+            move a file from the target to the project directory
+          </documentation>
+        </annotation>
+      </element>
+    </choice>
+  </group>
+
   <complexType name="addgroup">
     <annotation>
       <documentation>
-- 
2.11.0




More information about the elbe-devel mailing list