glibc-locales: check that all we build is supported

Until now, if e.g. the user passed "en_US.UTF-8" instead of "en_US.UTF-8/UTF-8",
the locales would be generated without failing but wouldn't work well.
Now we guard against such mistakes. Real life examples:
https://github.com/fish-shell/fish-shell/issues/1927
This commit is contained in:
Vladimír Čunát 2015-07-31 15:20:06 +02:00
parent adfd0c7830
commit eb4a88d8fd

View File

@ -29,10 +29,25 @@ build null {
# Hack to allow building of the locales (needed since glibc-2.12)
sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
''
+ stdenv.lib.optionalString (!allLocales) ''
# Check that all locales to be built are supported
echo -n '${stdenv.lib.concatMapStrings (s: s + " \\\n") locales}' \
| sort > locales-to-build.txt
cat ../glibc-2*/localedata/SUPPORTED | grep ' \\' \
| sort > locales-supported.txt
comm -13 locales-supported.txt locales-to-build.txt \
> locales-unsupported.txt
if [[ $(wc -c locales-unsupported.txt) != "0 locales-unsupported.txt" ]]; then
cat locales-supported.txt
echo "Error: unsupported locales detected:"
cat locales-unsupported.txt
echo "You should choose from the list above the error."
false
fi
${if allLocales then "" else
"echo SUPPORTED-LOCALES=\"${toString locales}\" > ../glibc-2*/localedata/SUPPORTED"}
echo SUPPORTED-LOCALES='${toString locales}' > ../glibc-2*/localedata/SUPPORTED
'' + ''
make localedata/install-locales \
localedir=$out/lib/locale \
'';