Blame SOURCES/0023-Conditionally-create-debug-entries-when-installing-k.patch

56d25d
From 591c275f45202e8f0d2d8f1c719ef224a2ec325c Mon Sep 17 00:00:00 2001
775cb0
From: Peter Jones <pjones@redhat.com>
775cb0
Date: Mon, 15 Sep 2014 15:20:34 -0400
56d25d
Subject: [PATCH 23/41] Conditionally create debug entries when installing
775cb0
 kernels.
775cb0
775cb0
if /etc/sysconfig/kernel has MAKEDEBUG set to "yes", create non-default
775cb0
entries that have systemd.debug set.
775cb0
775cb0
Resolves: rhbz#957681
775cb0
Signed-off-by: Peter Jones <pjones@redhat.com>
775cb0
---
775cb0
 new-kernel-pkg | 190 ++++++++++++++++++++++++++++++++++++---------------------
775cb0
 1 file changed, 119 insertions(+), 71 deletions(-)
775cb0
775cb0
diff --git a/new-kernel-pkg b/new-kernel-pkg
775cb0
index d9a9b67..70f6118 100755
775cb0
--- a/new-kernel-pkg
775cb0
+++ b/new-kernel-pkg
775cb0
@@ -50,6 +50,7 @@ grubConfig=""
775cb0
 grub2Config=""
775cb0
 grub2EfiConfig=""
775cb0
 extlinuxConfig=""
775cb0
+ubootScript="/boot/boot.scr"
775cb0
 
775cb0
 ARCH=$(uname -m)
775cb0
 
775cb0
@@ -120,6 +121,7 @@ mbkernel="$HYPERVISOR"
775cb0
 mbargs="$HYPERVISOR_ARGS"
775cb0
 adddracutargs=""
775cb0
 addplymouthinitrd=""
775cb0
+DEBUGARG="systemd.debug"
775cb0
 
775cb0
 usage() {
775cb0
     echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
775cb0
@@ -134,6 +136,41 @@ usage() {
775cb0
     exit 1
775cb0
 }
775cb0
 
775cb0
+rungrubby() {
775cb0
+	if [ "$1" == "--debug" ]; then
775cb0
+		[ "$MAKEDEBUG" != "yes" ] && return 0
775cb0
+		[ -n "$verbose" ] && echo "- First, making a debug entry."
775cb0
+		declare -x debugtitle=" with debugging"
775cb0
+		declare -x debugargs="$DEBUGARG"
775cb0
+		shift
775cb0
+	else
775cb0
+		[ -n "$verbose" ] && echo "- Making a normal entry."
775cb0
+	fi
775cb0
+	$(eval $grubby $@)
775cb0
+	export -n debugargs
775cb0
+	export -n debugtitle
775cb0
+	unset debugargs
775cb0
+	unset debugtitle
775cb0
+}
775cb0
+
775cb0
+set_title() {
775cb0
+    if [ -n "$banner" ]; then
775cb0
+	if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
775cb0
+	    title=$(echo $banner | sed 's/ /_/g')
775cb0
+	else
775cb0
+	    title="$banner ($version)"
775cb0
+	fi
775cb0
+    elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
775cb0
+	title=$(echo $version | sed 's/ /_/g')
775cb0
+    elif [ -f /etc/os-release ]; then
775cb0
+	. /etc/os-release
775cb0
+	title="$NAME ($version) $VERSION"
775cb0
+    elif [ -f /etc/redhat-release ]; then
775cb0
+	title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)"
775cb0
+    else
775cb0
+	title="Red Hat Linux ($version)"
775cb0
+    fi
775cb0
+}
775cb0
 
