diff mbox series

[bug#68675,v2] gnu: Add dhcpcd.

Message ID 2156325d2caa8d4298c9828d84fa5fff40592da4.1706123111.git.soeren@soeren-tempel.net
State New
Headers show
Series [bug#68675,v2] gnu: Add dhcpcd. | expand

Commit Message

Sören Tempel Jan. 24, 2024, 7:05 p.m. UTC
From: Sören Tempel <soeren@soeren-tempel.net>

* gnu/packages/admin.scm (dhcpcd): new procedure.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
---
Change since v1:

* wrap dhcpcd-run-hooks to make sed and coreutils available
* fix various lint and style warnings for the dhcpcd package

 gnu/packages/admin.scm | 57 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)


base-commit: 29c26a8d308286cf378ce9cfa3d73e3d1454263d

Comments

Ludovic Courtès Feb. 12, 2024, 9:32 p.m. UTC | #1
Hi,

soeren@soeren-tempel.net skribis:

> From: Sören Tempel <soeren@soeren-tempel.net>
>
> * gnu/packages/admin.scm (dhcpcd): new procedure.
>
> Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>

Overall LGTM modulo minor stylistic issues:

> +      #:configure-flags #~(list "--enable-ipv6"
> +                                "--enable-privsep"
> +                                "--privsepuser=dhcpcd"
> +                                (string-append "--dbdir=" "/var/db/dhcpcd")
> +                                (string-append "--rundir=" "/var/run/dhcpcd")
> +                                "CC=gcc")

Should be (string-append "CC=" #$(cc-for-target)).

> +                   (add-before 'build 'setenv
> +                     (lambda _
> +                       (setenv "HOST_SH"
> +                               (string-append #$bash-minimal "/bin/sh"))))

Rather (setenv "HOST_SH" (which "sh")).

That way users can still override the shell used by the package.

> +                   (add-after 'install 'wrap-hooks
> +                     (lambda* (#:key inputs outputs #:allow-other-keys)
> +                       (let* ((out (assoc-ref outputs "out"))
> +                              (libexec (string-append out "/libexec"))
> +                              (sed (assoc-ref inputs "sed"))
> +                              (coreutils (assoc-ref inputs "coreutils")))

Rather (search-input-file inputs "/bin/sed") and likewise for coreutils,
and then…

> +                         (wrap-program (string-append libexec
> +                                                      "/dhcpcd-run-hooks")
> +                           `("PATH" ":" suffix
> +                             (,(string-append coreutils "/bin")
> +                              ,(string-append sed "/bin"))))))))))

… use (dirname sed) and (dirname ls), say, to get their /bin directory.

This is more robust than relying on the input label.

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index fcf05992d8..4b106f87a8 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -1608,6 +1608,63 @@  (define-public isc-dhcp
       (license license:mpl2.0)
       (properties '((cpe-name . "dhcp"))))))
 
+(define-public dhcpcd
+  (package
+    (name "dhcpcd")
+    (version "10.0.6")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/NetworkConfiguration/dhcpcd")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "07n7d5wsmy955i6l8rkcmxhgxjygj2cxgpw79id2hx9w41fbkl5l"))
+       (file-name (git-file-name name version))))
+    (inputs (list bash-minimal))
+    (native-inputs (list eudev))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:test-target "test"
+      #:configure-flags #~(list "--enable-ipv6"
+                                "--enable-privsep"
+                                "--privsepuser=dhcpcd"
+                                (string-append "--dbdir=" "/var/db/dhcpcd")
+                                (string-append "--rundir=" "/var/run/dhcpcd")
+                                "CC=gcc")
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'do-not-create-dbdir
+                     (lambda _
+                       ;; Make sure that the Makefile doesn't attempt to create
+                       ;; /var/db/dhcpcd for which it doesn't have permissions.
+                       (substitute* "src/Makefile"
+                         (("\\$\\{INSTALL\\} -m \\$\\{DBMODE\\} -d \\$\\{DESTDIR\\}\\$\\{DBDIR\\}")
+                          ""))))
+                   (add-before 'build 'setenv
+                     (lambda _
+                       (setenv "HOST_SH"
+                               (string-append #$bash-minimal "/bin/sh"))))
+                   (add-after 'install 'wrap-hooks
+                     (lambda* (#:key inputs outputs #:allow-other-keys)
+                       (let* ((out (assoc-ref outputs "out"))
+                              (libexec (string-append out "/libexec"))
+                              (sed (assoc-ref inputs "sed"))
+                              (coreutils (assoc-ref inputs "coreutils")))
+                         (wrap-program (string-append libexec
+                                                      "/dhcpcd-run-hooks")
+                           `("PATH" ":" suffix
+                             (,(string-append coreutils "/bin")
+                              ,(string-append sed "/bin"))))))))))
+    (home-page "https://roy.marples.name/projects/dhcpcd")
+    (synopsis "Feature-rich DHCP and DHCPv6 client")
+    (description
+     "Provides a DHCP and a DHCPv6 client.  Additionally,
+dhcpcd is also an IPv4LL (aka ZeroConf) client.  In layperson's terms,
+dhcpcd runs on your machine and silently configures your computer to work
+on the attached networks without trouble and mostly without configuration.")
+    (license license:bsd-2)))
+
 (define-public radvd
   (package
     (name "radvd")