gnu: Add rust-sharded-slab-0.1.
[jackhill/guix/guix.git] / gnu / packages / diffoscope.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
6 ;;; Copyright © 2018, 2019 Rutger Helling <rhelling@mykolab.com>
7 ;;; Copyright © 2019 Vagrant Cascadian <vagrant@reproducible-builds.org>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages diffoscope)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages acl)
27 #:use-module (gnu packages admin)
28 #:use-module (gnu packages android)
29 #:use-module (gnu packages backup)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bootloaders)
32 #:use-module (gnu packages cdrom)
33 #:use-module (gnu packages check)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages cpio)
36 #:use-module (gnu packages dbm)
37 #:use-module (gnu packages gettext)
38 #:use-module (gnu packages ghostscript)
39 #:use-module (gnu packages gnome)
40 #:use-module (gnu packages gnupg)
41 #:use-module (gnu packages haskell)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages imagemagick)
44 #:use-module (gnu packages java)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages llvm)
47 #:use-module (gnu packages man)
48 #:use-module (gnu packages maths)
49 #:use-module (gnu packages mono)
50 #:use-module (gnu packages ocaml)
51 #:use-module (gnu packages package-management)
52 #:use-module (gnu packages patchutils)
53 #:use-module (gnu packages pdf)
54 #:use-module (gnu packages python-web)
55 #:use-module (gnu packages python-xyz)
56 #:use-module (gnu packages sqlite)
57 #:use-module (gnu packages ssh)
58 #:use-module (gnu packages statistics)
59 #:use-module (gnu packages textutils)
60 #:use-module (gnu packages tls)
61 #:use-module (gnu packages video)
62 #:use-module (gnu packages vim)
63 #:use-module (gnu packages web)
64 #:use-module (guix build-system python)
65 #:use-module (guix gexp)
66 #:use-module (guix git-download)
67 #:use-module ((guix licenses) #:prefix license:)
68 #:use-module (guix packages)
69 #:use-module (guix utils)
70 #:use-module (ice-9 match))
71
72 (define-public diffoscope
73 (package
74 (name "diffoscope")
75 (version "162")
76 (source (origin
77 (method git-fetch)
78 (uri (git-reference
79 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
80 (commit version)))
81 (file-name (git-file-name name version))
82 (sha256
83 (base32
84 "02wjjbmdbyqpyizw384j50bc2ar4g5m40amz9q102gqbw6sflwbf"))))
85 (build-system python-build-system)
86 (arguments
87 `(#:phases (modify-phases %standard-phases
88 ;; This test is broken because our `file` package has a
89 ;; bug in berkeley-db file type detection.
90 (add-after 'unpack 'remove-berkeley-test
91 (lambda _
92 (delete-file "tests/comparators/test_berkeley_db.py")
93 #t))
94 (add-after 'unpack 'embed-tool-references
95 (lambda* (#:key inputs #:allow-other-keys)
96 (substitute* "diffoscope/comparators/utils/compare.py"
97 (("\\['xxd',")
98 (string-append "['" (which "xxd") "',")))
99 (substitute* "diffoscope/comparators/elf.py"
100 (("@tool_required\\('readelf'\\)") "")
101 (("get_tool_name\\('readelf'\\)")
102 (string-append "'" (which "readelf") "'")))
103 (substitute* "diffoscope/comparators/directory.py"
104 (("@tool_required\\('stat'\\)") "")
105 (("@tool_required\\('getfacl'\\)") "")
106 (("\\['stat',")
107 (string-append "['" (which "stat") "',"))
108 (("\\['getfacl',")
109 (string-append "['" (which "getfacl") "',")))
110 #t))
111 (add-after 'build 'build-man-page
112 (lambda* (#:key (make-flags '()) #:allow-other-keys)
113 (apply invoke "make" "-C" "doc" make-flags)))
114 (add-before 'check 'writable-test-data
115 (lambda _
116 ;; Tests may need write access to tests directory.
117 (for-each make-file-writable (find-files "tests"))
118 #t))
119 (add-before 'check 'delete-failing-test
120 (lambda _
121 ;; This requires /sbin to be in $PATH.
122 (delete-file "tests/test_tools.py")
123 #t))
124 (add-before 'check 'skip-dex-test-with-missing-procyon
125 (lambda _
126 ;; This test actually requires procyon decompiler
127 (substitute* "tests/comparators/test_dex.py"
128 (("skip_unless_tools_exist.\"enjarify\", \"zipinfo\", \"javap\"")
129 "skip_unless_tools_exist(\"enjarify\", \"zipinfo\", \"javap\", \"procyon\""))
130 #t))
131 (add-after 'install 'install-man-page
132 (lambda* (#:key outputs #:allow-other-keys)
133 (let* ((out (assoc-ref outputs "out"))
134 (man (string-append out "/share/man/man1")))
135 (install-file "doc/diffoscope.1" man)
136 #t))))))
137 (inputs `(("rpm" ,rpm) ;for rpm-python
138 ("python-file" ,python-file)
139 ("python-debian" ,python-debian)
140 ("python-libarchive-c" ,python-libarchive-c)
141 ("python-magic" ,python-magic)
142 ("python-tlsh" ,python-tlsh)
143 ("acl" ,acl) ;for getfacl
144 ("colordiff" ,colordiff)
145 ("xxd" ,xxd)))
146 (native-inputs `(("help2man" ,help2man)
147 ;; Below are modules used for tests.
148 ("python-pytest" ,python-pytest)
149 ("python-chardet" ,python-chardet)
150 ("python-binwalk" ,python-binwalk)
151 ("python-black" ,python-black)
152 ("python-h5py" ,python-h5py)
153 ("python-pypdf2" ,python-pypdf2)
154 ("python-progressbar33" ,python-progressbar33)
155 ;; The test suite skips tests when these are missing.
156 ,@(match (%current-system)
157 ;; ghc is only available on x86 currently.
158 ((or "x86_64-linux" "i686-linux")
159 `(("ghc" ,ghc)))
160 (_
161 `()))
162 ,@(match (%current-system)
163 ;; openjdk and dependent packages are only
164 ;; available on x86_64 currently.
165 ((or "x86_64-linux")
166 `(("enjarify" ,enjarify)
167 ;; no unversioned openjdk available
168 ("openjdk:jdk" ,openjdk12 "jdk")))
169 (_
170 `()))
171 ("abootimg" ,abootimg)
172 ("bdb" ,bdb)
173 ("binutils" ,binutils)
174 ("bzip2" ,bzip2)
175 ("cdrtools" ,cdrtools)
176 ("colord" ,colord)
177 ("cpio" ,cpio)
178 ("docx2txt" ,docx2txt)
179 ("dtc" ,dtc)
180 ("e2fsprogs" ,e2fsprogs)
181 ("ffmpeg" ,ffmpeg)
182 ("gettext" ,gettext-minimal)
183 ("ghostscript" ,ghostscript)
184 ("giflib:bin" ,giflib "bin")
185 ("gnumeric" ,gnumeric)
186 ("gnupg" ,gnupg)
187 ("hdf5" ,hdf5)
188 ("imagemagick" ,imagemagick)
189 ("libarchive" ,libarchive)
190 ("llvm" ,llvm)
191 ("lz4" ,lz4)
192 ("mono" ,mono)
193 ("ocaml" ,ocaml)
194 ("odt2txt" ,odt2txt)
195 ("openssh" ,openssh)
196 ("openssl" ,openssl)
197 ("pgpdump" ,pgpdump)
198 ("poppler" ,poppler)
199 ("python-jsbeautifier" ,python-jsbeautifier)
200 ("r-minimal" ,r-minimal)
201 ("rpm" ,rpm)
202 ("sng" ,sng)
203 ("sqlite" ,sqlite)
204 ("squashfs-tools" ,squashfs-tools)
205 ("tcpdump" ,tcpdump)
206 ("unzip" ,unzip)
207 ("wabt" ,wabt)
208 ("xxd" ,xxd)
209 ("xz" ,xz)
210 ("zip" ,zip)
211 ("zstd" ,zstd)))
212 (home-page "https://diffoscope.org/")
213 (synopsis "Compare files, archives, and directories in depth")
214 (description
215 "Diffoscope tries to get to the bottom of what makes files or directories
216 different. It recursively unpacks archives of many kinds and transforms
217 various binary formats into more human readable forms to compare them. It can
218 compare two tarballs, ISO images, or PDFs just as easily.
219
220 Diffoscope has many optional dependencies; @code{diffoscope
221 --list-missing-tools guix} will display optional packages to
222 install.")
223 (license license:gpl3+)))
224
225 (define-public reprotest
226 (package
227 (name "reprotest")
228 (version "0.7.15")
229 (source
230 (origin
231 (method git-fetch)
232 (uri (git-reference
233 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
234 (commit version)))
235 (file-name (git-file-name name version))
236 (sha256
237 (base32
238 "12lc1pb9d5h3blrzzx9nbqqj5bi9x23yj31fxafmk37803rl8a0m"))))
239 (inputs
240 `(("python-debian" ,python-debian)
241 ("python-distro" ,python-distro)
242 ("python-libarchive-c" ,python-libarchive-c)
243 ("python-rstr" ,python-rstr)))
244 (native-inputs
245 `(("diffoscope" ,diffoscope)
246 ("help2man" ,help2man)
247 ("libfaketime" ,libfaketime)
248 ("python-coverage" ,python-coverage)
249 ("python-docutils" ,python-docutils)
250 ("python-magic " ,python-magic)
251 ("python-pytest " ,python-pytest)
252 ("python-tlsh" ,python-tlsh)
253 ("python-tox" ,python-tox)
254 ("unzip" ,unzip)
255 ("xxd" ,xxd)))
256 (build-system python-build-system)
257 (arguments
258 `(#:phases
259 (modify-phases %standard-phases
260 ;; Neither glibc-locales nor glibc-utf8-locales have the C.UTF-8
261 ;; locale or several other locales used in reprotest.
262 (add-after 'unpack 'adjust-locales
263 (lambda _
264 (substitute* "reprotest/build.py"
265 (("'C.UTF-8'") "'en_US.UTF-8'")
266 (("'ru_RU.CP1251'") "'ru_RU.KOI8-R'")
267 (("'kk_KZ.RK1048'") "'kk_KZ'"))
268 (substitute* "reprotest/lib/adt_testbed.py"
269 (("export LANG=C.UTF-8") "export LANG=en_US.UTF-8"))
270 #t))
271 (add-after 'install 'install-doc
272 (lambda* (#:key outputs #:allow-other-keys)
273 (let* ((mandir1 (string-append
274 (assoc-ref outputs "out") "/share/man/man1"))
275 (docdir (string-append
276 (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version)))
277 (invoke "make" "-C" "doc")
278 (mkdir-p mandir1)
279 (install-file "doc/reprotest.1" mandir1)
280 (mkdir-p docdir)
281 (install-file "./README.rst" docdir)
282 (install-file "./README-dev.rst" docdir))
283 #t)))))
284 (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
285 (synopsis "Build software and check it for reproducibility")
286 (description "Reprotest builds the same source code twice in different
287 environments, and then checks the binaries produced by each build for
288 differences. If any are found, then diffoscope or diff is used to display
289 them in detail for later analysis.")
290 (license (list license:gpl3+ license:gpl2+))))
291
292 (define-public trydiffoscope
293 (package
294 (name "trydiffoscope")
295 (version "67.0.1")
296 (source
297 (origin
298 (method git-fetch)
299 (uri (git-reference
300 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
301 (commit version)))
302 (file-name (git-file-name name version))
303 (sha256
304 (base32
305 "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
306 (arguments
307 `(#:phases
308 (modify-phases %standard-phases
309 (add-after 'install 'install-doc
310 (lambda* (#:key outputs #:allow-other-keys)
311 (let* ((share (string-append (assoc-ref outputs "out") "/share/")))
312 (mkdir-p (string-append share "/man/man1/" ))
313 (invoke "rst2man.py"
314 "trydiffoscope.1.rst"
315 (string-append share "/man/man1/trydiffoscope.1"))
316 (mkdir-p (string-append share "/doc/" ,name "-" ,version))
317 (install-file "./README.rst"
318 (string-append share "/doc/" ,name "-" ,version)))
319 #t)))))
320 (propagated-inputs
321 `(("python-requests" ,python-requests)))
322 (native-inputs
323 `(("gzip" ,gzip)
324 ("python-docutils" ,python-docutils)))
325 (build-system python-build-system)
326 (home-page "https://try.diffoscope.org")
327 (synopsis "Client for remote diffoscope service")
328 (description "This is a client for the @url{https://try.diffoscope.org,
329 remote diffoscope service}.
330
331 Diffoscope tries to get to the bottom of what makes files or directories
332 different. It recursively unpacks archives of many kinds and transforms
333 various binary formats into more human readable forms to compare them. It can
334 compare two tarballs, ISO images, or PDFs just as easily.
335
336 Results are displayed by default, stored as local text or html files, or made
337 available via a URL on @url{https://try.diffoscope.org}. Results stored on the
338 server are purged after 30 days.")
339 (license license:gpl3+)))