1{ lib, stdenv, fetchurl, python3Packages, docutils, help2man, installShellFiles
2, abootimg, acl, apksigner, apktool, binutils-unwrapped-all-targets, bzip2, cbfstool, cdrkit, colord, colordiff, coreutils, cpio, db, diffutils, dtc
3, e2fsprogs, enjarify, file, findutils, fontforge-fonttools, ffmpeg, fpc, gettext, ghc, ghostscriptX, giflib, gnumeric, gnupg, gnutar
4, gzip, hdf5, imagemagick, jdk, libarchive, libcaca, llvm, lz4, mono, ocaml, oggvideotools, openssh, openssl, pdftk, pgpdump, poppler_utils, procyon, qemu, R
5, radare2, sng, sqlite, squashfsTools, tcpdump, ubootTools, odt2txt, unzip, wabt, xmlbeans, xxd, xz, zip, zstd
6, enableBloat ? false
7# updater only
8, writeScript
9}:
10
11# Note: when upgrading this package, please run the list-missing-tools.sh script as described below!
12python3Packages.buildPythonApplication rec {
13 pname = "diffoscope";
14 version = "225";
15
16 src = fetchurl {
17 url = "https://diffoscope.org/archive/diffoscope-${version}.tar.bz2";
18 sha256 = "sha256-nuQmvYpCSzw2kUj/UdcBpn6jabaVMYT47MDblzpb/o0=";
19 };
20
21 outputs = [ "out" "man" ];
22
23 patches = [
24 ./ignore_links.patch
25 ];
26
27 postPatch = ''
28 # Upstream doesn't provide a PKG-INFO file
29 sed -i setup.py -e "/'rpm-python',/d"
30
31 # When generating manpage, use the installed version
32 substituteInPlace doc/Makefile --replace "../bin" "$out/bin"
33 '';
34
35 nativeBuildInputs = [ docutils help2man installShellFiles ];
36
37 # Most of the non-Python dependencies here are optional command-line tools for various file-format parsers.
38 # To help figuring out what's missing from the list, run: ./pkgs/tools/misc/diffoscope/list-missing-tools.sh
39 #
40 # Still missing these tools: docx2txt lipo otool r2pipe
41 pythonPath = [
42 binutils-unwrapped-all-targets bzip2 colordiff coreutils cpio db diffutils
43 e2fsprogs file findutils fontforge-fonttools gettext gnutar gzip
44 libarchive lz4 openssl pgpdump sng sqlite squashfsTools unzip xxd
45 xz zip zstd
46 ]
47 ++ (with python3Packages; [
48 argcomplete debian defusedxml jsondiff jsbeautifier libarchive-c
49 python-magic progressbar33 pypdf2 tlsh
50 ])
51 ++ lib.optionals stdenv.isLinux [ python3Packages.pyxattr python3Packages.rpm acl cdrkit dtc ]
52 ++ lib.optionals enableBloat ([
53 abootimg apksigner apktool cbfstool colord enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg gnumeric
54 hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt oggvideotools openssh pdftk poppler_utils procyon qemu R tcpdump ubootTools wabt radare2 xmlbeans
55 ] ++ (with python3Packages; [ androguard binwalk guestfs h5py pdfminer-six ]));
56
57 checkInputs = with python3Packages; [ pytestCheckHook ] ++ pythonPath;
58
59 postInstall = ''
60 make -C doc
61 installManPage doc/diffoscope.1
62 '';
63
64 disabledTests = [
65 "test_sbin_added_to_path"
66 "test_diff_meta"
67 "test_diff_meta2"
68
69 # fails because it fails to determine llvm version
70 "test_item3_deflate_llvm_bitcode"
71 ] ++ lib.optionals stdenv.isDarwin [
72 # Disable flaky tests on Darwin
73 "test_non_unicode_filename"
74 "test_listing"
75 "test_symlink_root"
76 ];
77
78 # flaky tests on Darwin
79 disabledTestPaths = lib.optionals stdenv.isDarwin [
80 "tests/comparators/test_git.py"
81 "tests/comparators/test_java.py"
82 "tests/comparators/test_uimage.py"
83 "tests/comparators/test_device.py"
84 "tests/comparators/test_macho.py"
85 ];
86
87 passthru = {
88 updateScript = writeScript "update-diffoscope" ''
89 #!/usr/bin/env nix-shell
90 #!nix-shell -i bash -p curl pcre common-updater-scripts
91
92 set -eu -o pipefail
93
94 # Expect the text in format of "Latest release: 198 (31 Dec 2021)"'.
95 newVersion="$(curl -s https://diffoscope.org/ | pcregrep -o1 'Latest release: ([0-9]+)')"
96 update-source-version ${pname} "$newVersion"
97 '';
98 };
99
100 meta = with lib; {
101 description = "Perform in-depth comparison of files, archives, and directories";
102 longDescription = ''
103 diffoscope will try to get to the bottom of what makes files or directories
104 different. It will recursively unpack archives of many kinds and transform
105 various binary formats into more human readable form to compare them. It can
106 compare two tarballs, ISO images, or PDF just as easily. The differences can
107 be shown in a text or HTML report.
108
109 diffoscope is developed as part of the "reproducible builds" Debian
110 project and was formerly known as "debbindiff".
111 '';
112 homepage = "https://diffoscope.org/";
113 license = licenses.gpl3Plus;
114 maintainers = with maintainers; [ dezgeg danielfullmer ];
115 platforms = platforms.unix;
116 };
117}