[v3,7/7] initramfs-tee-supplicant-hook: Convert to hook.inc

Message ID 1681d4daf7fcd5013cd36b32a5aa2bb66dd083ef.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>

Reduces the own bits significantly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../{tee-supplicant.script => local-top}      | 18 +---------
 .../files/tee-supplicant.hook                 | 36 -------------------
 .../initramfs-tee-supplicant-hook_0.1.bb      | 27 --------------
 .../initramfs-tee-supplicant-hook_0.2.bb      | 16 +++++++++
 4 files changed, 17 insertions(+), 80 deletions(-)
 rename meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/{tee-supplicant.script => local-top} (68%)
 delete mode 100644 meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.hook
 delete mode 100644 meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.1.bb
 create mode 100644 meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.2.bb

Patch

diff --git a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.script b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/local-top
similarity index 68%
rename from meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.script
rename to meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/local-top
index ac01d7ec..575a742d 100644
--- a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.script
+++ b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/local-top
@@ -1,4 +1,4 @@ 
-#!/bin/sh
+#
 # Copyright (c) Siemens AG, 2023
 #
 # Authors:
@@ -7,22 +7,6 @@ 
 # SPDX-License-Identifier: MIT
 #
 
-set -e
-
-PREREQ=""
-prereqs()
-{
-	echo "$PREREQ"
-}
-case $1 in
-prereqs)
-	prereqs
-	exit 0
-	;;
-esac
-
-. /scripts/functions
-
 /usr/sbin/modprobe optee
 /usr/sbin/tee-supplicant -d
 
diff --git a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.hook b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.hook
deleted file mode 100644
index 3e2f4016..00000000
--- a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/files/tee-supplicant.hook
+++ /dev/null
@@ -1,36 +0,0 @@ 
-#!/bin/sh
-# Copyright (c) Siemens AG, 2023
-#
-# Authors:
-#  Su Bao Cheng <baocheng.su@siemens.com>
-#
-# SPDX-License-Identifier: MIT
-#
-
-set -e
-
-PREREQ=""
-prereqs()
-{
-    echo "$PREREQ"
-}
-case $1 in
-prereqs)
-    prereqs
-    exit 0
-    ;;
-esac
-
-. /usr/share/initramfs-tools/hook-functions
-
-hook_error() {
-    echo "(ERROR): $1" >&2
-    exit 1
-}
-
-# For stock debian bookworm arm64 kernel, these two .ko exist, but not built-in.
-manual_add_modules tee
-manual_add_modules optee
-
-copy_exec /usr/sbin/tee-supplicant || hook_error "/usr/sbin/tee-supplicant not found"
-copy_exec /usr/bin/pgrep || hook_error "/usr/bin/pgrep not found"
diff --git a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.1.bb b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.1.bb
deleted file mode 100644
index a7a19bee..00000000
--- a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.1.bb
+++ /dev/null
@@ -1,27 +0,0 @@ 
-# Copyright (c) Siemens AG, 2023
-#
-# Authors:
-#  Su Bao Cheng <baocheng.su@siemens.com>
-#
-# SPDX-License-Identifier: MIT
-#
-
-inherit dpkg-raw
-
-SRC_URI += " \
-    file://tee-supplicant.hook \
-    file://tee-supplicant.script \
-    "
-
-DEBIAN_DEPENDS = "initramfs-tools, tee-supplicant, procps"
-
-do_install[cleandirs] += " \
-    ${D}/usr/share/initramfs-tools/hooks \
-    ${D}/usr/share/initramfs-tools/scripts/local-top"
-
-do_install() {
-    install -m 0755 "${WORKDIR}/tee-supplicant.hook" \
-        "${D}/usr/share/initramfs-tools/hooks/tee-supplicant"
-    install -m 0755 "${WORKDIR}/tee-supplicant.script" \
-        "${D}/usr/share/initramfs-tools/scripts/local-top/tee-supplicant"
-}
diff --git a/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.2.bb b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.2.bb
new file mode 100644
index 00000000..b9dedfd3
--- /dev/null
+++ b/meta/recipes-initramfs/initramfs-tee-supplicant-hook/initramfs-tee-supplicant-hook_0.2.bb
@@ -0,0 +1,16 @@ 
+# Copyright (c) Siemens AG, 2023-2024
+#
+# Authors:
+#  Su Bao Cheng <baocheng.su@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+require recipes-initramfs/initramfs-hook/hook.inc
+
+SRC_URI += "file://local-top"
+
+HOOK_ADD_MODULES = "tee optee"
+HOOK_COPY_EXECS = "tee-supplicant pgrep"
+
+DEBIAN_DEPENDS .= ", tee-supplicant, procps"