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>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
73 (define-public diffoscope
81 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
83 (file-name (git-file-name name version))
85 (base32 "106ynj34cp5kcqdxrsb4cyskf0lv0sdghyayq1xiardy4p4jafcr"))
87 (search-patches "diffoscope-fix-llvm-test.patch"))))
88 (build-system python-build-system)
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
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"
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'\\)") "")
110 (string-append "['" (which "stat") "',"))
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
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
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"
133 (add-before 'check 'delete-failing-test
134 ;; Please add new tests to fix-failing-test and not here ;-)
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
151 (native-inputs `(("help2man" ,help2man)
152 ;; Below are modules used for tests.
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")
167 ,@(match (%current-system)
168 ;; openjdk and dependent packages are only
169 ;; available on x86_64 currently.
171 `(("enjarify" ,enjarify)
172 ;; no unversioned openjdk available
173 ("openjdk:jdk" ,openjdk12 "jdk")))
176 ("abootimg" ,abootimg)
178 ("binutils" ,binutils)
180 ("cdrtools" ,cdrtools)
183 ("docx2txt" ,docx2txt)
185 ("e2fsprogs" ,e2fsprogs)
188 ("gettext" ,gettext-minimal)
189 ("ghostscript" ,ghostscript)
190 ("giflib:bin" ,giflib "bin")
191 ("gnumeric" ,gnumeric)
194 ("imagemagick" ,imagemagick)
195 ("libarchive" ,libarchive)
205 ("python-jsbeautifier" ,python-jsbeautifier)
206 ("r-minimal" ,r-minimal)
210 ("squashfs-tools" ,squashfs-tools)
218 (home-page "https://diffoscope.org/")
219 (synopsis "Compare files, archives, and directories in depth")
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.
226 Diffoscope has many optional dependencies; @code{diffoscope
227 --list-missing-tools guix} will display optional packages to
229 (license license:gpl3+)))
231 (define-public reprotest
239 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
241 (file-name (git-file-name name version))
244 "19lwsxq53isgfkvlxvxqqmbjfcim3lhcxwk7m9ddfjiynhq74949"))))
246 (list python-debian python-distro python-libarchive-c python-rstr))
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)
259 (build-system python-build-system)
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
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"))
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")
282 (install-file "doc/reprotest.1" mandir1)
284 (install-file "./README.rst" docdir)
285 (install-file "./README-dev.rst" docdir))
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+))))
295 (define-public trydiffoscope
297 (name "trydiffoscope")
303 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
305 (file-name (git-file-name name version))
308 "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
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/" ))
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)))
324 (list python-requests))
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}.
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.
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+)))