projects/guix·blob dexed · refs

397 lines · 15.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <[email protected]>
3;;; Copyright © 2017, 2021 Ricardo Wurmus <[email protected]>
4;;; Copyright © 2017–2022 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2018 Julien Lepiller <[email protected]>
6;;; Copyright © 2018, 2019 Rutger Helling <[email protected]>
7;;; Copyright © 2019 Vagrant Cascadian <[email protected]>
8;;; Copyright © 2022, 2023 Efraim Flashner <[email protected]>
9;;;
10;;; This file is part of GNU Guix.
11;;;
12;;; GNU Guix is free software; you can redistribute it and/or modify it
13;;; under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 3 of the License, or (at
15;;; your option) any later version.
16;;;
17;;; GNU Guix is distributed in the hope that it will be useful, but
18;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
21;;;
22;;; You should have received a copy of the GNU General Public License
23;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25(define-module (gnu packages diffoscope)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages acl)
28 #:use-module (gnu packages admin)
29 #:use-module (gnu packages android)
30 #:use-module (gnu packages backup)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages bootloaders)
33 #:use-module (gnu packages cdrom)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cpio)
37 #:use-module (gnu packages dbm)
38 #:use-module (gnu packages firmware)
39 #:use-module (gnu packages gettext)
40 #:use-module (gnu packages ghostscript)
41 #:use-module (gnu packages gnome)
42 #:use-module (gnu packages gnupg)
43 #:use-module (gnu packages haskell)
44 #:use-module (gnu packages image)
45 #:use-module (gnu packages imagemagick)
46 #:use-module (gnu packages java)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages llvm)
49 #:use-module (gnu packages man)
50 #:use-module (gnu packages maths)
51 #:use-module (gnu packages ocaml)
52 #:use-module (gnu packages package-management)
53 #:use-module (gnu packages pascal)
54 #:use-module (gnu packages patchutils)
55 #:use-module (gnu packages pdf)
56 #:use-module (gnu packages perl)
57 #:use-module (gnu packages python-build)
58 #:use-module (gnu packages python-check)
59 #:use-module (gnu packages python-web)
60 #:use-module (gnu packages python-xyz)
61 #:use-module (gnu packages sqlite)
62 #:use-module (gnu packages ssh)
63 #:use-module (gnu packages statistics)
64 #:use-module (gnu packages textutils)
65 #:use-module (gnu packages tls)
66 #:use-module (gnu packages video)
67 #:use-module (gnu packages vim)
68 #:use-module (gnu packages web)
69 #:use-module (gnu packages xml)
70 #:use-module (guix build-system python)
71 #:use-module (guix build-system pyproject)
72 #:use-module (guix gexp)
73 #:use-module (guix git-download)
74 #:use-module ((guix licenses) #:prefix license:)
75 #:use-module (guix packages)
76 #:use-module (guix utils)
77 #:use-module (ice-9 match))
78
79(define-public diffoscope
80 (package
81 (name "diffoscope")
82 ;; Use git snapshot to fix tests using u-boot-tools 2026.01
83 (version "311-2-ge4ec97f7")
84 (source
85 (origin
86 (method git-fetch)
87 (uri (git-reference
88 (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
89 (commit version)))
90 (file-name (git-file-name name version))
91 (sha256
92 (base32 "1nk8di19r5x5jwb2jh1m7mzj109z2a2axikysijz2hm7m30wjkq7"))))
93 (build-system pyproject-build-system)
94 (arguments
95 (list
96 #:phases
97 #~(modify-phases %standard-phases
98 ;; These tests are broken because our `file` package has a
99 ;; bug in berkeley-db and wasm file type detection.
100 (add-after 'unpack 'remove-broken-file-type-detection-test
101 (lambda _
102 (delete-file "tests/comparators/test_berkeley_db.py")
103 (delete-file "tests/comparators/test_wasm.py")))
104 (add-after 'compress-documentation 'make-extract-vmlinux-executable
105 ;; The script extract-vmlinux needs to be marked executable to be
106 ;; able to extract vmlinux files.
107 (lambda _
108 (for-each (lambda (file)
109 (chmod file #o755))
110 (find-files #$output "extract-vmlinux"))))
111 (add-after 'unpack 'embed-tool-references
112 (lambda* (#:key inputs #:allow-other-keys)
113 (define (bin command)
114 (search-input-file inputs (string-append "bin/" command)))
115 (substitute* "diffoscope/comparators/utils/compare.py"
116 (("\\[\"(xxd)\"," _ command)
117 (string-append "[\"" (bin command) "\",")))
118 (substitute* "diffoscope/diff.py"
119 (("@tool_required\\(\"diff\"\\)") "")
120 (("get_tool_name\\(\"(diff)\"\\)" _ command)
121 (string-append "get_tool_name(\"" (bin command) "\")")))
122 (substitute* "diffoscope/comparators/directory.py"
123 (("@tool_required\\(\"stat\"\\)") "")
124 (("@tool_required\\(\"getfacl\"\\)") "")
125 (("\\[\"(stat)\"," _ command)
126 (string-append "[\"" (bin command) "\","))
127 (("\\[\"(getfacl)\"," _ command)
128 (string-append "[\"" (bin command) "\",")))))
129 (add-after 'build 'build-man-page
130 (lambda _
131 (invoke "make" "-C" "doc")))
132 (add-before 'check 'writable-test-data
133 (lambda _
134 ;; Tests may need write access to tests directory.
135 (for-each make-file-writable (find-files "tests"))))
136 (add-before 'check 'fix-failing-test
137 (lambda _
138 ;; There is no user name mapping in the build environment.
139 ;; Pytest made it so much harder than should be necessary,
140 ;; so I'm leaving… this here in case I ever need it again:
141 ;; (substitute* "tests/comparators/test_squashfs.py"
142 ;; (("^def test_symlink_root.*" match) ; no, I don't
143 ;; (string-append ; know Python
144 ;; match "\n raise ValueError(" ; why do you
145 ;; "differences_root[1].unified_diff)\n"))) ; ask
146 (substitute* "tests/data/squashfs_root_expected_diff"
147 (("root/root")
148 '"0/0 "))))
149 (add-before 'check 'delete-failing-test
150 ;; Please add new tests to fix-failing-test and not here ;-)
151 (lambda _
152 ;; This requires /sbin to be in $PATH.
153 (delete-file "tests/test_tools.py")))
154 (replace 'check
155 (lambda* (#:key tests? #:allow-other-keys)
156 (when tests?
157 ;; Increase verbosity of tests and provide a summary
158 (invoke "pytest" "-vv" "-r" "sxX"))))
159 (add-after 'install 'install-man-page
160 (lambda* (#:key outputs #:allow-other-keys)
161 (let* ((out (assoc-ref outputs "out"))
162 (man (string-append out "/share/man/man1")))
163 (install-file "doc/diffoscope.1" man)))))))
164 (inputs (list rpm ;for rpm-python
165 python-debian
166 python-libarchive-c
167 python-magic
168 python-tlsh
169 acl ;for getfacl
170 coreutils ;for stat
171 diffutils ;for diff
172 xxd))
173 (native-inputs
174 (append
175 (list help2man
176 python-setuptools
177 python-wheel
178
179 ;; Below are packages used for tests.
180 binwalk
181 python-pytest
182 python-chardet
183 python-defusedxml
184 python-h5py
185 python-pypdf
186 python-progressbar33
187
188 abootimg
189 bdb
190 binutils
191 bzip2
192 cdrkit-libre
193 colord
194 cpio
195 docx2txt
196 dtc
197 e2fsprogs
198 ffmpeg)
199
200 (match (%current-system)
201 ;; fpc is only available on x86 currently.
202 ((or "x86_64-linux" "i686-linux")
203 (list fpc))
204 (_ '()))
205
206 (list gettext-minimal
207 ghostscript
208 `(,giflib "bin")
209 gnumeric
210 gnupg
211 hdf5
212 html2text
213 imagemagick
214 libarchive
215 libcaca
216 llvm
217 lz4
218 lzip
219 ocaml
220 odt2txt
221 openssh
222 openssl
223 p7zip
224 perl
225 pgpdump
226 poppler
227 python-jsbeautifier
228 r-minimal
229 rpm
230 sng
231 sqlite
232 squashfs-tools
233 tcpdump
234 u-boot-tools
235 unzip
236 wabt
237 xxd
238 xz
239 zip
240 zstd)
241
242 ;; Also for tests. The test suite skips tests when these are missing.
243 (match (%current-system)
244 ;; ghc is only available on x86 currently.
245 ((or "x86_64-linux" "i686-linux")
246 (list ghc))
247 (_ '()))
248 (match (%current-system)
249 ;; openjdk and dependent packages are only
250 ;; available on x86_64 currently.
251 ((or "x86_64-linux")
252 ;; No unversioned openjdk available.
253 (list `(,openjdk12 "jdk")
254 enjarify))
255 (_ '()))))
256 (home-page "https://diffoscope.org/")
257 (synopsis "Compare files, archives, and directories in depth")
258 (description
259 "Diffoscope tries to get to the bottom of what makes files or directories
260different. It recursively unpacks archives of many kinds and transforms
261various binary formats into more human readable forms to compare them. It can
262compare two tarballs, ISO images, or PDFs just as easily.
263
264Diffoscope has many optional dependencies; @code{diffoscope
265--list-missing-tools guix} will display optional packages to
266install.")
267 (license license:gpl3+)))
268
269(define-public reprotest
270 (package
271 (name "reprotest")
272 (version "0.7.32")
273 (source
274 (origin
275 (method git-fetch)
276 (uri (git-reference
277 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
278 (commit version)))
279 (file-name (git-file-name name version))
280 (sha256
281 (base32 "0z67291rv9ii3llv2hwz9ak99818fwkxcqibb5zk8qkamh4y2bww"))))
282 (build-system pyproject-build-system)
283 (arguments
284 (list
285 #:phases
286 #~(modify-phases %standard-phases
287 (add-after 'compress-documentation 'make-virt-files-executable
288 ;; The autopkgtest-virt- files need to be marked executable for
289 ;; reprotest to function correctly.
290 (lambda _
291 (for-each (lambda (file)
292 (chmod file #o755))
293 (find-files #$output "autopkgtest-virt-.*"))))
294 ;; Adjust use of importlib.resources to use python 3.10 compatible
295 ;; syntax, which requires an argument.
296 ;; Drop when switching to python 3.12+.
297 (add-after 'unpack 'adjust-importlib-resources-for-old-python
298 (lambda _
299 (substitute* "reprotest/__init__.py"
300 (("importlib.resources.files\\(\\)")
301 "importlib.resources.files(package='reprotest')"))))
302 (add-after 'unpack 'skip-most-tests
303 ;; These tests require functionality not available in the guix
304 ;; build environment
305 (lambda _
306 (substitute* "tests/test_reprotest.py"
307 (("def (test_simple_build|test_self_build|test_variations)"
308 def)
309 (string-append
310 "@pytest.mark.skip(reason='guix environment lacks permissions')
311"
312 def)))))
313 (add-after 'install 'install-doc
314 (lambda _
315 (let* ((mandir1 (string-append
316 #$output "/share/man/man1"))
317 (docdir (string-append
318 #$output "/share/doc/" #$name "-" #$version)))
319 (invoke "make" "-C" "doc")
320 (mkdir-p mandir1)
321 (install-file "doc/reprotest.1" mandir1)
322 (mkdir-p docdir)
323 (install-file "./README.rst" docdir)
324 (install-file "./README-dev.rst" docdir)))))))
325 (native-inputs
326 (list diffoscope
327 help2man
328 libfaketime
329 python-docutils
330 python-magic
331 python-pytest
332 python-setuptools
333 python-tlsh
334 python-wheel
335 unzip
336 xxd))
337 (propagated-inputs
338 (list python-debian
339 python-distro
340 python-libarchive-c
341 python-rstr))
342 (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
343 (synopsis "Build software and check it for reproducibility")
344 (description "Reprotest builds the same source code twice in different
345environments, and then checks the binaries produced by each build for
346differences. If any are found, then diffoscope or diff is used to display
347them in detail for later analysis.")
348 (license (list license:gpl3+ license:gpl2+))))
349
350(define-public trydiffoscope
351 (package
352 (name "trydiffoscope")
353 (version "67.0.8")
354 (source
355 (origin
356 (method git-fetch)
357 (uri (git-reference
358 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
359 (commit version)))
360 (file-name (git-file-name name version))
361 (sha256
362 (base32
363 "0k698g4fws63rnav4pvfsf1hfds867xan59mmv5zw71r58lm6cxb"))))
364 (arguments
365 (list #:tests? #f
366 #:phases
367 #~(modify-phases %standard-phases
368 (add-after 'install 'install-doc
369 (lambda _
370 (let* ((share (string-append #$output "/share/")))
371 (mkdir-p (string-append share "/man/man1/"))
372 (invoke "rst2man.py" "trydiffoscope.1.rst"
373 (string-append share "/man/man1/trydiffoscope.1"))
374 (mkdir-p (string-append
375 share "/doc/" #$name "-" #$version))
376 (install-file
377 "./README.rst"
378 (string-append share "/doc/" #$name "-" #$version))))))))
379 (propagated-inputs
380 (list python-requests))
381 (native-inputs
382 (list gzip python-docutils-0.19 python-setuptools python-wheel))
383 (build-system pyproject-build-system)
384 (home-page "https://try.diffoscope.org")
385 (synopsis "Client for remote diffoscope service")
386 (description "This is a client for the @url{https://try.diffoscope.org,
387remote diffoscope service}.
388
389Diffoscope tries to get to the bottom of what makes files or directories
390different. It recursively unpacks archives of many kinds and transforms
391various binary formats into more human readable forms to compare them. It can
392compare two tarballs, ISO images, or PDFs just as easily.
393
394Results are displayed by default, stored as local text or html files, or made
395available via a URL on @url{https://try.diffoscope.org}. Results stored on the
396server are purged after 30 days.")
397 (license license:gpl3+)))