Merge branch 'version-1.1.0'
[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 mono)
49 #:use-module (gnu packages ocaml)
50 #:use-module (gnu packages package-management)
51 #:use-module (gnu packages patchutils)
52 #:use-module (gnu packages pdf)
53 #:use-module (gnu packages python-web)
54 #:use-module (gnu packages python-xyz)
55 #:use-module (gnu packages sqlite)
56 #:use-module (gnu packages ssh)
57 #:use-module (gnu packages statistics)
58 #:use-module (gnu packages textutils)
59 #:use-module (gnu packages video)
60 #:use-module (gnu packages vim)
61 #:use-module (gnu packages web)
62 #:use-module (guix build-system python)
63 #:use-module (guix gexp)
64 #:use-module (guix git-download)
65 #:use-module ((guix licenses) #:prefix license:)
66 #:use-module (guix packages)
67 #:use-module (guix utils)
68 #:use-module (ice-9 match))
69
70 (define-public diffoscope
71 (let ((version "139"))
72 (package
73 (name "diffoscope")
74 (version version)
75 (source (origin
76 (method git-fetch)
77 (uri (git-reference
78 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
79 (commit version)))
80 (file-name (git-file-name name version))
81 (sha256
82 (base32
83 "1k4yjyvmn5nfdapkwgkr9gzpn18kr4c58n0f32pfkx4yakfqkk4i"))))
84 (build-system python-build-system)
85 (arguments
86 `(#:phases (modify-phases %standard-phases
87 ;; setup.py mistakenly requires python-magic from PyPi, even
88 ;; though the Python bindings of `file` are sufficient.
89 ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815844
90 (add-after 'unpack 'dependency-on-python-magic
91 (lambda _
92 (substitute* "setup.py"
93 (("'python-magic',") ""))))
94 ;; This test is broken because our `file` package has a
95 ;; bug in berkeley-db file type detection.
96 (add-after 'unpack 'remove-berkeley-test
97 (lambda _
98 (delete-file "tests/comparators/test_berkeley_db.py")
99 #t))
100 ;; Test is dynamically generated and may have false
101 ;; negatives with different ocaml versions. Further
102 ;; background in: https://bugs.debian.org/939386
103 (add-after 'unpack 'remove-ocaml-test
104 (lambda _
105 (substitute* "tests/comparators/test_ocaml.py"
106 (("def test_diff.differences.:")
107 "def skip_test_diff(differences):"))
108 #t))
109 (add-after 'unpack 'skip-elf-tests
110 ;; FIXME: libmix_differences test added in 125, and is
111 ;; failing, need to explore why...
112 (lambda _
113 (substitute* "tests/comparators/test_elf.py"
114 (("def test_libmix_differences.libmix_differences.:")
115 "def skip_test_libmix_differences(libmix_differences):"))
116 #t))
117 (add-after 'unpack 'embed-tool-references
118 (lambda* (#:key inputs #:allow-other-keys)
119 (substitute* "diffoscope/comparators/utils/compare.py"
120 (("\\['xxd',")
121 (string-append "['" (which "xxd") "',")))
122 (substitute* "diffoscope/comparators/elf.py"
123 (("@tool_required\\('readelf'\\)") "")
124 (("get_tool_name\\('readelf'\\)")
125 (string-append "'" (which "readelf") "'")))
126 (substitute* "diffoscope/comparators/directory.py"
127 (("@tool_required\\('stat'\\)") "")
128 (("@tool_required\\('getfacl'\\)") "")
129 (("\\['stat',")
130 (string-append "['" (which "stat") "',"))
131 (("\\['getfacl',")
132 (string-append "['" (which "getfacl") "',")))
133 #t))
134 (add-before 'check 'writable-test-data
135 (lambda _
136 ;; tests may need needs write access to tests
137 ;; directory
138 (for-each make-file-writable (find-files "tests"))
139 #t))
140 (add-before 'check 'delete-failing-test
141 (lambda _
142 ;; this requires /sbin to be on the path
143 (delete-file "tests/test_tools.py")
144 #t)))))
145 (inputs `(("rpm" ,rpm) ;for rpm-python
146 ("python-file" ,python-file)
147 ("python-debian" ,python-debian)
148 ("python-libarchive-c" ,python-libarchive-c)
149 ("python-tlsh" ,python-tlsh)
150 ("acl" ,acl) ;for getfacl
151 ("colordiff" ,colordiff)
152 ("xxd" ,xxd)))
153 ;; Below are modules used for tests.
154 (native-inputs `(("python-pytest" ,python-pytest)
155 ("python-chardet" ,python-chardet)
156 ("python-binwalk" ,python-binwalk)
157 ("python-pypdf2" ,python-pypdf2)
158 ("python-progressbar33" ,python-progressbar33)
159 ;; test suite skips tests when tool is missing
160 ,@(match (%current-system)
161 ;; ghc is only available on x86 currently.
162 ((or "x86_64-linux" "i686-linux")
163 `(("ghc" ,ghc)))
164 (_
165 `()))
166 ,@(match (%current-system)
167 ;; openjdk and dependent packages are only
168 ;; available on x86_64 currently.
169 ((or "x86_64-linux")
170 `(("enjarify" ,enjarify)
171 ;; no unversioned openjdk available
172 ("openjdk:jdk" ,openjdk12 "jdk")
173 ))
174 (_
175 `()))
176 ("abootimg" ,abootimg)
177 ("bdb" ,bdb)
178 ("binutils" ,binutils)
179 ("bzip2" ,bzip2)
180 ("cdrtools" ,cdrtools)
181 ("colord" ,colord)
182 ("cpio" ,cpio)
183 ("docx2txt" ,docx2txt)
184 ("dtc" ,dtc)
185 ("e2fsprogs" ,e2fsprogs)
186 ("ffmpeg" ,ffmpeg)
187 ("gettext" ,gettext-minimal)
188 ("ghostscript" ,ghostscript)
189 ("giflib:bin" ,giflib "bin")
190 ("gnumeric" ,gnumeric)
191 ("gnupg" ,gnupg)
192 ("imagemagick" ,imagemagick)
193 ("libarchive" ,libarchive)
194 ("llvm" ,llvm)
195 ("lz4" ,lz4)
196 ("mono" ,mono)
197 ("ocaml" ,ocaml)
198 ("odt2txt" ,odt2txt)
199 ("openssh" ,openssh)
200 ("pgpdump" ,pgpdump)
201 ("poppler" ,poppler)
202 ("python-jsbeautifier" ,python-jsbeautifier)
203 ("r-minimal" ,r-minimal)
204 ("rpm" ,rpm)
205 ("sng" ,sng)
206 ("sqlite" ,sqlite)
207 ("squashfs-tools" ,squashfs-tools)
208 ("tcpdump" ,tcpdump)
209 ("unzip" ,unzip)
210 ("wabt" ,wabt)
211 ("xxd" ,xxd)
212 ("xz" ,xz)
213 ("zip" ,zip)
214 ("zstd" ,zstd)))
215 (home-page "https://diffoscope.org/")
216 (synopsis "Compare files, archives, and directories in depth")
217 (description
218 "Diffoscope tries to get to the bottom of what makes files or directories
219 different. It recursively unpacks archives of many kinds and transforms
220 various binary formats into more human readable forms to compare them. It can
221 compare two tarballs, ISO images, or PDFs just as easily.
222
223 Diffoscope has many optional dependencies; @code{diffoscope
224 --list-missing-tools guix} will display optional packages to
225 install.")
226 (license license:gpl3+))))
227
228 (define-public reprotest
229 (package
230 (name "reprotest")
231 (version "0.7.14")
232 (source
233 (origin
234 (method git-fetch)
235 (uri (git-reference
236 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
237 (commit version)))
238 (file-name (git-file-name name version))
239 (sha256
240 (base32
241 "12d07xq5zx5dfbsgakm6zcn7hgf0h9f5kvfjqkiyak4ix5aa6xkf"))))
242 (inputs
243 `(("python-debian" ,python-debian)
244 ("python-distro" ,python-distro)
245 ("python-libarchive-c", python-libarchive-c)
246 ("python-rstr" ,python-rstr)))
247 (native-inputs
248 `(("diffoscope" ,diffoscope)
249 ("help2man" ,help2man)
250 ("libfaketime" ,libfaketime)
251 ("python-coverage" ,python-coverage)
252 ("python-docutils" ,python-docutils)
253 ("python-pytest " ,python-pytest)
254 ("python-tlsh" ,python-tlsh)
255 ("python-tox" ,python-tox)
256 ("unzip" ,unzip)
257 ("xxd" ,xxd)))
258 (build-system python-build-system)
259 (arguments
260 `(#:phases
261 (modify-phases %standard-phases
262 ;; Neither glibc-locales nor glibc-utf8-locales have the C.UTF-8
263 ;; locale or several other locales used in reprotest.
264 (add-after 'unpack 'adjust-locales
265 (lambda _
266 (substitute* "reprotest/build.py"
267 (("'C.UTF-8'") "'en_US.UTF-8'")
268 (("'ru_RU.CP1251'") "'ru_RU.KOI8-R'")
269 (("'kk_KZ.RK1048'") "'kk_KZ'"))
270 (substitute* "reprotest/lib/adt_testbed.py"
271 (("export LANG=C.UTF-8") "export LANG=en_US.UTF-8"))
272 #t))
273 (add-after 'install 'install-doc
274 (lambda* (#:key outputs #:allow-other-keys)
275 (let* ((mandir1 (string-append
276 (assoc-ref outputs "out") "/share/man/man1"))
277 (docdir (string-append
278 (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version)))
279 (invoke "make" "-C" "doc")
280 (mkdir-p mandir1)
281 (install-file "doc/reprotest.1" mandir1)
282 (mkdir-p docdir)
283 (install-file "./README.rst" docdir)
284 (install-file "./README-dev.rst" docdir))
285 #t)))))
286 (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
287 (synopsis "Build software and check it for reproducibility")
288 (description "Reprotest builds the same source code twice in different
289 environments, and then checks the binaries produced by each build for
290 differences. If any are found, then diffoscope or diff is used to display
291 them in detail for later analysis.")
292 (license (list license:gpl3+ license:gpl2+))))
293
294 (define-public trydiffoscope
295 (package
296 (name "trydiffoscope")
297 (version "67.0.1")
298 (source
299 (origin
300 (method git-fetch)
301 (uri (git-reference
302 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
303 (commit version)))
304 (file-name (git-file-name name version))
305 (sha256
306 (base32
307 "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
308 (arguments
309 `(#:phases
310 (modify-phases %standard-phases
311 (add-after 'install 'install-doc
312 (lambda* (#:key outputs #:allow-other-keys)
313 (let* ((share (string-append (assoc-ref outputs "out") "/share/")))
314 (mkdir-p (string-append share "/man/man1/" ))
315 (invoke "rst2man.py"
316 "trydiffoscope.1.rst"
317 (string-append share "/man/man1/trydiffoscope.1"))
318 (mkdir-p (string-append share "/doc/" ,name "-" ,version))
319 (install-file "./README.rst"
320 (string-append share "/doc/" ,name "-" ,version)))
321 #t)))))
322 (propagated-inputs
323 `(("python-requests" ,python-requests)))
324 (native-inputs
325 `(("gzip" ,gzip)
326 ("python-docutils" ,python-docutils)))
327 (build-system python-build-system)
328 (home-page "https://try.diffoscope.org")
329 (synopsis "Client for remote diffoscope service")
330 (description "This is a client for the @url{https://try.diffoscope.org,
331 remote diffoscope service}.
332
333 Diffoscope tries to get to the bottom of what makes files or directories
334 different. It recursively unpacks archives of many kinds and transforms
335 various binary formats into more human readable forms to compare them. It can
336 compare two tarballs, ISO images, or PDFs just as easily.
337
338 Results are displayed by default, stored as local text or html files, or made
339 available via a URL on @url{https://try.diffoscope.org}. Results stored on the
340 server are purged after 30 days.")
341 (license license:gpl3+)))