patchutils.scm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2018 Eric Bavier <bavier@member.fsf.org>
  3. ;;; Copyright © 2015, 2018 Leo Famulari <leo@famulari.name>
  4. ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
  6. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages patchutils)
  23. #:use-module (guix utils)
  24. #:use-module (guix packages)
  25. #:use-module (guix licenses)
  26. #:use-module (guix download)
  27. #:use-module (guix git-download)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix build-system python)
  30. #:use-module (gnu packages)
  31. #:use-module (gnu packages ed)
  32. #:use-module (gnu packages base)
  33. #:use-module (gnu packages bash)
  34. #:use-module (gnu packages check)
  35. #:use-module (gnu packages databases)
  36. #:use-module (gnu packages django)
  37. #:use-module (gnu packages file)
  38. #:use-module (gnu packages gawk)
  39. #:use-module (gnu packages gettext)
  40. #:use-module (gnu packages glib)
  41. #:use-module (gnu packages gnome)
  42. #:use-module (gnu packages gtk)
  43. #:use-module (gnu packages less)
  44. #:use-module (gnu packages mail)
  45. #:use-module (gnu packages ncurses)
  46. #:use-module (gnu packages perl)
  47. #:use-module (gnu packages python)
  48. #:use-module (gnu packages python-xyz)
  49. #:use-module (gnu packages version-control)
  50. #:use-module (gnu packages xml))
  51. (define-public patchutils
  52. (package
  53. (name "patchutils")
  54. (version "0.4.2")
  55. (source
  56. (origin
  57. (method url-fetch)
  58. (uri (string-append "http://cyberelk.net/tim/data/patchutils/stable/"
  59. name "-" version ".tar.xz"))
  60. (sha256
  61. (base32
  62. "1va5pzmxbzpi87vdnbjm9qdf9bvzps9xfv0gi4mycgg3bybb0xc8"))))
  63. (build-system gnu-build-system)
  64. (inputs
  65. (list perl python))
  66. (arguments
  67. '(#:parallel-tests? #f
  68. #:phases
  69. (modify-phases %standard-phases
  70. (add-before 'check 'patch-test-scripts
  71. (lambda _
  72. (substitute* (find-files "tests" "^run-test$")
  73. (("/bin/echo") (which "echo")))))
  74. (add-after 'install 'wrap-program
  75. ;; Point installed scripts to the utilities they need.
  76. (lambda* (#:key inputs outputs #:allow-other-keys)
  77. (let* ((out (assoc-ref outputs "out"))
  78. (diffutils (assoc-ref inputs "diffutils"))
  79. (sed (assoc-ref inputs "sed"))
  80. (gawk (assoc-ref inputs "gawk")))
  81. (for-each
  82. (lambda (prog)
  83. (wrap-program (string-append out "/bin/" prog)
  84. `("PATH" ":" prefix
  85. ,(map (lambda (dir)
  86. (string-append dir "/bin"))
  87. (list diffutils sed gawk)))))
  88. '("dehtmldiff" "editdiff" "espdiff"))))))))
  89. (home-page "http://cyberelk.net/tim/software/patchutils")
  90. (synopsis "Collection of tools for manipulating patch files")
  91. (description
  92. "Patchutils is a collection of programs that can manipulate patch files
  93. in useful ways such as interpolating between two pre-patches, combining two
  94. incremental patches, fixing line numbers in hand-edited patches, and simply
  95. listing the files modified by a patch.")
  96. (license gpl2+)))
  97. (define-public quilt
  98. (package
  99. (name "quilt")
  100. (version "0.66")
  101. (source
  102. (origin
  103. (method url-fetch)
  104. (uri (string-append "mirror://savannah/quilt/"
  105. "quilt-" version ".tar.gz"))
  106. (sha256
  107. (base32 "01vfvk4pqigahx82fhaaffg921ivd3k7rylz1yfvy4zbdyd32jri"))))
  108. (build-system gnu-build-system)
  109. (native-inputs
  110. `(("gettext" ,gettext-minimal)))
  111. (inputs (list perl less file ed diffstat))
  112. (arguments
  113. '(#:parallel-tests? #f
  114. #:phases
  115. (modify-phases %standard-phases
  116. (add-before 'check 'patch-tests
  117. (lambda _
  118. (substitute*
  119. '("test/run"
  120. "test/edit.test")
  121. (("/bin/sh") (which "sh")))
  122. #t))
  123. (add-after 'install 'wrap-program
  124. ;; quilt's configure checks for the absolute path to the utilities it
  125. ;; needs, but uses only the name when invoking them, so we need to
  126. ;; make sure the quilt script can find those utilities when run.
  127. (lambda* (#:key inputs outputs #:allow-other-keys)
  128. (let* ((out (assoc-ref outputs "out"))
  129. (coreutils (assoc-ref inputs "coreutils"))
  130. (diffutils (assoc-ref inputs "diffutils"))
  131. (findutils (assoc-ref inputs "findutils"))
  132. (diffstat (assoc-ref inputs "diffstat"))
  133. (less (assoc-ref inputs "less"))
  134. (file (assoc-ref inputs "file"))
  135. (ed (assoc-ref inputs "ed"))
  136. (sed (assoc-ref inputs "sed"))
  137. (bash (assoc-ref inputs "bash"))
  138. (grep (assoc-ref inputs "grep")))
  139. (wrap-program (string-append out "/bin/quilt")
  140. `("PATH" ":" prefix
  141. ,(map (lambda (dir)
  142. (string-append dir "/bin"))
  143. (list coreutils diffutils findutils
  144. less file ed sed bash grep
  145. diffstat)))))
  146. #t)))))
  147. (home-page "https://savannah.nongnu.org/projects/quilt/")
  148. (synopsis "Script for managing patches to software")
  149. (description
  150. "Quilt allows you to easily manage large numbers of patches by keeping
  151. track of the changes each patch makes. Patches can be applied, un-applied,
  152. refreshed, and more.")
  153. (license gpl2)))
  154. (define-public colordiff
  155. (package
  156. (name "colordiff")
  157. (version "1.0.19")
  158. (source
  159. (origin
  160. (method url-fetch)
  161. (uri (list (string-append "https://www.colordiff.org/colordiff-"
  162. version ".tar.gz")
  163. (string-append "http://www.colordiff.org/archive/colordiff-"
  164. version ".tar.gz")))
  165. (sha256
  166. (base32 "069vzzgs7b44bmfh3ks2psrdb26s1w19gp9w4xxbgi7nhx6w3s26"))))
  167. (build-system gnu-build-system)
  168. (arguments
  169. `(#:tests? #f ; no tests
  170. #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
  171. "INSTALL_DIR=/bin" "MAN_DIR=/share/man/man1")
  172. #:phases
  173. (modify-phases %standard-phases
  174. (delete 'configure) ; no configure script
  175. (delete 'build)))) ; nothing to build
  176. (inputs
  177. (list perl xmlto))
  178. (home-page "https://www.colordiff.org")
  179. (synopsis "Display diff output with colors")
  180. (description
  181. "Colordiff is Perl script wrapper on top of diff command which provides
  182. 'syntax highlighting' for various patch formats.")
  183. (license gpl2+)))
  184. (define-public patches
  185. (let ((commit "ef1b8a7d954b82ed4af3a08fd63d2085d19090ef"))
  186. (package
  187. (name "patches")
  188. (home-page "https://github.com/stefanha/patches")
  189. (version (string-append "0.0-1." (string-take commit 7)))
  190. (source (origin
  191. (method git-fetch)
  192. (uri (git-reference
  193. (url home-page)
  194. (commit commit)))
  195. (sha256
  196. (base32
  197. "11rdmhv0l1s8nqb20ywmw2zqizczch2p62qf9apyx5wqgxlnjshk"))
  198. (file-name (string-append name "-"version "-checkout"))))
  199. (build-system python-build-system)
  200. (inputs (list python2-notmuch))
  201. (arguments
  202. `(#:tests? #f ;no "test" target
  203. #:python ,python-2)) ;not compatible with Python 3
  204. (synopsis "Patch tracking tool")
  205. (description
  206. "@code{Patches} is a patch-tracking tool initially written for the QEMU
  207. project. It provides commands that build a database of patches from a mailing
  208. list, and commands that can search that database. It allows users to track
  209. the status of a patch, apply patches, and search for patches---all that from
  210. the command-line or from Emacs via its Notmuch integration.")
  211. (license gpl2+))))
  212. (define-public vbindiff
  213. (package
  214. (name "vbindiff")
  215. (version "3.0_beta5")
  216. (source (origin
  217. (method url-fetch)
  218. (uri (string-append "https://www.cjmweb.net/vbindiff/vbindiff-"
  219. version ".tar.gz"))
  220. (sha256
  221. (base32
  222. "1f1kj4jki08bnrwpzi663mjfkrx4wnfpzdfwd2qgijlkx5ysjkgh"))))
  223. (build-system gnu-build-system)
  224. (inputs
  225. (list ncurses))
  226. (home-page "https://www.cjmweb.net/vbindiff/")
  227. (synopsis "Console-based tool for comparing binary data")
  228. (description "Visual Binary Diff (@command{vbindiff}) displays files in
  229. hexadecimal and ASCII (or EBCDIC). It can also display two files at once, and
  230. highlight the differences between them. It works well with large files (up to 4
  231. GiB).")
  232. (license gpl2+)))
  233. (define-public meld
  234. (package
  235. (name "meld")
  236. (version "3.20.4")
  237. (source
  238. (origin
  239. (method url-fetch)
  240. (uri (string-append "mirror://gnome/sources/meld/"
  241. (version-major+minor version)
  242. "/meld-" version ".tar.xz"))
  243. (sha256
  244. (base32 "04vx2mdbcdin0g3w8x910czfch5vyrl8drv1f2l8gxh6qvp113pl"))))
  245. (build-system python-build-system)
  246. (native-inputs
  247. `(("intltool" ,intltool)
  248. ("xmllint" ,libxml2)
  249. ("glib-compile-schemas" ,glib "bin")
  250. ("python-pytest" ,python-pytest)))
  251. (inputs
  252. `(("python-cairo" ,python-pycairo)
  253. ("python-gobject" ,python-pygobject)
  254. ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
  255. ("gtksourceview" ,gtksourceview-3)))
  256. (propagated-inputs
  257. (list dconf))
  258. (arguments
  259. `(#:imported-modules ((guix build glib-or-gtk-build-system)
  260. ,@%python-build-system-modules)
  261. #:modules ((guix build python-build-system)
  262. ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
  263. (guix build utils))
  264. #:phases
  265. (modify-phases %standard-phases
  266. ;; This setup.py script does not support one of the Python build
  267. ;; system's default flags, "--single-version-externally-managed".
  268. (replace 'install
  269. (lambda* (#:key outputs #:allow-other-keys)
  270. (invoke "python" "setup.py"
  271. ;; This setup.py runs gtk-update-icon-cache which we don't want.
  272. "--no-update-icon-cache"
  273. ;; "--no-compile-schemas"
  274. "install"
  275. (string-append "--prefix=" (assoc-ref outputs "out"))
  276. "--root=/")))
  277. ;; The tests need to be run after installation.
  278. (delete 'check)
  279. (add-after 'install 'check
  280. (lambda* (#:key inputs outputs #:allow-other-keys)
  281. ;; Tests look for installed package
  282. (add-installed-pythonpath inputs outputs)
  283. ;; The tests fail when HOME=/homeless-shelter.
  284. (setenv "HOME" "/tmp")
  285. (invoke "py.test" "-v" "-k"
  286. ;; TODO: Those tests fail, why?
  287. "not test_classify_change_actions")))
  288. (add-after 'install 'copy-styles
  289. (lambda* (#:key inputs outputs #:allow-other-keys)
  290. (let ((styles "/share/gtksourceview-3.0/styles"))
  291. (copy-recursively
  292. (string-append (assoc-ref inputs "gtksourceview") styles)
  293. (string-append (assoc-ref outputs "out") styles))
  294. #t)))
  295. (add-after 'wrap 'glib-or-gtk-wrap
  296. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
  297. (add-after 'wrap 'wrap-typelib
  298. (lambda* (#:key inputs outputs #:allow-other-keys)
  299. (let ((out (assoc-ref outputs "out")))
  300. (wrap-program (string-append out "/bin/meld")
  301. `("GI_TYPELIB_PATH" prefix
  302. ,(search-path-as-string->list (getenv "GI_TYPELIB_PATH"))))
  303. #t))))))
  304. (home-page "https://meldmerge.org/")
  305. (synopsis "Compare files, directories and working copies")
  306. (description "Meld is a visual diff and merge tool targeted at
  307. developers. Meld helps you compare files, directories, and version controlled
  308. projects. It provides two- and three-way comparison of both files and
  309. directories, and has support for many popular version control systems.
  310. Meld helps you review code changes and understand patches. It might even help
  311. you to figure out what is going on in that merge you keep avoiding.")
  312. (license gpl2)))
  313. (define-public patchwork
  314. (package
  315. (name "patchwork")
  316. (version "3.0.4")
  317. (source (origin
  318. (method git-fetch)
  319. (uri (git-reference
  320. (url "https://github.com/getpatchwork/patchwork")
  321. (commit (string-append "v" version))))
  322. (file-name (git-file-name name version))
  323. (sha256
  324. (base32
  325. "0dl0prsyzsnlq6g0jw05mxx00bq9y2rpc3vrbfxfiblyyydrn2xn"))))
  326. (build-system python-build-system)
  327. (arguments
  328. `(;; TODO: Tests require a running database
  329. #:tests? #f
  330. #:phases
  331. (modify-phases %standard-phases
  332. (delete 'configure)
  333. (delete 'build)
  334. (add-after 'unpack 'replace-wsgi.py
  335. (lambda* (#:key inputs outputs #:allow-other-keys)
  336. (delete-file "patchwork/wsgi.py")
  337. (call-with-output-file "patchwork/wsgi.py"
  338. (lambda (port)
  339. ;; Embed the PYTHONPATH containing the dependencies, as well
  340. ;; as the python modules in this package in the wsgi.py file,
  341. ;; as this will ensure they are available at runtime.
  342. (define pythonpath
  343. (string-append (getenv "GUIX_PYTHONPATH")
  344. ":"
  345. (site-packages inputs outputs)))
  346. (display
  347. (string-append "
  348. import os, sys
  349. sys.path.extend('" pythonpath "'.split(':'))
  350. from django.core.wsgi import get_wsgi_application
  351. # By default, assume that patchwork is running as a Guix service, which
  352. # provides the settings as the 'guix.patchwork.settings' Python module.
  353. #
  354. # When using httpd, it's hard to set environment variables, so rely on the
  355. # default set here.
  356. os.environ['DJANGO_SETTINGS_MODULE'] = os.getenv(
  357. 'DJANGO_SETTINGS_MODULE',
  358. 'guix.patchwork.settings' # default
  359. )
  360. application = get_wsgi_application()\n") port)))))
  361. (replace 'check
  362. (lambda* (#:key tests? #:allow-other-keys)
  363. (when tests?
  364. (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
  365. (invoke "python" "-Wonce" "./manage.py" "test" "--noinput"))
  366. #t))
  367. (replace 'install
  368. (lambda* (#:key inputs outputs #:allow-other-keys)
  369. (let ((out (assoc-ref outputs "out"))
  370. (out-site-packages (site-packages inputs outputs)))
  371. (for-each (lambda (directory)
  372. (copy-recursively
  373. directory
  374. (string-append out-site-packages "/" directory)))
  375. '(;; Contains the python code
  376. "patchwork"
  377. ;; Contains the templates for the generated HTML
  378. "templates"))
  379. (delete-file-recursively
  380. (string-append out-site-packages "/patchwork/tests"))
  381. ;; Install patchwork related tools
  382. (for-each (lambda (file)
  383. (install-file file (string-append out "/bin")))
  384. (list
  385. (string-append out-site-packages
  386. "/patchwork/bin/parsemail.sh")
  387. (string-append out-site-packages
  388. "/patchwork/bin/parsemail-batch.sh")))
  389. ;; Collect the static assets, this includes JavaScript, CSS and
  390. ;; fonts. This is a standard Django process when running a
  391. ;; Django application for regular use, and includes assets for
  392. ;; dependencies like the admin site from Django.
  393. ;;
  394. ;; The intent here is that you can serve files from this
  395. ;; directory through a webserver, which is recommended when
  396. ;; running Django applications.
  397. (let ((static-root
  398. (string-append out "/share/patchwork/htdocs")))
  399. (mkdir-p static-root)
  400. (copy-file "patchwork/settings/production.example.py"
  401. "patchwork/settings/assets.py")
  402. (setenv "DJANGO_SECRET_KEY" "dummyvalue")
  403. (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.assets")
  404. (setenv "STATIC_ROOT" static-root)
  405. (invoke "./manage.py" "collectstatic" "--no-input"))
  406. ;; The lib directory includes example configuration files that
  407. ;; may be useful when deploying patchwork.
  408. (copy-recursively "lib"
  409. (string-append
  410. out "/share/doc/" ,name "-" ,version)))
  411. #t))
  412. ;; The hasher script is used from the post-receive.hook
  413. (add-after 'install 'install-hasher
  414. (lambda* (#:key inputs outputs #:allow-other-keys)
  415. (let* ((out (assoc-ref outputs "out"))
  416. (out-site-packages (site-packages inputs outputs))
  417. (out-hasher.py (string-append out-site-packages
  418. "/patchwork/hasher.py")))
  419. (chmod out-hasher.py #o555)
  420. (symlink out-hasher.py (string-append out "/bin/hasher")))
  421. #t))
  422. ;; Create a patchwork specific version of Django's command line admin
  423. ;; utility.
  424. (add-after 'install 'install-patchwork-admin
  425. (lambda* (#:key inputs outputs #:allow-other-keys)
  426. (let* ((out (assoc-ref outputs "out")))
  427. (mkdir-p (string-append out "/bin"))
  428. (call-with-output-file (string-append out "/bin/patchwork-admin")
  429. (lambda (port)
  430. (simple-format port "#!~A
  431. import os, sys
  432. if __name__ == \"__main__\":
  433. from django.core.management import execute_from_command_line
  434. execute_from_command_line(sys.argv)" (which "python"))))
  435. (chmod (string-append out "/bin/patchwork-admin") #o555))
  436. #t)))))
  437. (inputs
  438. (list python-wrapper))
  439. (propagated-inputs
  440. (list python-django-3.2
  441. ;; TODO: Make this configurable
  442. python-psycopg2
  443. python-mysqlclient
  444. python-django-filter
  445. python-django-rest-framework
  446. python-django-debug-toolbar))
  447. (synopsis "Web based patch tracking system")
  448. (description
  449. "Patchwork is a patch tracking system. It takes in emails containing
  450. patches, and displays the patches along with comments and state information.
  451. Users can login allowing them to change the state of patches.")
  452. (home-page "http://jk.ozlabs.org/projects/patchwork/")
  453. (license gpl2+)))
  454. (define-public pwclient
  455. (package
  456. (name "pwclient")
  457. (version "1.3.0")
  458. (source (origin
  459. (method git-fetch)
  460. (uri (git-reference
  461. (url "https://github.com/getpatchwork/pwclient")
  462. (commit version)))
  463. (file-name (git-file-name name version))
  464. (sha256
  465. (base32
  466. "1xckwvcqklzpyh3xs4k2zm40ifp0q5fdkj2vmgb8vhfvl1ivs6jv"))))
  467. (build-system python-build-system)
  468. (arguments
  469. `(#:phases
  470. (modify-phases %standard-phases
  471. (add-after 'unpack 'patch-requirements
  472. (lambda _
  473. (substitute* "test-requirements.txt"
  474. ;; The pytest requirement is unnecessarily strict
  475. (("pytest>=3.0,<5.0;")
  476. "pytest>=3.0,<6.0;"))
  477. #t))
  478. (add-before 'build 'set-PBR_VERSION
  479. (lambda _
  480. (setenv "PBR_VERSION"
  481. ,version)
  482. #t))
  483. (replace 'check
  484. (lambda* (#:key tests? #:allow-other-keys)
  485. (when tests?
  486. (invoke "pytest"))
  487. #t))
  488. (add-after 'install 'install-man-page
  489. (lambda* (#:key outputs #:allow-other-keys)
  490. (install-file "man/pwclient.1"
  491. (string-append
  492. (assoc-ref outputs "out")
  493. "/share/man/man1"))
  494. #t)))))
  495. (native-inputs
  496. (list python-pbr python-pytest python-pytest-cov python-mock))
  497. (home-page
  498. "https://github.com/getpatchwork/pwclient")
  499. (synopsis "Command-line client for the Patchwork patch tracking tool")
  500. (description
  501. "pwclient is a VCS-agnostic tool for interacting with Patchwork, the
  502. web-based patch tracking system.")
  503. (license gpl2+)))