summary refs log tree commit diff
diff options
context:
space:
mode:
authorIvan Gankevich <i.gankevich@spbu.ru>2021-07-23 21:19:03 +0300
committerLudovic Courtès <ludo@gnu.org>2021-08-10 17:32:20 +0200
commit224093fb855cb37024e92a8d15e749751d0ed6e2 (patch)
tree84cf2caeafa9faf9415eef3cef323a4292ac4758
parente6d0264b8218ba2354547a5925f6e6e89af42d37 (diff)
downloadguix-224093fb855cb37024e92a8d15e749751d0ed6e2.tar.gz
gnu: Add task-spooler.
* gnu/packages/task-runners.scm (task-spooler): New variable.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--gnu/packages/task-runners.scm64
1 files changed, 64 insertions, 0 deletions
diff --git a/gnu/packages/task-runners.scm b/gnu/packages/task-runners.scm
index 49a07fa3bd..1c1fa69894 100644
--- a/gnu/packages/task-runners.scm
+++ b/gnu/packages/task-runners.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
+;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,8 +20,14 @@
 (define-module (gnu packages task-runners)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix utils)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages mail)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system go))
 
 (define-public run
@@ -47,3 +54,60 @@
 using a Runfile.")
     (home-page "https://github.com/TekWizely/run")
     (license license:expat)))
+
+(define-public task-spooler
+  (package
+    (name "task-spooler")
+    (version "1.0.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+               "https://vicerveza.homeunix.net/~viric/soft/ts/ts-" version ".tar.gz"))
+        (sha256 (base32 "0y32sm2i2jxs88c307h76449fynk75p9qfw1k11l5ixrn03z67pl"))))
+    (build-system gnu-build-system)
+    (arguments
+      `(#:make-flags
+        (let ((c-flags "-g -O2"))
+          (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
+                ,(string-append "CC=" (cc-for-target))
+                (string-append "CFLAGS=" c-flags)))
+        #:phases
+        (modify-phases %standard-phases
+          (delete 'configure) ;; no configuration script
+          (add-after 'unpack 'rename-and-patch-paths
+            (lambda _
+              ;; Rename "ts" to "tsp" to not interfere with "ts" command
+              ;; from moreutils package.
+              (rename-file "ts.1" "tsp.1");
+              (substitute* '("Makefile" "testbench.sh")
+                (("\\bts\\b") "tsp"))
+              ;; Patch gzip/sendmail/shell paths.
+              (substitute* "execute.c"
+                (("execlp\\(\"gzip\"")
+                 (format #f "execlp(\"~a/bin/gzip\""
+                         (assoc-ref %build-inputs "gzip"))))
+              (substitute* "list.c"
+                (("/bin/sh\\b") (which "sh")))
+              (substitute* "env.c"
+                (("execlp\\(\"/bin/sh\"")
+                 (format #f "execlp(\"~a/bin/sh\""
+                         (assoc-ref %build-inputs "bash"))))
+              (substitute* "mail.c"
+                (("execl\\(\"/usr/sbin/sendmail\"")
+                 (format #f "execl(\"~a/sbin/sendmail\""
+                         (assoc-ref %build-inputs "sendmail"))))))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (setenv "PATH" (string-join (list (getenv "PATH") (getcwd)) ":"))
+                (invoke "./testbench.sh")))))))
+    (inputs
+      `(("bash" ,bash-minimal)
+        ("gzip" ,gzip)
+        ("sendmail" ,sendmail)))
+    (synopsis "UNIX task queue system")
+    (description "Task spooler lets users run shell commands asynchronously
+one after the other in a separate process.")
+    (home-page "https://vicerveza.homeunix.net/~viric/soft/ts/")
+    (license license:gpl2+)))