projects/guix·blob bootstrap-team · refs

396 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 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 (version "308")
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 "0g4kac0r2plhcl3drpihp2z99yfqlz36xvvfr4v6sn49zj103kny"))))
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-h5py
184 python-pypdf
185 python-progressbar33
186
187 abootimg
188 bdb
189 binutils
190 bzip2
191 cdrkit-libre
192 colord
193 cpio
194 docx2txt
195 dtc
196 e2fsprogs
197 ffmpeg)
198
199 (match (%current-system)
200 ;; fpc is only available on x86 currently.
201 ((or "x86_64-linux" "i686-linux")
202 (list fpc))
203 (_ '()))
204
205 (list gettext-minimal
206 ghostscript
207 `(,giflib "bin")
208 gnumeric
209 gnupg
210 hdf5
211 html2text
212 imagemagick
213 libarchive
214 libcaca
215 llvm
216 lz4
217 lzip
218 ocaml
219 odt2txt
220 openssh
221 openssl
222 p7zip
223 perl
224 pgpdump
225 poppler
226 python-jsbeautifier
227 r-minimal
228 rpm
229 sng
230 sqlite
231 squashfs-tools
232 tcpdump
233 u-boot-tools
234 unzip
235 wabt
236 xxd
237 xz
238 zip
239 zstd)
240
241 ;; Also for tests. The test suite skips tests when these are missing.
242 (match (%current-system)
243 ;; ghc is only available on x86 currently.
244 ((or "x86_64-linux" "i686-linux")
245 (list ghc))
246 (_ '()))
247 (match (%current-system)
248 ;; openjdk and dependent packages are only
249 ;; available on x86_64 currently.
250 ((or "x86_64-linux")
251 ;; No unversioned openjdk available.
252 (list `(,openjdk12 "jdk")
253 enjarify))
254 (_ '()))))
255 (home-page "https://diffoscope.org/")
256 (synopsis "Compare files, archives, and directories in depth")
257 (description
258 "Diffoscope tries to get to the bottom of what makes files or directories
259different. It recursively unpacks archives of many kinds and transforms
260various binary formats into more human readable forms to compare them. It can
261compare two tarballs, ISO images, or PDFs just as easily.
262
263Diffoscope has many optional dependencies; @code{diffoscope
264--list-missing-tools guix} will display optional packages to
265install.")
266 (license license:gpl3+)))
267
268(define-public reprotest
269 (package
270 (name "reprotest")
271 (version "0.7.32")
272 (source
273 (origin
274 (method git-fetch)
275 (uri (git-reference
276 (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
277 (commit version)))
278 (file-name (git-file-name name version))
279 (sha256
280 (base32 "0z67291rv9ii3llv2hwz9ak99818fwkxcqibb5zk8qkamh4y2bww"))))
281 (build-system pyproject-build-system)
282 (arguments
283 (list
284 #:phases
285 #~(modify-phases %standard-phases
286 (add-after 'compress-documentation 'make-virt-files-executable
287 ;; The autopkgtest-virt- files need to be marked executable for
288 ;; reprotest to function correctly.
289 (lambda _
290 (for-each (lambda (file)
291 (chmod file #o755))
292 (find-files #$output "autopkgtest-virt-.*"))))
293 ;; Adjust use of importlib.resources to use python 3.10 compatible
294 ;; syntax, which requires an argument.
295 ;; Drop when switching to python 3.12+.
296 (add-after 'unpack 'adjust-importlib-resources-for-old-python
297 (lambda _
298 (substitute* "reprotest/__init__.py"
299 (("importlib.resources.files\\(\\)")
300 "importlib.resources.files(package='reprotest')"))))
301 (add-after 'unpack 'skip-most-tests
302 ;; These tests require functionality not available in the guix
303 ;; build environment
304 (lambda _
305 (substitute* "tests/test_reprotest.py"
306 (("def (test_simple_build|test_self_build|test_variations)"
307 def)
308 (string-append
309 "@pytest.mark.skip(reason='guix environment lacks permissions')
310"
311 def)))))
312 (add-after 'install 'install-doc
313 (lambda _
314 (let* ((mandir1 (string-append
315 #$output "/share/man/man1"))
316 (docdir (string-append
317 #$output "/share/doc/" #$name "-" #$version)))
318 (invoke "make" "-C" "doc")
319 (mkdir-p mandir1)
320 (install-file "doc/reprotest.1" mandir1)
321 (mkdir-p docdir)
322 (install-file "./README.rst" docdir)
323 (install-file "./README-dev.rst" docdir)))))))
324 (native-inputs
325 (list diffoscope
326 help2man
327 libfaketime
328 python-docutils
329 python-magic
330 python-pytest
331 python-setuptools
332 python-tlsh
333 python-wheel
334 unzip
335 xxd))
336 (propagated-inputs
337 (list python-debian
338 python-distro
339 python-libarchive-c
340 python-rstr))
341 (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
342 (synopsis "Build software and check it for reproducibility")
343 (description "Reprotest builds the same source code twice in different
344environments, and then checks the binaries produced by each build for
345differences. If any are found, then diffoscope or diff is used to display
346them in detail for later analysis.")
347 (license (list license:gpl3+ license:gpl2+))))
348
349(define-public trydiffoscope
350 (package
351 (name "trydiffoscope")
352 (version "67.0.8")
353 (source
354 (origin
355 (method git-fetch)
356 (uri (git-reference
357 (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
358 (commit version)))
359 (file-name (git-file-name name version))
360 (sha256
361 (base32
362 "0k698g4fws63rnav4pvfsf1hfds867xan59mmv5zw71r58lm6cxb"))))
363 (arguments
364 (list #:tests? #f
365 #:phases
366 #~(modify-phases %standard-phases
367 (add-after 'install 'install-doc
368 (lambda _
369 (let* ((share (string-append #$output "/share/")))
370 (mkdir-p (string-append share "/man/man1/"))
371 (invoke "rst2man.py" "trydiffoscope.1.rst"
372 (string-append share "/man/man1/trydiffoscope.1"))
373 (mkdir-p (string-append
374 share "/doc/" #$name "-" #$version))
375 (install-file
376 "./README.rst"
377 (string-append share "/doc/" #$name "-" #$version))))))))
378 (propagated-inputs
379 (list python-requests))
380 (native-inputs
381 (list gzip python-docutils-0.19 python-setuptools python-wheel))
382 (build-system pyproject-build-system)
383 (home-page "https://try.diffoscope.org")
384 (synopsis "Client for remote diffoscope service")
385 (description "This is a client for the @url{https://try.diffoscope.org,
386remote diffoscope service}.
387
388Diffoscope tries to get to the bottom of what makes files or directories
389different. It recursively unpacks archives of many kinds and transforms
390various binary formats into more human readable forms to compare them. It can
391compare two tarballs, ISO images, or PDFs just as easily.
392
393Results are displayed by default, stored as local text or html files, or made
394available via a URL on @url{https://try.diffoscope.org}. Results stored on the
395server are purged after 30 days.")
396 (license license:gpl3+)))