diff mbox series

[bug#52174,v2,6/6] gnu: add podman

Message ID 5d39e8142d916df8da9d317bf7a3781c0513ad77.1639889841.git.mail@timmydouglas.com
State Accepted
Headers show
Series [bug#52174,v2,1/6] gnu: add crun | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Timmy Douglas Dec. 19, 2021, 4:58 a.m. UTC
* gnu/packages/containers.scm: add podman
---

Thanks for the review Ludo! Hopefully this v2 fixes the issues you
pointed out.

gnu/packages/containers.scm | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/containers.scm b/gnu/packages/containers.scm
index 8810ecb8c8..389ef42092 100644
--- a/gnu/packages/containers.scm
+++ b/gnu/packages/containers.scm
@@ -214,3 +214,63 @@  (define-public cni-plugins
     (description
      "Some CNI network plugins, maintained by the containernetworking team.")
     (license license:asl2.0)))
+
+;; For podman to work, the user needs to run
+;; `sudo mount -t cgroup2 none /sys/fs/cgroup`
+
+(define-public podman
+  (package
+    (name "podman")
+    (version "3.4.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/containers/podman")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1q09qsl1wwiiy5njvb97n1j5f5jin4ckmzj5xbdfs28czb2kx3g5"))
+       (file-name (git-file-name name version))))
+
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list ,(string-append "CC=" (cc-for-target))
+                          (string-append "PREFIX=" %output))
+       #:tests? #f ; need to setup ginkgo
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure)
+                  (add-after 'unpack 'set-env
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      ;; when running go, things fail because
+                      ;; HOME=/homeless-shelter.
+                      (setenv "HOME" "/tmp")))
+                  (add-after 'unpack 'fix-hardcoded-paths
+                    (lambda _
+                      (substitute* (find-files "libpod" "\\.go")
+                        (("exec.LookPath[(][\"]slirp4netns[\"][)]")
+                         (string-append "exec.LookPath(\"" (which "slirp4netns") "\")")))
+                      (substitute* "vendor/github.com/containers/common/pkg/config/config_linux.go"
+                        (("/usr/local/libexec/podman")
+                         (string-append (assoc-ref %outputs "out") "/bin")))
+                      (substitute* "vendor/github.com/containers/common/pkg/config/default.go"
+                        (("/usr/libexec/podman/conmon") (which "conmon"))
+                        (("/usr/local/libexec/cni")
+                         (string-append (assoc-ref %build-inputs "cni-plugins") "/bin"))
+                        (("/usr/bin/crun") (which "crun")))
+                      #true))
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys)
+                      (when tests?
+                        (invoke "make" "test")))))))
+    (inputs
+     (list btrfs-progs cni-plugins conmon crun gpgme go-github-com-go-md2man
+           iptables libassuan libseccomp libselinux slirp4netns))
+    (native-inputs
+     (list git go pkg-config))
+    (home-page "https://podman.io")
+    (synopsis "Manage containers, images, pods, and their volumes")
+    (description
+     "Podman (the POD MANager) is a tool for managing containers and images,
+volumes mounted into those containers, and pods made from groups of
+containers.")
+    (license license:asl2.0)))