[libvirt] [dockerfiles PATCH 3/4] refresh: Add support for cross-compilation Dockerfiles

Andrea Bolognani abologna at redhat.com
Fri Mar 8 18:00:49 UTC 2019


lcitool can generate these Dockerfiles already, so we just
need to parse the relevant information encoded in the file
name and hand them over.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 refresh | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/refresh b/refresh
index 5f7c41c..1e6c185 100755
--- a/refresh
+++ b/refresh
@@ -35,6 +35,7 @@ class MoveAlongException(Exception):
 class Dockerfile:
 
     PREFIX = "buildenv-"
+    CROSS  = "-cross-"
     SUFFIX = ".Dockerfile"
 
     def __init__(self, path):
@@ -49,7 +50,20 @@ class Dockerfile:
             raise Error("Invalid name '{}'".format(path.stem))
 
         self.path = path
-        self.os = path.stem[len(Dockerfile.PREFIX):]
+        stem = path.stem[len(Dockerfile.PREFIX):]
+        cross = stem.rfind(Dockerfile.CROSS)
+
+        if cross >= 0:
+            # If we found CROSS, then everything before it is the name of
+            # the OS and everything after it the name of the architecture
+            # we're targeting for cross-compilation
+            self.os = stem[:cross]
+            self.cross_arch = stem[cross + len(Dockerfile.CROSS):]
+        else:
+            # Otherwise the entire stem is the name of the OS and there
+            # is no cross-compilation architecture
+            self.os = stem
+            self.cross_arch = None
 
         # Fedora Rawhide is special in that we use it to perform MinGW
         # builds, so we need to add the corresponding projects
@@ -63,6 +77,16 @@ class Dockerfile:
         args = [
             lcitool,
             "dockerfile",
+        ]
+
+        # Pass the cross-compilation architecture if present
+        if self.cross_arch is not None:
+            args += [
+                "--cross-arch",
+                self.cross_arch,
+            ]
+
+        args += [
             "libvirt-" + self.os,
             self.projects,
         ]
-- 
2.20.1




More information about the libvir-list mailing list