commit:     803a7e0b95164ddb661dee1448a4b19eceb09cc2
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Nov  7 15:00:13 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Thu Nov  9 02:27:41 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=803a7e0b

sys-kernel/dracut: fix resume module in hostonly mode

Closes: https://bugs.gentoo.org/917000
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 sys-kernel/dracut/dracut-060_pre20231030.ebuild    |  1 +
 .../files/dracut-060-fix-resume-hostonly.patch     | 65 ++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/sys-kernel/dracut/dracut-060_pre20231030.ebuild 
b/sys-kernel/dracut/dracut-060_pre20231030.ebuild
index f6149bdc6877..25b978da1b87 100644
--- a/sys-kernel/dracut/dracut-060_pre20231030.ebuild
+++ b/sys-kernel/dracut/dracut-060_pre20231030.ebuild
@@ -68,6 +68,7 @@ QA_MULTILIB_PATHS="usr/lib/dracut/.*"
 
 PATCHES=(
        "${FILESDIR}"/gentoo-ldconfig-paths-r1.patch
+       "${FILESDIR}"/dracut-060-fix-resume-hostonly.patch
 )
 
 src_configure() {

diff --git a/sys-kernel/dracut/files/dracut-060-fix-resume-hostonly.patch 
b/sys-kernel/dracut/files/dracut-060-fix-resume-hostonly.patch
new file mode 100644
index 000000000000..3563f85293fd
--- /dev/null
+++ b/sys-kernel/dracut/files/dracut-060-fix-resume-hostonly.patch
@@ -0,0 +1,65 @@
+https://bugs.gentoo.org/917000
+https://github.com/dracutdevs/dracut/pull/2494
+
+From b88d0bab791bdc4ca75d13802f0391caf537650d Mon Sep 17 00:00:00 2001
+From: Andrew Ammerlaan <andrewammerl...@gentoo.org>
+Date: Sun, 20 Aug 2023 11:47:22 +0200
+Subject: [PATCH] fix(resume): include in hostonly mode if resume= on cmdline
+
+The grep introduced in commit e3a7112bef794e2f2dd741ec2c74fa9cb9117651
+does not work as intended. The resume module is always excluded in hostonly
+mode.
+
+Made this a bit more explicit with if/else so it is more clear what is going
+on. The in-line ||/&& makes the line really long and makes it more difficult
+to understand what is going on.
+
+Bug: https://github.com/dracutdevs/dracut/issues/924
+Signed-off-by: Andrew Ammerlaan <andrewammerl...@gentoo.org>
+---
+ modules.d/95resume/module-setup.sh | 32 +++++++++++++++++++++++-------
+ 1 file changed, 25 insertions(+), 7 deletions(-)
+
+diff --git a/modules.d/95resume/module-setup.sh 
b/modules.d/95resume/module-setup.sh
+index d255103366..2d48043827 100755
+--- a/modules.d/95resume/module-setup.sh
++++ b/modules.d/95resume/module-setup.sh
+@@ -10,13 +10,31 @@ check() {
+         return 1
+     }
+ 
+-    # Only support resume if hibernation is currently on
+-    # and no swap is mounted on a net device
+-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+-        swap_on_netdevice || [[ -f /sys/power/resume && "$(< 
/sys/power/resume)" == "0:0" ]] || grep -rq '^\|[[:space:]]resume=' 
/proc/cmdline /etc/cmdline /etc/cmdline.d /etc/kernel/cmdline 
/usr/lib/kernel/cmdline 2> /dev/null && return 255
+-    }
+-
+-    return 0
++    # If hostonly check if we want to include the resume module
++    if [[ $hostonly ]] || [[ $mount_needs ]]; then
++        # Resuming won't work if swap is on a netdevice
++        swap_on_netdevice && return 255
++        if grep -rq 'resume=' /proc/cmdline /etc/cmdline /etc/cmdline.d 
/etc/kernel/cmdline /usr/lib/kernel/cmdline 2> /dev/null; then
++            # hibernation support requested on kernel command line
++            return 0
++        else
++            # resume= not set on kernel command line
++            if [[ -f /sys/power/resume ]]; then
++                if [[ "$(< /sys/power/resume)" == "0:0" ]]; then
++                    # hibernation supported by the kernel, but not enabled
++                    return 255
++                else
++                    # hibernation supported by the kernel and enabled
++                    return 0
++                fi
++            else
++                # resume file doesn't exist, hibernation not supported by 
kernel
++                return 255
++            fi
++        fi
++    else
++        return 0
++    fi
+ }
+ 
+ # called by dracut

Reply via email to