Browse Source

dracut: script adjusted to new logging facility; -v changed

-v meaning has changed. Now it increases verbosity level. -q option has
been added, which decreases verbosity level. Both options might be
specified multiple times.
master
Amadeusz Żołnowski 14 years ago committed by Harald Hoyer
parent
commit
432196aef8
  1. 64
      dracut

64
dracut

@ -67,8 +67,8 @@ Creates initial ramdisk images for preloading modules
4 - info (default) 4 - info (default)
5 - debug info (here starts lots of output) 5 - debug info (here starts lots of output)
6 - trace info (and even more) 6 - trace info (and even more)
-v, --verbose Verbose output during the build process (info level) -v, --verbose Increase verbosity level (default is info(4))
-q, --quiet Display only errors and fatal errors during build -q, --quiet Decrease verbosity level (default is info(4))
-c, --conf [FILE] Specify configuration file to use. -c, --conf [FILE] Specify configuration file to use.
Default: /etc/dracut.conf Default: /etc/dracut.conf
--confdir [DIR] Specify configuration directory to use *.conf files --confdir [DIR] Specify configuration directory to use *.conf files
@ -179,7 +179,7 @@ push_arg() {
} }


kernel="unset" kernel="unset"
stdloglvl_l=0 verbosity_mod_l=0


while (($# > 0)); do while (($# > 0)); do
case ${1%%=*} in case ${1%%=*} in
@ -205,8 +205,8 @@ while (($# > 0)); do
--lvmconf) lvmconf_l="yes";; --lvmconf) lvmconf_l="yes";;
--nolvmconf) lvmconf_l="no";; --nolvmconf) lvmconf_l="no";;
--debug) debug="yes";; --debug) debug="yes";;
-v|--verbose) beverbose="yes";; -v|--verbose) ((verbosity_mod_l++));;
-q|--quiet) bequiet="yes";; -q|--quiet) ((verbosity_mod_l--));;
-l|--local) allowlocal="yes" ;; -l|--local) allowlocal="yes" ;;
-H|--hostonly) hostonly_l="yes" ;; -H|--hostonly) hostonly_l="yes" ;;
--fstab) use_fstab_l="yes" ;; --fstab) use_fstab_l="yes" ;;
@ -249,12 +249,6 @@ export PATH
set -x set -x
} }


# For compatibility with -v behaviour. Set to info level.
[[ $beverbose ]] && (( $stdloglvl_l < 4 )) && stdloglvl_l=4

# When quiet, display only errors and fatal errors.
[[ $bequiet ]] && (( $stdloglvl_l > 2 )) && stdloglvl_l=2

