From f6bcd819fc2645f762946a802c15684e7627f379 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 15 Jul 2022 15:11:44 +0800 Subject: [PATCH] use /run/ostree-booted to tell if scriptlet is running on OSTree system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: bz2092012 According to the ostree team [1], the existence of /run/ostree-booted > is the most stable way to signal/check that a system has been > booted in ostree-style. It is also used by rpm-ostree at > compose/install time in the sandboxed environment where scriptlets run, > in order to signal that the package is being installed/composed into > an ostree commit (i.e. not directly on a live system). See > https://github.com/coreos/rpm-ostree/blob/8ddf5f40d9cbbd9d3668cc75b703316e0a89ab11/src/libpriv/rpmostree-scripts.cxx#L350-L353 > for reference. By checking the existence of /run/ostree-booted, we could skip trying to update kernel cmdline during OSTree compose time. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2092012#c3 Reported-by: Luca BRUNO Suggested-by: Luca BRUNO Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Acked-by: Timothée Ravier --- kexec-tools.spec | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index bdc3b95..c82bea8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -262,8 +262,12 @@ mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ %pre -# save the old default crashkernel values to /tmp/ when upgrading the package -if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then +# Save the old default crashkernel values to /tmp/ when upgrading the package +# so kdumpctl later can tell if it should update the kernel crashkernel +# parameter in the posttrans scriptlet. Note this feauture of auto-updating +# the kernel crashkernel parameter currently doesn't support ostree, so skip it +# for ostree. +if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null @@ -338,9 +342,14 @@ do done %posttrans -# try to reset kernel crashkernel value to new default value when upgrading -# the package -if ! grep -qs "ostree" /proc/cmdline && [ $1 == 1 ]; then +# Try to reset kernel crashkernel value to new default value based on the old +# default value or set up crasherkernel value for osbuild +# +# Note +# 1. Skip ostree systems as they are not supported. +# 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The +# former case is used to set up crashkernel for osbuild +if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then kdumpctl reset-crashkernel-after-update rm /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le