[isar-cip-core][PATCH v5 4/6] overlay: add prerequisite 'encrypt_partition'


Quirin Gylstorff
 

From: Quirin Gylstorff <quirin.gylstorff@...>

If /var shall be encrypted encrypt_partition needs to be executed
before the overlay script.

If the prerequisite is not available the overlay script will be executed.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@...>
---
.../initramfs-overlay-hook/files/overlay.hook | 1 +
.../initramfs-overlay-hook/files/overlay.script.tmpl | 12 +++++++-----
.../initramfs-overlay-hook_0.1.bb | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook
index 5bec258..8b00ecf 100644
--- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook
+++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook
@@ -23,4 +23,5 @@ esac
. /usr/share/initramfs-tools/hook-functions

manual_add_modules overlay
+copy_exec /usr/bin/mountpoint
copy_exec /usr/bin/awk
diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
index 87ec72f..71d2599 100644
--- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
+++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
@@ -9,7 +9,7 @@
# Quirin Gylstorff <quirin.gylstorff@...>
#

-PREREQ=""
+PREREQ="encrypt_partition"

prereqs()
{
@@ -33,10 +33,12 @@ ovl_lower_dirs="${INITRAMFS_OVERLAY_PATHS}"

root_mount_storage=${rootmnt}${ovl_storage_path}

-if ! mount -t $(get_fstype /dev/disk/by-label/${ovl_partition_label}) \
- /dev/disk/by-label/${ovl_partition_label} \
- ${rootmnt}/${ovl_partition_label}; then
- panic "Can't mount /${ovl_partition_label} partition - overlay will not work!"
+if ! mountpoint -q "${rootmnt}/${ovl_partition_label}"; then
+ if ! mount -t $(get_fstype /dev/disk/by-label/${ovl_partition_label}) \
+ /dev/disk/by-label/${ovl_partition_label} \
+ ${rootmnt}/${ovl_partition_label}; then
+ panic "Can't mount /${ovl_partition_label} partition - overlay will not work!"
+ fi
fi

for ovl_lower_dir in ${ovl_lower_dirs}; do
diff --git a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
index 78831ba..566bd15 100644
--- a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
+++ b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb
@@ -26,7 +26,7 @@ TEMPLATE_VARS += " INITRAMFS_OVERLAY_STORAGE_PATH \
INITRAMFS_OVERLAY_PATHS \
INITRAMFS_OVERLAY_STORAGE_PARTITION_LABEL"

-DEBIAN_DEPENDS = "initramfs-tools, awk, coreutils"
+DEBIAN_DEPENDS = "initramfs-tools, awk, coreutils, util-linux"

do_install[cleandirs] += " \
${D}/usr/share/initramfs-tools/hooks \
--
2.39.2