nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 109 lines 3.9 kB view raw
1/* 2 This function builds just the `lib/locale/locale-archive' file from 3 Glibc and nothing else. If `allLocales' is true, all supported 4 locales are included; otherwise, just the locales listed in 5 `locales'. See localedata/SUPPORTED in the Glibc source tree for 6 the list of all supported locales: 7 https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED 8*/ 9 10{ 11 lib, 12 stdenv, 13 buildPackages, 14 callPackage, 15 writeText, 16 glibc, 17 allLocales ? true, 18 locales ? [ "en_US.UTF-8/UTF-8" ], 19 linuxHeaders, 20 withLinuxHeaders ? !stdenv.cc.isGNU, 21}: 22 23(callPackage ./common.nix 24 ({ inherit stdenv; } // lib.optionalAttrs withLinuxHeaders { inherit linuxHeaders; }) 25 { 26 pname = "glibc-locales"; 27 extraNativeBuildInputs = [ glibc ]; 28 inherit withLinuxHeaders; 29 } 30).overrideAttrs 31 ( 32 finalAttrs: previousAttrs: { 33 34 outputs = [ "out" ]; 35 36 env = (previousAttrs.env or { }) // { 37 LOCALEDEF_FLAGS = if stdenv.hostPlatform.isLittleEndian then "--little-endian" else "--big-endian"; 38 39 # Glibc cannot have itself in its RPATH. 40 NIX_NO_SELF_RPATH = 1; 41 }; 42 43 postConfigure = (previousAttrs.postConfigure or "") + '' 44 # Hack: get rid of the `-static' flag set by the bootstrap stdenv. 45 # This has to be done *after* `configure' because it builds some 46 # test binaries. 47 export NIX_CFLAGS_LINK= 48 export NIX_LDFLAGS_BEFORE= 49 50 export NIX_DONT_SET_RPATH=1 51 unset CFLAGS 52 ''; 53 54 preBuild = 55 (previousAttrs.preBuild or "") 56 + '' 57 # Awful hack: `localedef' doesn't allow the path to `locale-archive' 58 # to be overriden, but you *can* specify a prefix, i.e. it will use 59 # <prefix>/<path-to-glibc>/lib/locale/locale-archive. So we use 60 # $TMPDIR as a prefix, meaning that the locale-archive is placed in 61 # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive. 62 LOCALEDEF_FLAGS+=" --prefix=$TMPDIR" 63 64 export inst_complocaledir="$TMPDIR/"${buildPackages.glibc.out}/lib/locale 65 mkdir -p "$inst_complocaledir" 66 67 echo 'C.UTF-8/UTF-8 \' >> ../localedata/SUPPORTED 68 69 # Hack to allow building of the locales (needed since glibc-2.12) 70 substituteInPlace ../localedata/Makefile \ 71 --replace-fail '$(rtld-prefix) $(common-objpfx)locale/localedef' 'localedef $(LOCALEDEF_FLAGS)' 72 '' 73 + lib.optionalString (!allLocales) '' 74 # Check that all locales to be built are supported 75 echo -n '${lib.concatMapStrings (s: s + " \\\n") locales}' \ 76 | sort -u > locales-to-build.txt 77 cat ../localedata/SUPPORTED | grep ' \\' \ 78 | sort -u > locales-supported.txt 79 comm -13 locales-supported.txt locales-to-build.txt \ 80 > locales-unsupported.txt 81 if [[ $(wc -c locales-unsupported.txt) != "0 locales-unsupported.txt" ]]; then 82 cat locales-supported.txt 83 echo "Error: unsupported locales detected:" 84 cat locales-unsupported.txt 85 echo "You should choose from the list above the error." 86 false 87 fi 88 89 echo SUPPORTED-LOCALES='${toString locales}' > ../localedata/SUPPORTED 90 ''; 91 92 makeFlags = (previousAttrs.makeFlags or [ ]) ++ [ 93 "localedata/install-locales" 94 "localedir=${placeholder "out"}/lib/locale" 95 ]; 96 97 installPhase = '' 98 mkdir -p "$out/lib/locale" "$out/share/i18n" 99 cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale" 100 cp -v ../localedata/SUPPORTED "$out/share/i18n/SUPPORTED" 101 ''; 102 103 setupHook = writeText "locales-setup-hook.sh" '' 104 export LOCALE_ARCHIVE=@out@/lib/locale/locale-archive 105 ''; 106 107 meta.description = "Locale information for the GNU C Library"; 108 } 109 )