Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchpatch, 6 bzip2, 7}: 8 9stdenv.mkDerivation rec { 10 pname = "bsdiff"; 11 version = "4.3"; 12 13 src = fetchurl { 14 url = "https://www.daemonology.net/bsdiff/${pname}-${version}.tar.gz"; 15 sha256 = "0j2zm3z271x5aw63mwhr3vymzn45p2vvrlrpm9cz2nywna41b0hq"; 16 }; 17 18 buildInputs = [ bzip2 ]; 19 patches = [ 20 (fetchpatch { 21 url = "https://sources.debian.org/data/main/b/bsdiff/4.3-22/debian/patches/20-CVE-2014-9862.patch"; 22 sha256 = "sha256-3UuUfNvShQ8fLqxCKUTb/n4BmjL4+Nl7aEqCxYrrERQ="; 23 }) 24 ./CVE-2020-14315.patch 25 ./include-systypes.patch 26 ] 27 ++ lib.optionals stdenv.hostPlatform.isLinux [ 28 (fetchpatch { 29 url = "https://sources.debian.org/data/main/b/bsdiff/4.3-22/debian/patches/30-bug-632585-mmap-src-file-instead-of-malloc-read-it.patch"; 30 sha256 = "sha256-esbhz2/efUiuQDuF7LGfSeEn3/f1WbqCxQpTs2A0ulI="; 31 }) 32 (fetchpatch { 33 url = "https://sources.debian.org/data/main/b/bsdiff/4.3-22/debian/patches/31-bug-632585-mmap-dst-file-instead-of-malloc-read-it.patch"; 34 sha256 = "sha256-Of4aOcI0rsgdRzPqyw2VRn2p9wQuo3hdlgDTBdXGzoc="; 35 }) 36 (fetchpatch { 37 url = "https://sources.debian.org/data/main/b/bsdiff/4.3-22/debian/patches/32-bug-632585-use-int32_t-instead-off_t-for-file-size.patch"; 38 sha256 = "sha256-SooFnFK4uKNXvXQb/LEcH8GocnRtkryExI4b3BZTsAY="; 39 }) 40 ]; 41 42 buildPhase = '' 43 $CC -O3 -lbz2 bspatch.c -o bspatch 44 $CC -O3 -lbz2 bsdiff.c -o bsdiff 45 ''; 46 47 installPhase = '' 48 mkdir -p $out/bin 49 mkdir -p $out/share/man/man1 50 51 cp bsdiff $out/bin 52 cp bspatch $out/bin 53 cp bsdiff.1 $out/share/man/man1 54 cp bspatch.1 $out/share/man/man1 55 ''; 56 57 meta = with lib; { 58 description = "Efficient binary diff/patch tool"; 59 homepage = "https://www.daemonology.net/bsdiff/"; 60 license = licenses.bsd2; 61 platforms = platforms.unix; 62 maintainers = [ maintainers.thoughtpolice ]; 63 }; 64}