[v5,6/7] initramfs-tee-ftpm-hook: Convert to hook.inc

Message ID 9c99494b0bbaf84f50cd70388372d5309224afc2.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:03 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Reduces the own bits significantly.

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

Patch

diff --git a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.script b/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/local-top
similarity index 75%
rename from meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.script
rename to meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/local-top
index 3355a7e0..989bf288 100644
--- a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.script
+++ b/meta/recipes-initramfs/initramfs-tee-ftpm-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="tee-supplicant"
-prereqs()
-{
-	echo "$PREREQ"
-}
-case $1 in
-prereqs)
-	prereqs
-	exit 0
-	;;
-esac
-
-. /scripts/functions
-
 FTPM_DEV=/dev/tpmrm0
 
 # The tee-supplicant would take some time to be discovered, 30 seconds should
diff --git a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.hook b/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.hook
deleted file mode 100644
index e80f00b4..00000000
--- a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/files/tee-ftpm.hook
+++ /dev/null
@@ -1,28 +0,0 @@ 
-#!/bin/sh
-# Copyright (c) Siemens AG, 2023
-#
-# Authors:
-#  Su Bao Cheng <baocheng.su@siemens.com>
-#
-# SPDX-License-Identifier: MIT
-#
-
-set -e
-
-PREREQ="tee-supplicant"
-prereqs()
-{
-    echo "$PREREQ"
-}
-case $1 in
-prereqs)
-    prereqs
-    exit 0
-    ;;
-esac
-
-. /usr/share/initramfs-tools/hook-functions
-
-# The tpm_ftpm_tee.ko does not exist in any stock debian kernels, it could be
-# provided by customized kernel.
-manual_add_modules tpm_ftpm_tee
diff --git a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-hook_0.1.bb b/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-hook_0.1.bb
deleted file mode 100644
index 82fec1bb..00000000
--- a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-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-ftpm.hook \
-    file://tee-ftpm.script \
-    "
-
-DEBIAN_DEPENDS = "initramfs-tools"
-
-do_install[cleandirs] += " \
-    ${D}/usr/share/initramfs-tools/hooks \
-    ${D}/usr/share/initramfs-tools/scripts/local-top"
-
-do_install() {
-    install -m 0755 "${WORKDIR}/tee-ftpm.hook" \
-        "${D}/usr/share/initramfs-tools/hooks/tee-ftpm"
-    install -m 0755 "${WORKDIR}/tee-ftpm.script" \
-        "${D}/usr/share/initramfs-tools/scripts/local-top/tee-ftpm"
-}
diff --git a/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-hook_0.2.bb b/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-hook_0.2.bb
new file mode 100644
index 00000000..9f77c158
--- /dev/null
+++ b/meta/recipes-initramfs/initramfs-tee-ftpm-hook/initramfs-tee-ftpm-hook_0.2.bb
@@ -0,0 +1,15 @@ 
+# 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_PREREQ = "tee-supplicant"
+HOOK_ADD_MODULES = "tpm_ftpm_tee"
+SCRIPT_PREREQ = "tee-supplicant"