initramfs-overlay-hook: Rename INITRAMFS_OVERLAY_MOUNT_OPTION variable to plural
PATCH 1/2 initramfs-overlay-hook: Rename INITRAMFS_OVERLAY_MOUNT_OPTION variable to plural
From: Jan Kiszka <[email protected]>
There can actually be multiple options. So make the variable name more intuitive. Provide a smooth migration path, only annoying users with a parser warning for now. The cleanup date is set to two years from now which should be enough.
Signed-off-by Jan Kiszka <[email protected]>
---
.../initramfs-overlay-hook/files/local-bottom.tmpl | 2 +-
...y-hook_0.3.bb => initramfs-overlay-hook_0.4.bb} | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
rename recipes-initramfs/initramfs-overlay-hook/{initramfs-overlay-hook_0.3.bb => initramfs-overlay-hook_0.4.bb} (77%)recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl +1 -1
@@ -16,7 +16,7 @@ storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )" if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then ovl_partition_device="${INITRAMFS_OVERLAY_STORAGE_DEVICE}" - ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" + ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTIONS}" ovl_recovery_script="/scripts/${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}" partition_fstype=$(get_fstype "${ovl_partition_device}")
recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.4.bb renamed from recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.3.bb +11 -3
@@ -1,7 +1,7 @@ # # CIP Core, generic profile # -# Copyright (c) Siemens AG, 2022 - 2024 +# Copyright (c) Siemens AG, 2022 - 2025 # # Authors: # Jan Kiszka <[email protected]>
@@ -33,13 +33,21 @@ INITRAMFS_OVERLAY_STORAGE_PATH ??= "/var/local" INITRAMFS_OVERLAY_STORAGE_DEVICE ??= "/dev/disk/by-label/var" # options to use for mounting INITRAMFS_OVERLAY_STORAGE_DEVICE -INITRAMFS_OVERLAY_MOUNT_OPTION ??= "defaults,nodev,nosuid,noexec" +INITRAMFS_OVERLAY_MOUNT_OPTIONS ??= "defaults,nodev,nosuid,noexec" + +python() { + # to be dropped end of 2027 + legacy_var = d.getVar('INITRAMFS_OVERLAY_MOUNT_OPTION') + if legacy_var: + bb.warn("Legacy use of INITRAMFS_OVERLAY_MOUNT_OPTION detected. Migrate to INITRAMFS_OVERLAY_MOUNT_OPTIONS.") + d.setVar('INITRAMFS_OVERLAY_MOUNT_OPTIONS', legacy_var) +} TEMPLATE_FILES += "local-bottom.tmpl" TEMPLATE_VARS += " INITRAMFS_OVERLAY_STORAGE_PATH \ INITRAMFS_OVERLAY_PATHS \ INITRAMFS_OVERLAY_STORAGE_DEVICE \ - INITRAMFS_OVERLAY_MOUNT_OPTION \ + INITRAMFS_OVERLAY_MOUNT_OPTIONS \ INITRAMFS_OVERLAY_RECOVERY_SCRIPT" DEBIAN_DEPENDS .= ", awk, coreutils, util-linux, e2fsprogs"
Signature · 1 line
2.51.0
PATCH 2/2 initramfs-overlay-hook: Address shellcheck findings
From: Jan Kiszka <[email protected]>
Just quoting warnings.
Signed-off-by Jan Kiszka <[email protected]>
--- .../files/local-bottom.tmpl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl +9 -9
@@ -33,10 +33,10 @@ if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then fi ;; esac - if ! mount -t ${partition_fstype} \ - -o ${ovl_mount_option} \ - ${ovl_partition_device} \ - ${rootmnt}${storage_mount_point}; then + if ! mount -t "${partition_fstype}" \ + -o "${ovl_mount_option}" \ + "${ovl_partition_device}" \ + "${rootmnt}${storage_mount_point}"; then panic "Can't mount ${storage_mount_point} partition - overlay will not work!" fi fi
@@ -44,19 +44,19 @@ fi for ovl_lower_dir in ${ovl_lower_dirs}; do # remove the first '/' and replace all '/' with '_' # on variable $ovl_lower_dir - work_dir_name=$(awk -v var=$ovl_lower_dir \ + work_dir_name=$(awk -v var="$ovl_lower_dir" \ 'BEGIN{subvar=substr(var,2);gsub("/","_",subvar);print subvar}') lower_dir=${rootmnt}${ovl_lower_dir} upper_dir=${root_mount_storage}${ovl_lower_dir} work_dir=${root_mount_storage}/.${work_dir_name}-atomic - mkdir -p ${upper_dir} - mkdir -p ${work_dir} + mkdir -p "${upper_dir}" + mkdir -p "${work_dir}" if ! mount -t overlay \ - -o lowerdir=${lower_dir},upperdir=${upper_dir},workdir=${work_dir} \ - overlay ${lower_dir}; then + -o lowerdir="${lower_dir}",upperdir="${upper_dir}",workdir="${work_dir}" \ + overlay "${lower_dir}"; then panic "Can't mount overlay for '$ovl_lower_dir' !" fi done
Signature · 1 line
2.51.0