Subject: [bug#49685] [PATCH] gnu: Add task-spooler.

From: Maxime Devos <[email-masked]>
Date: Wed, 21 Jul 2021 21:00:26 +0200

Ivan Gankevich schreef op wo 21-07-2021 om 21:35 [+0300]:
> +(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"))
> +                "CC=gcc"

This shoul be ,(string-append "CC=" (cc-for-target)), such that the cross-compiler
is used when cross-compililng.

> +                (string-append "CFLAGS=" c-flags)
> +                (string-append "LDFLAGS=" c-flags)))

Why are you adding "-g -O2" to LDFLAGS? I understand adding it to CFLAGS,
but I don't see why it would be added to CFLAGS.

> +        #: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\"" (which "gzip"))))

This needs to be (search-input-file "bin/gzip") instead of (which "gzip")
for cross-compilation purposes ('which' searches for a native "gzip" in $PATH)
'search-input-file' is not yet defined on 'master' (it's only on 'core-updates'
currently), so you could do something like

  (string-append (assoc-ref inputs "gzip") "/bin/gzip")

> +              (substitute* "list.c"
> +                (("/bin/sh\\b") (which "sh")))

Ditto (and you need to add "bash-minimal" to "inputs").

> +              (substitute* "env.c"
> +                (("execlp\\(\"/bin/sh\"") (format #f "execlp(\"~a\"" (which "sh"))))

Ditto.

> +              (substitute* "mail.c"
> +                (("execl\\(\"/usr/sbin/sendmail\"")
> +                 (format #f "execl(\"~a/usr/sbin/sendmail\""
> +                         (assoc-ref %build-inputs "sendmail"))))))

If you fix 'sendemail' to install things in "sbin" instead of
"usr/sbin", then you can do (search-input-file inputs "bin/sendmail").

> +          (replace 'check
> +            (lambda* (#:key tests? #:allow-other-keys)
> +              (when tests?
> +                (setenv "PATH" (string-join (list (getenv "PATH") (getcwd)) ":"))

Greetings,
Maxime.