Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / diffoscope.scm
CommitLineData
52211add
VC
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 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)
3244b64f 28 #:use-module (gnu packages android)
52211add
VC
29 #:use-module (gnu packages backup)
30 #:use-module (gnu packages base)
3244b64f 31 #:use-module (gnu packages bootloaders)
52211add
VC
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 mono)
3fb581ca 48 #:use-module (gnu packages ocaml)
52211add
VC
49 #:use-module (gnu packages package-management)
50 #:use-module (gnu packages patchutils)
51 #:use-module (gnu packages pdf)
52 #:use-module (gnu packages python-web)
53 #:use-module (gnu packages python-xyz)
54 #:use-module (gnu packages sqlite)
55 #:use-module (gnu packages ssh)
3244b64f 56 #:use-module (gnu packages statistics)
52211add
VC
57 #:use-module (gnu packages textutils)
58 #:use-module (gnu packages video)
59 #:use-module (gnu packages vim)
4d83157c 60 #:use-module (gnu packages web)
52211add
VC
61 #:use-module (guix build-system python)
62 #:use-module (guix gexp)
63 #:use-module (guix git-download)
64 #:use-module ((guix licenses) #:prefix license:)
65 #:use-module (guix packages)
aaeb2b34
VC
66 #:use-module (guix utils)
67 #:use-module (ice-9 match))
52211add
VC
68
69(define-public diffoscope
a3bf4348 70 (let ((version "135"))
52211add
VC
71 (package
72 (name "diffoscope")
73 (version version)
74 (source (origin
75 (method git-fetch)
76 (uri (git-reference
77 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
78 (commit version)))
79 (file-name (git-file-name name version))
80 (sha256
81 (base32
a3bf4348 82 "0rkpvajkp3qryi6dxkrh8aq5xg79aybnw8iy73wsblcnfq6yhba7"))))
52211add
VC
83 (build-system python-build-system)
84 (arguments
85 `(#:phases (modify-phases %standard-phases
86 ;; setup.py mistakenly requires python-magic from PyPi, even
87 ;; though the Python bindings of `file` are sufficient.
88 ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815844
89 (add-after 'unpack 'dependency-on-python-magic
90 (lambda _
91 (substitute* "setup.py"
92 (("'python-magic',") ""))))
93 ;; This test is broken because our `file` package has a
94 ;; bug in berkeley-db file type detection.
95 (add-after 'unpack 'remove-berkeley-test
96 (lambda _
97 (delete-file "tests/comparators/test_berkeley_db.py")
98 #t))
99 ;; Test is dynamically generated and may have false
100 ;; negatives with different ocaml versions. Further
101 ;; background in: https://bugs.debian.org/939386
102 (add-after 'unpack 'remove-ocaml-test
103 (lambda _
3fb581ca
VC
104 (substitute* "tests/comparators/test_ocaml.py"
105 (("def test_diff.differences.:")
106 "def skip_test_diff(differences):"))
107 #t))
108 (add-after 'unpack 'skip-elf-tests
109 ;; FIXME: libmix_differences test added in 125, and is
110 ;; failing, need to explore why...
111 (lambda _
112 (substitute* "tests/comparators/test_elf.py"
113 (("def test_libmix_differences.libmix_differences.:")
114 "def skip_test_libmix_differences(libmix_differences):"))
52211add
VC
115 #t))
116 (add-after 'unpack 'embed-tool-references
117 (lambda* (#:key inputs #:allow-other-keys)
118 (substitute* "diffoscope/comparators/utils/compare.py"
119 (("\\['xxd',")
120 (string-append "['" (which "xxd") "',")))
121 (substitute* "diffoscope/comparators/elf.py"
122 (("@tool_required\\('readelf'\\)") "")
123 (("get_tool_name\\('readelf'\\)")
124 (string-append "'" (which "readelf") "'")))
125 (substitute* "diffoscope/comparators/directory.py"
126 (("@tool_required\\('stat'\\)") "")
127 (("@tool_required\\('getfacl'\\)") "")
128 (("\\['stat',")
129 (string-append "['" (which "stat") "',"))
130 (("\\['getfacl',")
131 (string-append "['" (which "getfacl") "',")))
132 #t))
133 (add-before 'check 'writable-test-data
134 (lambda _
135 ;; tests may need needs write access to tests
136 ;; directory
137 (for-each make-file-writable (find-files "tests"))
138 #t))
139 (add-before 'check 'delete-failing-test
140 (lambda _
141 ;; this requires /sbin to be on the path
142 (delete-file "tests/test_tools.py")
143 #t)))))
144 (inputs `(("rpm" ,rpm) ;for rpm-python
145 ("python-file" ,python-file)
146 ("python-debian" ,python-debian)
147 ("python-libarchive-c" ,python-libarchive-c)
148 ("python-tlsh" ,python-tlsh)
149 ("acl" ,acl) ;for getfacl
150 ("colordiff" ,colordiff)
151 ("xxd" ,xxd)))
152 ;; Below are modules used for tests.
153 (native-inputs `(("python-pytest" ,python-pytest)
154 ("python-chardet" ,python-chardet)
f315673d 155 ("python-binwalk" ,python-binwalk)
36f5f23c
VC
156 ("python-pypdf2" ,python-pypdf2)
157 ("python-progressbar33" ,python-progressbar33)
52211add 158 ;; test suite skips tests when tool is missing
aaeb2b34
VC
159 ,@(match (%current-system)
160 ;; ghc is only available on x86 currently.
161 ((or "x86_64-linux" "i686-linux")
162 `(("ghc" ,ghc)))
163 (_
164 `()))
165 ,@(match (%current-system)
166 ;; openjdk and dependent packages are only
167 ;; available on x86_64 currently.
168 ((or "x86_64-linux")
169 `(("enjarify" ,enjarify)
170 ;; no unversioned openjdk available
171 ("openjdk:jdk" ,openjdk12 "jdk")
172 ))
173 (_
174 `()))
3244b64f 175 ("abootimg" ,abootimg)
52211add
VC
176 ("bdb" ,bdb)
177 ("binutils" ,binutils)
178 ("bzip2" ,bzip2)
179 ("cdrtools" ,cdrtools)
180 ("colord" ,colord)
181 ("cpio" ,cpio)
182 ("docx2txt" ,docx2txt)
3244b64f 183 ("dtc" ,dtc)
52211add
VC
184 ("e2fsprogs" ,e2fsprogs)
185 ("ffmpeg" ,ffmpeg)
186 ("gettext" ,gettext-minimal)
52211add
VC
187 ("ghostscript" ,ghostscript)
188 ("giflib:bin" ,giflib "bin")
189 ("gnumeric" ,gnumeric)
190 ("gnupg" ,gnupg)
191 ("imagemagick" ,imagemagick)
192 ("libarchive" ,libarchive)
193 ("llvm" ,llvm)
194 ("lz4" ,lz4)
195 ("mono" ,mono)
3fb581ca 196 ("ocaml" ,ocaml)
52211add 197 ("odt2txt" ,odt2txt)
52211add
VC
198 ("openssh" ,openssh)
199 ("pgpdump" ,pgpdump)
200 ("poppler" ,poppler)
6ec87223 201 ("python-jsbeautifier" ,python-jsbeautifier)
3244b64f 202 ("r-minimal" ,r-minimal)
52211add
VC
203 ("rpm" ,rpm)
204 ("sng" ,sng)
205 ("sqlite" ,sqlite)
206 ("squashfs-tools" ,squashfs-tools)
207 ("tcpdump" ,tcpdump)
208 ("unzip" ,unzip)
4d83157c 209 ("wabt" ,wabt)
52211add
VC
210 ("xxd" ,xxd)
211 ("xz" ,xz)
bc685e1c
VC
212 ("zip" ,zip)
213 ("zstd" ,zstd)))
52211add
VC
214 (home-page "https://diffoscope.org/")
215 (synopsis "Compare files, archives, and directories in depth")
216 (description
217 "Diffoscope tries to get to the bottom of what makes files or directories
218different. It recursively unpacks archives of many kinds and transforms
219various binary formats into more human readable forms to compare them. It can
220compare two tarballs, ISO images, or PDFs just as easily.")
221 (license license:gpl3+))))
222
223(define-public trydiffoscope
224 (package
225 (name "trydiffoscope")
226 (version "67.0.1")
227 (source
228 (origin
229 (method git-fetch)
230 (uri (git-reference
231 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
232 (commit version)))
233 (file-name (git-file-name name version))
234 (sha256
235 (base32
236 "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
237 (arguments
238 `(#:phases
239 (modify-phases %standard-phases
240 (add-after 'install 'install-doc
241 (lambda* (#:key outputs #:allow-other-keys)
242 (let* ((share (string-append (assoc-ref outputs "out") "/share/")))
243 (mkdir-p (string-append share "/man/man1/" ))
244 (invoke "rst2man.py"
245 "trydiffoscope.1.rst"
246 (string-append share "/man/man1/trydiffoscope.1"))
247 (mkdir-p (string-append share "/doc/" ,name "-" ,version))
248 (install-file "./README.rst"
249 (string-append share "/doc/" ,name "-" ,version)))
250 #t)))))
251 (propagated-inputs
252 `(("python-requests" ,python-requests)))
253 (native-inputs
254 `(("gzip" ,gzip)
255 ("python-docutils" ,python-docutils)))
256 (build-system python-build-system)
257 (home-page "https://try.diffoscope.org")
258 (synopsis "Client for remote diffoscope service")
259 (description "This is a client for the @url{https://try.diffoscope.org,
260remote diffoscope service}.
261
262Diffoscope tries to get to the bottom of what makes files or directories
263different. It recursively unpacks archives of many kinds and transforms
264various binary formats into more human readable forms to compare them. It can
265compare two tarballs, ISO images, or PDFs just as easily.
266
267Results are displayed by default, stored as local text or html files, or made
268available via a URL on @url{https://try.diffoscope.org}. Results stored on the
269server are purged after 30 days.")
270 (license license:gpl3+)))