From cb9a055f42c023f527e4f97d1a3ec80a44729cf2 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: May 11 2020 09:39:07 +0000 Subject: subr/build_init.subr:buildp_init_{args,getopts}(): call rtl_fileop_set_log() as soon as possible. subr/ex_pkg.subr:ex_pkg_load_vars(): log variable file names at `notice' level. subr/rtl_fileop.subr:rtl_fileop(): implements `source'. --- diff --git a/subr/build_init.subr b/subr/build_init.subr index 5938ecf..c876919 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -73,16 +73,6 @@ buildp_init_args() { *) _rc=1; _status="Error: unknown packages: $(rtl_subst "${_pkg_names_unknown}" " " ", ")"; ;; esac; fi; - if [ "${_rc}" -eq 0 ]; then - case "${ARG_VERBOSE:-0}" in - 0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;; - 1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 3) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 4) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;; - *) _rc=1; _status="Error: invalid verbosity level (max. -vvvv)"; ;; - esac; - fi; fi; fi; fi; @@ -218,6 +208,14 @@ buildp_init_getopts() { esac; if [ "${_rc:-0}" -eq 0 ]; then DEFAULT_BUILD_CPUS="${ARG_PARALLEL}"; + case "${ARG_VERBOSE:-0}" in + 0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;; + 1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 3) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 4) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;; + *) _rc=1; _status="Error: invalid verbosity level (max. -vvvv)"; ;; + esac; fi; fi; fi; diff --git a/subr/ex_pkg.subr b/subr/ex_pkg.subr index 4b88622..317bd72 100644 --- a/subr/ex_pkg.subr +++ b/subr/ex_pkg.subr @@ -105,7 +105,7 @@ ex_pkg_load_dump() { # Return: zero (0) on success, non-zero (>0) on failure, build variables post-return on success. # ex_pkg_load_vars() { - local _rc=0; _status=""; + local _rc=0 _fname=""; _status=""; if ! rtl_lmatch "${ARCH}" "nt32 nt64"; then _rc=1; _status="Error: invalid architecture \`${ARCH}'."; elif ! rtl_lmatch "${BUILD_KIND}" "debug release"; then @@ -114,9 +114,16 @@ ex_pkg_load_vars() { nt32) DEFAULT_TARGET="i686-nt32-midipix"; ;; nt64) DEFAULT_TARGET="x86_64-nt64-midipix"; ;; esac; - rtl_fileop source_opt \ - "${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars" \ - ../midipix_build.vars ./midipix.env; + for _fname in \ + "${HOME}/midipix_build.vars" \ + "${HOME}/.midipix_build.vars" \ + ../midipix_build.vars \ + ./midipix.env; do + if [ -r "${_fname}" ]; then + rtl_log_msg notice "Sourcing \`%s'." "${_fname}"; + rtl_fileop source "${_fname}"; + fi; + done; if [ -z "${PREFIX}" ]; then _rc=1; _status="Error: \${PREFIX} empty or unset."; fi; diff --git a/subr/rtl_fileop.subr b/subr/rtl_fileop.subr index 64538c5..dd82311 100644 --- a/subr/rtl_fileop.subr +++ b/subr/rtl_fileop.subr @@ -92,7 +92,7 @@ rtl_fileop() { rtlp_fileop_log "Moving \`${1}' to \`${2}' w/ -fs"; mv -f -- "${1}" "${2}"; _rc="${?}"; fi; ;; - mkdir|mkfifo|rm|source_opt|test|touch) + mkdir|mkfifo|rm|source|source_opt|test|touch) while [ \( "${?}" -eq 0 \) -a \( ""${#}"" -gt 0 \) ]; do if [ -z "${1}" ]; then rtl_log_msg fatalexit "Missing parameters (in: %s %s.)" "${_op}" "${*}"; @@ -117,6 +117,10 @@ rtl_fileop() { && rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Removing directory or file \`${1}'."; rm -rf -- "${1}"; _rc="${?}"; + elif [ "${_op}" = source ]\ + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then + rtlp_fileop_log "Sourcing file \`${1}'."; + . "${1}"; _rc="${?}"; elif [ "${_op}" = source_opt ]\ && rtl_fileop test "${1}"\ && rtlp_fileop_check "${PREFIX:-}" "${1}"; then