git.iko.soy/typeable/nixpkgs
on master help sign in
coreutils: Modernize and fix for cross

"--host=..." needs to be passed but crossAttrs overrides that.

commit167b80ba76ae767b1d37458afb113683921d8c74 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateMon 19 Jun 2017, 22:18 (9 years ago) parentf63f96a
1 file changed+37−39
pkgs/tools/misc/coreutils/default.nix+37−39
pkgs/tools/misc/coreutils/default.nix+37−39
@@ -1,8 +1,9 @@
1−{ lib, stdenv, buildPackages, fetchurl, perl, xz, gmp ? null
1+{ stdenv, lib, buildPackages
2+, autoconf, automake114x, texinfo, fetchurl, perl, xz, libiconv, gmp ? null
3+, hostPlatform, buildPlatform
24, aclSupport ? false, acl ? null
35, attrSupport ? false, attr ? null
46, selinuxSupport? false, libselinux ? null, libsepol ? null
5−, autoconf, automake114x, texinfo
67, withPrefix ? false
78, singleBinary ? "symlinks" # you can also pass "shebangs" or false
89}:
@@ -23,10 +24,10 @@ stdenv.mkDerivation rec {
2324 # FIXME needs gcc 4.9 in bootstrap tools
2425 hardeningDisable = [ "stackprotector" ];
2526
26− patches = optional stdenv.isCygwin ./coreutils-8.23-4.cygwin.patch;
27+ patches = optional hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch;
2728
2829 # The test tends to fail on btrfs and maybe other unusual filesystems.
29− postPatch = optionalString (!stdenv.isDarwin) ''
30+ postPatch = optionalString (!hostPlatform.isDarwin) ''
3031 sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh
3132 sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh
3233 sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh
@@ -39,58 +40,54 @@ stdenv.mkDerivation rec {
3940 configureFlags =
4041 optional (singleBinary != false)
4142 ("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}")
42− ++ optional stdenv.isSunOS "ac_cv_func_inotify_init=no"
43− ++ optional withPrefix "--program-prefix=g";
43+ ++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
44+ ++ optional withPrefix "--program-prefix=g"
45+ ++ optionals (hostPlatform != buildPlatform && hostPlatform.libc == "glibc") [
46+ # TODO(19b98110126fde7cbb1127af7e3fe1568eacad3d): Needed for fstatfs() I
47+ # don't know why it is not properly detected cross building with glibc.
48+ "fu_cv_sys_stat_statfs2_bsize=yes"
49+ ];
50+
4451
4552 buildInputs = [ gmp ]
4653 ++ optional aclSupport acl
4754 ++ optional attrSupport attr
48− ++ optionals stdenv.isCygwin [ autoconf automake114x texinfo ] # due to patch
49− ++ optionals selinuxSupport [ libselinux libsepol ];
50−
51− crossAttrs = {
52− buildInputs = [ gmp.crossDrv ]
53− ++ optional aclSupport acl.crossDrv
54− ++ optional attrSupport attr.crossDrv
55− ++ optionals selinuxSupport [ libselinux.crossDrv libsepol.crossDrv ]
56− ++ optional (stdenv ? ccCross.libc.libiconv)
57− stdenv.ccCross.libc.libiconv.crossDrv;
58−
59− # Prevents attempts of running 'help2man' on cross-built binaries.
60− PERL = "missing";
61−
62− # Works around a bug with 8.26:
63− # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
64− preInstall = ''
65− sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
66− '';
67−
68− postInstall = ''
69− rm $out/share/man/man1/*
70− cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
71− '';
72−
73− # Needed for fstatfs()
74− # I don't know why it is not properly detected cross building with glibc.
75− configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ];
76− doCheck = false;
77− };
55+ ++ optionals hostPlatform.isCygwin [ autoconf automake114x texinfo ] # due to patch
56+ ++ optionals selinuxSupport [ libselinux libsepol ]
57+ # TODO(@Ericson2314): Investigate whether Darwin could benefit too
58+ ++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv;
7859
7960 # The tests are known broken on Cygwin
8061 # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
8162 # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
8263 # and {Open,Free}BSD.
8364 # With non-standard storeDir: https://github.com/NixOS/nix/issues/512
84− doCheck = stdenv ? glibc && builtins.storeDir == "/nix/store";
65+ doCheck = hostPlatform == buildPlatform
66+ && hostPlatform.libc == "glibc"
67+ && builtins.storeDir == "/nix/store";
68+
69+ # Prevents attempts of running 'help2man' on cross-built binaries.
70+ ${if hostPlatform == buildPlatform then null else "PERL"} = "missing";
8571
8672 # Saw random failures like ‘help2man: can't get '--help' info from
8773 # man/sha512sum.td/sha512sum’.
8874 enableParallelBuilding = false;
8975
9076 NIX_LDFLAGS = optionalString selinuxSupport "-lsepol";
91− FORCE_UNSAFE_CONFIGURE = optionalString stdenv.isSunOS "1";
77+ FORCE_UNSAFE_CONFIGURE = optionalString hostPlatform.isSunOS "1";
78+
79+ makeFlags = optionalString hostPlatform.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0";
80+
81+ # Works around a bug with 8.26:
82+ # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
83+ ${if hostPlatform == buildPlatform then null else "preInstall"} = ''
84+ sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
85+ '';
9286
93− makeFlags = optionalString stdenv.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0";
87+ ${if hostPlatform == buildPlatform then null else "postInstall"} = ''
88+ rm $out/share/man/man1/*
89+ cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
90+ '';
9491
9592 meta = {
9693 homepage = http://www.gnu.org/software/coreutils/;
@@ -109,4 +106,5 @@ stdenv.mkDerivation rec {
109106
110107 maintainers = [ maintainers.eelco ];
111108 };
109+
112110}