Skip to content

Commit

Permalink
dracut: make tpm2-tss an optional dependency of systemd-pcrphase (#10693
Browse files Browse the repository at this point in the history
)

Signed-off-by: Thien Trung Vuong <[email protected]>
  • Loading branch information
trungams authored Oct 26, 2024
1 parent 59216ae commit 1346b91
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From 96d153fe927987ce31a1f876b7eeea6fe9cee06a Mon Sep 17 00:00:00 2001
From: Laszlo Gombos <[email protected]>
Date: Thu, 30 May 2024 10:06:04 -0400
Subject: [PATCH] fix(systemd-pcrphase): in hostonly mode do not try to include
systemd-pcrphase

---
modules.d/01systemd-pcrphase/module-setup.sh | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules.d/01systemd-pcrphase/module-setup.sh b/modules.d/01systemd-pcrphase/module-setup.sh
index eb8520799..922711709 100755
--- a/modules.d/01systemd-pcrphase/module-setup.sh
+++ b/modules.d/01systemd-pcrphase/module-setup.sh
@@ -4,7 +4,6 @@

# Prerequisite check(s) for module.
check() {
-
# If the binary(s) requirements are not fulfilled the module can't be installed.
# systemd-255 renamed the binary, check for old and new location.
if ! require_binaries "$systemdutildir"/systemd-pcrphase \
@@ -12,23 +11,24 @@ check() {
return 1
fi

- return 0
+ if [[ $hostonly ]]; then
+ return 255
+ fi

+ return 0
}

# Module dependency requirements.
depends() {
-
# This module has external dependency on other module(s).
echo systemd tpm2-tss
+
# Return 0 to include the dependent module(s) in the initramfs.
return 0
-
}

# Install the required file(s) and directories for the module in the initramfs.
install() {
-
inst_multiple -o \
"$systemdutildir"/systemd-pcrphase \
"$systemdutildir"/systemd-pcrextend \
@@ -43,5 +43,4 @@ install() {
"$systemdsystemconfdir/systemd-pcrphase-initrd.service.d/*.conf" \
"$systemdsystemconfdir"/initrd.target.wants/systemd-pcrphase-initrd.service
fi
-
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From a2193b71f7be75f719eec29faacae36ab25e9147 Mon Sep 17 00:00:00 2001
From: Laszlo Gombos <[email protected]>
Date: Fri, 5 Jul 2024 14:17:00 -0400
Subject: [PATCH] fix(systemd-pcrphase): make tpm2-tss an optional dependency

---
modules.d/01systemd-pcrphase/module-setup.sh | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules.d/01systemd-pcrphase/module-setup.sh b/modules.d/01systemd-pcrphase/module-setup.sh
index 922711709..3016d7e44 100755
--- a/modules.d/01systemd-pcrphase/module-setup.sh
+++ b/modules.d/01systemd-pcrphase/module-setup.sh
@@ -21,7 +21,17 @@ check() {
# Module dependency requirements.
depends() {
# This module has external dependency on other module(s).
- echo systemd tpm2-tss
+
+ local deps
+ deps="systemd"
+
+ # optional dependencies
+ module="tpm2-tss"
+ module_check $module > /dev/null 2>&1
+ if [[ $? == 255 ]]; then
+ deps+=" $module"
+ fi
+ echo "$deps"

# Return 0 to include the dependent module(s) in the initramfs.
return 0
7 changes: 6 additions & 1 deletion SPECS/dracut/dracut.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Summary: dracut to create initramfs
Name: dracut
Version: 102
Release: 5%{?dist}
Release: 6%{?dist}
# The entire source code is GPLv2+
# except install/* which is LGPLv2+
License: GPLv2+ AND LGPLv2+
Expand Down Expand Up @@ -34,6 +34,8 @@ Patch: 0006-dracut.sh-validate-instmods-calls.patch
Patch: 0011-Remove-reference-to-kernel-module-zlib-in-fips-module.patch
Patch: 0012-fix-dracut-functions-avoid-awk-in-get_maj_min.patch
Patch: 0013-revert-fix-crypt-unlock-encrypted-devices-by-default.patch
Patch: 0014-fix-systemd-pcrphase-in-hostonly-mode-do-not-try-to-include-systemd-pcrphase.patch
Patch: 0015-fix-systemd-pcrphase-make-tpm2-tss-an-optional-dependency.patch

BuildRequires: bash
BuildRequires: kmod-devel
Expand Down Expand Up @@ -288,6 +290,9 @@ ln -srv %{buildroot}%{_bindir}/%{name} %{buildroot}%{_sbindir}/%{name}
%dir %{_sharedstatedir}/%{name}/overlay

%changelog
* Thu Oct 10 2024 Thien Trung Vuong <[email protected]> - 102-6
- Add patch to make tpm2-tss an optional dependency for systemd-pcrphase

* Sun Oct 06 2024 Jon Slobodzian <[email protected]> - 102-5
- Bump version to build with latest systemd

Expand Down

0 comments on commit 1346b91

Please sign in to comment.