public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] initramfs-fsck-hook: bump version and improve error handling
@ 2024-09-06  9:39 'Rakesh Kumar' via isar-users
  2024-09-06  9:56 ` 'Jan Kiszka' via isar-users
  0 siblings, 1 reply; 7+ messages in thread
From: 'Rakesh Kumar' via isar-users @ 2024-09-06  9:39 UTC (permalink / raw)
  To: isar-users; +Cc: jan.kiszka, cedric.hombourger, Rakesh Kumar

* Bump initramfs-fsck-hook version from 0.2 to 0.3.
* Renamed the package from initramfs-fsck-hook-ext4 to initramfs-fsck-ext4
  for better readability.
* Improved error handling in the hook script by introducing the
  hook_error() function to handle failures during copy_exec calls.
* Corrected the path for fsck from /sbin/fsck to /usr/sbin/fsck to
  reflect the correct location of the binary.

The script now provides clear error messages and exits on failure,
preventing silent errors during the initramfs setup.

Signed-off-by: Rakesh Kumar <kumar.rakesh@siemens.com>
---
 ...sck.ext4.hook => initramfs-fsck-ext4.hook} | 21 +++++++------------
 ....triggers => initramfs-fsck-ext4.triggers} |  0
 .../initramfs-fsck-ext4_0.3.bb                | 19 +++++++++++++++++
 .../initramfs-fsck-hook-ext4_0.2.bb           | 18 ----------------
 4 files changed, 26 insertions(+), 32 deletions(-)
 rename meta/recipes-support/initramfs-fsck-hook/files/{initramfs.fsck.ext4.hook => initramfs-fsck-ext4.hook} (51%)
 rename meta/recipes-support/initramfs-fsck-hook/files/{initramfs-fsck-hook-ext4.triggers => initramfs-fsck-ext4.triggers} (100%)
 create mode 100644 meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-ext4_0.3.bb
 delete mode 100644 meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-hook-ext4_0.2.bb

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
similarity index 51%
rename from meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook
rename to meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook
index 259b73b4..e81f06f9 100644
--- a/meta/recipes-support/initramfs-fsck-hook/files/initramfs.fsck.ext4.hook
+++ b/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook
@@ -5,8 +5,6 @@
 
 #!/bin/sh
 
-set -e
-
 PREREQ=""
 
 prereqs()
@@ -24,16 +22,11 @@ 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
+hook_error() {
+    echo "(ERROR): $1" >&2
+    exit 1
+}
 
-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
+copy_exec /usr/sbin/fsck || hook_error "Unable to copy /usr/sbin/fsck"
+copy_exec /usr/sbin/logsave || hook_error "Unable to copy /usr/sbin/logsave"
+copy_exec /usr/sbin/fsck.ext4 || hook_error "Unable to copy /usr/sbin/fsck.ext4"
diff --git a/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers b/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.triggers
similarity index 100%
rename from meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-hook-ext4.triggers
rename to meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.triggers
diff --git a/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-ext4_0.3.bb b/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-ext4_0.3.bb
new file mode 100644
index 00000000..c2136f9d
--- /dev/null
+++ b/meta/recipes-support/initramfs-fsck-hook/initramfs-fsck-ext4_0.3.bb
@@ -0,0 +1,19 @@
+# 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"
+
+DEBIAN_DEPENDS   = "e2fsprogs,initramfs-tools"
+
+inherit dpkg-raw
+SRC_URI = "file://${PN}.triggers    \
+           file://${PN}.hook        \
+          "
+do_install[cleandirs] += "${D}/etc/initramfs-tools/hooks"
+
+do_install() {
+        install -m 0755 ${WORKDIR}/${PN}.hook ${D}/etc/initramfs-tools/hooks/
+}
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
-}
-- 
2.39.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20240906093927.1814962-1-kumar.rakesh%40siemens.com.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-09  3:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06  9:39 [PATCH] initramfs-fsck-hook: bump version and improve error handling 'Rakesh Kumar' via isar-users
2024-09-06  9:56 ` 'Jan Kiszka' via isar-users
2024-09-07 16:51   ` [PATCH 1/2] initramfs-fsck-hook: bump version, rename package and files 'Rakesh Kumar' via isar-users
2024-09-07 16:51     ` [PATCH 2/2] initramfs-fsck-hook: improve error handling and correct fsck path 'Rakesh Kumar' via isar-users
2024-09-09  3:13       ` 'cedric.hombourger@siemens.com' via isar-users
2024-09-09  3:15     ` [PATCH 1/2] initramfs-fsck-hook: bump version, rename package and files 'cedric.hombourger@siemens.com' via isar-users
2024-09-07 16:59   ` [PATCH 0/2] initramfs-fsck-hook: version bump to 0.3 and error handling improvement 'Rakesh Kumar' via isar-users

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox