summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsegfault <segfault@riseup.net>2019-10-02 23:59:59 +0200
committersegfault <segfault@riseup.net>2019-10-04 15:42:10 +0200
commit1bd1795e325646c279771c130be399f29e27914c (patch)
tree08fdc32b30f00058c5c8f636f2659b10660de41d
parent8874ddcf6b877a75db1185568c5cffba025190ce (diff)
Generate the list of supported locales during build (refs: #16095)
-rw-r--r--.gitignore1
-rw-r--r--config/chroot_local-hooks/16-greeter44
2 files changed, 45 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 78d237c..3f91291 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
/config/chroot_local-includes/usr/share/doc/tails/website
/config/chroot_local-includes/usr/share/tails/build/variables
/config/chroot_local-includes/usr/share/tails/greeter/supported_languages
+/config/chroot_local-includes/usr/share/tails/greeter/supported_locales
/.lock
/.stage
/source
diff --git a/config/chroot_local-hooks/16-greeter b/config/chroot_local-hooks/16-greeter
new file mode 100644
index 0000000..920efd6
--- /dev/null
+++ b/config/chroot_local-hooks/16-greeter
@@ -0,0 +1,44 @@
+#! /bin/sh
+
+set -e
+set -u
+
+echo "Generate list of supported locales"
+
+OUTFILE="/usr/share/tails/greeter/supported_locales"
+LANGUAGES_FILE="/usr/share/tails/greeter/supported_languages"
+DEFAULT_LOCALES="$(cat /usr/share/tails/greeter/default_locales)"
+
+# Ensure that the output file is empty
+rm -f "${OUTFILE}"
+
+# Extract language and country part from the locales supported by Debian
+ALL_LOCALES="$(tr '.' ' ' < /usr/share/i18n/SUPPORTED | \
+ grep -E ".+_[^.@]+ " | \
+ awk '{print $1;}' | \
+ uniq)"
+
+# Filter the locales by the supported languages
+for lang_code in $(cat ${LANGUAGES_FILE}); do
+ # First add our default locale for the language (i.e. the locale
+ # with the country code that should be used as the default for the
+ # language).
+ default_locale="$(echo "${DEFAULT_LOCALES}" | \
+ grep -E "^${lang_code}_" || true)"
+ if [ -n "${default_locale}" ]; then
+ echo "${default_locale}" >> "${OUTFILE}"
+ fi
+
+ # Get all the locales for the language
+ locales="$(echo "${ALL_LOCALES}" | grep -E "^${lang_code}_")"
+
+ # Remove the default locale from this list to avoid duplicates
+ if [ -n "${default_locale}" ]; then
+ locales="$(echo "${locales}" | grep -v "${default_locale}" || true)"
+ fi
+
+ # Add the locales to the output
+ if [ -n "${locales}" ]; then
+ echo "${locales}" >> "${OUTFILE}"
+ fi
+done