lol

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

+18 -3
+18 -3
pkgs/development/libraries/glibc/locales.nix
··· 29 29 30 30 # Hack to allow building of the locales (needed since glibc-2.12) 31 31 sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile 32 - 33 - ${if allLocales then "" else 34 - "echo SUPPORTED-LOCALES=\"${toString locales}\" > ../glibc-2*/localedata/SUPPORTED"} 32 + '' 33 + + stdenv.lib.optionalString (!allLocales) '' 34 + # Check that all locales to be built are supported 35 + echo -n '${stdenv.lib.concatMapStrings (s: s + " \\\n") locales}' \ 36 + | sort > locales-to-build.txt 37 + cat ../glibc-2*/localedata/SUPPORTED | grep ' \\' \ 38 + | sort > locales-supported.txt 39 + comm -13 locales-supported.txt locales-to-build.txt \ 40 + > locales-unsupported.txt 41 + if [[ $(wc -c locales-unsupported.txt) != "0 locales-unsupported.txt" ]]; then 42 + cat locales-supported.txt 43 + echo "Error: unsupported locales detected:" 44 + cat locales-unsupported.txt 45 + echo "You should choose from the list above the error." 46 + false 47 + fi 35 48 49 + echo SUPPORTED-LOCALES='${toString locales}' > ../glibc-2*/localedata/SUPPORTED 50 + '' + '' 36 51 make localedata/install-locales \ 37 52 localedir=$out/lib/locale \ 38 53 '';