projects/guix·blob sysadmin-team · refs

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