[v5,5/7] initramfs-fsck-ext4-hook: Convert to hook.inc and improve

Message ID 0c4bdba32d59b3e97b2962ffc7edfde9659b6ae0.1732122181.git.jan.kiszka@siemens.com
State Accepted, archived
Headers show
Series Simplify writing initramfs hooks | expand

Commit Message

Jan Kiszka Nov. 20, 2024, 5:02 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Use the convention and helping features of the new initramfs hook.inc to
simplify this hook. We move it under recipes-initramfs to align with
other recipes there. Another change is making fsck.ext4 mandatory, both
as dependency and while copying it in via the helper - there is no
reason for this recipe to almost silently ignore any unavailability.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../images/isar-initramfs.bb                  |  2 +-
 .../files/initramfs-fsck-hook-ext4.triggers   |  0
 .../initramfs-fsck-ext4-hook_0.3.bb           | 14 +++++++
 .../files/initramfs.fsck.ext4.hook            | 39 -------------------
 .../initramfs-fsck-hook-ext4_0.2.bb           | 18 ---------
 5 files changed, 15 insertions(+), 58 deletions(-)
 rename meta/{recipes-support => recipes-initramfs}/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers (100%)
 create mode 100644 meta/recipes-initramfs/initramfs-fsck-hook/initramfs-fsck-ext4-hook_0.3.bb
 delete mode 100644 meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook
 delete mode 100644 meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-hook-ext4_0.2.bb

Patch

diff --git a/meta-isar/recipes-initramfs/images/isar-initramfs.bb b/meta-isar/recipes-initramfs/images/isar-initramfs.bb
index 71dbaa43..d2a946f7 100644
--- a/meta-isar/recipes-initramfs/images/isar-initramfs.bb
+++ b/meta-isar/recipes-initramfs/images/isar-initramfs.bb
@@ -15,5 +15,5 @@  INITRAMFS_PREINSTALL += " \
 # Recipes that should be installed into the initramfs build rootfs.
 INITRAMFS_INSTALL += " \
     initramfs-isar-example-hook \
-    initramfs-fsck-hook-ext4 \
+    initramfs-fsck-ext4-hook \
     "
diff --git a/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers b/meta/recipes-initramfs/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers
similarity index 100%
rename from meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers
rename to meta/recipes-initramfs/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers
diff --git a/meta/recipes-initramfs/initramfs-fsck-hook/initramfs-fsck-ext4-hook_0.3.bb b/meta/recipes-initramfs/initramfs-fsck-hook/initramfs-fsck-ext4-hook_0.3.bb
new file mode 100644
index 00000000..c4d10c44
--- /dev/null
+++ b/meta/recipes-initramfs/initramfs-fsck-hook/initramfs-fsck-ext4-hook_0.3.bb
@@ -0,0 +1,14 @@ 
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019-2024
+#
+# SPDX-License-Identifier: MIT
+
+DESCRIPTION = "Recipe to add fsck hook to the initramfs"
+
+require recipes-initramfs/initramfs-hook/hook.inc
+
+SRC_URI += "file://initramfs-fsck-hook-ext4.triggers"
+
+HOOK_COPY_EXECS = "fsck fsck.ext4 logsave"
+
+DEBIAN_DEPENDS .= ", e2fsprogs, logsave"
diff --git a/meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook b/meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook
deleted file mode 100644
index 259b73b4..00000000
--- a/meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook
+++ /dev/null
@@ -1,39 +0,0 @@ 
-# This software is a part of ISAR.
-# Copyright (C) Siemens AG, 2019
-#
-# SPDX-License-Identifier: MIT
-
-#!/bin/sh
-
-set -e
-
-PREREQ=""
-
-prereqs()
-{
-     echo "$PREREQ"
-}
-
-case $1 in
-prereqs)
-     prereqs
-     exit 0
-     ;;
-esac
-
-. /usr/share/initramfs-tools/scripts/functions
-. /usr/share/initramfs-tools/hook-functions
-
-if [ ! -x /sbin/fsck ]; then
-	echo "Warning: couldn't find /sbin/fsck!"
-	exit 0
-fi
-
-copy_exec /sbin/fsck
-copy_exec /sbin/logsave
-
-if prog="$(command -v fsck.ext4)"; then
-  copy_exec "$prog"
-else
-  echo "Warning: /sbin/fsck.ext4 doesn't exist, can't install to initramfs, ignoring."
-fi
diff --git a/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-hook-ext4_0.2.bb b/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-hook-ext4_0.2.bb
deleted file mode 100644
index 9860dbc8..00000000
--- a/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-hook-ext4_0.2.bb
+++ /dev/null
@@ -1,18 +0,0 @@ 
-# This software is a part of ISAR.
-# Copyright (C) Siemens AG, 2019
-#
-# SPDX-License-Identifier: MIT
-
-
-DESCRIPTION = "Recipe to add fsck hook to the initramfs"
-
-inherit dpkg-raw
-SRC_URI = "file://initramfs-fsck-hook-ext4.triggers \
-           file://initramfs.fsck.ext4.hook \
-          "
-
-
-do_install() {
-        install -m 0755 -d ${D}/etc/initramfs-tools/hooks
-        install -m 0740 ${WORKDIR}/initramfs.fsck.ext4.hook ${D}/etc/initramfs-tools/hooks/fsck.ext4.hook
-}