homebrew-core/Formula/podman.rb

182 lines
6.0 KiB
Ruby

class Podman < Formula
desc "Tool for managing OCI containers and pods"
homepage "https://podman.io/"
url "https://github.com/containers/podman/archive/v4.3.0.tar.gz"
sha256 "55a3a09b80f23f78aaeb74fbf878fa0b1ef1842e5b282ad61e82a9dc4c74bf34"
license all_of: ["Apache-2.0", "GPL-3.0-or-later"]
head "https://github.com/containers/podman.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "1d00923c766901f7799db6d700be99a748844bd1b49ed4f282bacc3cf19cb7ae"
sha256 cellar: :any_skip_relocation, arm64_monterey: "7f79e939884236f72d8203500afee7028301a118d1e056249367e113ae3df4a7"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "3b6cb25d4b073d804b3bd417a521fb6975d08faace7a626a7dde3f42aceef954"
sha256 cellar: :any_skip_relocation, monterey: "7bf63f644c51853697913b7e3e68c24555dd710f900d985ffac2791ebaca9926"
sha256 cellar: :any_skip_relocation, big_sur: "21182a70c3303a36cf38c906b13d0099f61e1c47835ecda4fdd40014273e5750"
sha256 cellar: :any_skip_relocation, catalina: "14c4f2ae2e6d4cded8ccc40d40a878e711e01fe8833e5d063c17308d2b8c37b9"
sha256 x86_64_linux: "8bd25a7fdc39d83c44a861a2f3ab1e670bbf2d3338a8af435b82ae253e54ba0f"
end
depends_on "go-md2man" => :build
# Required latest gvisor.dev/gvisor/pkg/gohacks
# Try to switch to the latest go on the next release
depends_on "go@1.18" => :build
on_macos do
depends_on "qemu"
end
on_linux do
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "pkg-config" => :build
depends_on "rust" => :build
depends_on "conmon"
depends_on "crun"
depends_on "fuse-overlayfs"
depends_on "gpgme"
depends_on "libseccomp"
depends_on "slirp4netns"
depends_on "systemd"
end
resource "gvproxy" do
on_macos do
url "https://github.com/containers/gvisor-tap-vsock/archive/v0.4.0.tar.gz"
sha256 "896cf02fbabce9583a1bba21e2b384015c0104d634a73a16d2f44552cf84d972"
end
end
resource "catatonit" do
on_linux do
url "https://github.com/openSUSE/catatonit/archive/refs/tags/v0.1.7.tar.gz"
sha256 "e22bc72ebc23762dad8f5d2ed9d5ab1aaad567bdd54422f1d1da775277a93296"
# Fix autogen.sh. Delete on next catatonit release.
patch do
url "https://github.com/openSUSE/catatonit/commit/99bb9048f532257f3a2c3856cfa19fe957ab6cec.patch?full_index=1"
sha256 "cc0828569e930ae648e53b647a7d779b1363bbb9dcbd8852eb1cd02279cdbe6c"
end
end
end
resource "netavark" do
on_linux do
url "https://github.com/containers/netavark/archive/refs/tags/v1.2.0.tar.gz"
sha256 "35b710197f321a2e45c59460fd8faf67b7b8ebc345d22aa8ecccf806790c6edc"
end
end
resource "aardvark-dns" do
on_linux do
url "https://github.com/containers/aardvark-dns/archive/refs/tags/v1.2.0.tar.gz"
sha256 "434163027660feebb87e288d9c9f8468a1a9d1a632d1f9fe0a84585dfde3f4dd"
end
end
def install
if OS.mac?
ENV["CGO_ENABLED"] = "1"
system "make", "podman-remote"
bin.install "bin/darwin/podman" => "podman-remote"
bin.install_symlink bin/"podman-remote" => "podman"
system "make", "podman-mac-helper"
bin.install "bin/darwin/podman-mac-helper" => "podman-mac-helper"
resource("gvproxy").stage do
system "make", "gvproxy"
(libexec/"podman").install "bin/gvproxy"
end
system "make", "podman-remote-darwin-docs"
man1.install Dir["docs/build/remote/darwin/*.1"]
bash_completion.install "completions/bash/podman"
zsh_completion.install "completions/zsh/_podman"
fish_completion.install "completions/fish/podman.fish"
else
paths = Dir["**/*.go"].select do |file|
(buildpath/file).read.lines.grep(%r{/etc/containers/}).any?
end
inreplace paths, "/etc/containers/", etc/"containers/"
ENV.O0
ENV["PREFIX"] = prefix
ENV["HELPER_BINARIES_DIR"] = opt_libexec/"podman"
system "make"
system "make", "install", "install.completions"
(prefix/"etc/containers/policy.json").write <<~EOS
{"default":[{"type":"insecureAcceptAnything"}]}
EOS
(prefix/"etc/containers/storage.conf").write <<~EOS
[storage]
driver="overlay"
EOS
(prefix/"etc/containers/registries.conf").write <<~EOS
unqualified-search-registries=["docker.io"]
EOS
resource("catatonit").stage do
system "./autogen.sh"
system "./configure"
system "make"
mv "catatonit", libexec/"podman/"
end
resource("netavark").stage do
system "cargo", "install", *std_cargo_args
mv bin/"netavark", libexec/"podman/"
end
resource("aardvark-dns").stage do
system "cargo", "install", *std_cargo_args
mv bin/"aardvark-dns", libexec/"podman/"
end
end
end
def caveats
on_linux do
<<~EOS
You need "newuidmap" and "newgidmap" binaries installed system-wide
for rootless containers to work properly.
EOS
end
end
service do
run [opt_bin/"podman", "system", "service", "--time=0"]
environment_variables PATH: std_service_path_env
working_dir HOMEBREW_PREFIX
end
test do
assert_match "podman-remote version #{version}", shell_output("#{bin}/podman-remote -v")
out = shell_output("#{bin}/podman-remote info 2>&1", 125)
assert_match "Cannot connect to Podman", out
if OS.mac?
out = shell_output("#{bin}/podman-remote machine init --image-path fake-testi123 fake-testvm 2>&1", 125)
assert_match "Error: open fake-testi123: no such file or directory", out
else
assert_equal %W[
#{bin}/podman
#{bin}/podman-remote
].sort, Dir[bin/"*"].sort
assert_equal %W[
#{libexec}/podman/catatonit
#{libexec}/podman/netavark
#{libexec}/podman/aardvark-dns
#{libexec}/podman/rootlessport
].sort, Dir[libexec/"podman/*"].sort
out = shell_output("file #{libexec}/podman/catatonit")
assert_match "statically linked", out
end
end
end