gnu: Simplify package inputs.
[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, 2021 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2017–2021 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 pascal)
53 #:use-module (gnu packages patchutils)
54 #:use-module (gnu packages pdf)
55 #:use-module (gnu packages python-web)
56 #:use-module (gnu packages python-xyz)
57 #:use-module (gnu packages sqlite)
58 #:use-module (gnu packages ssh)
59 #:use-module (gnu packages statistics)
60 #:use-module (gnu packages textutils)
61 #:use-module (gnu packages tls)
62 #:use-module (gnu packages video)
63 #:use-module (gnu packages vim)
64 #:use-module (gnu packages web)
65 #:use-module (guix build-system python)
66 #:use-module (guix gexp)
67 #:use-module (guix git-download)
68 #:use-module ((guix licenses) #:prefix license:)
69 #:use-module (guix packages)
70 #:use-module (guix utils)
71 #:use-module (ice-9 match))
72
73 (define-public diffoscope
74 (package
75 (name "diffoscope")
76 (version "194")
77 (source
78 (origin
79 (method git-fetch)
80 (uri (git-reference
81 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
82 (commit version)))
83 (file-name (git-file-name name version))
84 (sha256
85 (base32 "106ynj34cp5kcqdxrsb4cyskf0lv0sdghyayq1xiardy4p4jafcr"))
86 (patches
87 (search-patches "diffoscope-fix-llvm-test.patch"))))
88 (build-system python-build-system)
89 (arguments
90 `(#:phases (modify-phases %standard-phases
91 ;; These tests are broken because our `file` package has a
92 ;; bug in berkeley-db and wasm file type detection.
93 (add-after 'unpack 'remove-broken-file-type-detection-test
94 (lambda _
95 (delete-file "tests/comparators/test_berkeley_db.py")
96 (delete-file "tests/comparators/test_wasm.py")))
97 (add-after 'unpack 'embed-tool-references
98 (lambda* (#:key inputs #:allow-other-keys)
99 (substitute* "diffoscope/comparators/utils/compare.py"
100 (("\\['xxd',")
101 (string-append "['" (which "xxd") "',")))
102 (substitute* "diffoscope/comparators/elf.py"
103 (("@tool_required\\('readelf'\\)") "")
104 (("get_tool_name\\('readelf'\\)")
105 (string-append "'" (which "readelf") "'")))
106 (substitute* "diffoscope/comparators/directory.py"
107 (("@tool_required\\('stat'\\)") "")
108 (("@tool_required\\('getfacl'\\)") "")
109 (("\\['stat',")
110 (string-append "['" (which "stat") "',"))
111 (("\\['getfacl',")
112 (string-append "['" (which "getfacl") "',")))))
113 (add-after 'build 'build-man-page
114 (lambda* (#:key (make-flags '()) #:allow-other-keys)
115 (apply invoke "make" "-C" "doc" make-flags)))
116 (add-before 'check 'writable-test-data
117 (lambda _
118 ;; Tests may need write access to tests directory.
119 (for-each make-file-writable (find-files "tests"))))
120 (add-before 'check 'fix-failing-test
121 (lambda _
122 ;; There is no user name mapping in the build environment.
123 ;; Pytest made it so much harder than should be necessary,
124 ;; so I'm leaving… this here in case I ever need it again:
125 ;; (substitute* "tests/comparators/test_squashfs.py"
126 ;; (("^def test_symlink_root.*" match) ; no, I don't
127 ;; (string-append ; know Python
128 ;; match "\n raise ValueError(" ; why do you
129 ;; "differences_root[1].unified_diff)\n"))) ; ask
130 (substitute* "tests/data/squashfs_root_expected_diff"
131 (("root/root")
132 '"0/0 "))))
133 (add-before 'check 'delete-failing-test
134 ;; Please add new tests to fix-failing-test and not here ;-)
135 (lambda _
136 ;; This requires /sbin to be in $PATH.
137 (delete-file "tests/test_tools.py")))
138 (add-after 'install 'install-man-page
139 (lambda* (#:key outputs #:allow-other-keys)
140 (let* ((out (assoc-ref outputs "out"))
141 (man (string-append out "/share/man/man1")))
142 (install-file "doc/diffoscope.1" man)))))))
143 (inputs (list rpm ;for rpm-python
144 python-debian
145 python-libarchive-c
146 python-magic
147 python-tlsh
148 acl ;for getfacl
149 colordiff
150 xxd))
151 (native-inputs `(("help2man" ,help2man)
152 ;; Below are modules used for tests.
153 ("binwalk" ,binwalk)
154 ("python-pytest" ,python-pytest)
155 ("python-chardet" ,python-chardet)
156 ("python-black" ,python-black)
157 ("python-h5py" ,python-h5py)
158 ("python-pypdf2" ,python-pypdf2)
159 ("python-progressbar33" ,python-progressbar33)
160 ;; The test suite skips tests when these are missing.
161 ,@(match (%current-system)
162 ;; ghc is only available on x86 currently.
163 ((or "x86_64-linux" "i686-linux")
164 `(("ghc" ,ghc)))
165 (_
166 `()))
167 ,@(match (%current-system)
168 ;; openjdk and dependent packages are only
169 ;; available on x86_64 currently.
170 ((or "x86_64-linux")
171 `(("enjarify" ,enjarify)
172 ;; no unversioned openjdk available
173 ("openjdk:jdk" ,openjdk12 "jdk")))
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 ("fpc" ,fpc)
188 ("gettext" ,gettext-minimal)
189 ("ghostscript" ,ghostscript)
190 ("giflib:bin" ,giflib "bin")
191 ("gnumeric" ,gnumeric)
192 ("gnupg" ,gnupg)
193 ("hdf5" ,hdf5)
194 ("imagemagick" ,imagemagick)
195 ("libarchive" ,libarchive)
196 ("llvm" ,llvm)
197 ("lz4" ,lz4)
198 ("mono" ,mono)
199 ("ocaml" ,ocaml)
200 ("odt2txt" ,odt2txt)
201 ("openssh" ,openssh)
202 ("openssl" ,openssl)
203 ("pgpdump" ,pgpdump)
204 ("poppler" ,poppler)
205 ("python-jsbeautifier" ,python-jsbeautifier)
206 ("r-minimal" ,r-minimal)
207 ("rpm" ,rpm)
208 ("sng" ,sng)
209 ("sqlite" ,sqlite)
210 ("squashfs-tools" ,squashfs-tools)
211 ("tcpdump" ,tcpdump)
212 ("unzip" ,unzip)
213 ("wabt" ,wabt)
214 ("xxd" ,xxd)
215 ("xz" ,xz)
216 ("zip" ,zip)
217 ("zstd" ,zstd)))
218 (home-page "https://diffoscope.org/")
219 (synopsis "Compare files, archives, and directories in depth")
220 (description
221 "Diffoscope tries to get to the bottom of what makes files or directories
222 different. It recursively unpacks archives of many kinds and transforms
223 various binary formats into more human readable forms to compare them. It can
224 compare two tarballs, ISO images, or PDFs just as easily.
225
226 Diffoscope has many optional dependencies; @code{diffoscope
227 --list-missing-tools guix} will display optional packages to
228 install.")
229 (license license:gpl3+)))
230
231 (define-public reprotest
232 (package
233 (name "reprotest")
234 (version "0.7.18")
235 (source
236 (origin
237 (method git-fetch)
238 (uri (git-reference
239 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
240 (commit version)))
241 (file-name (git-file-name name version))
242 (sha256
243 (base32
244 "19lwsxq53isgfkvlxvxqqmbjfcim3lhcxwk7m9ddfjiynhq74949"))))
245 (inputs
246 (list python-debian python-distro python-libarchive-c 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-magic " ,python-magic)
254 ("python-pytest " ,python-pytest)
255 ("python-tlsh" ,python-tlsh)
256 ("python-tox" ,python-tox)
257 ("unzip" ,unzip)
258 ("xxd" ,xxd)))
259 (build-system python-build-system)
260 (arguments
261 `(#:phases
262 (modify-phases %standard-phases
263 ;; Neither glibc-locales nor glibc-utf8-locales have the C.UTF-8
264 ;; locale or several other locales used in reprotest.
265 (add-after 'unpack 'adjust-locales
266 (lambda _
267 (substitute* "reprotest/build.py"
268 (("'C.UTF-8'") "'en_US.UTF-8'")
269 (("'ru_RU.CP1251'") "'ru_RU.KOI8-R'")
270 (("'kk_KZ.RK1048'") "'kk_KZ'"))
271 (substitute* "reprotest/lib/adt_testbed.py"
272 (("export LANG=C.UTF-8") "export LANG=en_US.UTF-8"))
273 #t))
274 (add-after 'install 'install-doc
275 (lambda* (#:key outputs #:allow-other-keys)
276 (let* ((mandir1 (string-append
277 (assoc-ref outputs "out") "/share/man/man1"))
278 (docdir (string-append
279 (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version)))
280 (invoke "make" "-C" "doc")
281 (mkdir-p mandir1)
282 (install-file "doc/reprotest.1" mandir1)
283 (mkdir-p docdir)
284 (install-file "./README.rst" docdir)
285 (install-file "./README-dev.rst" docdir))
286 #t)))))
287 (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
288 (synopsis "Build software and check it for reproducibility")
289 (description "Reprotest builds the same source code twice in different
290 environments, and then checks the binaries produced by each build for
291 differences. If any are found, then diffoscope or diff is used to display
292 them in detail for later analysis.")
293 (license (list license:gpl3+ license:gpl2+))))
294
295 (define-public trydiffoscope
296 (package
297 (name "trydiffoscope")
298 (version "67.0.1")
299 (source
300 (origin
301 (method git-fetch)
302 (uri (git-reference
303 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
304 (commit version)))
305 (file-name (git-file-name name version))
306 (sha256
307 (base32
308 "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
309 (arguments
310 `(#:phases
311 (modify-phases %standard-phases
312 (add-after 'install 'install-doc
313 (lambda* (#:key outputs #:allow-other-keys)
314 (let* ((share (string-append (assoc-ref outputs "out") "/share/")))
315 (mkdir-p (string-append share "/man/man1/" ))
316 (invoke "rst2man.py"
317 "trydiffoscope.1.rst"
318 (string-append share "/man/man1/trydiffoscope.1"))
319 (mkdir-p (string-append share "/doc/" ,name "-" ,version))
320 (install-file "./README.rst"
321 (string-append share "/doc/" ,name "-" ,version)))
322 #t)))))
323 (propagated-inputs
324 (list python-requests))
325 (native-inputs
326 (list gzip 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+)))