From fadf99af05414e76ba6e2d1fb100769f117c79e4 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 12 Oct 2018 12:03:26 +1100 Subject: [PATCH] Add a pre-finalise.d phase In exploring Gentoo caching, it was realised that we have no way to bind mount the cache into the finalised image for the finalise.d phases. By adding a pre-finalise.d phase that runs outside the chroot, we can mount outside things into the hierarchy at $TMP_BUILD_DIR/mnt which are then seen by the in-chroot finalise.d phase. This is similar to the pre-install phase Change-Id: I9d782994843383ddf90f62c40498af9925fd9558 --- diskimage_builder/lib/disk-image-create | 1 + doc/source/developer/developing_elements.rst | 10 ++++++++++ .../notes/pre-finalise-stage-574ae7886274bcba.yaml | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 releasenotes/notes/pre-finalise-stage-574ae7886274bcba.yaml diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index 189a0798d..8400ae709 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -486,6 +486,7 @@ sudo cp -ra ${TMP_BUILD_DIR}/built/* $TMP_BUILD_DIR/mnt sudo rm -fr ${TMP_BUILD_DIR}/built/* mount_proc_dev_sys +run_d pre-finalise run_d_in_target finalise finalise_base diff --git a/doc/source/developer/developing_elements.rst b/doc/source/developer/developing_elements.rst index 2ce884fe3..d37bc09c1 100644 --- a/doc/source/developer/developing_elements.rst +++ b/doc/source/developer/developing_elements.rst @@ -137,6 +137,16 @@ The phases are: * outputs: ``$IMAGE_BLOCK_DEVICE={path}`` +``pre-finalise.d`` + + Final tuning of the root filesystem, outside the chroot. Filesystem + content has been copied into the final file system which is rooted + at ``$TMP_BUILD_DIR/mnt``. You might do things like re-mount a + cache directory that was used during the build in this phase (with + subsequent unmount in ``cleanup.d``). + + * runs: **outside chroot** + ``finalise.d`` Perform final tuning of the root filesystem. Runs in a chroot after the root filesystem content has been copied into the mounted filesystem: this is an diff --git a/releasenotes/notes/pre-finalise-stage-574ae7886274bcba.yaml b/releasenotes/notes/pre-finalise-stage-574ae7886274bcba.yaml new file mode 100644 index 000000000..f580d0e54 --- /dev/null +++ b/releasenotes/notes/pre-finalise-stage-574ae7886274bcba.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + A ``pre-finalise`` stage is added that runs outside the chroot and + before the ``finalise`` stage. For example, this may be useful + for mounting external resources that are used inside the chroot + during the ``finalise`` stage, but do not need to be distributed + in the final image such as build-time caches.