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.
This commit is contained in:
Joey Hess 2016-10-04 16:37:43 -04:00
parent a93e38e8fc
commit aacd9b190d
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
4 changed files with 40 additions and 11 deletions

View file

@ -91,6 +91,8 @@ preferredBundledPrograms = catMaybes
-- used to unpack the tarball when upgrading
, Just "gunzip"
, Just "tar"
-- used by runshell to generate locales
, Just "localedef"
#endif
-- nice, ionice, and nocache are not included in the bundle;
-- we rely on the system's own version, which may better match

View file

@ -14,12 +14,9 @@ git-annex (6.20160924) UNRELEASED; urgency=medium
external special remotes, because running multiple git-annex commands
at the same time could already start multiple processes for the same
external special remotes.
* Linux standalone: Add back the LOCPATH=/dev/null hack to avoid
the system locale-archive being read. Version mismatches between the
system locale-archive and the glibc in the bundle have been observed
to cause git crashes. Unfortunately, this causes locales to not be
used in the linux standalone bundle, reverting back to pre-6.20160419
behavior.
* 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.)
-- Joey Hess <id@joeyh.name> Mon, 26 Sep 2016 16:46:19 -0400

View file

@ -143,6 +143,8 @@ linuxstandalone-nobuild: Build/Standalone Build/LinuxMkLibs
install -d "$(LINUXSTANDALONE_DEST)/templates"
install -d "$(LINUXSTANDALONE_DEST)/magic"
cp /usr/share/file/magic.mgc "$(LINUXSTANDALONE_DEST)/magic"
install -d "$(LINUXSTANDALONE_DEST)/i18n"
cp /usr/share/i18n -a "$(LINUXSTANDALONE_DEST)/i18n"
./Build/LinuxMkLibs "$(LINUXSTANDALONE_DEST)"

View file

@ -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"