projects/guix·blob wip-postfix · refs

605 lines · 24.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2018, 2023 Eric Bavier <[email protected]>
3;;; Copyright © 2015, 2018 Leo Famulari <[email protected]>
4;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2019 Christopher Baines <[email protected]>
6;;; Copyright © 2021 Xinglu Chen <[email protected]>
7;;; Copyright © 2022 jgart <[email protected]>
8;;; Copyright © 2023 Andy Tai <[email protected]>
9;;; Copyright © 2023 Efraim Flashner <[email protected]>
10;;; Copyright © 2023 Foundation Devices, Inc. <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages patchutils)
28 #:use-module (guix gexp)
29 #:use-module (guix utils)
30 #:use-module (guix packages)
31 #:use-module (guix licenses)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system glib-or-gtk)
36 #:use-module (guix build-system meson)
37 #:use-module (guix build-system ocaml)
38 #:use-module (guix build-system python)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages ed)
42 #:use-module (gnu packages base)
43 #:use-module (gnu packages bash)
44 #:use-module (gnu packages check)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages databases)
47 #:use-module (gnu packages django)
48 #:use-module (gnu packages freedesktop)
49 #:use-module (gnu packages file)
50 #:use-module (gnu packages gawk)
51 #:use-module (gnu packages gettext)
52 #:use-module (gnu packages glib)
53 #:use-module (gnu packages gnome)
54 #:use-module (gnu packages groff)
55 #:use-module (gnu packages gtk)
56 #:use-module (gnu packages less)
57 #:use-module (gnu packages mail)
58 #:use-module (gnu packages ncurses)
59 #:use-module (gnu packages ocaml)
60 #:use-module (gnu packages package-management)
61 #:use-module (gnu packages perl)
62 #:use-module (gnu packages pkg-config)
63 #:use-module (gnu packages python)
64 #:use-module (gnu packages python-build)
65 #:use-module (gnu packages python-xyz)
66 #:use-module (gnu packages version-control)
67 #:use-module (gnu packages xml))
68
69(define-public coccinelle
70 (let ((revision "0")
71 (commit "6608e45f85a10c57a3c910154cf049a5df4d98e4"))
72 (package
73 (name "coccinelle")
74 (version (git-version "1.1.1" revision commit))
75 (source
76 (origin
77 (method git-fetch)
78 (uri (git-reference
79 (url "https://github.com/coccinelle/coccinelle")
80 (commit commit)))
81 (file-name (git-file-name name version))
82 (modules '((guix build utils)))
83 (snippet
84 #~(delete-file-recursively "bundles"))
85 (sha256
86 (base32
87 "08nycmjyckqmqjpi78dcqdbmjq1xp18qdc6023dl90gdi6hmxz9l"))))
88 (build-system gnu-build-system)
89 (arguments
90 (list #:phases
91 #~(modify-phases %standard-phases
92 (add-before 'bootstrap 'prepare-version.sh
93 (lambda _
94 (setenv "MAKE_COCCI_RELEASE" "y")
95 (patch-shebang "version.sh")))
96 (add-before 'check 'set-batch-mode
97 (lambda _
98 (substitute* "Makefile"
99 (("--testall")
100 "--batch_mode --testall")))))))
101 (propagated-inputs
102 (list ocaml-menhir
103 ocaml-num
104 ocaml-parmap
105 ocaml-pcre
106 ocaml-pyml
107 ocaml-stdcompat))
108 (native-inputs
109 (list autoconf
110 automake
111 ocaml
112 ocaml-findlib
113 pkg-config))
114 (home-page "https://coccinelle.lip6.fr")
115 (synopsis "Transformation of C code using semantic patches")
116 (description "Coccinelle is a tool that allows modification of C code
117using semantic patches in the @acronym{SmPL, Semantic Patch Language} for
118specifying desired matches and transformations in the C code.")
119 (license gpl2))))
120
121(define-public patchutils
122 (package
123 (name "patchutils")
124 (version "0.4.2")
125 (source
126 (origin
127 (method url-fetch)
128 (uri (string-append "http://cyberelk.net/tim/data/patchutils/stable/"
129 name "-" version ".tar.xz"))
130 (sha256
131 (base32
132 "1va5pzmxbzpi87vdnbjm9qdf9bvzps9xfv0gi4mycgg3bybb0xc8"))))
133 (build-system gnu-build-system)
134 (inputs
135 (list perl python))
136 (arguments
137 '(#:parallel-tests? #f
138 #:phases
139 (modify-phases %standard-phases
140 (add-before 'check 'patch-test-scripts
141 (lambda _
142 (substitute* (find-files "tests" "^run-test$")
143 (("/bin/echo") (which "echo")))))
144 (add-after 'install 'wrap-program
145 ;; Point installed scripts to the utilities they need.
146 (lambda* (#:key inputs outputs #:allow-other-keys)
147 (let* ((out (assoc-ref outputs "out"))
148 (diffutils (assoc-ref inputs "diffutils"))
149 (sed (assoc-ref inputs "sed"))
150 (gawk (assoc-ref inputs "gawk")))
151 (for-each
152 (lambda (prog)
153 (wrap-program (string-append out "/bin/" prog)
154 `("PATH" ":" prefix
155 ,(map (lambda (dir)
156 (string-append dir "/bin"))
157 (list diffutils sed gawk)))))
158 '("dehtmldiff" "editdiff" "espdiff"))))))))
159 (home-page "http://cyberelk.net/tim/software/patchutils")
160 (synopsis "Collection of tools for manipulating patch files")
161 (description
162 "Patchutils is a collection of programs that can manipulate patch files
163in useful ways such as interpolating between two pre-patches, combining two
164incremental patches, fixing line numbers in hand-edited patches, and simply
165listing the files modified by a patch.")
166 (license gpl2+)))
167
168(define-public quilt
169 (package
170 (name "quilt")
171 (version "0.67")
172 (source
173 (origin
174 (method url-fetch)
175 (uri (string-append "mirror://savannah/quilt/"
176 "quilt-" version ".tar.gz"))
177 (sha256
178 (base32 "1hiw05aqysbnnl15zg2n5cr11k0z7rz85fvq8qv6qap7hw4vxqrv"))
179 (patches (search-patches "quilt-grep-compat.patch"))))
180 (build-system gnu-build-system)
181 (native-inputs
182 (list gettext-minimal))
183 (inputs
184 (list bash-minimal perl less file gzip ed
185 diffutils diffstat findutils tar))
186 (arguments
187 '(#:parallel-tests? #f
188 #:phases
189 (modify-phases %standard-phases
190 (delete 'check)
191 (add-after 'install 'wrap-program
192 ;; quilt's configure checks for the absolute path to the utilities it
193 ;; needs, but uses only the name when invoking them, so we need to
194 ;; make sure the quilt script can find those utilities when run.
195 (lambda* (#:key inputs outputs #:allow-other-keys)
196 (let ((cmd-path (lambda (cmd) (dirname (which cmd))))
197 (out (assoc-ref outputs "out")))
198 (wrap-program (string-append out "/bin/quilt")
199 `("PATH" ":" prefix
200 ,(map cmd-path
201 (list "bash" "diff" "diffstat" "ed" "file" "find" "grep"
202 "gzip" "less" "patch" "perl" "rm" "sed" "tar"))))
203 (wrap-program (string-append out "/share/quilt/scripts/backup-files")
204 `("PATH" ":" prefix
205 ,(map cmd-path
206 (list "find" "grep" "mkdir")))))))
207 (add-after 'compress-documentation 'check
208 (lambda _
209 (substitute* '("test/run" "test/edit.test")
210 (("/bin/sh") (which "sh"))
211 (("rm -rf") (string-append (which "rm") " -rf")))
212 (substitute* "Makefile"
213 (("^(PATH|QUILT_DIR).*" &)
214 (string-append "#" &)) ; Test the installed 'quilt'
215 (("export QUILT_DIR") "export")
216 (("\\| sort") (string-append "| " (which "sort")))
217 (("\\| sed") (string-append "| " (which "sed")))
218 (("(chmod|touch)" &) (which &)))
219 ;; Tests are scripts interpreted by `test/run` and may specify
220 ;; the execution of several tools. But PATH will be empty, so
221 ;; rewrite with the full file name:
222 (setenv "PATH" (string-append %output "/bin" ":" (getenv "PATH")))
223 (substitute* (find-files "test" "\\.test$")
224 (("([\\$\\|] )([[:graph:]]+)([[:blank:]\n]+)"
225 & > cmd <)
226 (if (string=? cmd "zcat")
227 ;; The `zcat` program is a script, and it will not be able
228 ;; to invoke its `gzip` with PATH unset. It's a simple
229 ;; script though, so just translate here:
230 (string-append > (which "gzip") " -cd " <)
231 (or (and=> (which cmd)
232 (lambda (p) (string-append > p <)))
233 &))))
234 (let ((make (which "make")))
235 ;; Assert the installed 'quilt' can find utilities it needs.
236 (unsetenv "PATH")
237 ;; Used by some tests for access to internal "scripts"
238 (setenv "QUILT_DIR" (string-append %output "/share/quilt"))
239 (invoke make "check")))))))
240 (home-page "https://savannah.nongnu.org/projects/quilt/")
241 (synopsis "Script for managing patches to software")
242 (description
243 "Quilt allows you to easily manage large numbers of patches by keeping
244track of the changes each patch makes. Patches can be applied, un-applied,
245refreshed, and more.")
246 (license gpl2)))
247
248(define-public colordiff
249 (package
250 (name "colordiff")
251 (version "1.0.21")
252 (source
253 (origin
254 (method url-fetch)
255 (uri (list (string-append "https://www.colordiff.org/colordiff-"
256 version ".tar.gz")
257 (string-append "http://www.colordiff.org/archive/colordiff-"
258 version ".tar.gz")))
259 (sha256
260 (base32 "05g64z4ls1i70rpzznjxy2cpjgywisnwj9ssx9nq1w7hgqjz8c4v"))))
261 (build-system gnu-build-system)
262 (arguments
263 `(#:tests? #f ; no tests
264 #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
265 "INSTALL_DIR=/bin" "MAN_DIR=/share/man/man1")
266 #:phases
267 (modify-phases %standard-phases
268 (delete 'configure) ; no configure script
269 (delete 'build)))) ; nothing to build
270 (inputs
271 (list perl xmlto))
272 (home-page "https://www.colordiff.org")
273 (synopsis "Display diff output with colors")
274 (description
275 "Colordiff is Perl script wrapper on top of diff command which provides
276'syntax highlighting' for various patch formats.")
277 (license gpl2+)))
278
279(define-public vbindiff
280 (package
281 (name "vbindiff")
282 (version "3.0_beta5")
283 (source (origin
284 (method url-fetch)
285 (uri (string-append "https://www.cjmweb.net/vbindiff/vbindiff-"
286 version ".tar.gz"))
287 (sha256
288 (base32
289 "1f1kj4jki08bnrwpzi663mjfkrx4wnfpzdfwd2qgijlkx5ysjkgh"))))
290 (build-system gnu-build-system)
291 (inputs
292 (list ncurses))
293 (home-page "https://www.cjmweb.net/vbindiff/")
294 (synopsis "Console-based tool for comparing binary data")
295 (description "Visual Binary Diff (@command{vbindiff}) displays files in
296hexadecimal and ASCII (or EBCDIC). It can also display two files at once, and
297highlight the differences between them. It works well with large files (up to 4
298GiB).")
299 (license gpl2+)))
300
301(define-public meld
302 (package
303 (name "meld")
304 (version "3.22.0")
305 (source
306 (origin
307 (method url-fetch)
308 (uri (string-append "mirror://gnome/sources/meld/"
309 (version-major+minor version)
310 "/meld-" version ".tar.xz"))
311 (sha256
312 (base32 "03f4j27amyi28flkks8i9bhqzd6xhm6d3c6jzxc57rzniv4hgh9z"))))
313 (build-system meson-build-system)
314 (native-inputs
315 (list desktop-file-utils
316 intltool
317 itstool
318 libxml2
319 `(,glib "bin") ; for glib-compile-schemas
320 gobject-introspection
321 pkg-config
322 python))
323 (inputs
324 (list bash-minimal
325 python
326 python-pycairo
327 python-pygobject
328 gsettings-desktop-schemas
329 gtksourceview-4))
330 (propagated-inputs
331 (list dconf))
332 (arguments
333 (list
334 #:glib-or-gtk? #t
335 #:imported-modules `(,@%meson-build-system-modules
336 (guix build python-build-system))
337 #:modules '((guix build meson-build-system)
338 ((guix build python-build-system) #:prefix python:)
339 (guix build utils))
340 #:phases
341 #~(modify-phases %standard-phases
342 (add-after 'unpack 'skip-gtk-update-icon-cache
343 ;; Don't create 'icon-theme.cache'.
344 (lambda _
345 (substitute* "meson_post_install.py"
346 (("gtk-update-icon-cache") (which "true")))))
347 (add-after 'install 'copy-styles
348 (lambda* (#:key inputs outputs #:allow-other-keys)
349 (let ((styles "/share/gtksourceview-4/styles"))
350 (copy-recursively
351 (string-append (assoc-ref inputs "gtksourceview") styles)
352 (string-append (assoc-ref outputs "out") styles)))))
353 (add-after 'glib-or-gtk-wrap 'python-and-gi-wrap
354 (lambda* (#:key inputs outputs #:allow-other-keys)
355 (wrap-program (search-input-file outputs "bin/meld")
356 `("GUIX_PYTHONPATH" = (,(getenv "GUIX_PYTHONPATH")
357 ,(python:site-packages inputs outputs)))
358 `("GI_TYPELIB_PATH" = (,(getenv "GI_TYPELIB_PATH")))))))))
359 (home-page "https://meldmerge.org/")
360 (synopsis "Compare files, directories and working copies")
361 (description "Meld is a visual diff and merge tool targeted at
362developers. Meld helps you compare files, directories, and version controlled
363projects. It provides two- and three-way comparison of both files and
364directories, and has support for many popular version control systems.
365
366Meld helps you review code changes and understand patches. It might even help
367you to figure out what is going on in that merge you keep avoiding.")
368 (license gpl2)))
369
370(define-public patchwork
371 (package
372 (name "patchwork")
373 (version "3.1.1")
374 (source (origin
375 (method git-fetch)
376 (uri (git-reference
377 (url "https://github.com/getpatchwork/patchwork")
378 (commit (string-append "v" version))))
379 (file-name (git-file-name name version))
380 (sha256
381 (base32
382 "0is9d4gf93jcbyshyj2k3kjyrjnvimrm6bai6dbcx630md222j5w"))))
383 (build-system python-build-system)
384 (arguments
385 `(;; TODO: Tests require a running database
386 #:tests? #f
387 #:phases
388 (modify-phases %standard-phases
389 (delete 'configure)
390 (delete 'build)
391 (add-after 'unpack 'replace-wsgi.py
392 (lambda* (#:key inputs outputs #:allow-other-keys)
393 (delete-file "patchwork/wsgi.py")
394 (call-with-output-file "patchwork/wsgi.py"
395 (lambda (port)
396 ;; Embed the PYTHONPATH containing the dependencies, as well
397 ;; as the python modules in this package in the wsgi.py file,
398 ;; as this will ensure they are available at runtime.
399 (define pythonpath
400 (string-append (getenv "GUIX_PYTHONPATH")
401 ":"
402 (site-packages inputs outputs)))
403 (display
404 (string-append "
405import os, sys
406
407sys.path.extend('" pythonpath "'.split(':'))
408
409from django.core.wsgi import get_wsgi_application
410
411# By default, assume that patchwork is running as a Guix service, which
412# provides the settings as the 'guix.patchwork.settings' Python module.
413#
414# When using httpd, it's hard to set environment variables, so rely on the
415# default set here.
416os.environ['DJANGO_SETTINGS_MODULE'] = os.getenv(
417 'DJANGO_SETTINGS_MODULE',
418 'guix.patchwork.settings' # default
419)
420
421application = get_wsgi_application()\n") port)))))
422 (replace 'check
423 (lambda* (#:key tests? #:allow-other-keys)
424 (when tests?
425 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
426 (invoke "python" "-Wonce" "./manage.py" "test" "--noinput"))
427 #t))
428 (replace 'install
429 (lambda* (#:key inputs outputs #:allow-other-keys)
430 (let ((out (assoc-ref outputs "out"))
431 (out-site-packages (site-packages inputs outputs)))
432 (for-each (lambda (directory)
433 (copy-recursively
434 directory
435 (string-append out-site-packages "/" directory)))
436 '(;; Contains the python code
437 "patchwork"
438 ;; Contains the templates for the generated HTML
439 "templates"))
440 (delete-file-recursively
441 (string-append out-site-packages "/patchwork/tests"))
442
443 ;; Install patchwork related tools
444 (for-each (lambda (file)
445 (install-file file (string-append out "/bin")))
446 (list
447 (string-append out-site-packages
448 "/patchwork/bin/parsemail.sh")
449 (string-append out-site-packages
450 "/patchwork/bin/parsemail-batch.sh")))
451
452 ;; Collect the static assets, this includes JavaScript, CSS and
453 ;; fonts. This is a standard Django process when running a
454 ;; Django application for regular use, and includes assets for
455 ;; dependencies like the admin site from Django.
456 ;;
457 ;; The intent here is that you can serve files from this
458 ;; directory through a webserver, which is recommended when
459 ;; running Django applications.
460 (let ((static-root
461 (string-append out "/share/patchwork/htdocs")))
462 (mkdir-p static-root)
463 (copy-file "patchwork/settings/production.example.py"
464 "patchwork/settings/assets.py")
465 (setenv "DJANGO_SECRET_KEY" "dummyvalue")
466 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.assets")
467 (setenv "STATIC_ROOT" static-root)
468 (invoke "./manage.py" "collectstatic" "--no-input"))
469
470 ;; The lib directory includes example configuration files that
471 ;; may be useful when deploying patchwork.
472 (copy-recursively "lib"
473 (string-append
474 out "/share/doc/" ,name "-" ,version)))
475 #t))
476 ;; The hasher script is used from the post-receive.hook
477 (add-after 'install 'install-hasher
478 (lambda* (#:key inputs outputs #:allow-other-keys)
479 (let* ((out (assoc-ref outputs "out"))
480 (out-site-packages (site-packages inputs outputs))
481 (out-hasher.py (string-append out-site-packages
482 "/patchwork/hasher.py")))
483 (chmod out-hasher.py #o555)
484 (symlink out-hasher.py (string-append out "/bin/hasher")))
485 #t))
486 ;; Create a patchwork specific version of Django's command line admin
487 ;; utility.
488 (add-after 'install 'install-patchwork-admin
489 (lambda* (#:key inputs outputs #:allow-other-keys)
490 (let* ((out (assoc-ref outputs "out")))
491 (mkdir-p (string-append out "/bin"))
492 (call-with-output-file (string-append out "/bin/patchwork-admin")
493 (lambda (port)
494 (simple-format port "#!~A
495import os, sys
496
497if __name__ == \"__main__\":
498 from django.core.management import execute_from_command_line
499
500 execute_from_command_line(sys.argv)" (which "python"))))
501 (chmod (string-append out "/bin/patchwork-admin") #o555))
502 #t)))))
503 (inputs
504 (list python-wrapper))
505 (propagated-inputs
506 (list python-django-3.2
507 ;; TODO: Make this configurable
508 python-psycopg2
509 python-mysqlclient
510 python-django-filter
511 python-django-rest-framework
512 python-django-debug-toolbar))
513 (synopsis "Web based patch tracking system")
514 (description
515 "Patchwork is a patch tracking system. It takes in emails containing
516patches, and displays the patches along with comments and state information.
517Users can login allowing them to change the state of patches.")
518 (home-page "http://jk.ozlabs.org/projects/patchwork/")
519 (license gpl2+)))
520
521(define-public wiggle
522 (package
523 (name "wiggle")
524 (version "1.3")
525 (source (origin
526 (method git-fetch)
527 (uri (git-reference
528 (url "https://github.com/neilbrown/wiggle")
529 (commit (string-append "v" version))))
530 (file-name (git-file-name name version))
531 (sha256
532 (base32
533 "18ilzr9sbal1j8p1d94ilm1j5blac5cngvcvjpdmgmpw6diy2ldf"))))
534 (build-system gnu-build-system)
535 (arguments
536 (list
537 #:make-flags
538 #~(list "CFLAGS=-I. -O3" "INSTALL=install" "STRIP=-s"
539 (string-append "CC=" #$(cc-for-target))
540 (string-append "BINDIR=" #$output "/bin")
541 (string-append "MANDIR=" #$output "/share/man")
542 (string-append "PREFIX=" #$output))
543 #:test-target "test"
544 #:phases
545 #~(modify-phases %standard-phases
546 (delete 'configure))))
547 (home-page "http://neil.brown.name/wiggle/")
548 (inputs (list ncurses))
549 (native-inputs (list groff))
550 (synopsis "Apply patches with conflicts")
551 (description
552 "@code{wiggle} attempts to apply patches to a target file even if the
553patches do not match perfectly.")
554 (license gpl2+)))
555
556(define-public pwclient
557 (package
558 (name "pwclient")
559 (version "1.3.0")
560 (source (origin
561 (method git-fetch)
562 (uri (git-reference
563 (url "https://github.com/getpatchwork/pwclient")
564 (commit version)))
565 (file-name (git-file-name name version))
566 (sha256
567 (base32
568 "1xckwvcqklzpyh3xs4k2zm40ifp0q5fdkj2vmgb8vhfvl1ivs6jv"))))
569 (build-system python-build-system)
570 (arguments
571 `(#:phases
572 (modify-phases %standard-phases
573 (add-after 'unpack 'patch-requirements
574 (lambda _
575 (substitute* "test-requirements.txt"
576 ;; The pytest requirement is unnecessarily strict
577 (("pytest>=3.0,<5.0;")
578 "pytest>=3.0,<6.0;"))
579 #t))
580 (add-before 'build 'set-PBR_VERSION
581 (lambda _
582 (setenv "PBR_VERSION"
583 ,version)
584 #t))
585 (replace 'check
586 (lambda* (#:key tests? #:allow-other-keys)
587 (when tests?
588 (invoke "pytest"))
589 #t))
590 (add-after 'install 'install-man-page
591 (lambda* (#:key outputs #:allow-other-keys)
592 (install-file "man/pwclient.1"
593 (string-append
594 (assoc-ref outputs "out")
595 "/share/man/man1"))
596 #t)))))
597 (native-inputs
598 (list python-pbr python-pytest python-pytest-cov python-mock))
599 (home-page
600 "https://github.com/getpatchwork/pwclient")
601 (synopsis "Command-line client for the Patchwork patch tracking tool")
602 (description
603 "pwclient is a VCS-agnostic tool for interacting with Patchwork, the
604web-based patch tracking system.")
605 (license gpl2+)))