summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-03 19:55:29 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-31 20:22:23 +0100
commit4764c6cc4671c06a2dd6be41b4b512fd80fa759a (patch)
treef31983dd9e624df2768b275a2582f383bfafb004 /gnu
parentf6b0e1f8ff6a6459d7d39238ced165f4caa988fe (diff)
gnu: Add patchwork.
* gnu/packages/patchutils.scm (patchwork): New variable.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/patchutils.scm167
1 files changed, 167 insertions, 0 deletions
diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
index f6197b98eea..687864c0087 100644
--- a/gnu/packages/patchutils.scm
+++ b/gnu/packages/patchutils.scm
@@ -2,6 +2,7 @@
2;;; Copyright © 2014, 2018 Eric Bavier <bavier@member.fsf.org> 2;;; Copyright © 2014, 2018 Eric Bavier <bavier@member.fsf.org>
3;;; Copyright © 2015, 2018 Leo Famulari <leo@famulari.name> 3;;; Copyright © 2015, 2018 Leo Famulari <leo@famulari.name>
4;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr> 4;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
5;;; 6;;;
6;;; This file is part of GNU Guix. 7;;; This file is part of GNU Guix.
7;;; 8;;;
@@ -31,6 +32,8 @@
31 #:use-module (gnu packages base) 32 #:use-module (gnu packages base)
32 #:use-module (gnu packages bash) 33 #:use-module (gnu packages bash)
33 #:use-module (gnu packages check) 34 #:use-module (gnu packages check)
35 #:use-module (gnu packages databases)
36 #:use-module (gnu packages django)
34 #:use-module (gnu packages file) 37 #:use-module (gnu packages file)
35 #:use-module (gnu packages gawk) 38 #:use-module (gnu packages gawk)
36 #:use-module (gnu packages gettext) 39 #:use-module (gnu packages gettext)
@@ -300,3 +303,167 @@ directories, and has support for many popular version control systems.
300Meld helps you review code changes and understand patches. It might even help 303Meld helps you review code changes and understand patches. It might even help
301you to figure out what is going on in that merge you keep avoiding.") 304you to figure out what is going on in that merge you keep avoiding.")
302 (license gpl2))) 305 (license gpl2)))
306
307(define-public patchwork
308 (package
309 (name "patchwork")
310 (version "2.1.2")
311 (source (origin
312 (method git-fetch)
313 (uri (git-reference
314 (url "https://github.com/getpatchwork/patchwork.git")
315 (commit (string-append "v" version))))
316 (file-name (git-file-name name version))
317 (sha256
318 (base32
319 "06ng5pv6744w98zkyfm0ldkmpdgnsql3gbbbh6awq61sr2ndr3qw"))))
320 (build-system python-build-system)
321 (arguments
322 `(;; TODO: Tests require a running database
323 #:tests? #f
324 #:phases
325 (modify-phases %standard-phases
326 (delete 'configure)
327 (delete 'build)
328 (add-after 'unpack 'replace-wsgi.py
329 (lambda* (#:key inputs outputs #:allow-other-keys)
330 (delete-file "patchwork/wsgi.py")
331 (call-with-output-file "patchwork/wsgi.py"
332 (lambda (port)
333 ;; Embed the PYTHONPATH containing the dependencies, as well
334 ;; as the python modules in this package in the wsgi.py file,
335 ;; as this will ensure they are available at runtime.
336 (define pythonpath
337 (string-append (getenv "PYTHONPATH")
338 ":"
339 (site-packages inputs outputs)))
340 (display
341 (string-append "
342import os, sys
343
344sys.path.extend('" pythonpath "'.split(':'))
345
346from django.core.wsgi import get_wsgi_application
347
348# By default, assume that patchwork is running as a Guix service, which
349# provides the settings as the 'guix.patchwork.settings' Python module.
350#
351# When using httpd, it's hard to set environment variables, so rely on the
352# default set here.
353os.environ['DJANGO_SETTINGS_MODULE'] = os.getenv(
354 'DJANGO_SETTINGS_MODULE',
355 'guix.patchwork.settings' # default
356)
357
358application = get_wsgi_application()\n") port)))))
359 (replace 'check
360 (lambda* (#:key tests? #:allow-other-keys)
361 (when tests?
362 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
363 (invoke "python" "-Wonce" "./manage.py" "test" "--noinput"))
364 #t))
365 (replace 'install
366 (lambda* (#:key inputs outputs #:allow-other-keys)
367 (let ((out (assoc-ref outputs "out"))
368 (out-site-packages (site-packages inputs outputs)))
369 (for-each (lambda (directory)
370 (copy-recursively
371 directory
372 (string-append out-site-packages directory)))
373 '(;; Contains the python code
374 "patchwork"
375 ;; Contains the templates for the generated HTML
376 "templates"))
377 (delete-file-recursively
378 (string-append out-site-packages "patchwork/tests"))
379
380 ;; Install patchwork related tools
381 (for-each (lambda (file)
382 (install-file file (string-append out "/bin")))
383 (list
384 (string-append out-site-packages
385 "patchwork/bin/pwclient")
386 (string-append out-site-packages
387 "patchwork/bin/parsemail.sh")
388 (string-append out-site-packages
389 "patchwork/bin/parsemail-batch.sh")))
390
391 ;; Delete the symlink to pwclient, and replace it with the
392 ;; actual file, as this can cause issues when serving the file
393 ;; from a webserver.
394 (let ((template-pwclient (string-append
395 out-site-packages
396 "patchwork/templates/patchwork/pwclient")))
397 (delete-file template-pwclient)
398 (copy-file (string-append out-site-packages
399 "patchwork/bin/pwclient")
400 template-pwclient))
401
402 ;; Collect the static assets, this includes JavaScript, CSS and
403 ;; fonts. This is a standard Django process when running a
404 ;; Django application for regular use, and includes assets for
405 ;; dependencies like the admin site from Django.
406 ;;
407 ;; The intent here is that you can serve files from this
408 ;; directory through a webserver, which is recommended when
409 ;; running Django applications.
410 (let ((static-root
411 (string-append out "/share/patchwork/htdocs")))
412 (mkdir-p static-root)
413 (copy-file "patchwork/settings/production.example.py"
414 "patchwork/settings/assets.py")
415 (setenv "DJANGO_SECRET_KEY" "dummyvalue")
416 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.assets")
417 (setenv "STATIC_ROOT" static-root)
418 (invoke "./manage.py" "collectstatic" "--no-input"))
419
420 ;; The lib directory includes example configuration files that
421 ;; may be useful when deploying patchwork.
422 (copy-recursively "lib"
423 (string-append
424 out "/share/doc/" ,name "-" ,version)))
425 #t))
426 ;; The hasher script is used from the post-receive.hook
427 (add-after 'install 'install-hasher
428 (lambda* (#:key inputs outputs #:allow-other-keys)
429 (let* ((out (assoc-ref outputs "out"))
430 (out-site-packages (site-packages inputs outputs))
431 (out-hasher.py (string-append out-site-packages
432 "/patchwork/hasher.py")))
433 (chmod out-hasher.py #o555)
434 (symlink out-hasher.py (string-append out "/bin/hasher")))
435 #t))
436 ;; Create a patchwork specific version of Django's command line admin
437 ;; utility.
438 (add-after 'install 'install-patchwork-admin
439 (lambda* (#:key inputs outputs #:allow-other-keys)
440 (let* ((out (assoc-ref outputs "out")))
441 (mkdir-p (string-append out "/bin"))
442 (call-with-output-file (string-append out "/bin/patchwork-admin")
443 (lambda (port)
444 (simple-format port "#!~A
445import os, sys
446
447if __name__ == \"__main__\":
448 from django.core.management import execute_from_command_line
449
450 execute_from_command_line(sys.argv)" (which "python"))))
451 (chmod (string-append out "/bin/patchwork-admin") #o555))
452 #t)))))
453 (inputs
454 `(("python-wrapper" ,python-wrapper)))
455 (propagated-inputs
456 `(("python-django" ,python-django)
457 ;; TODO: Make this configurable
458 ("python-psycopg2" ,python-psycopg2)
459 ("python-mysqlclient" ,python-mysqlclient)
460 ("python-django-filter" ,python-django-filter)
461 ("python-djangorestframework" ,python-djangorestframework)
462 ("python-django-debug-toolbar" ,python-django-debug-toolbar)))
463 (synopsis "Web based patch tracking system")
464 (description
465 "Patchwork is a patch tracking system. It takes in emails containing
466patches, and displays the patches along with comments and state information.
467Users can login allowing them to change the state of patches.")
468 (home-page "http://jk.ozlabs.org/projects/patchwork/")
469 (license gpl2+)))