775cb0
 install() {
775cb0
     # XXX kernel should be able to be specified also (or work right on ia64)
775cb0
@@ -184,57 +221,49 @@ install() {
775cb0
 	cfgLilo=""
775cb0
     fi
775cb0
 
775cb0
-
775cb0
-    if [ -n "$banner" ]; then
775cb0
-	if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
775cb0
-	    title=$(echo $banner | sed 's/ /_/g')
775cb0
-	else
775cb0
-	    title="$banner ($version)"
775cb0
-	fi
775cb0
-    elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
775cb0
-	title=$(echo $version | sed 's/ /_/g')
775cb0
-    elif [ -f /etc/os-release ]; then
775cb0
-	. /etc/os-release
775cb0
-	title="$NAME ($version) $VERSION"
775cb0
-    elif [ -f /etc/redhat-release ]; then
775cb0
-	title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)"
775cb0
-    else
775cb0
-	title="Red Hat Linux ($version)"
775cb0
-    fi
775cb0
-
775cb0
+    set_title
775cb0
 
775cb0
     if [ -n "$cfgGrub" ]; then
775cb0
 	[ -n "$verbose" ] && echo "adding $version to $grubConfig"
775cb0
 
775cb0
-	$grubby --grub -c $grubConfig \
775cb0
-	    --add-kernel=$kernelImage \
775cb0
-	    $INITRD --copy-default $makedefault --title "$title" \
775cb0
-	    ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
775cb0
-	    --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
775cb0
+	ARGS="--grub -c $grubConfig --add-kernel=$kernelImage $INITRD \
775cb0
+		${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+		${mbargs:+--mbargs=\"$mbargs\"} \
775cb0
+		--title=\"$title\$debugtitle\" --copy-default \
775cb0
+		--args=\"root=$rootdevice $kernargs \$debugargs\" \
775cb0
+		--remove-kernel=\"TITLE=$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS} $makedefault
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97"
775cb0
     fi
775cb0
     if [ -n "$cfgGrub2" ]; then
775cb0
 	[ -n "$verbose" ] && echo "adding $version to $grub2Config"
775cb0
 
775cb0
-	$grubby --grub2 -c $grub2Config \
775cb0
-	    --add-kernel=$kernelImage \
775cb0
-	    $INITRD --copy-default $makedefault --title "$title" \
775cb0
-	    ${mbkernel:+--add-multiboot="$mbkernel"} \
775cb0
-	    ${mbargs:+--mbargs="$mbargs"} \
775cb0
-	    --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
775cb0
+	ARGS="--grub2 -c $grub2Config --add-kernel=$kernelImage $INITRD \
775cb0
+		--copy-default --title \"$title\$debugtitle\" \
775cb0
+		${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+		${mbargs:+--mbargs=\"$mbargs\"} \
775cb0
+		--args=\"root=$rootdevice $kernargs \$debugargs\" \
775cb0
+		--remove-kernel=\"TITLE=$title\$debugtitle\""
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS} $makedefault
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2"
775cb0
     fi
775cb0
     if [ -n "$cfgGrub2Efi" ]; then
775cb0
 	[ -n "$verbose" ] && echo "adding $version to $grub2EfiConfig"
775cb0
 
775cb0
-	$grubby --grub2 -c $grub2EfiConfig --efi \
775cb0
-	    --add-kernel=$kernelImage $DEVTREE \
775cb0
-	    $INITRD --copy-default $makedefault --title "$title" \
775cb0
-	    ${mbkernel:+--add-multiboot="$mbkernel"} \
775cb0
-	    ${mbargs:+--mbargs="$mbargs"} \
775cb0
-	    --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
775cb0
+	ARGS="--grub2 -c $grub2EfiConfig --efi \
775cb0
+		--add-kernel=$kernelImage $DEVTREE $INITRD \
775cb0
+		--copy-default --title \"$title\$debugtitle\" \
775cb0
+		${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+		${mbargs:+--mbargs=\"$mbargs\"} \
775cb0
+		--args=\"root=$rootdevice $kernargs \$debugargs\" \
775cb0
+		--remove-kernel=\"TITLE=$title\$debugtitle\""
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS} $makedefault
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI"
775cb0
     fi
775cb0
@@ -242,12 +271,15 @@ install() {
775cb0
     if [ -n "$cfgLilo" ]; then
775cb0
 	[ -n "$verbose" ] && echo "adding $version to $liloConfig"
775cb0
 
775cb0
-	$grubby --add-kernel=$kernelImage $INITRD \
775cb0
-		--copy-default $makedefault --title "$title" \
775cb0
-		${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
775cb0
-		--args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$version" \
775cb0
-		--$liloFlag
775cb0
+	ARGS="--$liloFlag --add-kernel=$kernelImage $INITRD \
775cb0
+		--copy-default --title \"$title\$debugtitle\" \
775cb0
+		${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+		${mbargs:+--mbargs=\"$mbargs\"} \
775cb0
+		--args=\"root=$rootdevice $kernargs \$debugargs\" \
775cb0
+		--remove-kernel=\"TITLE=$version\""
775cb0
 
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS} $makedefault
775cb0
 	if [ -n "$runLilo" ]; then
775cb0
 	    [ -n "$verbose" ] && echo "running $lilo"
775cb0
 	    if [ ! -x $lilo ] ; then
775cb0
@@ -263,11 +295,15 @@ install() {
775cb0
     if [ -n "$cfgExtlinux" ]; then
775cb0
 	[ -n "$verbose" ] && echo "adding $version to $extlinuxConfig"
775cb0
 
775cb0
-	$grubby --extlinux -c $extlinuxConfig \
775cb0
-	    --add-kernel=$kernelImage \
775cb0
-	    $INITRD --copy-default $makedefault --title "$title" \
775cb0
-	    ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
775cb0
-	    --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
775cb0
+	ARGS="--extlinux -c $extlinuxConfig --add-kernel=$kernelImage \
775cb0
+	    $INITRD --copy-default --title \"$title\$debugtitle\" \
775cb0
+	    ${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+	    ${mbargs:+--mbargs=\"$mbargs\"} \
775cb0
+	    --args=\"root=$rootdevice $kernargs \$debugargs\" \
775cb0
+	    --remove-kernel=\"TITLE=$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS} $makedefault
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux"
775cb0
     fi
775cb0
@@ -401,6 +437,8 @@ update() {
775cb0
 	return
775cb0
     fi
775cb0
 
775cb0
+    set_title
775cb0
+
775cb0
     INITRD=""
775cb0
     if [ -f $initrdfile ]; then
775cb0
 	[ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"
775cb0
@@ -413,45 +451,53 @@ update() {
775cb0
 
775cb0
     if [ -n "$cfgGrub" ]; then
775cb0
 	[ -n "$verbose" ] && echo "updating $version from $grubConfig"
775cb0
-	$grubby --grub -c $grubConfig \
775cb0
-	    --update-kernel=$kernelImage \
775cb0
-	    $INITRD \
775cb0
-	    ${kernargs:+--args="$kernargs"} \
775cb0
-	    ${removeargs:+--remove-args="$removeargs"} \
775cb0
-	    ${mbkernel:+--add-multiboot="$mbkernel"}
775cb0
+	ARGS="--grub -c $grubConfig --update-kernel=$kernelImage $INITRD \
775cb0
+		${kernargs:+--args=\"$kernargs\"} \
775cb0
+		${removeargs:+--remove-args=\"$removeargs\"} \
775cb0
+		${mbkernel:+--add-multiboot=\"$mbkernel\"} \
775cb0
+		--title=\"$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS}
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
775cb0
     fi
775cb0
 
775cb0
     if [ -n "$cfgGrub2" ]; then
775cb0
 	[ -n "$verbose" ] && echo "updating $version from $grub2Config"
775cb0
-	$grubby --grub2 -c $grub2Config \
775cb0
-	    --update-kernel=$kernelImage \
775cb0
-	    $INITRD \
775cb0
-	    ${kernargs:+--args="$kernargs"} \
775cb0
-	    ${removeargs:+--remove-args="$removeargs"}
775cb0
+	ARGS="--grub2 -c $grub2Config --update-kernel=$kernelImage $INITRD \
775cb0
+		${kernargs:+--args=\"$kernargs\"} \
775cb0
+		${removeargs:+--remove-args=\"$removeargs\"} \
775cb0
+		--title=\"$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS}
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby"
775cb0
     fi
775cb0
 
775cb0
     if [ -n "$cfgGrub2Efi" ]; then
775cb0
 	[ -n "$verbose" ] && echo "updating $version from $grub2EfiConfig"
775cb0
-	$grubby --grub2 -c $grub2EfiConfig --efi \
775cb0
-	    --update-kernel=$kernelImage \
775cb0
-	    $INITRD \
775cb0
-	    ${kernargs:+--args="$kernargs"} \
775cb0
-	    ${removeargs:+--remove-args="$removeargs"}
775cb0
+	ARGS="--grub2 -c $grub2EfiConfig --efi --update-kernel=$kernelImage \
775cb0
+		$INITRD ${kernargs:+--args=\"$kernargs\"} \
775cb0
+		${removeargs:+--remove-args=\"$removeargs\"} \
775cb0
+		--title=\"$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS}
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby"
775cb0
     fi
775cb0
 
775cb0
     if [ -n "$cfgLilo" ]; then
775cb0
 	[ -n "$verbose" ] && echo "updating $version from $liloConfig"
775cb0
-	$grubby --update-kernel=$kernelImage \
775cb0
-	    $INITRD \
775cb0
-	    ${kernargs:+--args="$kernargs"} \
775cb0
-	    ${removeargs:+--remove-args="$removeargs"}	\
775cb0
-		     --$liloFlag
775cb0
+	ARGS="--$liloFlag --update-kernel=$kernelImage $INITRD \
775cb0
+		${kernargs:+--args=\"$kernargs\"} \
775cb0
+		${removeargs:+--remove-args=\"$removeargs\"} \
775cb0
+		--title=\"$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS}
775cb0
 
775cb0
 	if [ -n "$runLilo" ]; then
775cb0
 	    [ -n "$verbose" ] && echo "running $lilo"
775cb0
@@ -497,11 +543,13 @@ update() {
775cb0
 
775cb0
     if [ -n "$cfgExtlinux" ]; then
775cb0
 	[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
775cb0
-	$grubby --extlinux -c $extlinuxConfig \
775cb0
-	    --update-kernel=$kernelImage \
775cb0
-	    $INITRD \
775cb0
-	    ${kernargs:+--args="$kernargs"} \
775cb0
-	    ${removeargs:+--remove-args="$removeargs"}
775cb0
+	ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
775cb0
+		$INITRD ${kernargs:+--args=\"$kernargs\"} \
775cb0
+		${removeargs:+--remove-args=\"$removeargs\"} \
775cb0
+		--title=\"$title\$debugtitle\""
775cb0
+
775cb0
+	rungrubby --debug ${ARGS}
775cb0
+	rungrubby ${ARGS}
775cb0
     else
775cb0
 	[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby"
775cb0
     fi
775cb0
-- 
56d25d
2.4.3
775cb0