From eb4a88d8fd27cbda512c8728c797ef2b13a91ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Fri, 31 Jul 2015 15:20:06 +0200 Subject: [PATCH] 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 --- pkgs/development/libraries/glibc/locales.nix | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/glibc/locales.nix b/pkgs/development/libraries/glibc/locales.nix index 5d6e678bfe6..cbf7af22cac 100644 --- a/pkgs/development/libraries/glibc/locales.nix +++ b/pkgs/development/libraries/glibc/locales.nix @@ -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 \ '';