Subject: [bug#66887] [PATCH v2 2/3] gnu: podman: Use catatonit.

From: Jack Hill <[email-masked]>
Date: Wed, 8 Nov 2023 12:24:56 -0500

From: Wilke Schwiedop <[email-masked]>

defaultHelperBinariesDir is a string array of paths searched by the
FindHelperBinary function. This patch inserts new entries at the
beginning of array instead of modifying individual elements. This will
make it easier to include additional helper binaries, e.g. aardvark,
netavark and pasta.

Change-Id: I2f988b9225f3fcee7f00c48ba3aedc9289ba9d47
---
 gnu/packages/containers.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/containers.scm b/gnu/packages/containers.scm
index e26b5acf21..c00394af2b 100644
--- a/gnu/packages/containers.scm
+++ b/gnu/packages/containers.scm
@@ -381,22 +381,31 @@ (define-public podman
                 (("CATATONIT_PATH=\"[^\"]+\"")
                  (string-append "CATATONIT_PATH=" (which "true"))))
               (substitute* "vendor/github.com/containers/common/pkg/config/config_linux.go"
-                (("/usr/local/libexec/podman")
-                 (string-append #$output "/libexec/podman"))
-                (("/usr/local/lib/podman")
-                 (string-append #$output "/bin")))
+                (("var defaultHelperBinariesDir = ..string." all)
+                 (string-append
+                  all
+                  (string-join
+                   (map (lambda (s) (string-append "\n\"" s "\","))
+                        (list
+                         (string-append #$output "/libexec/podman")
+                         (string-append #$output "/bin")
+                         (string-append #$(this-package-input "catatonit") "/bin")))))))
               (substitute* "vendor/github.com/containers/common/pkg/config/default.go"
                 (("/usr/libexec/podman/conmon") (which "conmon"))
                 (("/usr/local/libexec/cni")
                  (string-append #$(this-package-input "cni-plugins")
                                 "/bin"))
-                (("/usr/bin/crun") (which "crun")))))
+                (("/usr/bin/crun") (which "crun"))
+                (("/usr/libexec/podman/catatonit") (which "catatonit")))
+              (substitute* "pkg/rootless/rootless_linux.c"
+                (("/usr/bin/catatonit") (which "catatonit")))))
           (add-after 'install 'install-completions
             (lambda _
               (invoke "make" "install.completions"
                       (string-append "PREFIX=" #$output)))))))
     (inputs
      (list btrfs-progs
+           catatonit
            cni-plugins
            conmon
            crun
-- 
2.41.0