From 7f3696574f94a477653cbccb06760fc0ce7df4aa Mon Sep 17 00:00:00 2001 From: papajoker Date: Wed, 22 Feb 2017 18:39:22 +0100 Subject: [PATCH 1/5] return function --- lib/util.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/util.sh b/lib/util.sh index 97a82b5..9ad4673 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -61,7 +61,7 @@ VG_PARTS="" LVM_SEP_BOOT=0 # 1 = Seperate /boot, 2 = seperate /boot & LVM LV_SIZE_INVALID=0 # Is LVM LV size entered valid? VG_SIZE_TYPE="" # Is VG in Gigabytes or Megabytes? - + # Mounting MOUNT="" # Installation: All other mounts branching MOUNTPOINT="/mnt" # Installation: Root mount from Root @@ -120,7 +120,7 @@ id_system() { else modprobe -q efivarfs # all others fi - + # BIOS or UEFI Detection if [[ -d "/sys/firmware/efi/" ]]; then # Mount efivarfs if it is not already mounted @@ -145,10 +145,14 @@ id_system() { # If there is an error, display it and go back to main menu. In any case, write to logfile. # param 2 : error code is optional +# param 3 : return menu function , optional, default: main_menu_online check_for_error() { local _msg="$1" local _err="${2:-0}" + local _function_menu="${3:-main_menu_online}" local _canceldlg=1 + local _fpath="${FUNCNAME[*]:1}()" + _fpath=" --${_fpath// /()<-}" ((${_err}!=0)) && _msg="[${_msg}][${_err}]" [[ -f "${ERR}" ]] && { _msg="${_msg} $(head -n1 ${ERR})" @@ -157,11 +161,11 @@ check_for_error() { } if ((${_err}!=0)) && ((${_canceldlg}==0)); then # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" - echo -e "$(date +%D\ %T) ERROR ${_msg}" >> "${LOGFILE}" + echo -e "$(date +%D\ %T) ERROR ${_msg} ${_fpath}" >> "${LOGFILE}" DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 - main_menu_online + ($_main_menu_online) else - echo -e "$(date +%D\ %T) ${_msg}" >> "${LOGFILE}" + echo -e "$(date +%D\ %T) ${_msg} ${_fpath}]" >> "${LOGFILE}" fi } @@ -178,7 +182,7 @@ select_language() { "8" $"Portuguese [Brasil]|(pt_BR)" \ "9" $"Russian|(ru_RU)" \ "10" $"Spanish|(es_ES)" 2>${ANSWER} - + # "5" $"German|(de_DE)" \ case $(cat ${ANSWER}) in @@ -282,7 +286,7 @@ greeting() { } rank_mirrors() { - #Choose the branch for mirrorlist + #Choose the branch for mirrorlist BRANCH="/tmp/.branch" DIALOG "$_MirrorBranch" --radiolist "\n\n$_UseSpaceBar" 0 0 3 \ "stable" "-" off \ @@ -357,7 +361,7 @@ inst_needed() { # install a pkg in the chroot if not installed check_pkg() { if ! arch_chroot "pacman -Q $1" ; then - basestrap "$1" 2>$ERR + basestrap "$1" 2>$ERR check_for_error "install missing pkg $1 to target." "$?" fi } From 8f820e6cc36d186d890c166c108031018b9f3942 Mon Sep 17 00:00:00 2001 From: papajoker Date: Wed, 22 Feb 2017 20:08:54 +0100 Subject: [PATCH 2/5] path limit 3 --- lib/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.sh b/lib/util.sh index 9ad4673..02d51d8 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -151,7 +151,7 @@ check_for_error() { local _err="${2:-0}" local _function_menu="${3:-main_menu_online}" local _canceldlg=1 - local _fpath="${FUNCNAME[*]:1}()" + local _fpath="${FUNCNAME[*]:1:3}()" _fpath=" --${_fpath// /()<-}" ((${_err}!=0)) && _msg="[${_msg}][${_err}]" [[ -f "${ERR}" ]] && { @@ -165,7 +165,7 @@ check_for_error() { DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 ($_main_menu_online) else - echo -e "$(date +%D\ %T) ${_msg} ${_fpath}]" >> "${LOGFILE}" + echo -e "$(date +%D\ %T) ${_msg} ${_fpath}" >> "${LOGFILE}" fi } From 1d97800b4da2c3deb59449f403dd84f5cc587d9b Mon Sep 17 00:00:00 2001 From: papajoker Date: Wed, 22 Feb 2017 20:50:12 +0100 Subject: [PATCH 3/5] call good function --- lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.sh b/lib/util.sh index 02d51d8..81a6f33 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -163,7 +163,7 @@ check_for_error() { # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" echo -e "$(date +%D\ %T) ERROR ${_msg} ${_fpath}" >> "${LOGFILE}" DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 - ($_main_menu_online) + ($_function_menu) else echo -e "$(date +%D\ %T) ${_msg} ${_fpath}" >> "${LOGFILE}" fi From 8c27ef2d2ebf0874b1a025cc9a9e3c91941bc286 Mon Sep 17 00:00:00 2001 From: papajoker Date: Thu, 23 Feb 2017 20:25:32 +0100 Subject: [PATCH 4/5] path 2 functions only if error --- lib/util.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util.sh b/lib/util.sh index 973308f..e243750 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -151,8 +151,7 @@ check_for_error() { local _err="${2:-0}" local _function_menu="${3:-main_menu_online}" local _canceldlg=1 - local _fpath="${FUNCNAME[*]:1:3}()" - _fpath=" --${_fpath// /()<-}" + local _fpath="${FUNCNAME[*]:1:2}()" ((${_err}!=0)) && _msg="[${_msg}][${_err}]" [[ -f "${ERR}" ]] && { _msg="${_msg} $(head -n1 ${ERR})" @@ -161,11 +160,12 @@ check_for_error() { } if ((${_err}!=0)) && ((${_canceldlg}==0)); then # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" + _fpath=" --${_fpath// /()<-}" echo -e "$(date +%D\ %T) ERROR ${_msg} ${_fpath}" >> "${LOGFILE}" DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 ($_function_menu) else - echo -e "$(date +%D\ %T) ${_msg} ${_fpath}" >> "${LOGFILE}" + echo -e "$(date +%D\ %T) ${_msg}" >> "${LOGFILE}" fi } From 18b2e4752a408dd27cd2d033cb41a6008d928c65 Mon Sep 17 00:00:00 2001 From: papajoker Date: Thu, 23 Feb 2017 23:57:40 +0100 Subject: [PATCH 5/5] remove _canceldlg var --- lib/util.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/util.sh b/lib/util.sh index e243750..535858f 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -150,16 +150,14 @@ check_for_error() { local _msg="$1" local _err="${2:-0}" local _function_menu="${3:-main_menu_online}" - local _canceldlg=1 - local _fpath="${FUNCNAME[*]:1:2}()" ((${_err}!=0)) && _msg="[${_msg}][${_err}]" [[ -f "${ERR}" ]] && { _msg="${_msg} $(head -n1 ${ERR})" - _canceldlg=0 # not btn cancel rm "${ERR}" } - if ((${_err}!=0)) && ((${_canceldlg}==0)); then - # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" + if ((${_err}!=0)) ; then + # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" + local _fpath="${FUNCNAME[*]:1:2}()" _fpath=" --${_fpath// /()<-}" echo -e "$(date +%D\ %T) ERROR ${_msg} ${_fpath}" >> "${LOGFILE}" DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0