deal with the persistent locpath issue

linux standalone: Generate locale files in ~/.cache/git-annex/locales/ so
they're available even when the standalone tarball is installed in a
directory owned by root.

This avoids a full-on reference counting cleanup hell, by letting old
locale caches linger as long as the standalone bundle directory associated
with them is still around. Old ones get cleaned up.

In the case where the directory has a new bundle unpacked over top of it,
the old locale cache is invalidated and rebuilt. Of course, running
programs using that may get confused, but this was already the case, and
unpacking over top of a bundle is probably not a good idea anyhow.

To support that, added a buildid file, which only needs to be unique across
builds of git-annex with different libc versions. sha1sum of git-annex
seems good enough for that.

Removed debian/patches/standalone-no-LOCPATH as it's no longer
necessary.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2018-07-10 12:13:14 -04:00
parent ac228fa723
commit e802323071
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 31 additions and 65 deletions

View file

@ -12,6 +12,9 @@ git-annex (6.20180627) UNRELEASED; urgency=medium
stop processing files when unable to contact a ssh remote.
* p2p --pair: Fix interception of the magic-wormhole pairing code,
which since 0.8.2 it has sent to stderr rather than stdout.
* linux standalone: Generate locale files in ~/.cache/git-annex/locales/
so they're available even when the standalone tarball is installed
in a directory owned by root.
-- Joey Hess <id@joeyh.name> Fri, 22 Jun 2018 10:36:22 -0400

View file

@ -160,6 +160,7 @@ linuxstandalone:
$(MAKE) install-mans DESTDIR="$(LINUXSTANDALONE_DEST)"
sha1sum git-annex > "$(LINUXSTANDALONE_DEST)/buildid"
cd tmp/git-annex.linux && find . -type f > git-annex.MANIFEST
cd tmp/git-annex.linux && find . -type l >> git-annex.MANIFEST
cd tmp && tar c git-annex.linux | gzip -9 --rsyncable > git-annex-standalone-$(shell dpkg --print-architecture).tar.gz

View file

@ -1,2 +1 @@
standalone-build
standalone-no-LOCPATH

View file

@ -1,53 +0,0 @@
From 71cbc1012941495ec20a7cb11dad3da638aae2cf Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <debian@onerussian.com>
Date: Tue, 22 May 2018 22:57:26 -0400
Subject: BF: do not bother changing/setting LOCPATH
Some of the initial reasoning and discussion is at
https://github.com/datalad/datalad/pull/1921
but overall summary is that a typical standalone build relies on
user having RW permissions into its installation so locales are
generated upon initial use. For NeuroDebian standalone:
- built/installed by root
- locales are likely to be installed and be compatible
thus patching of LOCPATH seems to resolve some issues, primarily
with custom remotes which are ran by annex, thus provided with
LOCPATH
---
standalone/linux/skel/runshell | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
--- a/standalone/linux/skel/runshell
+++ b/standalone/linux/skel/runshell
@@ -118,12 +118,6 @@ 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
-
# LD_PRELOAD may interact badly with the bundled libc and other libraries,
# which may have a different subarchitecture than the preloaded library.
unset LD_PRELOAD
@@ -180,13 +174,13 @@ case "$os" in
GIT_ANNEX_TMP_DIR="$TMPDIR"
export GIT_ANNEX_TMP_DIR
- GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH MANPATH LOCPATH"
+ GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH MANPATH"
export GIT_ANNEX_STANDLONE_ENV
;;
*)
# 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"
+ GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR MANPATH"
export GIT_ANNEX_STANDLONE_ENV
;;
esac

View file

@ -118,16 +118,32 @@ 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
# LD_PRELOAD may interact badly with the bundled libc and other libraries,
# which may have a different subarchitecture than the preloaded library.
unset LD_PRELOAD
# Avoid using system locales, which may interact badly with bundled libc.
ORIG_LOCPATH="$LOCPATH"
export ORIG_LOCPATH
LOCPATH="$HOME/.cache/git-annex/locales/$(echo "$base" | tr / _ )"
export LOCPATH
# Clean up locale caches when their standalone bundle no longer exists.
for localecache in $HOME/.cache/git-annex/locales/*; do
cachebase=$(cat "$localecache/base" 2>/dev/null || true)
if [ ! -d "$cachebase" ] || ! cmp "$localecache/buildid" "$cachebase/buildid" >/dev/null ; then
rm -rf "$localecache"
fi
done
# If the locale cache for this bundle is out of date, refresh it.
if [ -e "$LOCPATH/buildid" ] && ! cmp "$LOCPATH/buildid" "$base/buildid" >/dev/null ; then
rm -rf "$LOCPATH"
fi
mkdir -p "$LOCPATH"
echo "$base" > "$LOCPATH/base"
cp "$base/buildid" "$LOCPATH/buildid"
# 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.
@ -138,17 +154,17 @@ for localeenv in "$LANG" "$LANGUAGE" "$LC_CTYPE" "$LC_NUMERIC" "$LC_TIME" \
"$LC_IDENTIFICATION" "$LC_ALL"; do
if [ "$localeenv" != "$lastlocaleenv" ]; then
lastlocaleenv="$localeenv"
if [ ! -d "$base/locales/$localeenv" ]; then
if [ ! -d "$LOCPATH/$localeenv" ]; then
if [ "${localeenv##[!.]*.}" = "utf8" ] || [ "${localeenv##[!.]*.}" = "UTF-8" ]; then
(
rm -rf "$base/locales/$localeenv.new.$$" &&
mkdir -p "$base/locales/$localeenv.new.$$" &&
rm -rf "$LOCPATH/$localeenv.new.$$" &&
mkdir -p "$LOCPATH/$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"
I18NPATH="$base/i18n" LANG=C localedef -i "${localeenv%%.*}" -c -f UTF-8 "$LOCPATH/$localeenv.new.$$" &&
mv "$LOCPATH/$localeenv.new.$$" "$LOCPATH/$localeenv"
) >/dev/null 2>/dev/null || true
fi
fi