1{ lib, stdenv, fetchurl, fetchpatch, libuuid, autoreconfHook }:
2
3stdenv.mkDerivation rec {
4 pname = "jfsutils";
5 version = "1.1.15";
6
7 src = fetchurl {
8 url = "mirror://sourceforge/jfs/jfsutils-${version}.tar.gz";
9 sha256 = "0kbsy2sk1jv4m82rxyl25gwrlkzvl3hzdga9gshkxkhm83v1aji4";
10 };
11
12 patches = [
13 ./types.patch
14 ./hardening-format.patch
15 # required for cross-compilation
16 ./ar-fix.patch
17 # fix for glibc>=2.28
18 (fetchpatch {
19 name = "add_sysmacros.patch";
20 url = "https://sources.debian.org/data/main/j/jfsutils/1.1.15-4/debian/patches/add_sysmacros.patch";
21 sha256 = "1qcwvxs4d0d24w5x98z59arqfx2n7f0d9xaqhjcg6w8n34vkhnyc";
22 })
23 # fix for musl
24 (fetchpatch {
25 name = "musl-fix-includes.patch";
26 url = "https://git.alpinelinux.org/aports/plain/main/jfsutils/musl-fix-includes.patch?id=567823dca7dc1f8ce919efbe99762d2d5c020124";
27 sha256 = "sha256-FjdUOI+y+MdSWxTR+csH41uR0P+PWWTfIMPwQjBfQtQ=";
28 })
29 ];
30
31 nativeBuildInputs = [ autoreconfHook ];
32 buildInputs = [ libuuid ];
33
34 # Workaround build failure on -fno-common toolchains like upstream
35 # gcc-10. Otherwise build fails as:
36 # ld: extract.o:/build/jfsutils-1.1.15/fscklog/extract.c:67: multiple definition of
37 # `xchklog_buffer'; display.o:/build/jfsutils-1.1.15/fscklog/display.c:57: first defined here
38 env.NIX_CFLAGS_COMPILE = "-fcommon";
39
40 # this required for wipefreespace
41 postInstall = ''
42 mkdir -p $out/include
43 cp include/*.h $out/include
44 mkdir -p $out/lib
45 cp ./libfs/libfs.a $out/lib
46 '';
47
48 meta = with lib; {
49 description = "IBM JFS utilities";
50 homepage = "https://jfs.sourceforge.net";
51 license = licenses.gpl3;
52 platforms = platforms.linux;
53 };
54}