New commits:
commit 8bdc92c0f661c115a007ef391608ec6042e8311e
Author: Thomas Orgis <sobukus AT sourcemage.org>
Commit: Thomas Orgis <sobukus AT sourcemage.org>
libmisc: introduce get_safe_locale and use it in cast, libgpg
This makes sorcery not blindly assume that C.UTF-8 is a valid
locale, which it is not on ancient systems (meaning: stable
Source Mage). Now, a list of preferred UTF-8 locales is matched
against $(locale -a) to avoid the annoying stream of errors.
#---------------------------------------------------------------------
## @Type API
+## @param optional list of preferred locales to test for instead
+## of internal default, in order (one string, space-separated)
+##
+## @See <@function
var.lib.sorcery.modules.libmisc.html,real_get_safe_locale,> for more details.
+##
+## On a modern system, this should print C.UTF-8 or en_US.UTF-8, falling
+## back to C, which always has to be there.
+##
+## @return 0 if the returned locale is a preferred one (not C fallback)
+## @stdout the locale name
+#---------------------------------------------------------------------
+get_safe_locale() {
+ debug "libapi" "get_safe_locale - $*"
+ real_get_safe_locale "$@"
+}
+
+#---------------------------------------------------------------------
+## @Type API
## @param Spell name
## @param Provider name
## @param If empty get the uncommited spell info, if anything else get
diff --git a/var/lib/sorcery/modules/libgpg b/var/lib/sorcery/modules/libgpg
index 5434091..a7bbee1 100755
--- a/var/lib/sorcery/modules/libgpg
+++ b/var/lib/sorcery/modules/libgpg
@@ -49,7 +49,7 @@ gpg_verify_signature() { # $1 sig $2 file $3 pubring $4
algo var
return 200
else
local output=$TMP_DIR/$(smgl_basename $file).gpgout
- LC_ALL=C.UTF-8 gpg --no-default-keyring \
+ LC_ALL="$(get_safe_locale)" gpg --no-default-keyring \
--always-trust \
--keyring $keyring \
--batch \
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 8329349..1bde1d5 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -1172,6 +1172,27 @@ real_config_query_list() {
}
#---------------------------------------------------------------------
+## Print out a safe locale to use, hopefully supporting UTF-8
+## The default list of locales to look for can be overridden by
+## an optional argument.
+## This returns 0 if one of he preferred (UTF-8) locales is found.
+## The fallback C is always there.
+#---------------------------------------------------------------------
+real_get_safe_locale() {
+ local sys_locales=$(locale -a)
+ local check_locales=${1:-C.UTF-8 C.utf8 en_US.UTF-8 en_US.utf8}
+ for l in $check_locales
+ do
+ if list_find "$sys_locales" "$l"; then
+ printf "%s\n" "$l"
+ return 0
+ fi
+ done
+ echo C
+ return 1
+}
+
+#---------------------------------------------------------------------
## Output a list of source numbers associated with the current spell.
## This is the number portion of SOURCE[[:digit:]], eg '', "2", "3", etc.
## A prefix may be given and it will be prepended to each result value.
[SM-Commit] GIT changes to devel-sobukus-protection sorcery by Thomas Orgis (8bdc92c0f661c115a007ef391608ec6042e8311e),
Thomas Orgis, 03/18/2020