|
Harald Hoyer |
2f4f1d |
From c32908cee324c60cc6d31a7030a9fb11cdfa0d45 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
2f4f1d |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
2f4f1d |
Date: Mon, 23 Apr 2012 11:28:10 +0200
|
|
Harald Hoyer |
2f4f1d |
Subject: [PATCH] base: add debug_on() and debug_off() functions
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
---
|
|
Harald Hoyer |
2f4f1d |
modules.d/99base/dracut-lib.sh | 42 +++++++++++++++++++++++++++-------------
|
|
Harald Hoyer |
2f4f1d |
modules.d/99base/init.sh | 6 ++----
|
|
Harald Hoyer |
0c26bf |
2 Dateien geändert, 31 Zeilen hinzugefügt(+), 17 Zeilen entfernt(-)
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
index a29d586..f46c4a7 100755
|
|
Harald Hoyer |
2f4f1d |
--- a/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
+++ b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
@@ -2,6 +2,14 @@
|
|
Harald Hoyer |
2f4f1d |
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
Harald Hoyer |
2f4f1d |
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
+debug_off() {
|
|
Harald Hoyer |
2f4f1d |
+ set +x
|
|
Harald Hoyer |
2f4f1d |
+}
|
|
Harald Hoyer |
2f4f1d |
+
|
|
Harald Hoyer |
2f4f1d |
+debug_on() {
|
|
Harald Hoyer |
2f4f1d |
+ [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+}
|
|
Harald Hoyer |
2f4f1d |
+
|
|
Harald Hoyer |
2f4f1d |
# returns OK if $1 contains $2
|
|
Harald Hoyer |
2f4f1d |
strstr() {
|
|
Harald Hoyer |
2f4f1d |
[ "${1#*$2*}" != "$1" ]
|
|
Harald Hoyer |
2f4f1d |
@@ -93,29 +101,29 @@ _dogetarg() {
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
getarg() {
|
|
Harald Hoyer |
2f4f1d |
- set +x
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
while [ $# -gt 0 ]; do
|
|
Harald Hoyer |
2f4f1d |
case $1 in
|
|
Harald Hoyer |
2f4f1d |
-y) if _dogetarg $2 >/dev/null; then
|
|
Harald Hoyer |
2f4f1d |
echo 1
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 0
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
shift 2;;
|
|
Harald Hoyer |
2f4f1d |
-n) if _dogetarg $2 >/dev/null; then
|
|
Harald Hoyer |
2f4f1d |
echo 0;
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 1
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
shift 2;;
|
|
Harald Hoyer |
2f4f1d |
*) if _dogetarg $1; then
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 0;
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
shift;;
|
|
Harald Hoyer |
2f4f1d |
esac
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 1
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
@@ -135,7 +143,7 @@ getargbool() {
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
_dogetargs() {
|
|
Harald Hoyer |
2f4f1d |
- set +x
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
local _o _found _key
|
|
Harald Hoyer |
2f4f1d |
unset _o
|
|
Harald Hoyer |
2f4f1d |
unset _found
|
|
Harald Hoyer |
2f4f1d |
@@ -158,7 +166,7 @@ _dogetargs() {
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
getargs() {
|
|
Harald Hoyer |
2f4f1d |
- set +x
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
local _val _i _args _gfound
|
|
Harald Hoyer |
2f4f1d |
unset _val
|
|
Harald Hoyer |
2f4f1d |
unset _gfound
|
|
Harald Hoyer |
2f4f1d |
@@ -175,10 +183,10 @@ getargs() {
|
|
Harald Hoyer |
2f4f1d |
else
|
|
Harald Hoyer |
2f4f1d |
echo -n 1
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 0
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 1;
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
@@ -221,6 +229,7 @@ getoptcomma() {
|
|
Harald Hoyer |
2f4f1d |
#
|
|
Harald Hoyer |
2f4f1d |
# TODO: ':' inside fields.
|
|
Harald Hoyer |
2f4f1d |
splitsep() {
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
local sep="$1"; local str="$2"; shift 2
|
|
Harald Hoyer |
2f4f1d |
local tmp
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
@@ -232,7 +241,7 @@ splitsep() {
|
|
Harald Hoyer |
2f4f1d |
shift
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
[ -n "$str" -a -n "$1" ] && eval "$1=$str"
|
|
Harald Hoyer |
2f4f1d |
-
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 0
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
@@ -248,7 +257,7 @@ setdebug() {
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
export RD_DEBUG
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
- [ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
setdebug
|
|
Harald Hoyer |
2f4f1d |
@@ -347,6 +356,7 @@ check_occurances() {
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
incol2() {
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
local dummy check;
|
|
Harald Hoyer |
2f4f1d |
local file="$1";
|
|
Harald Hoyer |
2f4f1d |
local str="$2";
|
|
Harald Hoyer |
2f4f1d |
@@ -355,8 +365,12 @@ incol2() {
|
|
Harald Hoyer |
2f4f1d |
[ -z "$str" ] && return 1;
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
while read dummy check restofline; do
|
|
Harald Hoyer |
2f4f1d |
- [ "$check" = "$str" ] && return 0
|
|
Harald Hoyer |
2f4f1d |
+ if [ "$check" = "$str" ]; then
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
+ return 0
|
|
Harald Hoyer |
2f4f1d |
+ fi
|
|
Harald Hoyer |
2f4f1d |
done < $file
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
return 1
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
@@ -719,6 +733,7 @@ cancel_wait_for_dev()
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
killproc() {
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
local _exe="$(command -v $1)"
|
|
Harald Hoyer |
2f4f1d |
local _sig=$2
|
|
Harald Hoyer |
2f4f1d |
local _i
|
|
Harald Hoyer |
2f4f1d |
@@ -729,6 +744,7 @@ killproc() {
|
|
Harald Hoyer |
2f4f1d |
kill $_sig ${_i##*/}
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
+ debug_on
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
need_shutdown() {
|
|
Harald Hoyer |
2f4f1d |
@@ -739,7 +755,7 @@ wait_for_loginit()
|
|
Harald Hoyer |
2f4f1d |
{
|
|
Harald Hoyer |
2f4f1d |
[ "$RD_DEBUG" = "yes" ] || return
|
|
Harald Hoyer |
2f4f1d |
[ -e /run/initramfs/loginit.pipe ] || return
|
|
Harald Hoyer |
2f4f1d |
- set +x
|
|
Harald Hoyer |
2f4f1d |
+ debug_off
|
|
Harald Hoyer |
2f4f1d |
echo "DRACUT_LOG_END"
|
|
Harald Hoyer |
2f4f1d |
exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
|
|
Harald Hoyer |
2f4f1d |
# wait for loginit
|
|
Harald Hoyer |
2f4f1d |
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
index 88ec184..cb03137 100755
|
|
Harald Hoyer |
2f4f1d |
--- a/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
+++ b/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
@@ -277,7 +277,6 @@ for var in root rflags fstype netroot NEWROOT; do
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
export RD_TIMESTAMP
|
|
Harald Hoyer |
2f4f1d |
-set +x # Turn off debugging for this section
|
|
Harald Hoyer |
2f4f1d |
# Clean up the environment
|
|
Harald Hoyer |
2f4f1d |
for i in $(export -p); do
|
|
Harald Hoyer |
2f4f1d |
i=${i#declare -x}
|
|
Harald Hoyer |
2f4f1d |
@@ -298,7 +297,6 @@ rm -f /tmp/export.orig
|
|
Harald Hoyer |
2f4f1d |
initargs=""
|
|
Harald Hoyer |
2f4f1d |
read CLINE
|
|
Harald Hoyer |
2f4f1d |
if getarg init= >/dev/null ; then
|
|
Harald Hoyer |
2f4f1d |
- set +x # Turn off debugging for this section
|
|
Harald Hoyer |
2f4f1d |
ignoreargs="console BOOT_IMAGE"
|
|
Harald Hoyer |
2f4f1d |
# only pass arguments after init= to the init
|
|
Harald Hoyer |
2f4f1d |
CLINE=${CLINE#*init=}
|
|
Harald Hoyer |
2f4f1d |
@@ -312,7 +310,7 @@ if getarg init= >/dev/null ; then
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
unset CLINE
|
|
Harald Hoyer |
2f4f1d |
else
|
|
Harald Hoyer |
2f4f1d |
- set +x # Turn off debugging for this section
|
|
Harald Hoyer |
2f4f1d |
+ debug_off # Turn off debugging for this section
|
|
Harald Hoyer |
2f4f1d |
set -- $CLINE
|
|
Harald Hoyer |
2f4f1d |
for x in "$@"; do
|
|
Harald Hoyer |
2f4f1d |
case "$x" in
|
|
Harald Hoyer |
2f4f1d |
@@ -322,7 +320,7 @@ else
|
|
Harald Hoyer |
2f4f1d |
esac
|
|
Harald Hoyer |
2f4f1d |
done
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
-[ "$RD_DEBUG" = "yes" ] && set -x
|
|
Harald Hoyer |
2f4f1d |
+debug_on
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
if ! [ -d "$NEWROOT"/run ]; then
|
|
Harald Hoyer |
2f4f1d |
NEWRUN=/dev/.initramfs
|