Browse Source

Fix "--debug" parameter for dracut

remove "-d" as a short-alias for --debug. It collides with the
--driver short-alias.

If --debug is set, inst_script() spews binary "garbage" to the screen
which are interpreted as control characters by the terminal, prompting
the user to call "reset" after dracut has finished. This is related to
set -x  printing binary headers from files to stdout.
As inst_script() is only checking if it is a script it should copy by
reading the first 80chars of the file and checking for the shebang line,
it is safe to call tr on the read in data and remove all unprintable
chars if the debug switch is set.
master
Andreas Thienemann 15 years ago committed by Harald Hoyer
parent
commit
0053156804
  1. 6
      dracut
  2. 2
      dracut-functions

6
dracut

@ -21,7 +21,7 @@ Creates initial ramdisk images for preloading modules @@ -21,7 +21,7 @@ Creates initial ramdisk images for preloading modules
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
include in the initramfs
-h, --help This message
-d, --debug Output debug information of the build process
--debug Output debug information of the build process
-v, --verbose Verbose output during the build process
-c, --conf [FILE] Specify configuration file to use.
Default: /etc/dracut.conf
@ -43,7 +43,7 @@ while (($# > 0)); do @@ -43,7 +43,7 @@ while (($# > 0)); do
-m|--modules) dracutmodules_l="$2"; shift;;
-d|--drivers) modules_l="$2"; shift;;
-h|--help) usage; exit 1 ;;
-d|--debug) set -x;;
--debug) debug="yes"; set -x;;
-v|--verbose) beverbose="yes";;
-c|--conf) conffile="$2"; shift;;
-l|--local) allowlocal="yes" ;;
@ -96,7 +96,7 @@ hookdirs="pre-udev pre-mount pre-pivot mount" @@ -96,7 +96,7 @@ hookdirs="pre-udev pre-mount pre-pivot mount"
readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.

export initdir hookdirs dsrc dracutmodules modules
export initdir hookdirs dsrc dracutmodules modules debug

# Create some directory structure first
for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do

2
dracut-functions

@ -127,6 +127,8 @@ inst_script() { @@ -127,6 +127,8 @@ inst_script() {
[[ -f $1 ]] || return 1
local line
read -r -n 80 line <"$1"
# If debug is set, clean unprintable chars to prevent messing up the term
[[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
[[ $line =~ (#! *)(/[^ ]+).* ]] || return 1
inst "${BASH_REMATCH[2]}" && inst_simple "$@"
}

Loading…
Cancel
Save