]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Allow to mount build sources 292/head
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 21 Nov 2018 09:16:13 +0000 (01:16 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 21 Nov 2018 20:35:06 +0000 (12:35 -0800)
This allows us to just mount the build sources into the build image in
order to run the script. By doing this the user may avoid problems with
recursive submodules and at the same time speed up execution for large
trees. This means the user will need to take care of possibly cleaning
up the tree if he wants to make sure he has a clean build.

mkosi

diff --git a/mkosi b/mkosi
index 601ef6d9919c331abe557c3a5b65afc23b0e4485..e63818214ef6e7b440595149599e88fbfd25d36a 100755 (executable)
--- a/mkosi
+++ b/mkosi
@@ -91,6 +91,7 @@ class SourceFileTransfer(enum.Enum):
     copy_all = "copy-all"
     copy_git_cached = "copy-git-cached"
     copy_git_others = "copy-git-others"
+    mount = "mount"
 
     def __str__(self):
         return self.value
@@ -99,7 +100,8 @@ class SourceFileTransfer(enum.Enum):
     def doc(cls):
         return {cls.copy_all: "normal file copy",
                 cls.copy_git_cached: "use git-ls-files --cached, ignoring any file that git itself ignores",
-                cls.copy_git_others: "use git-ls-files --others, ignoring any file that git itself ignores"}
+                cls.copy_git_others: "use git-ls-files --others, ignoring any file that git itself ignores",
+                cls.mount: "bind mount source files into the build image"}
 
 
 class OutputFormat(enum.Enum):
@@ -2078,7 +2080,7 @@ def install_build_src(args, workspace, run_build_script, for_cache):
 
             if source_file_transfer in (SourceFileTransfer.copy_git_others, SourceFileTransfer.copy_git_cached):
                 copy_git_files(args.build_sources, target, source_file_transfer=source_file_transfer)
-            else:
+            elif source_file_transfer == SourceFileTransfer.copy_all:
                 ignore = shutil.ignore_patterns('.git',
                                                 '.mkosi-*',
                                                 '*.cache-pre-dev',
@@ -3771,6 +3773,8 @@ def run_build_script(args: CommandLineArguments, workspace: str, raw: IO[str]) -
         if args.build_sources is not None:
             cmdline.append("--setenv=SRCDIR=/root/src")
             cmdline.append("--chdir=/root/src")
+            if args.source_file_transfer == SourceFileTransfer.mount:
+                cmdline.append("--bind=" + args.build_sources + ":/root/src")
 
             if args.read_only:
                 cmdline.append("--overlay=+/root/src::/root/src")