diffoscope.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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>
  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. (define-module (gnu packages diffoscope)
  24. #:use-module (gnu packages)
  25. #:use-module (gnu packages acl)
  26. #:use-module (gnu packages admin)
  27. #:use-module (gnu packages android)
  28. #:use-module (gnu packages backup)
  29. #:use-module (gnu packages base)
  30. #:use-module (gnu packages bootloaders)
  31. #:use-module (gnu packages cdrom)
  32. #:use-module (gnu packages check)
  33. #:use-module (gnu packages compression)
  34. #:use-module (gnu packages cpio)
  35. #:use-module (gnu packages dbm)
  36. #:use-module (gnu packages file) ;for 'file-next'
  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))
  72. (define-public diffoscope
  73. (package
  74. (name "diffoscope")
  75. (version "207")
  76. (source
  77. (origin
  78. (method git-fetch)
  79. (uri (git-reference
  80. (url "https://salsa.debian.org/reproducible-builds/diffoscope.git")
  81. (commit version)))
  82. (file-name (git-file-name name version))
  83. (sha256
  84. (base32 "0djpkq9fpw8dpiqaghbbg5dshl27xgkqrifalx9nq87dix5c1y6d"))
  85. (patches
  86. (search-patches "diffoscope-fix-llvm-test.patch"))))
  87. (build-system python-build-system)
  88. (arguments
  89. `(#:phases (modify-phases %standard-phases
  90. ;; These tests are broken because our `file` package has a
  91. ;; bug in berkeley-db and wasm file type detection.
  92. (add-after 'unpack 'remove-broken-file-type-detection-test
  93. (lambda _
  94. (delete-file "tests/comparators/test_berkeley_db.py")
  95. (delete-file "tests/comparators/test_wasm.py")))
  96. (add-after 'unpack 'embed-tool-references
  97. (lambda* (#:key inputs #:allow-other-keys)
  98. (substitute* "diffoscope/comparators/utils/compare.py"
  99. (("\\['xxd',")
  100. (string-append "['" (which "xxd") "',")))
  101. (substitute* "diffoscope/comparators/elf.py"
  102. (("@tool_required\\('readelf'\\)") "")
  103. (("get_tool_name\\('readelf'\\)")
  104. (string-append "'" (which "readelf") "'")))
  105. (substitute* "diffoscope/comparators/directory.py"
  106. (("@tool_required\\('stat'\\)") "")
  107. (("@tool_required\\('getfacl'\\)") "")
  108. (("\\['stat',")
  109. (string-append "['" (which "stat") "',"))
  110. (("\\['getfacl',")
  111. (string-append "['" (which "getfacl") "',")))))
  112. (add-after 'build 'build-man-page
  113. (lambda* (#:key (make-flags '()) #:allow-other-keys)
  114. (apply invoke "make" "-C" "doc" make-flags)))
  115. (add-before 'check 'writable-test-data
  116. (lambda _
  117. ;; Tests may need write access to tests directory.
  118. (for-each make-file-writable (find-files "tests"))))
  119. (add-before 'check 'fix-failing-test
  120. (lambda _
  121. ;; There is no user name mapping in the build environment.
  122. ;; Pytest made it so much harder than should be necessary,
  123. ;; so I'm leaving… this here in case I ever need it again:
  124. ;; (substitute* "tests/comparators/test_squashfs.py"
  125. ;; (("^def test_symlink_root.*" match) ; no, I don't
  126. ;; (string-append ; know Python
  127. ;; match "\n raise ValueError(" ; why do you
  128. ;; "differences_root[1].unified_diff)\n"))) ; ask
  129. (substitute* "tests/data/squashfs_root_expected_diff"
  130. (("root/root")
  131. '"0/0 "))))
  132. (add-before 'check 'delete-failing-test
  133. ;; Please add new tests to fix-failing-test and not here ;-)
  134. (lambda _
  135. ;; This requires /sbin to be in $PATH.
  136. (delete-file "tests/test_tools.py")))
  137. (add-after 'install 'install-man-page
  138. (lambda* (#:key outputs #:allow-other-keys)
  139. (let* ((out (assoc-ref outputs "out"))
  140. (man (string-append out "/share/man/man1")))
  141. (install-file "doc/diffoscope.1" man)))))))
  142. (inputs (list rpm ;for rpm-python
  143. python-debian
  144. python-libarchive-c
  145. python-magic
  146. python-tlsh
  147. acl ;for getfacl
  148. colordiff
  149. xxd))
  150. (native-inputs
  151. (append
  152. (list help2man
  153. ;; Below are packages used for tests.
  154. binwalk
  155. python-pytest
  156. python-chardet
  157. python-h5py
  158. python-pypdf2
  159. python-progressbar33
  160. abootimg
  161. bdb
  162. binutils
  163. bzip2
  164. cdrtools
  165. colord
  166. cpio
  167. docx2txt
  168. dtc
  169. e2fsprogs
  170. ffmpeg
  171. ;; XXX: Must be the same version as python-magic uses;
  172. ;; remove when 'file' is updated.
  173. file-next
  174. fpc
  175. gettext-minimal
  176. ghostscript
  177. `(,giflib "bin")
  178. gnumeric
  179. gnupg
  180. hdf5
  181. imagemagick
  182. libarchive
  183. llvm-9
  184. lz4
  185. mono
  186. ocaml
  187. odt2txt
  188. openssh
  189. openssl
  190. pgpdump
  191. poppler
  192. python-jsbeautifier
  193. r-minimal
  194. rpm
  195. sng
  196. sqlite
  197. squashfs-tools
  198. tcpdump
  199. unzip
  200. wabt
  201. xxd
  202. xz
  203. zip
  204. zstd)
  205. ;; Also for tests. The test suite skips tests when these are missing.
  206. (match (%current-system)
  207. ;; ghc is only available on x86 currently.
  208. ((or "x86_64-linux" "i686-linux")
  209. (list ghc))
  210. (_ '()))
  211. (match (%current-system)
  212. ;; openjdk and dependent packages are only
  213. ;; available on x86_64 currently.
  214. ((or "x86_64-linux")
  215. (list enjarify)
  216. ;; No unversioned openjdk available.
  217. (list `(,openjdk12 "jdk")))
  218. (_ '()))))
  219. (home-page "https://diffoscope.org/")
  220. (synopsis "Compare files, archives, and directories in depth")
  221. (description
  222. "Diffoscope tries to get to the bottom of what makes files or directories
  223. different. It recursively unpacks archives of many kinds and transforms
  224. various binary formats into more human readable forms to compare them. It can
  225. 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
  228. install.")
  229. (license license:gpl3+)))
  230. (define-public reprotest
  231. (package
  232. (name "reprotest")
  233. (version "0.7.18")
  234. (source
  235. (origin
  236. (method git-fetch)
  237. (uri (git-reference
  238. (url "https://salsa.debian.org/reproducible-builds/reprotest.git")
  239. (commit version)))
  240. (file-name (git-file-name name version))
  241. (sha256
  242. (base32
  243. "19lwsxq53isgfkvlxvxqqmbjfcim3lhcxwk7m9ddfjiynhq74949"))))
  244. (inputs
  245. (list python-debian python-distro python-libarchive-c python-rstr))
  246. (native-inputs
  247. `(("diffoscope" ,diffoscope)
  248. ("help2man" ,help2man)
  249. ("libfaketime" ,libfaketime)
  250. ("python-coverage" ,python-coverage)
  251. ("python-docutils" ,python-docutils)
  252. ("python-magic " ,python-magic)
  253. ("python-pytest " ,python-pytest)
  254. ("python-tlsh" ,python-tlsh)
  255. ("python-tox" ,python-tox)
  256. ("unzip" ,unzip)
  257. ("xxd" ,xxd)))
  258. (build-system python-build-system)
  259. (arguments
  260. `(#:phases
  261. (modify-phases %standard-phases
  262. ;; Neither glibc-locales nor glibc-utf8-locales have the C.UTF-8
  263. ;; locale or several other locales used in reprotest.
  264. (add-after 'unpack 'adjust-locales
  265. (lambda _
  266. (substitute* "reprotest/build.py"
  267. (("'C.UTF-8'") "'en_US.UTF-8'")
  268. (("'ru_RU.CP1251'") "'ru_RU.KOI8-R'")
  269. (("'kk_KZ.RK1048'") "'kk_KZ'"))
  270. (substitute* "reprotest/lib/adt_testbed.py"
  271. (("export LANG=C.UTF-8") "export LANG=en_US.UTF-8"))
  272. #t))
  273. (add-after 'install 'install-doc
  274. (lambda* (#:key outputs #:allow-other-keys)
  275. (let* ((mandir1 (string-append
  276. (assoc-ref outputs "out") "/share/man/man1"))
  277. (docdir (string-append
  278. (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version)))
  279. (invoke "make" "-C" "doc")
  280. (mkdir-p mandir1)
  281. (install-file "doc/reprotest.1" mandir1)
  282. (mkdir-p docdir)
  283. (install-file "./README.rst" docdir)
  284. (install-file "./README-dev.rst" docdir))
  285. #t)))))
  286. (home-page "https://salsa.debian.org/reproducible-builds/reprotest")
  287. (synopsis "Build software and check it for reproducibility")
  288. (description "Reprotest builds the same source code twice in different
  289. environments, and then checks the binaries produced by each build for
  290. differences. If any are found, then diffoscope or diff is used to display
  291. them in detail for later analysis.")
  292. (license (list license:gpl3+ license:gpl2+))))
  293. (define-public trydiffoscope
  294. (package
  295. (name "trydiffoscope")
  296. (version "67.0.1")
  297. (source
  298. (origin
  299. (method git-fetch)
  300. (uri (git-reference
  301. (url "https://salsa.debian.org/reproducible-builds/trydiffoscope.git")
  302. (commit version)))
  303. (file-name (git-file-name name version))
  304. (sha256
  305. (base32
  306. "03b66cjii7l2yiwffj6ym6mycd5drx7prfp4j2550281pias6mjh"))))
  307. (arguments
  308. `(#:phases
  309. (modify-phases %standard-phases
  310. (add-after 'install 'install-doc
  311. (lambda* (#:key outputs #:allow-other-keys)
  312. (let* ((share (string-append (assoc-ref outputs "out") "/share/")))
  313. (mkdir-p (string-append share "/man/man1/" ))
  314. (invoke "rst2man.py"
  315. "trydiffoscope.1.rst"
  316. (string-append share "/man/man1/trydiffoscope.1"))
  317. (mkdir-p (string-append share "/doc/" ,name "-" ,version))
  318. (install-file "./README.rst"
  319. (string-append share "/doc/" ,name "-" ,version)))
  320. #t)))))
  321. (propagated-inputs
  322. (list python-requests))
  323. (native-inputs
  324. (list gzip python-docutils))
  325. (build-system python-build-system)
  326. (home-page "https://try.diffoscope.org")
  327. (synopsis "Client for remote diffoscope service")
  328. (description "This is a client for the @url{https://try.diffoscope.org,
  329. remote diffoscope service}.
  330. Diffoscope tries to get to the bottom of what makes files or directories
  331. different. It recursively unpacks archives of many kinds and transforms
  332. various binary formats into more human readable forms to compare them. It can
  333. compare two tarballs, ISO images, or PDFs just as easily.
  334. Results are displayed by default, stored as local text or html files, or made
  335. available via a URL on @url{https://try.diffoscope.org}. Results stored on the
  336. server are purged after 30 days.")
  337. (license license:gpl3+)))