From b9d37c0b29ac72696ee823b506349c11d8cfc26d Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Thu, 18 Jun 2009 02:20:11 +1200 Subject: [PATCH] Language alias linker/installer/upgrade scripts alias-link.sh This is a script set designed to be called via make/Makefile and setup language codes for those languages which it would be impractical to bundle duplicate translated files for. Relies on local environment tools to be detected by automake. make install - now also calls generation of aliases after existing install. Provided in file aliases. make upgrade - cleans out legacy files from pre-3.1 and replaces with symlinks to the new upgraded language codes. Provided in file alias-upgrade. NP: this is a destructive process and must be manually run. Bundle aliasing scripts and Makefile to use them with the langpack. --- errors/Makefile.am | 12 ++++++++++-- errors/alias-link.sh | 33 +++++++++++++++++++++++++++++++++ errors/alias-upgrade | 33 +++++++++++++++++++++++++++++++++ errors/aliases | 2 ++ mksnapshot.sh | 2 +- 5 files changed, 79 insertions(+), 3 deletions(-) create mode 100755 errors/alias-link.sh create mode 100644 errors/alias-upgrade create mode 100644 errors/aliases diff --git a/errors/Makefile.am b/errors/Makefile.am index 33d16074a2..1662abb4a0 100644 --- a/errors/Makefile.am +++ b/errors/Makefile.am @@ -30,7 +30,8 @@ install-data-local: else \ echo "$(INSTALL_DATA) $(srcdir)/errorpage.css $(DESTDIR)$(DEFAULT_STYLESHEET)"; \ $(INSTALL_DATA) $(srcdir)/errorpage.css $(DESTDIR)$(DEFAULT_STYLESHEET); \ - fi + fi \ + $(SHELL) $(srcdir)/alias-link.sh "$(LN)" "$(RM)" "$(DESTDIR)$(DEFAULT_ERROR_DIR)" "$(srcdir)/aliases" || exit 1 uninstall-local: @@ -46,6 +47,11 @@ uninstall-local: @$(SHELL) $(top_srcdir)/scripts/remove-cfg.sh "$(RM)" $(DESTDIR)$(DEFAULT_STYLESHEET) rm -f $(DESTDIR)$(DEFAULT_STYLESHEET).default + +## Upgrade requires the new files to be pre-installed +upgrade: install + $(SHELL) $(srcdir)/alias-link.sh "$(LN)" "$(RM)" "$(DESTDIR)$(DEFAULT_ERROR_DIR)" "$(srcdir)/alias-upgrade" || exit 1 + dist-hook: translate for lang in $(TRANSLATIONS); do \ if test -d $$lang ; then \ @@ -56,7 +62,9 @@ dist-hook: translate || exit 1; \ fi; \ done; \ - cp -p $(srcdir)/errorpage.css $(distdir)/errorpage.css + for f in aliases alias-link.sh alias-upgrade $(DEFAULT_STYLESHEET); do \ + cp -p $(srcdir)/$$f $(distdir)/`basename $$f`; \ + done; translate: @if ! test -f $(top_srcdir)/errors/en.po; then \ diff --git a/errors/alias-link.sh b/errors/alias-link.sh new file mode 100755 index 0000000000..043623c72c --- /dev/null +++ b/errors/alias-link.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Generate Symlinks for a set of aliases. +# Our base content is the bundled .po translation output +# +# This file creates the authoritative ISO aliases. +# +# INPUT: "$(LN)" "$(RM)" "$(DESTDIR)$(DEFAULT_ERROR_DIR)" "$(srcdir)/$@" + +LN="${1}" +RM="${2}" +DIR="${3}" +ALIASFILE="${4}" + +if ! test -f ${ALIASFILE} ; then + echo "FATAL: Alias file ${ALIASFILE} does not exist!" + exit 1 +fi + +# Parse the alias file +cat ${ALIASFILE} | +while read base aliases; do + # file may be commented or have empty lines + if test "${base}" = "#" || test "${base}" = ""; then + continue; + fi + # split aliases based on whitespace and create a symlink for each + # Remove and replace any pre-existing content/link + for alia in ${aliases}; do + ${RM} -f -r ${DIR}/${alia} || exit 1 + ${LN} -s ${DIR}/${base} ${DIR}/${alia} || exit 1 + done +done diff --git a/errors/alias-upgrade b/errors/alias-upgrade new file mode 100644 index 0000000000..a314d15084 --- /dev/null +++ b/errors/alias-upgrade @@ -0,0 +1,33 @@ +# 3.0 Still published with the old language namings. +# we leave these alone in case any are configured... +az Azerbaijani +bg Bulgarian +ca Catalan +cz Czech +da Danish +de German +el Greek +en English +es Spanish +et Estonian +fi Finnish +fr French +he Hebrew +hu Hungarian +hy Armenian +it Italian +ja Japanese +ko Korean +lt Lithuanian +nl Dutch +po Polish +pt Portuguese +ro Romanian +ru Russian-1251 Russian-koi8-r +sk Slovak +sr Serbian +sv Swedish +tr Turkish +uk Ukrainian-1251 Ukrainian-koi8-u Ukrainian-utf8 +zh-cn Simplify_Chinese +zh-tw Traditional_Chinese diff --git a/errors/aliases b/errors/aliases new file mode 100644 index 0000000000..49bf4866e3 --- /dev/null +++ b/errors/aliases @@ -0,0 +1,2 @@ +en en-nz en-au en-gb en-uk en-ca +ru ru-ru diff --git a/mksnapshot.sh b/mksnapshot.sh index 09e74f422e..b49bfe18e8 100755 --- a/mksnapshot.sh +++ b/mksnapshot.sh @@ -116,6 +116,6 @@ fi # Generate language-pack tarballs # NP: Only to be done on HEAD branch. if test "${VERSION}" = "3.HEAD" ; then - sh -c "cd $tmpdir/errors && tar -zcf ${PWD}/${PACKAGE}-${VERSION}-${date}-langpack.tar.gz ./*/*" + sh -c "cd $tmpdir/errors && tar -zcf ${PWD}/${PACKAGE}-${VERSION}-${date}-langpack.tar.gz ./*/* ./alias* ./Makefile " echo ${PACKAGE}-${VERSION}-${date}-langpack.tar.gz >>${tag}.out fi -- 2.47.2