[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut


[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \ [[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \
@ -331,6 +325,10 @@ if [[ ${#fw_dir_l[@]} ]]; then
fi fi


[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l [[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
stdloglvl=$((stdloglvl + verbosity_mod_l))
((stdloglvl > 6)) && stdloglvl=6
((stdloglvl < 0)) && stdloglvl=0

[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
[[ $do_strip_l ]] && do_strip=$do_strip_l [[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $hostonly_l ]] && hostonly=$hostonly_l [[ $hostonly_l ]] && hostonly=$hostonly_l
@ -359,7 +357,7 @@ fi
dracutfunctions=$dracutbasedir/dracut-functions dracutfunctions=$dracutbasedir/dracut-functions
export dracutfunctions export dracutfunctions


dinfo "Executing $0 $dracut_args" ddebug "Executing $0 $dracut_args"


[[ $do_list = yes ]] && { [[ $do_list = yes ]] && {
for mod in $dracutbasedir/modules.d/*; do for mod in $dracutbasedir/modules.d/*; do
@ -375,12 +373,13 @@ dinfo "Executing $0 $dracut_args"
[[ $libdir ]] || for libdir in /lib64 /lib; do [[ $libdir ]] || for libdir in /lib64 /lib; do
[[ -d $libdir ]] && break [[ -d $libdir ]] && break
done || { done || {
derror 'No lib directory?!!!' dfatal 'No lib directory?!!!'
exit 1 exit 1
} }

[[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do [[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do
[[ -d $usrlibdir ]] && break [[ -d $usrlibdir ]] && break
done || dwarning 'No usr/lib directory!' done || dwarn 'No usr/lib directory!'


# This is kinda legacy -- eventually it should go away. # This is kinda legacy -- eventually it should go away.
case $dracutmodules in case $dracutmodules in
@ -392,7 +391,7 @@ abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
srcmods="/lib/modules/$kernel/" srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && { [[ $drivers_dir ]] && {
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
derror 'To use --kmoddir option module-init-tools >= 3.7 is required.' dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1 exit 1
fi fi
srcmods="$drivers_dir" srcmods="$drivers_dir"
@ -400,19 +399,19 @@ srcmods="/lib/modules/$kernel/"
export srcmods export srcmods


if [[ -f $outfile && ! $force ]]; then if [[ -f $outfile && ! $force ]]; then
derror "Will not override existing initramfs ($outfile) without --force" dfatal "Will not override existing initramfs ($outfile) without --force"
exit 1 exit 1
fi fi


outdir=${outfile%/*} outdir=${outfile%/*}
if [[ ! -d "$outdir" ]]; then if [[ ! -d "$outdir" ]]; then
derror "Can't write $outfile: Directory $outdir does not exist." dfatal "Can't write $outfile: Directory $outdir does not exist."
exit 1 exit 1
elif [[ ! -w "$outdir" ]]; then elif [[ ! -w "$outdir" ]]; then
derror "No permission to write $outdir." dfatal "No permission to write $outdir."
exit 1 exit 1
elif [[ -f "$outfile" && ! -w "$outfile" ]]; then elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
derror "No permission to write $outfile." dfatal "No permission to write $outfile."
exit 1 exit 1
fi fi


@ -452,7 +451,7 @@ check_module_dir
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
mod=${moddir##*/}; mod=${mod#[0-9][0-9]} mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
if strstr "$mods_to_load" " $mod "; then if strstr "$mods_to_load" " $mod "; then
dinfo "*** Sourcing module $mod" dinfo "*** Including module: $mod ***"
if [[ $kernel_only = yes ]]; then if [[ $kernel_only = yes ]]; then
module_installkernel $mod module_installkernel $mod
else else
@ -465,13 +464,14 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
fi fi
done done
unset moddir unset moddir
dinfo "*** Including modules' done ***"


## final stuff that has to happen ## final stuff that has to happen


# generate module dependencies for the initrd # generate module dependencies for the initrd
if [[ -d $initdir/lib/modules/$kernel ]] && \ if [[ -d $initdir/lib/modules/$kernel ]] && \
! depmod -a -b "$initdir" $kernel; then ! depmod -a -b "$initdir" $kernel; then
derror "\"depmod -a $kernel\" failed." dfatal "\"depmod -a $kernel\" failed."
exit 1 exit 1
fi fi


@ -480,6 +480,7 @@ while pop include_src src && pop include_target tgt; do
if [[ -f $src ]]; then if [[ -f $src ]]; then
inst $src $tgt inst $src $tgt
else else
ddebug "Including directory: $src"
mkdir -p "${initdir}/${tgt}" mkdir -p "${initdir}/${tgt}"
cp -a -t "${initdir}/${tgt}" "$src"/* cp -a -t "${initdir}/${tgt}" "$src"/*
fi fi
@ -495,10 +496,18 @@ unset item


# make sure that library links are correct and up to date # make sure that library links are correct and up to date
dracut_install /etc/ld.so.conf /etc/ld.so.conf.d/* dracut_install /etc/ld.so.conf /etc/ld.so.conf.d/*
ldconfig -r "$initdir" || [[ $UID != "0" ]] && \ if ! ldconfig -r "$initdir"; then
dinfo "ldconfig might need uid=0 (root) for chroot()" if [[ $UID = 0 ]]; then
derror "ldconfig exited ungracefully"
else
derror "ldconfig might need uid=0 (root) for chroot()"
fi
fi


[[ $beverbose = yes ]] && (du -c "$initdir" | sort -n) if (($maxloglvl >= 5)); then
ddebug "Listing sizes of included files:"
du -c "$initdir" | sort -n | ddebug
fi


# strip binaries # strip binaries
if [[ $do_strip = yes ]] ; then if [[ $do_strip = yes ]] ; then
@ -525,10 +534,11 @@ type hardlink &>/dev/null && {


if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \ if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \
$compress > "$outfile"; ); then $compress > "$outfile"; ); then
derror "dracut: creation of $outfile failed" dfatal "dracut: creation of $outfile failed"
exit 1 exit 1
fi fi
dinfo "Wrote $outfile"
dinfo $(ls -l "$outfile") dinfo "Wrote $outfile:"
dinfo "$(ls -l "$outfile")"


exit 0 exit 0

Loading…
Cancel
Save