diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-04 16:37:43 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-04 16:37:43 -0400 |
commit | 218ceacf5dffd328fcc08e6e775f43cffa887238 (patch) | |
tree | 0340232fd51eb59cec8d48624814f5e32351a2c4 /standalone | |
parent | 2c2b8f0ec2ce32550ac79ae7c367104f68ec37b6 (diff) |
Linux standalone: Include locale files in the bundle, and generate locale definition files for the locales in use when starting runshell.
Currently only done for utf-8 locales because the charset can easily be
told for those. Other locales don't include the charset in their name.
The locale definition is generated under git-annex.linux/locales.
So, this only works if the user can write there.
If locale generation fails for any reason, it's silently skipped.
The git-annex-standalone.deb installs the bundle under /usr, so this locale
generation won't work for non-root users.
Diffstat (limited to 'standalone')
-rwxr-xr-x | standalone/linux/skel/runshell | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/standalone/linux/skel/runshell b/standalone/linux/skel/runshell index 6f6ba8a3e..d6bec7aa3 100755 --- a/standalone/linux/skel/runshell +++ b/standalone/linux/skel/runshell @@ -100,11 +100,6 @@ export ORIG_GCONV_PATH GCONV_PATH="$base/$(cat "$base/gconvdir")" export GCONV_PATH -ORIG_LOCPATH="$LOCPATH" -export ORIG_LOCPATH -LOCPATH=/dev/null -export LOCPATH - ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH" export ORIG_GIT_EXEC_PATH GIT_EXEC_PATH="$base/git-core" @@ -120,6 +115,39 @@ export ORIG_MANPATH MANPATH="$base/usr/share/man:$MANPATH" export MANPATH +# Avoid using system locales, which may interact badly with bundled libc. +ORIG_LOCPATH="$LOCPATH" +export ORIG_LOCPATH +LOCPATH="$base/locales" +export LOCPATH + +# Generate locale definition files for the locales in use, +# using the localedef and locale files from the bundle. +# Currently only utf-8 locales are handled. +lastlocaleenv="" +for localeenv in "$LANG" "$LANGUAGE" "$LC_CTYPE" "$LC_NUMERIC" "$LC_TIME" \ + "$LC_COLLATE" "$LC_MONETARY" "$LC_MESSAGES" "$LC_PAPER" \ + "$LC_NAME" "$LC_ADDRESS" "$LC_TELEPHONE" "$LC_MEASUREMENT" \ + "$LC_IDENTIFICATION" "$LC_ALL"; do + if [ "$localeenv" != "$lastlocaleenv" ]; then + lastlocaleenv="$localeenv" + if [ ! -d "$base/locales/$localeenv" ]; then + if [ "${localeenv##[!.]*.}" = "utf8" ]; then + ( + rm -rf "$base/locales/$localeenv.new.$$" && + mkdir -p "$base/locales/$localeenv.new.$$" && + # cd to $base since localedef reads files from pwd + cd "$base" && + # Run localedef using the bundled i18n files; + # use LANG=C to avoid it reading the system locale archive. + I18NPATH="$base/i18n" LANG=C localedef -i "${localeenv%%.*}" -c -f UTF-8 "$base/locales/$localeenv.new.$$" && + mv "$base/locales/$localeenv.new.$$" "$base/locales/$localeenv" + ) >/dev/null 2>/dev/null || true + fi + fi + fi +done + # Indicate which variables were exported above and should be cleaned # when running non-bundled programs. GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR MANPATH LOCPATH" |