1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 autoreconfHook,
6 lzmaSupport ? true,
7 xz ? null,
8}:
9
10assert lzmaSupport -> xz != null;
11
12let
13 mkWith = flag: name: if flag then "--with-${name}" else "--without-${name}";
14in
15stdenv.mkDerivation rec {
16 pname = "xdelta";
17 version = "3.1.0";
18
19 src = fetchFromGitHub {
20 sha256 = "09mmsalc7dwlvgrda56s2k927rpl3a5dzfa88aslkqcjnr790wjy";
21 rev = "v${version}";
22 repo = "xdelta-devel";
23 owner = "jmacd";
24 };
25
26 nativeBuildInputs = [ autoreconfHook ];
27 buildInputs = [ ] ++ lib.optionals lzmaSupport [ xz ];
28
29 postPatch = ''
30 cd xdelta3
31
32 substituteInPlace Makefile.am --replace \
33 "common_CFLAGS =" \
34 "common_CFLAGS = -DXD3_USE_LARGESIZET=1"
35 '';
36
37 configureFlags = [
38 (mkWith lzmaSupport "liblzma")
39 ];
40
41 enableParallelBuilding = true;
42
43 doCheck = true;
44 checkPhase = ''
45 mkdir $PWD/tmp
46 for i in testing/file.h xdelta3-test.h; do
47 substituteInPlace $i --replace /tmp $PWD/tmp
48 done
49 ./xdelta3regtest
50 '';
51
52 installPhase = ''
53 install -D -m755 xdelta3 $out/bin/xdelta3
54 install -D -m644 xdelta3.1 $out/share/man/man1/xdelta3.1
55 '';
56
57 meta = with lib; {
58 description = "Binary differential compression in VCDIFF (RFC 3284) format";
59 longDescription = ''
60 xdelta is a command line program for delta encoding, which generates two
61 file differences. This is similar to diff and patch, but it is targeted
62 for binary files and does not generate human readable output.
63 '';
64 homepage = "http://xdelta.org/";
65 license = licenses.gpl2Plus;
66 mainProgram = "xdelta3";
67 platforms = platforms.linux;
68 };
69}