summaryrefslogtreecommitdiffhomepage
path: root/subr.rtl
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-27 20:51:14 +0200
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-27 20:51:14 +0200
commitdc07baeb4b5443131e0bd7f2c5f3b506e23d74dc (patch)
treedb108f0ac5c8d568f0e13f1b98a82b0cbb45fb6d /subr.rtl
parent2c358983b2d80e298fdfd4f991bde9de54aa4302 (diff)
downloadmidipix_build-dc07baeb4b5443131e0bd7f2c5f3b506e23d74dc.tar.bz2
midipix_build-dc07baeb4b5443131e0bd7f2c5f3b506e23d74dc.tar.xz
Implements localised message files, pt. II.
Diffstat (limited to 'subr.rtl')
-rw-r--r--subr.rtl/rtl_fetch.subr19
-rw-r--r--subr.rtl/rtl_fileop.subr26
-rw-r--r--subr.rtl/rtl_install_v2.subr2
-rw-r--r--subr.rtl/rtl_log.subr20
-rw-r--r--subr.rtl/rtl_platform.subr4
5 files changed, 37 insertions, 34 deletions
diff --git a/subr.rtl/rtl_fetch.subr b/subr.rtl/rtl_fetch.subr
index 461893b6..5f557320 100644
--- a/subr.rtl/rtl_fetch.subr
+++ b/subr.rtl/rtl_fetch.subr
@@ -37,31 +37,26 @@ rtl_fetch_url_wget() {
case "${_rc}" in
0) break; ;;
1) if [ "${_urls_count}" -ge 1 ]; then
- rtl_log_msg "warning" "Warning: failed to acquire fetching lock for URL \`%s', retrying with alternative URL..." "${_url}";
+ rtl_log_msg "warning" "${MSG_rtl_fetch_lockfail_retryurl}" "${_url}";
else
- rtl_log_msg "fatal" "Error: failed to acquire fetching lock for URL \`%s'." "${_url}";
+ rtl_log_msg "fatal" "${MSG_rtl_fetch_lockfail}" "${_url}";
rtl_fileop rm "${_target_fname_full}"; break;
fi; ;;
2) if [ "${_urls_count}" -ge 1 ]; then
- rtl_log_msg "warning" "Warning: hash mismatch for URL \`%s', retrying with alternative URL... (from build variables: %s.)"\
- "${_url}" "${_sha256sum_src}";
+ rtl_log_msg "warning" "${MSG_rtl_fetch_hashfail_retryurl}" "${_url}" "${_sha256sum_src}";
else
if _sha256sum_target="$(sha256sum "${_target_fname_full}" |\
awk '{print $1}' 2>/dev/null)"; then
- rtl_log_msg "fatal" "Error: hash mismatch for URL \`%s' (should be: %s vs.: %s.)"\
- "${_url}" "${_sha256sum_src}" "${_sha256sum_target}";
+ rtl_log_msg "fatal" "${MSG_rtl_fetch_hashfail1}" "${_url}" "${_sha256sum_src}" "${_sha256sum_target}";
else
- rtl_log_msg "fatal" "Error: hash mismatch for URL \`%s' (should be: %s.)"\
- "${_url}" "${_sha256sum_src}";
+ rtl_log_msg "fatal" "${MSG_rtl_fetch_hashfail2}" "${_url}" "${_sha256sum_src}";
fi;
rtl_fileop rm "${_target_fname_full}"; break;
fi; ;;
*) if [ "${_urls_count}" -ge 1 ]; then
- rtl_log_msg "warning" "Warning: failed to fetch URL \`%s', retrying with alternative URL... (wget(1) exit status: %s)"\
- "${_url}" "$((${_rc}-2))";
+ rtl_log_msg "warning" "${MSG_rtl_fetch_fail_retryurl}" "${_url}" "$((${_rc}-2))";
else
- rtl_log_msg "fatal" "Error: failed to fetch URL \`%s' (wget(1) exit status: %s)"\
- "${_url}" "$((${_rc}-2))";
+ rtl_log_msg "fatal" "${MSG_rtl_fetch_fail}" "${_url}" "$((${_rc}-2))";
rtl_fileop rm "${_target_fname_full}"; break;
fi; ;;
esac;
diff --git a/subr.rtl/rtl_fileop.subr b/subr.rtl/rtl_fileop.subr
index 4addffcd..6d258f5e 100644
--- a/subr.rtl/rtl_fileop.subr
+++ b/subr.rtl/rtl_fileop.subr
@@ -14,7 +14,7 @@ rtlp_fileop_check() {
};
rtlp_fileop_log() {
- rtl_log_msg "fileop" "${1}";
+ rtl_log_msg "fileop" "0;${1}";
};
#
@@ -25,27 +25,27 @@ rtl_fileop() {
local _op="${1}" _dst="" _group="" _install_args="" _mode="" _owner="" _rc=0 _src=""; shift;
case "${_op}" in
cd) if [ \( -z "${1}" \) -o ! \( -L "${1}" -o -e "${1}" \) ]; then
- rtl_log_msg "fatalexit" "Error: Invalid or non-existent directory \`%s'." "${1}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invalid_dir}" "${1}";
elif rtlp_fileop_check "${PREFIX:-}" "${1}"; then
rtlp_fileop_log "Changing working directory to \`${1}'.";
cd -- "${1}"; _rc="${?}";
fi; ;;
chmod) if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: chmod %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_chmod}" "${*}";
elif _mode="${1}" && shift\
&& rtlp_fileop_check "${PREFIX:-}" "${*}"; then
rtlp_fileop_log "Changing file mode bits of \`${*}' to \`${_mode}'.";
chmod -- "${_mode}" "${@}"; _rc="${?}";
fi; ;;
chgrp) if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: chgrp %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_chgrp}" "${*}";
elif _group="${1}" && shift\
&& rtlp_fileop_check "${PREFIX:-}" "${*}"; then
rtlp_fileop_log "Changing file group of \`${*}' to \`${_group}'.";
chgrp -- "${_group}" "${@}"; _rc="${?}";
fi; ;;
chown) if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: chown %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_chown}" "${*}";
elif _owner="${1}" && shift\
&& rtlp_fileop_check "${PREFIX:-}" "${*}"; then
rtlp_fileop_log "Changing file owner of \`${*}' to \`${_owner}'.";
@@ -53,7 +53,7 @@ rtl_fileop() {
fi; ;;
cp_follow)
if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: cp_follow %s}.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_cp_follow}" "${*}";
elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then
_src="${*}"; _src="${_src% *}";
_dst="${*}"; _dst="${_dst##* }";
@@ -61,7 +61,7 @@ rtl_fileop() {
cp -pLR -- "${@}"; _rc="${?}";
fi; ;;
cp) if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: cp %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_cp}" "${*}";
elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then
_src="${*}"; _src="${_src% *}";
_dst="${*}"; _dst="${_dst##* }";
@@ -70,7 +70,7 @@ rtl_fileop() {
fi; ;;
install)
if [ "${#}" -lt 2 ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: install %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_install}" "${*}";
else _dst="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${2}")";
_install_args="$(while [ ""${#}"" -gt 2 ]; do printf "%s" "${1}"; shift; done)";
_src="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${1}")";
@@ -81,7 +81,7 @@ rtl_fileop() {
fi; ;;
ln_symbolic)
if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: ln_symbolic %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_ln_symbolic}" "${*}";
elif rtlp_fileop_check "${PREFIX:-}" "${2}"; then
if rtl_fileop test "${2}"; then
rtl_fileop rm "${2}";
@@ -92,13 +92,13 @@ rtl_fileop() {
fi;
fi; ;;
mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: mv %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_mv}" "${*}";
elif rtlp_fileop_check "${PREFIX:-}" "${1}" "${2}"; then
rtlp_fileop_log "Moving \`${1}' to \`${2}' w/ -fs";
mv -f -- "${1}" "${2}"; _rc="${?}";
fi; ;;
touch) if [ -z "${1}" ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: touch %s.)" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_touch}" "${*}";
elif rtlp_fileop_check "${PREFIX:-}" "${1}"; then
rtlp_fileop_log "Touching file \`${1}'${2:+ w/ timestamp \`${2}\'}.";
touch ${2:+-t "${2}"} -- "${1}"; _rc="${?}";
@@ -106,7 +106,7 @@ rtl_fileop() {
mkdir|mkfifo|rm|source|source_opt|test)
while [ \( "${?}" -eq 0 \) -a \( ""${#}"" -gt 0 \) ]; do
if [ -z "${1}" ]; then
- rtl_log_msg "fatalexit" "Error: Missing parameters (in: %s %s.)" "${_op}" "${*}";
+ rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm}" "${_op}" "${*}";
elif [ "${_op}" = mkdir ]\
&& [ ! -d "${1}" ]\
&& rtlp_fileop_check "${PREFIX:-}" "${1}"; then
@@ -143,7 +143,7 @@ rtl_fileop() {
return 1;
fi; shift;
done; ;;
- *) rtl_log_msg "fatalexit" "Error: rtl_fileop() called w/ invalid parameter(s): %s" "${*}"; ;;
+ *) rtl_log_msg "fatalexit" "${MSG_rtl_fileop_invparm_fileop}" "${*}"; ;;
esac; return "${_rc}";
};
diff --git a/subr.rtl/rtl_install_v2.subr b/subr.rtl/rtl_install_v2.subr
index 210ade97..6366376d 100644
--- a/subr.rtl/rtl_install_v2.subr
+++ b/subr.rtl/rtl_install_v2.subr
@@ -261,7 +261,7 @@ rtlp_install_rc() {
if [ "${_rir_nflag}" -eq 1 ]\
|| [ "${_rir_vflag}" -gt 0 ]; then
- rtl_log_msg "install" "%s" "${_rir_fn}${_rir_fn:+ ${*}}";
+ rtl_log_msg "install" "${MSG_rtl_install_v2_rc}" "${_rir_fn}${_rir_fn:+ ${*}}";
fi;
if [ "${_rir_nflag}" -eq 0 ]; then
"${_rir_fn}" "${@}"; _rir_rc="${?}";
diff --git a/subr.rtl/rtl_log.subr b/subr.rtl/rtl_log.subr
index 0a1e275b..3a7560a5 100644
--- a/subr.rtl/rtl_log.subr
+++ b/subr.rtl/rtl_log.subr
@@ -11,7 +11,15 @@ RTLP_LOG_NO_ATTR=0;
RTLP_LOG_TAGS="";
rtlp_log_printf() {
- local _attr="${1}" _fmt="${2}"; shift 2; _msg="$(printf "${_fmt}" "${@}")";
+ local _attr="${1}" _fmt_pfx="${2}" _fmt="${3#*;}" _fmt_argc="${3%%;*}"; shift 3;
+ if [ "${#}" -ne "${_fmt_argc}" ]; then
+ if [ "${_fmt_argc}" -eq 0 ]; then
+ shift "${#}";
+ else
+ rtlp_log_printf "" "" "0;==> FIXME TODO XXX MESSAGE STRING ARGUMENT COUNT MISMATCH\n";
+ fi;
+ fi;
+ _msg="$(printf "${_fmt_pfx}${_fmt}" "${@}")";
if [ -n "${RTLP_LOG_FNAME}" ]; then
printf "%s\n" "${_msg}" >> "${RTLP_LOG_FNAME}";
@@ -43,11 +51,11 @@ rtl_log_enable_tags() {
rtl_log_env_vars() {
local _tag="${1}" _type="${2}" _arg_len_max=0; shift 2;
- rtl_log_msg "${_tag}" "Variables for this ${_type}:";
+ rtl_log_msg "${_tag}" "${MSG_rtl_log_vars_header}" "${_type}";
_arg_len_max="$(rtl_lmax "${@}")";
while [ "${#}" -gt 0 ]; do
- rtl_log_msg "${_tag}" \
- "%${_arg_len_max}.${_arg_len_max}s=%s" \
+ rtl_log_msg "${_tag}" \
+ "2;%${_arg_len_max}.${_arg_len_max}s=%s" \
"${1%%=*}" "$(rtl_get_var_unsafe "${1#*=}")";
shift;
done; return 0;
@@ -60,9 +68,9 @@ rtl_log_msg() {
if rtl_lmatch "${RTLP_LOG_TAGS}" "${_tag}" ","; then
eval _attr='${LOG_TAG_'"${_tag}"':-}';
if [ "${#_attr}" -eq 0 ]; then
- rtlp_log_printf "" "==> FIXME TODO XXX UNKNOWN TAG \`%s' PASSED TO rtl_log_msg()\n" "${_tag}";
+ rtlp_log_printf "" "" "0;==> FIXME TODO XXX UNKNOWN TAG \`${_tag}' PASSED TO rtl_log_msg()\n";
fi;
- rtlp_log_printf "${_attr}" "==> %s ${_fmt}" "$(rtl_date)" "${@}";
+ rtlp_log_printf "${_attr}" "==> $(rtl_date) " "${_fmt}" "${@}";
if [ "${_exitfl}" -eq 1 ]; then
exit 1;
fi;
diff --git a/subr.rtl/rtl_platform.subr b/subr.rtl/rtl_platform.subr
index af3365eb..dd50852b 100644
--- a/subr.rtl/rtl_platform.subr
+++ b/subr.rtl/rtl_platform.subr
@@ -86,9 +86,9 @@ rtl_rc() {
local _nflag="${1}" _cmd="${2}"; shift 2;
case "${_nflag}" in
1) if [ "${#}" -gt 0 ]; then
- rtl_log_msg "verbose" "Command line: %s %s" "${_cmd}" "${*}";
+ rtl_log_msg "verbose" "${MSG_rtl_platform_rc1}" "${_cmd}" "${*}";
else
- rtl_log_msg "verbose" "Command line: %s" "${_cmd}";
+ rtl_log_msg "verbose" "${MSG_rtl_platform_rc2}" "${_cmd}";
fi; ;;
*) "${_cmd}" "${@}";
esac;