Browse Source

Start the work of installing locales in a better place

signals
Gavin Howard 3 years ago
parent
commit
f680e35607
Signed by untrusted user who does not match committer: gavin
GPG Key ID: C08038BDF280D33E
  1. 9
      Makefile.in
  2. 4
      configure.sh
  3. 56
      locale_install.sh
  4. 23
      locale_uninstall.sh
  5. 8
      tests/functions.sh

9
Makefile.in

@ -99,7 +99,7 @@ BINDIR = %%BINDIR%%
MAN1DIR = %%MAN1DIR%%
MAIN_EXEC = $(%%MAIN_EXEC%%)
EXEC = $(%%EXEC%%)
LOCALEDIR = %%LOCALEDIR%%/$(EXEC_PREFIX)$(MAIN_EXEC)$(EXEC_SUFFIX)
LOCALEDIR = %%LOCALEDIR%%
BC_ENABLE_SIGNALS = %%SIGNALS%%
BC_ENABLE_HISTORY = %%HISTORY%%
@ -114,7 +114,8 @@ INSTALL = ./install.sh
SAFE_INSTALL = ./safe-install.sh
LINK = ./link.sh
KARATSUBA = ./karatsuba.py
LOCALES_INSTALL = ./locales.sh
LOCALE_INSTALL = ./locale_install.sh
LOCALE_UNINSTALL = ./locale_uninstall.sh
CATALOGS = ./catalogs.sh
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
@ -282,7 +283,7 @@ clean_tests: clean clean_config
@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
install_locales:
$(LOCALES_INSTALL) $(DESTDIR)$(LOCALEDIR)
$(LOCALE_INSTALL) $(DESTDIR)$(LOCALEDIR) $(EXEC_PREFIX)$(MAIN_EXEC)$(EXEC_SUFFIX)
install_bc_manpage:
$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
@ -294,7 +295,7 @@ install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_PREREQS%%
$(INSTALL) $(DESTDIR)$(BINDIR) "$(EXEC_SUFFIX)"
uninstall_locales:
$(RM) -fr $(DESTDIR)$(LOCALEDIR)
$(LOCALE_UNINSTALL) $(DESTDIR)$(LOCALEDIR) $(EXEC_PREFIX)$(MAIN_EXEC)$(EXEC_SUFFIX)
uninstall_bc_manpage:
$(RM) -f $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)

4
configure.sh

@ -91,6 +91,10 @@ usage() {
printf ' MANDIR The location to install manpages to. Default is "$DATADIR/man".\n'
printf ' MAN1DIR The location to install Section 1 manpages to. Default is\n'
printf ' "$MANDIR/man1".\n'
printf ' LOCALEDIR The location to install locale catalogs to. Each locale will\n'
printf ' then be installed to "$LOCALEDIR/$LOCALE/LC_MESSAGES/$EXEC.cat",\n'
printf ' where "$LOCALE" is the locale of the catalog and "$EXEC" is the\n'
printf ' main executable name. Defaults to "$DATAROOTDIR/locale".\n'
printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n'
printf ' interfere with other installed bc executables. Default is "".\n'
printf ' EXECPREFIX The prefix to append to the executable names, used to not\n'

56
locale_install.sh

@ -0,0 +1,56 @@
#! /bin/sh
#
# Copyright 2018 Gavin D. Howard
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
usage() {
printf "usage: %s install_dir main_exec\n" "$0" 1>&2
exit 1
}
script="$0"
scriptdir=$(dirname "$script")
. "$scriptdir/tests/functions.sh"
INSTALL="$scriptdir/safe-install.sh"
test "$#" -ge 2 || usage
install_dir="$1"
shift
main_exec="$1"
shift
catalog_dir="$scriptdir/locales/catalogs"
for file in $catalog_dir/*.cat; do
base=$(basename "$file")
name=$(removeext "$base")
d="$install_dir/$name/LC_MESSAGES"
loc="$install_dir/$name/LC_MESSAGES/$main_exec.cat"
mkdir -p "$d"
if [ -L "$file" ]; then
link=$(readlink "$file")
linkname=$(basename "$link")
"$INSTALL" -Dlm 755 "../../$linkname/LC_MESSAGES/$link" "$loc"
else
"$INSTALL" -Dm 755 "$file" "$loc"
fi
done

23
locales.sh → locale_uninstall.sh

@ -15,7 +15,7 @@
#
usage() {
printf "usage: %s install_dir\n" "$0" 1>&2
printf "usage: %s locale_dir\n" "$0" 1>&2
exit 1
}
@ -26,24 +26,17 @@ scriptdir=$(dirname "$script")
INSTALL="$scriptdir/safe-install.sh"
test "$#" -ge 1 || usage
test "$#" -ge 2 || usage
installdir="$1"
locale_dir="$1"
shift
mkdir -p "$installdir"
catalogdir="$scriptdir/locales/catalogs"
for file in $catalogdir/*.cat; do
main_exec="$1"
shift
base=$(basename "$file")
for d in $locale_dir/*/; do
if [ -L "$file" ]; then
link=$(readlink "$file")
"$INSTALL" -Dlm 755 "$link" "$installdir/$base"
else
"$INSTALL" -Dm 755 "$file" "$installdir/$base"
fi
d=${d%*/}
rm -f "$d/LC_MESSAGES/$main_exec.cat"
done

8
tests/functions.sh

@ -24,6 +24,14 @@ readlink() {
printf ${L#*-> }
}
removeext() {
local name="$1"
shift
printf '%s' "$name" | cut -f 1 -d '.'
}
die() {
local d="$1"

Loading…
Cancel
Save