summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vmdb/plugins/cache_rootfs.mdwn11
-rw-r--r--vmdb/plugins/cache_rootfs_plugin.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/vmdb/plugins/cache_rootfs.mdwn b/vmdb/plugins/cache_rootfs.mdwn
index c4270a7..2077de5 100644
--- a/vmdb/plugins/cache_rootfs.mdwn
+++ b/vmdb/plugins/cache_rootfs.mdwn
@@ -6,8 +6,19 @@ Create a tarball of the root filesystem in the image.
Step keys:
* `cache-rootfs` — REQUIRED; tag of root filesystem on image.
+* `force` — OPTIONAL; boolean that enables overwriting of an existing rootfs
+ tarball by `vmdb2`, allowing the tarball to be used as both a build input and a
+ build output. This can be useful in multi-stage build chains where a "common base
+ OS" rootfs filesystem is populated and packaged as a rootfs tarball by `vmdb2`, and
+ this tarball is consumed by multiple downstream `vmdb2` builds that extract the
+ tarball into disk images that have different partition layouts and/or filesystems.
Example (in the .vmdb file):
+ # typical use
- cache-rootfs: root
unless: rootfs_unpacked
+
+ # create a rootfs tarball output at the end of a build process
+ - cache-rootfs: root
+ force: true
diff --git a/vmdb/plugins/cache_rootfs_plugin.py b/vmdb/plugins/cache_rootfs_plugin.py
index c7ebb6d..cdbd3e6 100644
--- a/vmdb/plugins/cache_rootfs_plugin.py
+++ b/vmdb/plugins/cache_rootfs_plugin.py
@@ -28,7 +28,7 @@ class CacheRootFSPlugin(vmdb.Plugin):
class MakeCacheStepRunner(vmdb.StepRunnerInterface):
def get_key_spec(self):
- return {"cache-rootfs": str, "options": "--one-file-system"}
+ return {"cache-rootfs": str, "options": "--one-file-system", "force": False}
def run(self, values, settings, state):
fs_tag = values["cache-rootfs"]
@@ -49,7 +49,7 @@ class MakeCacheStepRunner(vmdb.StepRunnerInterface):
vmdb.progress("caching rootdir {}".format(rootdir))
vmdb.progress("caching relative {}".format(dirs))
- if not os.path.exists(tar_path):
+ if values["force"] or not os.path.exists(tar_path):
vmdb.runcmd(["tar"] + opts + ["-C", rootdir, "-caf", tar_path] + dirs)
def _find_cacheable_mount_points(self, tags, rootdir):