nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 aapt,
5 abootimg,
6 acl,
7 apksigcopier,
8 apksigner,
9 apktool,
10 binutils-unwrapped-all-targets,
11 bzip2,
12 cbfstool,
13 cdrkit,
14 colord,
15 colordiff,
16 coreutils,
17 cpio,
18 db,
19 diffutils,
20 docutils,
21 dtc,
22 e2fsprogs,
23 enableBloat ? true,
24 enjarify,
25 fetchurl,
26 file,
27 findutils,
28 fontforge-fonttools,
29 ffmpeg,
30 fpc,
31 gettext,
32 ghc,
33 ghostscriptX,
34 giflib,
35 gnumeric,
36 gnupg,
37 gnutar,
38 gzip,
39 hdf5,
40 help2man,
41 html2text,
42 imagemagick,
43 installShellFiles,
44 jdk8,
45 libarchive,
46 libcaca,
47 libxmlb,
48 llvm,
49 lz4,
50 lzip,
51 mono,
52 ocaml,
53 odt2txt,
54 oggvideotools,
55 openssh,
56 openssl,
57 pdftk,
58 perl,
59 pgpdump,
60 poppler-utils,
61 procyon,
62 python3,
63 qemu,
64 R,
65 sng,
66 sqlite,
67 squashfsTools,
68 systemdUkify,
69 tcpdump,
70 ubootTools,
71 unzip,
72 wabt,
73 xmlbeans,
74 xxd,
75 xz,
76 zip,
77 zstd,
78 binwalk,
79 # updater only
80 writeScript,
81}:
82
83let
84 python = python3.override {
85 self = python;
86 packageOverrides = final: prev: {
87 # version 2 breaks dataset and thus androguard
88 sqlalchemy = prev.sqlalchemy_1_4;
89 # version 4 or newer would log the following error but tests currently don't fail because radare2 is disabled
90 # ValueError: argument TNULL is not a TLSH hex string
91 tlsh = prev.tlsh.overridePythonAttrs (
92 { src, ... }:
93 let
94 version = "3.19.1";
95 in
96 {
97 inherit version;
98 src = src.override {
99 tag = version;
100 hash = "sha256-ZYEjT/yShfA4+zpbGOtaFOx1nSSOWPtMvskPhHv3c9U=";
101 };
102 }
103 );
104 };
105 };
106in
107
108# Note: when upgrading this package, please run the list-missing-tools.sh script as described below!
109python.pkgs.buildPythonApplication rec {
110 pname = "diffoscope";
111 version = "309";
112 pyproject = true;
113
114 src = fetchurl {
115 url = "https://diffoscope.org/archive/diffoscope-${version}.tar.bz2";
116 hash = "sha256-VB7CBvHKIJWHanuDnoobSnvGcdxMFTUGLxRZgsNoLbQ=";
117 };
118
119 outputs = [
120 "out"
121 "man"
122 ];
123
124 patches = [ ./ignore_links.patch ];
125
126 postPatch = ''
127 # When generating manpage, use the installed version
128 substituteInPlace doc/Makefile --replace-fail "../bin" "$out/bin"
129
130 substituteInPlace diffoscope/comparators/apk.py \
131 --replace-fail "from androguard.core.bytecodes import apk" "from androguard.core import apk"
132 '';
133
134 nativeBuildInputs = [
135 docutils
136 help2man
137 installShellFiles
138 ];
139
140 build-system = with python.pkgs; [ setuptools ];
141
142 # Most of the non-Python dependencies here are optional command-line tools for various file-format parsers.
143 # To help figuring out what's missing from the list, run: ./pkgs/tools/misc/diffoscope/list-missing-tools.sh
144 #
145 # Still missing these tools:
146 # Android-specific tools:
147 # dexdump
148 # Darwin-specific tools:
149 # lipo
150 # otool
151 # Other tools:
152 # docx2txt <- makes tests broken:
153 # > FAILED tests/comparators/test_docx.py::test_diff - IndexError: list index out of range
154 # > FAILED tests/comparators/test_docx.py::test_compare_non_existing - AssertionError
155 # radare2
156 # > FAILED tests/comparators/test_elf_decompiler.py::test_ghidra_diff - IndexError: list index out of range
157 # > FAILED tests/comparators/test_elf_decompiler.py::test_radare2_diff - AssertionError
158 # > FAILED tests/comparators/test_macho_decompiler.py::test_ghidra_diff - assert 0 == 1
159 # > FAILED tests/comparators/test_macho_decompiler.py::test_radare2_diff - AssertionError
160 #
161 # We filter automatically all packages for the host platform (some dependencies are not supported on Darwin, aarch64, etc.).
162 # Packages which are marked broken for a platform are not automatically filtered to avoid accidentally removing them without noticing it.
163 pythonPath = lib.filter (lib.meta.availableOn stdenv.hostPlatform) (
164 [
165 acl
166 binutils-unwrapped-all-targets
167 bzip2
168 cdrkit
169 colordiff
170 coreutils
171 cpio
172 db
173 diffutils
174 dtc
175 e2fsprogs
176 file
177 findutils
178 fontforge-fonttools
179 gettext
180 gnutar
181 gzip
182 html2text
183 libarchive
184 libxmlb
185 lz4
186 lzip
187 openssl
188 pgpdump
189 sng
190 sqlite
191 squashfsTools
192 unzip
193 xxd
194 xz
195 zip
196 zstd
197 ]
198 ++ (with python.pkgs; [
199 argcomplete
200 python-debian
201 defusedxml
202 jsbeautifier
203 jsondiff
204 libarchive-c
205 progressbar33
206 pypdf
207 python-magic
208 pyxattr
209 rpm
210 tlsh
211 ])
212 ++ lib.optionals enableBloat (
213 [
214 aapt
215 abootimg
216 apksigcopier
217 apksigner
218 apktool
219 cbfstool
220 colord
221 enjarify
222 ffmpeg
223 fpc
224 ghc
225 ghostscriptX
226 giflib
227 gnumeric
228 gnupg
229 hdf5
230 imagemagick
231 jdk8
232 libcaca
233 llvm
234 mono
235 ocaml
236 odt2txt
237 openssh
238 pdftk
239 perl
240 poppler-utils
241 procyon
242 qemu
243 R
244 systemdUkify
245 tcpdump
246 ubootTools
247 wabt
248 xmlbeans
249 binwalk
250 ]
251 ++ (with python.pkgs; [
252 androguard
253 black
254 guestfs
255 h5py
256 pdfminer-six
257 r2pipe
258 # docx2txt, nixpkgs packages another project named the same, which does not work
259 ])
260 # oggvideotools is broken on Darwin, please put it back when it will be fixed?
261 ++ lib.optionals stdenv.hostPlatform.isLinux [ oggvideotools ]
262 )
263 );
264
265 nativeCheckInputs = with python.pkgs; [ pytestCheckHook ] ++ pythonPath;
266
267 pytestFlags = [
268 # Always show more information when tests fail
269 "-vv"
270 ];
271
272 postInstall = ''
273 make -C doc
274 installManPage doc/diffoscope.1
275 '';
276
277 disabledTests = [
278 "test_sbin_added_to_path"
279 "test_diff_meta"
280 "test_diff_meta2"
281
282 # Fails because it fails to determine llvm version
283 "test_item3_deflate_llvm_bitcode"
284
285 # Flaky test on Linux and Darwin
286 "test_non_unicode_filename"
287 ]
288 ++ lib.optionals stdenv.hostPlatform.isDarwin [
289 # Disable flaky tests on Darwin
290 "test_listing"
291 "test_symlink_root"
292
293 # Appears to be a sandbox related issue
294 "test_trim_stderr_in_command"
295 # Seems to be a bug caused by having different versions of rdata than
296 # expected. Will file upstream.
297 "test_item_rdb"
298 # Caused by getting an otool command instead of llvm-objdump. Could be Nix
299 # setup, could be upstream bug. Will file upstream.
300 "test_libmix_differences"
301 ];
302
303 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
304 "tests/comparators/test_git.py"
305 "tests/comparators/test_java.py"
306 "tests/comparators/test_uimage.py"
307 "tests/comparators/test_device.py"
308 "tests/comparators/test_macho.py"
309 # OSError: AF_UNIX path too long
310 "tests/comparators/test_sockets.py"
311 ];
312
313 passthru = {
314 updateScript = writeScript "update-diffoscope" ''
315 #!/usr/bin/env nix-shell
316 #!nix-shell -i bash -p curl pcre common-updater-scripts
317
318 set -eu -o pipefail
319
320 # Expect the text in format of "Latest release: 198 (31 Dec 2021)"'.
321 newVersion="$(curl -s https://diffoscope.org/ | pcregrep -o1 'Latest release: ([0-9]+)')"
322 update-source-version ${pname} "$newVersion"
323 '';
324 };
325
326 meta = {
327 description = "Perform in-depth comparison of files, archives, and directories";
328 longDescription = ''
329 diffoscope will try to get to the bottom of what makes files or directories
330 different. It will recursively unpack archives of many kinds and transform
331 various binary formats into more human readable form to compare them. It can
332 compare two tarballs, ISO images, or PDF just as easily. The differences can
333 be shown in a text or HTML report.
334
335 diffoscope is developed as part of the "reproducible builds" Debian
336 project and was formerly known as "debbindiff".
337 '';
338 homepage = "https://diffoscope.org/";
339 changelog = "https://diffoscope.org/news/diffoscope-${version}-released/";
340 license = lib.licenses.gpl3Plus;
341 maintainers = with lib.maintainers; [
342 dezgeg
343 danielfullmer
344 raitobezarius
345 ];
346 platforms = lib.platforms.unix;
347 mainProgram = "diffoscope";
348 };
349}