From 8be65c346aa8ca9c7650f935ad608a82250d9a0d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 13:22:21 +0100 Subject: support for debug categories --- src/core/libs/lib-blockdevices-filesystems.sh | 38 ++++++++++++------------ src/core/libs/lib-misc.sh | 8 ++--- src/core/libs/lib-ui-interactive.sh | 2 +- src/core/libs/lib-ui.sh | 42 +++++++++++++-------------- src/core/procedures/interactive | 2 +- 5 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/core') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 7369ec4..ae4f5d0 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -278,7 +278,7 @@ target_configure_fstab() # $2 a string of the form: :[:+] (the + is bootable flag) partition() { - debug "Partition called like: partition '$1' '$2'" + debug 'FS' "Partition called like: partition '$1' '$2'" [ -z "$1" ] && die_error "partition() requires a device file and a partition string" [ -z "$2" ] && die_error "partition() requires a partition string" @@ -317,7 +317,7 @@ partition() sfdisk_input=$(printf "$sfdisk_input") # convert \n to newlines # invoke sfdisk - debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input" + debug 'FS' "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input" printk off sfdisk $DEVICE -uM >$LOG 2>&1 <Already done" + debug 'FS' "$fs_id ->Already done" else # We can't always do -b on the lvm VG. because the devicefile sometimes doesn't exist for a VG. vgdisplay to the rescue! if [ "$part_type" = lvm-vg ] && vgdisplay $part | grep -q 'VG Name' # $part is a lvm VG and it exists. note that vgdisplay exists 0 when the requested vg doesn't exist. then - debug "$fs_id ->Still need to do it: Making the filesystem on a vg volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a vg volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 elif [ "$part_type" != lvm-pv -a -b "$part" ] # $part is not a lvm PV and it exists then - debug "$fs_id ->Still need to do it: Making the filesystem on a non-pv volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a non-pv volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 elif [ "$part_type" = lvm-pv ] && pvdisplay ${fs_params//:/ } >/dev/null # $part is a lvm PV. all needed lvm pv's exist. note that pvdisplay exits 5 as long as one of the args doesn't exist then - debug "$fs_id ->Still need to do it: Making the filesystem on a pv volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a pv volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem ${part/+/} $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 else - debug "$fs_id ->Cannot do right now..." + debug 'FS' "$fs_id ->Cannot do right now..." open_items=1 fi fi @@ -512,7 +512,7 @@ rollback_filesystems () then if pvdisplay $real_part &>/dev/null then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -523,7 +523,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-pv ] # Can be in use for: lvm-vg then @@ -531,7 +531,7 @@ rollback_filesystems () then if vgdisplay -v 2>/dev/null | grep -q $real_part # check if it's in use then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -542,7 +542,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-vg ] #Can be in use for: lvm-lv then @@ -551,7 +551,7 @@ rollback_filesystems () open_lv=`vgdisplay -c $part 2>/dev/null | cut -d ':' -f6` if [ $open_lv -gt 0 ] then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -562,7 +562,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-lv ] #Can be in use for: dm_crypt or raw. we don't need to care about raw (it will be unmounted so it can be destroyed) then @@ -570,7 +570,7 @@ rollback_filesystems () then if cryptsetup isLuks $part &>/dev/null then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -581,7 +581,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi else die_error "Unrecognised partition type $part_type for partition $part. This should never happen. please report this" @@ -616,7 +616,7 @@ process_filesystem () { [ "$2" != lvm-lv ] && [ -z "$1" -o ! -b "$1" ] && die_error "process_filesystem needs a partition as \$1" # Don't do this for lv's. It's a hack to workaround non-existence of VG device files. [ -z "$2" ] && die_error "process_filesystem needs a filesystem type as \$2" - debug "process_filesystem $@" + debug 'FS' "process_filesystem $@" part=$1 fs_type=$2 fs_create=${3:-yes} @@ -674,12 +674,12 @@ process_filesystem () BLOCK_ROLLBACK_USELESS=0 if [ "$fs_type" = swap ] then - debug "swaponning $part" + debug 'FS' "swaponning $part" swapon $part >$LOG 2>&1 || ( show_warning 'Swapon' "Error activating swap: swapon $part" ; return 1 ) else [ "$fs_mount" = runtime ] && dst=$fs_mountpoint [ "$fs_mount" = target ] && dst=$var_TARGET_DIR$fs_mountpoint - debug "mounting $part on $dst" + debug 'FS' "mounting $part on $dst" mkdir -p $dst &>/dev/null # directories may or may not already exist mount -t $fs_type $part $dst >$LOG 2>&1 || ( show_warning 'Mount' "Error mounting $part on $dst" ; return 1 ) if [ "$fs_mount" = target -a $fs_mountpoint = '/' ] diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index ac66bd1..97252b9 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -12,16 +12,16 @@ run_background () [ -z "$2" ] && die_error "run_background needs a command to execute!" [ -z "$3" ] && die_error "run_background needs a logfile to redirect output to!" - debug "run_background called. identifier: $1, command: $2, logfile: $3" + debug 'MISC' "run_background called. identifier: $1, command: $2, logfile: $3" ( \ touch $RUNTIME_DIR/aif-$1-running - debug "run_background starting $1: $2 >>$3 2>&1" + debug 'MISC' "run_background starting $1: $2 >>$3 2>&1" [ -f $3 ] && echo -e "\n\n\n" >>$3 echo "STARTING $1 . Executing $2 >>$3 2>&1\n" >> $3; var_exit=${1}_exitcode eval "$2" >>$3 2>&1 read $var_exit <<< $? #TODO: bash complains about 'not a valid identifier' - debug "run_background done with $1: exitcode (\$$1_exitcode): "${!var_exit}" .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now + debug 'MISC' "run_background done with $1: exitcode (\$$1_exitcode): ${!var_exit} .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now echo >> $3 rm -f $RUNTIME_DIR/aif-$1-running ) & @@ -50,7 +50,7 @@ wait_for () # $2 needle check_is_in () { - [ -z "$1" ] && debug "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$2 and a haystack as \$1!" # haystack can be empty though + [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$2 and a haystack as \$1!" # haystack can be empty though local pattern="$1" element shift diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index ccb912f..f015082 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -417,7 +417,7 @@ remove_blockdevice () declare target_escaped=${target//\//\\/} # note: apparently no need to escape the '+' sign for sed. declare target_escawk=${target_escaped/+/\\+} # ...but that doesn't count for awk fs_string=`awk "/^$target_escawk / { print \$4}" $TMP_BLOCKDEVICES` #TODO: fs_string is the entire line, incl part? - debug "Cleaning up partition $part (type $part_type, label $part_label). It has the following FS's on it: $fs_string" + debug 'UI-INTERACTIVE' "Cleaning up partition $part (type $part_type, label $part_label). It has the following FS's on it: $fs_string" sed -i "/$target_escaped/d" $TMP_BLOCKDEVICES || show_warning "blockdevice removal" "Could not remove partition $part (type $part_type, label $part_label). This is a bug. please report it" for fs in `sed 's/|/ /g' <<< $fs_string` do diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 53ff8ea..bfe49dc 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -18,7 +18,7 @@ var_CONSOLEFONT=`sed -n '/^CONSOLEFONT/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed # display error message and die die_error () { - debug "die_error: ERROR: $@" + debug 'UI' "die_error: ERROR: $@" notify "ERROR: $@" exit 2 } @@ -35,7 +35,7 @@ show_warning () [ -n "$3" -a "$3" != msg -a "$3" != text ] && die_error "show_warning \$3 must be text or msg" type=msg [ -n "$3" ] && type=$3 - debug "show_warning '$1': $2 ($type)" + debug 'UI' "show_warning '$1': $2 ($type)" if [ "$var_UI_TYPE" = dia ] then _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 18 70 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" @@ -52,7 +52,7 @@ show_warning () #notify user notify () { - debug "notify: $@" + debug 'UI' "notify: $@" if [ "$var_UI_TYPE" = dia ] then _dia_DIALOG --msgbox "$@" 20 50 @@ -72,7 +72,7 @@ infofy () #TODO: when using successive things, the screen can become full and yo { successive=${2:-0} succ_last=${3:-0} - debug "infofy: $1" + debug 'UI' "infofy: $1" if [ "$var_UI_TYPE" = dia ] then str="$1" @@ -152,7 +152,7 @@ _getavaildisks() ask_checklist () { [ -z "$1" ] && die_error "ask_checklist needs a question!" - [ -z "$4" ] && debug "ask_checklist args: $@" && die_error "ask_checklist makes only sense if you specify at least 1 thing (tag,item and ON/OFF switch)" + [ -z "$4" ] && debug 'UI' "ask_checklist args: $@" && die_error "ask_checklist makes only sense if you specify at least 1 thing (tag,item and ON/OFF switch)" [ "$var_UI_TYPE" = dia ] && { _dia_ask_checklist "$@" ; return $? ; } [ "$var_UI_TYPE" = cli ] && { _cli_ask_checklist "$@" ; return $? ; } } @@ -289,7 +289,7 @@ _dia_ask_checklist () _dia_DIALOG --checklist "$str" 30 60 20 $list 2>$ANSWER ret=$? ANSWER_CHECKLIST=`cat $ANSWER` - debug "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" + debug 'UI' "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" return $ret } @@ -301,7 +301,7 @@ _dia_ask_datetime () local _date="$(cat $ANSWER)" # form like: 07/12/2008 dialog --timebox "Set the time.\nUse to navigate and up/down to change values." 0 0 2> $ANSWER || return 1 local _time="$(cat $ANSWER)" # form like: 15:26:46 - debug "Date as specified by user $_date time: $_time" + debug 'UI' "Date as specified by user $_date time: $_time" # DD/MM/YYYY hh:mm:ss -> MMDDhhmmYYYY.ss (date default format, set like date $ANSWER_DATETIME) Not enabled because there is no use for it i think. # ANSWER_DATETIME=$(echo "$_date" "$_time" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\2\1\4\5\3\6#g') @@ -337,7 +337,7 @@ _dia_ask_number () fi fi done - debug "_dia_ask_number: user entered: $ANSWER_NUMBER" + debug 'UI' "_dia_ask_number: user entered: $ANSWER_NUMBER" [ -z "$ANSWER_NUMBER" ] && return 1 return $ret } @@ -349,7 +349,7 @@ _dia_ask_option () [ "$1" != 'no' ] && DEFAULT="--default-item $1" [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info - [ -z "$5" ] && debug "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user + [ -z "$5" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user DIA_MENU_TITLE=$2 EXTRA_INFO=$3 @@ -357,7 +357,7 @@ _dia_ask_option () _dia_DIALOG $DEFAULT --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 20 80 16 "$@" 2>$ANSWER ret=$? ANSWER_OPTION=`cat $ANSWER` - debug "dia_ask_option: User choose $ANSWER_OPTION ($DIA_MENU_TITLE)" + debug 'UI' "dia_ask_option: User choose $ANSWER_OPTION ($DIA_MENU_TITLE)" return $ret } @@ -378,7 +378,7 @@ _dia_ask_password () [ -n "$type_u" ] && read ${type_u}_PASSWORD < $ANSWER [ -z "$type_u" ] && read PASSWORD < $ANSWER cat $ANSWER - debug "_dia_ask_password: user entered <>" + debug 'UI' "_dia_ask_password: user entered <>" return $ret } @@ -389,7 +389,7 @@ _dia_ask_string () _dia_DIALOG --inputbox "$1" 8 65 "$2" 2>$ANSWER ret=$? ANSWER_STRING=`cat $ANSWER` - debug "_dia_ask_string: user entered $ANSWER_STRING" + debug 'UI' "_dia_ask_string: user entered $ANSWER_STRING" [ -z "$ANSWER_STRING" ] && return $exitcode return $ret } @@ -427,8 +427,8 @@ _dia_ask_yesno () [ -n "$2" ] && str="$str (default: $2)" dialog --yesno "$str" $height 55 # returns 0 for yes, 1 for no ret=$? - [ $ret -eq 0 ] && debug "dia_ask_yesno: User picked YES" - [ $ret -gt 0 ] && debug "dia_ask_yesno: User picked NO" + [ $ret -eq 0 ] && debug 'UI' "dia_ask_yesno: User picked YES" + [ $ret -gt 0 ] && debug 'UI' "dia_ask_yesno: User picked NO" return $ret } @@ -468,7 +468,7 @@ _cli_ask_datetime () { ask_string "Enter date [YYYY-MM-DD hh:mm:ss]" ANSWER_DATETIME=$ANSWER_STRING - debug "Date as picked by user: $ANSWER_STRING" + debug 'UI' "Date as picked by user: $ANSWER_STRING" } @@ -499,7 +499,7 @@ _cli_ask_number () fi fi done - debug "cli_ask_number: user entered: $ANSWER_NUMBER" + debug 'UI' "cli_ask_number: user entered: $ANSWER_NUMBER" [ -z "$ANSWER_NUMBER" ] && return 1 return 0 } @@ -513,7 +513,7 @@ _cli_ask_option () [ "$1" != 'no' ] && DEFAULT=$1 #TODO: if user forgot to specify a default (eg all args are 1 pos to the left, we can end up in an endless loop :s) [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info - [ -z "$5" ] && debug "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user + [ -z "$5" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user MENU_TITLE=$2 EXTRA_INFO=$3 @@ -531,7 +531,7 @@ _cli_ask_option () [ -z "$DEFAULT" ] && echo -n " > " read ANSWER_OPTION [ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT" - debug "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" + debug 'UI' "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" [ "$ANSWER_OPTION" = CANCEL ] && return 1 return 0 } @@ -565,7 +565,7 @@ _cli_ask_string () [ -n "$2" ] && echo "(Press enter for default. Default: $2)" echo -n ">" read ANSWER_STRING - debug "cli_ask_string: User entered: $ANSWER_STRING" + debug 'UI' "cli_ask_string: User entered: $ANSWER_STRING" if [ -z "$ANSWER_STRING" ] then if [ -n "$2" ] @@ -595,10 +595,10 @@ _cli_ask_yesno () answer=`tr '[:upper:]' '[:lower:]' <<< $answer` if [ "$answer" = y -o "$answer" = yes ] || [ -z "$answer" -a "$2" = yes ] then - debug "cli_ask_yesno: User picked YES" + debug 'UI' "cli_ask_yesno: User picked YES" return 0 else - debug "cli_ask_yesno: User picked NO" + debug 'UI' "cli_ask_yesno: User picked NO" return 1 fi } diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 051d187..46bd6d7 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -114,7 +114,7 @@ worker_configure_system() # /etc/pacman.d/mirrorlist # add installer-selected mirror to the top of the mirrorlist if [ "$var_PKG_SOURCE_TYPE" = "ftp" -a "${var_SYNC_URL}" != "" ]; then - debug "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" + debug 'PROCEDURE' "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" mirrorlist=`awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${var_SYNC_URL}"\n\n\") } 1 " "${var_TARGET_DIR}/$var_MIRRORLIST"` echo "$mirrorlist" > "${var_TARGET_DIR}/$var_MIRRORLIST" #TODO: test this, this may not work fi -- cgit v1.2.3-54-g00ecf