1{ lib
2, stdenv
3, abootimg
4, apksigcopier
5, apksigner
6, apktool
7, binutils-unwrapped-all-targets
8, bzip2
9, cbfstool
10, cdrkit
11, colord
12, colordiff
13, coreutils
14, cpio
15, db
16, diffutils
17, docutils
18, dtc
19, e2fsprogs
20, enableBloat ? true
21, enjarify
22, fetchurl
23, file
24, findutils
25, fontforge-fonttools
26, ffmpeg
27, fpc
28, gettext
29, ghc
30, ghostscriptX
31, giflib
32, gnumeric
33, gnupg
34, gnutar
35, gzip
36, hdf5
37, help2man
38, html2text
39, imagemagick
40, installShellFiles
41, jdk
42, libarchive
43, libcaca
44, libxmlb
45, llvm
46, lz4
47, lzip
48, mono
49, ocaml
50, odt2txt
51, oggvideotools
52, openssh
53, openssl
54, pdftk
55, pgpdump
56, poppler_utils
57, procyon
58, python3
59, qemu
60, R
61, radare2
62, sng
63, sqlite
64, squashfsTools
65, tcpdump
66, ubootTools
67, unzip
68, wabt
69, xmlbeans
70, xxd
71, xz
72, zip
73, zstd
74 # updater only
75, writeScript
76}:
77
78# Note: when upgrading this package, please run the list-missing-tools.sh script as described below!
79python3.pkgs.buildPythonApplication rec {
80 pname = "diffoscope";
81 version = "252";
82
83 src = fetchurl {
84 url = "https://diffoscope.org/archive/diffoscope-${version}.tar.bz2";
85 hash = "sha256-NmYv5htZT2v04vVksIWGuaPI1rXfNmrVSmErT/faBbQ=";
86 };
87
88 outputs = [
89 "out"
90 "man"
91 ];
92
93 patches = [
94 ./ignore_links.patch
95 ];
96
97 postPatch = ''
98 # Upstream doesn't provide a PKG-INFO file
99 sed -i setup.py -e "/'rpm-python',/d"
100
101 # When generating manpage, use the installed version
102 substituteInPlace doc/Makefile --replace "../bin" "$out/bin"
103 '';
104
105 nativeBuildInputs = [
106 docutils
107 help2man
108 installShellFiles
109 ];
110
111 # Most of the non-Python dependencies here are optional command-line tools for various file-format parsers.
112 # To help figuring out what's missing from the list, run: ./pkgs/tools/misc/diffoscope/list-missing-tools.sh
113 #
114 # Still missing these tools:
115 # aapt2
116 # dexdump
117 # docx2txt
118 # getfacl
119 # lipo
120 # otool
121 # r2pipe
122 #
123 # We filter automatically all packages for the host platform (some dependencies are not supported on Darwin, aarch64, etc.).
124 pythonPath = lib.filter (lib.meta.availableOn stdenv.hostPlatform) ([
125 binutils-unwrapped-all-targets
126 bzip2
127 cdrkit
128 colordiff
129 coreutils
130 cpio
131 db
132 diffutils
133 dtc
134 e2fsprogs
135 file
136 findutils
137 fontforge-fonttools
138 gettext
139 gnutar
140 gzip
141 html2text
142 libarchive
143 libxmlb
144 lz4
145 lzip
146 openssl
147 pgpdump
148 sng
149 sqlite
150 squashfsTools
151 unzip
152 xxd
153 xz
154 zip
155 zstd
156 ]
157 ++ (with python3.pkgs; [
158 argcomplete
159 debian
160 defusedxml
161 jsbeautifier
162 jsondiff
163 libarchive-c
164 progressbar33
165 pypdf2
166 python-magic
167 pyxattr
168 rpm
169 tlsh
170 ])
171 ++ lib.optionals enableBloat (
172 [
173 abootimg
174 apksigcopier
175 apksigner
176 apktool
177 cbfstool
178 colord
179 enjarify
180 ffmpeg
181 fpc
182 ghc
183 ghostscriptX
184 giflib
185 gnupg
186 hdf5
187 imagemagick
188 jdk
189 libcaca
190 llvm
191 mono
192 ocaml
193 odt2txt
194 openssh
195 pdftk
196 poppler_utils
197 procyon
198 qemu
199 R
200 radare2
201 tcpdump
202 ubootTools
203 wabt
204 xmlbeans
205 ]
206 ++ (with python3.pkgs; [
207 androguard
208 binwalk
209 guestfs
210 h5py
211 pdfminer-six
212 ])
213 # oggvideotools is broken on Darwin, please put it back when it will be fixed?
214 ++ lib.optionals stdenv.isLinux [ oggvideotools ]
215 # This doesn't work on aarch64-darwin
216 ++ lib.optionals (stdenv.hostPlatform != "aarch64-darwin") [ gnumeric ]
217 ));
218
219 nativeCheckInputs = with python3.pkgs; [
220 pytestCheckHook
221 ] ++ pythonPath;
222
223 pytestFlagsArray = [
224 # Always show more information when tests fail
225 "-vv"
226 ];
227
228 postInstall = ''
229 make -C doc
230 installManPage doc/diffoscope.1
231 '';
232
233 disabledTests = [
234 "test_sbin_added_to_path"
235 "test_diff_meta"
236 "test_diff_meta2"
237
238 # Fails because it fails to determine llvm version
239 "test_item3_deflate_llvm_bitcode"
240 ] ++ lib.optionals stdenv.isDarwin [
241 # Disable flaky tests on Darwin
242 "test_non_unicode_filename"
243 "test_listing"
244 "test_symlink_root"
245 ];
246
247 disabledTestPaths = [
248 # fails due to https://github.com/NixOS/nixpkgs/issues/256896
249 # should be removed once that issue is resolved in coreboot or diffoscope
250 "tests/comparators/test_cbfs.py"
251 ]
252 # Flaky tests on Darwin
253 ++ lib.optionals stdenv.isDarwin [
254 "tests/comparators/test_git.py"
255 "tests/comparators/test_java.py"
256 "tests/comparators/test_uimage.py"
257 "tests/comparators/test_device.py"
258 "tests/comparators/test_macho.py"
259 ];
260
261 passthru = {
262 updateScript = writeScript "update-diffoscope" ''
263 #!/usr/bin/env nix-shell
264 #!nix-shell -i bash -p curl pcre common-updater-scripts
265
266 set -eu -o pipefail
267
268 # Expect the text in format of "Latest release: 198 (31 Dec 2021)"'.
269 newVersion="$(curl -s https://diffoscope.org/ | pcregrep -o1 'Latest release: ([0-9]+)')"
270 update-source-version ${pname} "$newVersion"
271 '';
272 };
273
274 meta = with lib; {
275 description = "Perform in-depth comparison of files, archives, and directories";
276 longDescription = ''
277 diffoscope will try to get to the bottom of what makes files or directories
278 different. It will recursively unpack archives of many kinds and transform
279 various binary formats into more human readable form to compare them. It can
280 compare two tarballs, ISO images, or PDF just as easily. The differences can
281 be shown in a text or HTML report.
282
283 diffoscope is developed as part of the "reproducible builds" Debian
284 project and was formerly known as "debbindiff".
285 '';
286 homepage = "https://diffoscope.org/";
287 changelog = "https://diffoscope.org/news/diffoscope-${version}-released/";
288 license = licenses.gpl3Plus;
289 maintainers = with maintainers; [ dezgeg danielfullmer raitobezarius ];
290 platforms = platforms.unix;
291 };
292}