Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Thomas Orgis (da2b9f84a38012485bb7c9189b13698a9345f62f)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Thomas Orgis <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Thomas Orgis (da2b9f84a38012485bb7c9189b13698a9345f62f)
  • Date: Wed, 18 Mar 2020 18:21:09 +0000

GIT changes to master sorcery by Thomas Orgis <sobukus AT sourcemage.org>:

usr/sbin/cast | 2 +-
var/lib/sorcery/modules/libapi | 19 +++++++++++++++++++
var/lib/sorcery/modules/libgpg | 2 +-
var/lib/sorcery/modules/libmisc | 21 +++++++++++++++++++++
4 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit da2b9f84a38012485bb7c9189b13698a9345f62f
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.

diff --git a/usr/sbin/cast b/usr/sbin/cast
index dd11e05..09204f0 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -257,7 +257,7 @@ cast_spell() { (

# HACK for bug 2910 and 10546
local saved_lc_all=$LC_ALL
- export LC_ALL=C.UTF-8
+ export LC_ALL=$(get_safe_locale)

export DISTCC_DIR="$SOURCE_DIRECTORY/.distcc"

diff --git a/var/lib/sorcery/modules/libapi b/var/lib/sorcery/modules/libapi
index 11f78ba..5162437 100755
--- a/var/lib/sorcery/modules/libapi
+++ b/var/lib/sorcery/modules/libapi
@@ -39,6 +39,7 @@
# download_src (libsummon)
# force_depends (libdepends)
# gather_docs (build_api/common)
+# get_safe_locale (libmisc)
# get_spell_provider (libstate)
# get_source_nums (libmisc)
# guess_compressor (libunpack)
@@ -509,6 +510,24 @@ get_source_nums() {

#---------------------------------------------------------------------
## @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 master sorcery by Thomas Orgis (da2b9f84a38012485bb7c9189b13698a9345f62f), Thomas Orgis, 03/18/2020

Archive powered by MHonArc 2.6.24.

Top of Page