diff mbox series

[bug#57387] gnu: Add restartd.

Message ID 87czcp8wet.fsf@ngraves.fr
State New
Headers show
Series [bug#57387] gnu: Add restartd. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Nicolas Graves Aug. 24, 2022, 3:59 p.m. UTC
* gnu/packages/admin.scm (restartd): New variable.
---
 gnu/packages/admin.scm | 67 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

Comments

M Aug. 24, 2022, 6:09 p.m. UTC | #1
On 24-08-2022 17:59, Nicolas Graves via Guix-patches via wrote:

> +         (revision "1.1"))

"1.1" -> "1" ('revision' must be a string with a number, as expected by 
https://issues.guix.gnu.org/53144).

Also, why is an unreleased version used? I assume because of lack of 
activity upstream, but a comment would have been useful.

> +                (substitute* "Makefile"
> +                  (("CC \\?= gcc") "CC = gcc"))))
For cross-compilation, use (cc-for-target)

According to Debian, the home-page is 
<https://github.com/ajraymond/restartd>.

Looking at some source files, it appears to be gpl2-or-later, not gpl2-only.

In restartd.c, it is missing error checking for 'fopen', 'malloc' and 
'strdup'.

in config.c, it is missing error checking for 'malloc'  (and for printf 
on stderr, but there isn't much that can be odone in that case). Also 
printf on stdout, though less important.

On the patches: IIUC, in case additional commits are added to the PR, 
the patch is updated appropriately, so these patches are volatile. Even 
if that doesn't happen, the patch generation algorithm could change 
later. As such, copying these into gnu/packages/patches + search-pathes 
is recommended

> You can execute a script or a program if the process is or is not running.
Maybe: 'The daemon runs an user-provided script based once a program 
starts running or stops running.' That seems a little clearer English to 
me ('it is running or not running' is always true, and scripts / 
programs can be run, but it's not a claim about restartd).

Greetings,
Maxime.
\( Aug. 24, 2022, 6:14 p.m. UTC | #2
On Wed Aug 24, 2022 at 7:09 PM BST, Maxime Devos wrote:
> > +                (substitute* "Makefile"
> > +                  (("CC \\?= gcc") "CC = gcc"))))
> For cross-compilation, use (cc-for-target)

Also, you can replace this substitution with make-flags:

  #:make-flags
  #~(list (string-append "CC=" #$(cc-for-target)))

    -- (
Nicolas Graves Aug. 25, 2022, 9:16 a.m. UTC | #3
Made suggested changes, rephrased the description.
But I never learned C and am not at ease for adding checks in C source
code, sorry.
M Aug. 25, 2022, 10:34 a.m. UTC | #4
On 25-08-2022 11:16, Nicolas Graves via Guix-patches via wrote:
> Made suggested changes, rephrased the description.
> But I never learned C and am not at ease for adding checks in C source
> code, sorry.
>
I'll give it a try myself ...
M Aug. 25, 2022, 11:33 a.m. UTC | #5
On 25-08-2022 11:16, Nicolas Graves via Guix-patches via wrote:
> Made suggested changes, rephrased the description.
> But I never learned C and am not at ease for adding checks in C source
> code, sorry.
>
I have made a PR at <https://github.com/ajraymond/restartd/pull/8> 
<https://github.com/ajraymond/restartd/pull/8> adding some error checking.

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index a4c5189222..17a400bdf6 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -51,6 +51,7 @@ 
 ;;; Copyright © 2021 Artyom V. Poptsov <poptsov.artyom@gmail.com>
 ;;; Copyright © 2022 Wamm K. D. <jaft.r@outlook.com>
 ;;; Copyright © 2022 Roman Riabenko <roman@riabenko.com>
+;;; Copyright © 2022 Nicolas Graves <ngraves@ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5455,6 +5456,72 @@  (define-public fail2ban
 mechanisms if you really want to protect services.")
     (license license:gpl2+)))
 
+(define-public restartd
+  (let* ((commit "7044125ac55056f2663536f7137170edf92ebd75")
+         (revision "1.1"))
+    (package
+      (name "restartd")
+      (version (git-version "0.2.3" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/ajraymond/restartd")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1m1np00b4zvvwx63gzysbi38i5vj1jsjvh2s0p9czl6dzyz582z0"))
+         (patches
+          (list
+           ;; Fix segfault when run as normal user
+           (origin
+             (method url-fetch)
+             (uri
+              (string-append "https://patch-diff.githubusercontent.com/raw"
+                             "/ajraymond/restartd/pull/6.patch"))
+             (sha256
+              (base32
+               "1cqhy6fngvql9ynacrf4f2nc7mzypvdbab5nil96qlclfvb3far8")))
+           ;; Fix compilation with gcc-10+
+           (origin
+             (method url-fetch)
+             (uri
+              (string-append "https://patch-diff.githubusercontent.com/raw"
+                             "/ajraymond/restartd/pull/7.patch"))
+             (sha256
+              (base32
+               "0fk33af8sgrgxibmkyjlv3j8jikgbp4mkj84yamvhv38ic6x2rw6")))))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:tests? #f ; no tests
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'ensure-compilation
+              (lambda _
+                (substitute* "Makefile"
+                  (("CC \\?= gcc") "CC = gcc"))))
+            (delete  'configure)
+            (replace 'install
+              (lambda _
+                (install-file "restartd.conf" (string-append #$output "/etc"))
+                (install-file "restartd" (string-append #$output "/sbin"))
+                (install-file "restartd.8"
+                              (string-append #$output "/share/man/man8"))
+                (mkdir-p (string-append #$output "/share/man/fr/man8"))
+                (copy-file
+                 "restartd.fr.8"
+                 (string-append #$output "/share/man/fr/man8/restartd.8")))))))
+      (home-page "https://launchpad.net/debian/+source/restartd")
+      (synopsis "Daemon for restarting processes")
+      (description "This package provides a daemon for checking running and not
+running processes.  It reads the /proc directory every n seconds and does a
+POSIX regexp on the process names.  You can execute a script or a program if
+the process is or is not running.  The daemon can only be called by the root
+user, but can use @code{sudo -u user} in the process called if needed.")
+      (license license:gpl2))))
+
 (define-public rex
   (package
     (name "rex")