mirror of
https://github.com/linuxboot/heads.git
synced 2025-06-22 17:18:49 +00:00
Improve DEBUG and DO_WITH_DEBUG output handling to also keep output of kexec -l when BOARD is in DEBUG+TRACE mode (configuration settings menu + flash)
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
@ -151,7 +151,7 @@ if [ "$dryrun" = "y" ]; then exit 0; fi
|
|||||||
|
|
||||||
echo "Loading the new kernel:"
|
echo "Loading the new kernel:"
|
||||||
echo "$kexeccmd"
|
echo "$kexeccmd"
|
||||||
eval "$kexeccmd" \
|
DO_WITH_DEBUG "$kexeccmd" \
|
||||||
|| die "Failed to load the new kernel"
|
|| die "Failed to load the new kernel"
|
||||||
|
|
||||||
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
|
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
|
||||||
|
@ -61,7 +61,8 @@ if [ "$unseal_failed" = "y" ]; then
|
|||||||
-n 1 \
|
-n 1 \
|
||||||
-p "Do you wish to boot and use the LUKS Disk Recovery Key? [Y/n] " \
|
-p "Do you wish to boot and use the LUKS Disk Recovery Key? [Y/n] " \
|
||||||
confirm_boot
|
confirm_boot
|
||||||
|
echo
|
||||||
|
|
||||||
if [ "$confirm_boot" != 'y' \
|
if [ "$confirm_boot" != 'y' \
|
||||||
-a "$confirm_boot" != 'Y' \
|
-a "$confirm_boot" != 'Y' \
|
||||||
-a -n "$confirm_boot" ] \
|
-a -n "$confirm_boot" ] \
|
||||||
|
@ -23,8 +23,9 @@ warn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG() {
|
DEBUG() {
|
||||||
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
|
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ]; then
|
||||||
echo "DEBUG: $*" | while read line; do
|
# fold -s -w 960 will wrap lines at 960 characters on the last space before the limit
|
||||||
|
echo "DEBUG: $*" | fold -s -w 960 | while read line; do
|
||||||
echo "$line" | tee -a /tmp/debug.log /dev/kmsg >/dev/null
|
echo "$line" | tee -a /tmp/debug.log /dev/kmsg >/dev/null
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -19,18 +19,28 @@ mask_param() {
|
|||||||
# N=0 is the name of the command to be executed, N=1 is its first parameter,
|
# N=0 is the name of the command to be executed, N=1 is its first parameter,
|
||||||
# etc.
|
# etc.
|
||||||
DO_WITH_DEBUG() {
|
DO_WITH_DEBUG() {
|
||||||
if [ "$1" == "--mask-position" ]; then
|
local exit_status
|
||||||
mask_position="$2"
|
local cmd_output
|
||||||
|
DEBUG "PATH: $PATH"
|
||||||
|
local cmd=("$@")
|
||||||
|
if [[ "$1" == "--mask-position" ]]; then
|
||||||
|
local mask_position="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
DEBUG_ARGS=("$@")
|
cmd=("$@")
|
||||||
|
cmd[$mask_position]="$(mask_param "${cmd[$mask_position]}")"
|
||||||
DEBUG_ARGS[$mask_position]="$(mask_param "${DEBUG_ARGS[$mask_position]}")"
|
|
||||||
DEBUG "${DEBUG_ARGS[@]}"
|
|
||||||
else
|
|
||||||
DEBUG "$@"
|
|
||||||
fi
|
fi
|
||||||
"$@"
|
if [[ ${#cmd[@]} -eq 1 ]]; then
|
||||||
|
# If there's only one argument, try to split it into multiple arguments
|
||||||
|
read -a cmd <<< "${cmd[0]}"
|
||||||
|
fi
|
||||||
|
DEBUG "Executing command with cmd: ${cmd[*]}"
|
||||||
|
# Sanitize the command output by removing special characters
|
||||||
|
cmd_output=$("${cmd[@]}" 2>&1 | sed 's/[&;|`$(){}<>]//g')
|
||||||
|
exit_status=$?
|
||||||
|
DEBUG "Command output: $cmd_output"
|
||||||
|
DEBUG "Command exited with status: $exit_status"
|
||||||
|
return $exit_status
|
||||||
}
|
}
|
||||||
|
|
||||||
# Trace the current script and function.
|
# Trace the current script and function.
|
||||||
@ -682,7 +692,7 @@ scan_boot_options() {
|
|||||||
|
|
||||||
if [ -r $option_file ]; then rm $option_file; fi
|
if [ -r $option_file ]; then rm $option_file; fi
|
||||||
for i in $(find $bootdir -name "$config"); do
|
for i in $(find $bootdir -name "$config"); do
|
||||||
DO_WITH_DEBUG kexec-parse-boot "$bootdir" "$i" >>$option_file
|
kexec-parse-boot "$bootdir" "$i" >>$option_file
|
||||||
done
|
done
|
||||||
# FC29/30+ may use BLS format grub config files
|
# FC29/30+ may use BLS format grub config files
|
||||||
# https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault
|
# https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault
|
||||||
|
Reference in New Issue
Block a user