git.iko.soy/typeable/nixpkgs
on master help sign in
zfs: fix cross compilation
commit27e830fff99ae2d5547ffba96620679d7e03431d authorBen Wolsieffer <benwolsieffer@gmail.com> dateFri 21 Dec 2018, 17:26 (8 years ago) parenta0dcccc
1 file changed+32−39
pkgs/os-specific/linux/zfs/default.nix+32−39
pkgs/os-specific/linux/zfs/default.nix+32−39
@@ -1,5 +1,5 @@
11{ stdenv, fetchFromGitHub, autoreconfHook, utillinux, nukeReferences, coreutils
2−, perl
2+, perl, buildPackages
33, configFile ? "all"
44
55# Userspace dependencies
@@ -43,53 +43,43 @@ let
4343
4444 postPatch = optionalString buildKernel ''
4545 patchShebangs scripts
46− '' + optionalString stdenv.hostPlatform.isMusl ''
47− substituteInPlace config/user-libtirpc.m4 \
48− --replace /usr/include/tirpc ${libtirpc}/include/tirpc
49− '';
50−
51− nativeBuildInputs = [ autoreconfHook nukeReferences ]
52− ++ optional buildKernel (kernel.moduleBuildDependencies ++ [ perl ]);
53− buildInputs = optionals buildUser [ zlib libuuid python3 attr ]
54− ++ optionals (buildUser) [ openssl ]
55− ++ optional stdenv.hostPlatform.isMusl [ libtirpc ];
56−
57− # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
58− NIX_CFLAGS_LINK = "-lgcc_s";
59−
60− hardeningDisable = [ "fortify" "stackprotector" "pic" ];
61−
62− preConfigure = ''
63− substituteInPlace ./module/zfs/zfs_ctldir.c --replace "umount -t zfs" "${utillinux}/bin/umount -t zfs"
64− substituteInPlace ./module/zfs/zfs_ctldir.c --replace "mount -t zfs" "${utillinux}/bin/mount -t zfs"
65− substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount" "${utillinux}/bin/umount"
66− substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount" "${utillinux}/bin/mount"
46+ # The arrays must remain the same length, so we repeat a flag that is
47+ # already part of the command and therefore has no effect.
48+ substituteInPlace ./module/zfs/zfs_ctldir.c --replace '"/usr/bin/env", "umount"' '"${utillinux}/bin/umount", "-n"' \
49+ --replace '"/usr/bin/env", "mount"' '"${utillinux}/bin/mount", "-n"'
50+ '' + optionalString buildUser ''
51+ substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount" "${utillinux}/bin/umount" \
52+ --replace "/bin/mount" "${utillinux}/bin/mount"
6753 substituteInPlace ./lib/libshare/nfs.c --replace "/usr/sbin/exportfs" "${nfs-utils}/bin/exportfs"
68− substituteInPlace ./cmd/ztest/ztest.c --replace "/usr/sbin/ztest" "$out/sbin/ztest"
69− substituteInPlace ./cmd/ztest/ztest.c --replace "/usr/sbin/zdb" "$out/sbin/zdb"
7054 substituteInPlace ./config/user-systemd.m4 --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
7155 substituteInPlace ./config/zfs-build.m4 --replace "\$sysconfdir/init.d" "$out/etc/init.d"
7256 substituteInPlace ./etc/zfs/Makefile.am --replace "\$(sysconfdir)" "$out/etc"
7357 substituteInPlace ./cmd/zed/Makefile.am --replace "\$(sysconfdir)" "$out/etc"
74− substituteInPlace ./module/Makefile.in --replace "/bin/cp" "cp"
7558 substituteInPlace ./etc/systemd/system/zfs-share.service.in \
7659 --replace "/bin/rm " "${coreutils}/bin/rm "
7760
78− for f in ./udev/rules.d/*
79− do
80− substituteInPlace "$f" --replace "/lib/udev/vdev_id" "$out/lib/udev/vdev_id"
81− done
8261 substituteInPlace ./cmd/vdev_id/vdev_id \
8362 --replace "PATH=/bin:/sbin:/usr/bin:/usr/sbin" \
8463 "PATH=${makeBinPath [ coreutils gawk gnused gnugrep systemd ]}"
85−
86− ./autogen.sh
87− configureFlagsArray+=("--libexecdir=$out/libexec")
64+ '' + optionalString stdenv.hostPlatform.isMusl ''
65+ substituteInPlace config/user-libtirpc.m4 \
66+ --replace /usr/include/tirpc ${libtirpc}/include/tirpc
8867 '';
8968
69+ nativeBuildInputs = [ autoreconfHook nukeReferences ]
70+ ++ optionals buildKernel (kernel.moduleBuildDependencies ++ [ perl ]);
71+ buildInputs = optionals buildUser [ zlib libuuid attr ]
72+ ++ optionals (buildUser) [ openssl python3 ]
73+ ++ optional stdenv.hostPlatform.isMusl libtirpc;
74+
75+ # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
76+ NIX_CFLAGS_LINK = "-lgcc_s";
77+
78+ hardeningDisable = [ "fortify" "stackprotector" "pic" ];
79+
9080 configureFlags = [
9181 "--with-config=${configFile}"
92− "--with-python=${python3.interpreter}"
82+ (withFeatureAs buildUser "python" python3.interpreter)
9383 ] ++ optionals buildUser [
9484 "--with-dracutdir=$(out)/lib/dracut"
9585 "--with-udevdir=$(out)/lib/udev"
@@ -97,13 +87,16 @@ let
9787 "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
9888 "--with-systemdgeneratordir=$(out)/lib/systemd/system-generator"
9989 "--with-mounthelperdir=$(out)/bin"
90+ "--libexecdir=$(out)/libexec"
10091 "--sysconfdir=/etc"
10192 "--localstatedir=/var"
10293 "--enable-systemd"
103− ] ++ optionals buildKernel [
94+ ] ++ optionals buildKernel ([
10495 "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
10596 "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
106− ];
97+ ] ++ kernel.makeFlags);
98+
99+ makeFlags = optionals buildKernel kernel.makeFlags;
107100
108101 enableParallelBuilding = true;
109102
@@ -112,9 +105,10 @@ let
112105 "DEFAULT_INITCONF_DIR=\${out}/default"
113106 ];
114107
115− postInstall = ''
116− # Prevent kernel modules from depending on the Linux -dev output.
117− nuke-refs $(find $out -name "*.ko")
108+ postInstall = optionalString buildKernel ''
109+ # Add reference that cannot be detected due to compressed kernel module
110+ mkdir -p "$out/nix-support"
111+ echo "${utillinux}" >> "$out/nix-support/extra-refs"
118112 '' + optionalString buildUser ''
119113 # Remove provided services as they are buggy
120114 rm $out/etc/systemd/system/zfs-import-*.service
@@ -174,7 +168,6 @@ in {
174168 # incompatibleKernelVersion = "4.19";
175169
176170 # this package should point to a version / git revision compatible with the latest kernel release
177− # This is now "stable". Move to zfsStable after it's tested more.
178171 version = "0.8.1";
179172
180173 sha256 = "0wlbziijx08a9bmbyq4gfz4by9l5jrx44g18i99qnfm78k2q8a84";