[v3,4/7] initramfs-isar-example-hook: Convert recipe over to new hook.inc

Message ID a0fb4ba14224894e66f64a340be380caf9ca0bb8.1731754552.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series Simplify writing initramfs hooks | expand

Commit Message

Jan Kiszka Nov. 16, 2024, 10:55 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Allows to drop the own hook recipe and makes the local-top boot script
effectively a one-liner.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../images/isar-initramfs.bb                  |  2 +-
 .../initramfs-example/files/example.hook      | 21 -----------------
 .../initramfs-example/files/example.script    | 23 -------------------
 .../initramfs-example/files/local-top         |  3 +++
 ....bb => initramfs-isar-example-hook_0.1.bb} | 21 ++++++-----------
 5 files changed, 11 insertions(+), 59 deletions(-)
 delete mode 100644 meta-isar/recipes-initramfs/initramfs-example/files/example.hook
 delete mode 100644 meta-isar/recipes-initramfs/initramfs-example/files/example.script
 create mode 100644 meta-isar/recipes-initramfs/initramfs-example/files/local-top
 rename meta-isar/recipes-initramfs/initramfs-example/{initramfs-example.bb => initramfs-isar-example-hook_0.1.bb} (63%)

Patch

diff --git a/meta-isar/recipes-initramfs/images/isar-initramfs.bb b/meta-isar/recipes-initramfs/images/isar-initramfs.bb
index 4df9e0b8..71dbaa43 100644
--- a/meta-isar/recipes-initramfs/images/isar-initramfs.bb
+++ b/meta-isar/recipes-initramfs/images/isar-initramfs.bb
@@ -14,6 +14,6 @@  INITRAMFS_PREINSTALL += " \
 
 # Recipes that should be installed into the initramfs build rootfs.
 INITRAMFS_INSTALL += " \
-    initramfs-example \
+    initramfs-isar-example-hook \
     initramfs-fsck-hook-ext4 \
     "
diff --git a/meta-isar/recipes-initramfs/initramfs-example/files/example.hook b/meta-isar/recipes-initramfs/initramfs-example/files/example.hook
deleted file mode 100644
index ba848c92..00000000
--- a/meta-isar/recipes-initramfs/initramfs-example/files/example.hook
+++ /dev/null
@@ -1,21 +0,0 @@ 
-#!/bin/sh
-# Example hook script.
-#
-# See "HOOK SCRIPTS" in initramfs-tools(7) for details.
-
-set -e
-
-PREREQ=""
-prereqs()
-{
-    echo "$PREREQ"
-}
-case $1 in
-prereqs)
-    prereqs
-    exit 0
-    ;;
-esac
-
-. /usr/share/initramfs-tools/hook-functions
-# Begin real processing below this line
diff --git a/meta-isar/recipes-initramfs/initramfs-example/files/example.script b/meta-isar/recipes-initramfs/initramfs-example/files/example.script
deleted file mode 100644
index c55e9ea7..00000000
--- a/meta-isar/recipes-initramfs/initramfs-example/files/example.script
+++ /dev/null
@@ -1,23 +0,0 @@ 
-#!/bin/sh
-# Example boot script.
-#
-# See "BOOT SCRIPTS" in initramfs-tools(7) for details.
-
-set -e
-
-PREREQ=""
-prereqs()
-{
-    echo "$PREREQ"
-}
-case $1 in
-prereqs)
-    prereqs
-    exit 0
-    ;;
-esac
-
-. /scripts/functions
-# Begin real processing below this line
-
-log_success_msg "Hello from ISAR!"
diff --git a/meta-isar/recipes-initramfs/initramfs-example/files/local-top b/meta-isar/recipes-initramfs/initramfs-example/files/local-top
new file mode 100644
index 00000000..66e382b4
--- /dev/null
+++ b/meta-isar/recipes-initramfs/initramfs-example/files/local-top
@@ -0,0 +1,3 @@ 
+# Script header is provided by initramfs-hook/hook.inc
+
+log_success_msg "Hello from ISAR!"
diff --git a/meta-isar/recipes-initramfs/initramfs-example/initramfs-example.bb b/meta-isar/recipes-initramfs/initramfs-example/initramfs-isar-example-hook_0.1.bb
similarity index 63%
rename from meta-isar/recipes-initramfs/initramfs-example/initramfs-example.bb
rename to meta-isar/recipes-initramfs/initramfs-example/initramfs-isar-example-hook_0.1.bb
index c336dda9..8c600639 100644
--- a/meta-isar/recipes-initramfs/initramfs-example/initramfs-example.bb
+++ b/meta-isar/recipes-initramfs/initramfs-example/initramfs-isar-example-hook_0.1.bb
@@ -4,37 +4,30 @@ 
 #
 # This software is a part of ISAR.
 
+require recipes-initramfs/initramfs-hook/hook.inc
+
 DESCRIPTION = "Sample initramfs module for ISAR"
 MAINTAINER = "Your name here <you@domain.com>"
-DEBIAN_DEPENDS = "initramfs-tools"
 
 # If the conf-hook enables BUSYBOX=y, busybox is needed:
 DEBIAN_DEPENDS .= ", busybox"
 
-SRC_URI = " \
+SRC_URI += " \
     file://example.conf-hook \
-    file://example.hook \
-    file://example.script \
+    file://local-top \
     "
 
-inherit dpkg-raw
-
 do_install[cleandirs] += " \
     ${D}/usr/share/initramfs-tools/conf-hooks.d \
-    ${D}/usr/share/initramfs-tools/hooks \
-    ${D}/usr/share/initramfs-tools/scripts/local-top \
     "
-do_install() {
+do_install:append() {
     # See "CONFIGURATION HOOK SCRIPTS" in initramfs-tools(7) for details.
     install "${WORKDIR}/example.conf-hook" \
         "${D}/usr/share/initramfs-tools/conf-hooks.d/isar-example"
 
-    # See "HOOK SCRIPTS" in initramfs-tools(7) for details.
-    install "${WORKDIR}/example.hook" \
-        "${D}/usr/share/initramfs-tools/hooks/isar-example"
+    # See "HOOK SCRIPTS" in initramfs-tools(7) for details on
+    # hook-header[.tmpl] + hook.
 
     # Note that there are other places where a boot script might be deployed to,
     # apart from local-top.  See "BOOT SCRIPTS" in initramfs-tools(7) for details.
-    install "${WORKDIR}/example.script" \
-        "${D}/usr/share/initramfs-tools/scripts/local-top/example.script"
 }