homebrew-core/Formula/skopeo.rb

66 lines
2.8 KiB
Ruby

class Skopeo < Formula
desc "Work with remote images registries"
homepage "https://github.com/containers/skopeo"
url "https://github.com/containers/skopeo/archive/v1.5.0.tar.gz"
sha256 "4605a60a12a8f58cfe136d49242059a70810e786ee5849c778be0b4c7a49c453"
license "Apache-2.0"
bottle do
sha256 arm64_monterey: "2bcc1360b3a7bb924cac069d166672ea4f73f8dd282fa8389dcc619780f46ff4"
sha256 arm64_big_sur: "94bcb7f1dce02dfe3a9f1545000f56af8d59559be7a3f0be4e07f292b97ea793"
sha256 monterey: "bc6dedfd03a83d4b457006ab23116efdc571c4fa3f6636c8ee45a2c21f930edc"
sha256 big_sur: "5d3e658e846818a5bc11079ba639d18dd9a26c2e9a291f6e7108dcd634645621"
sha256 catalina: "c36c19630befee3bff7572f881805461da870560a5a72e5961bad13b9536a621"
sha256 mojave: "af5bb3200dcb02613eaeba66d58410afa6b4f5291e83d3c4b707430126bb8bd2"
sha256 x86_64_linux: "eae8c47f14fdfbeb834c3423c8fa7974a191a763a6ea905e0b9f974f88759fb7"
end
depends_on "go" => :build
depends_on "gpgme"
on_linux do
depends_on "pkg-config" => :build
depends_on "device-mapper"
end
def install
ENV["CGO_ENABLED"] = "1"
ENV.append "CGO_FLAGS", ENV.cppflags
ENV.append "CGO_FLAGS", Utils.safe_popen_read("#{Formula["gpgme"].bin}/gpgme-config", "--cflags")
buildtags = [
"containers_image_ostree_stub",
Utils.safe_popen_read("hack/btrfs_tag.sh").chomp,
Utils.safe_popen_read("hack/btrfs_installed_tag.sh").chomp,
Utils.safe_popen_read("hack/libdm_tag.sh").chomp,
].uniq.join(" ")
ldflags = [
"-X main.gitCommit=",
"-X github.com/containers/image/v5/docker.systemRegistriesDirPath=#{etc/"containers/registries.d"}",
"-X github.com/containers/image/v5/internal/tmpdir.unixTempDirForBigFiles=/var/tmp",
"-X github.com/containers/image/v5/signature.systemDefaultPolicyPath=#{etc/"containers/policy.json"}",
"-X github.com/containers/image/v5/pkg/sysregistriesv2.systemRegistriesConfPath=" \
"#{etc/"containers/registries.conf"}",
].join(" ")
system "go", "build", "-tags", buildtags, "-ldflags", ldflags, *std_go_args, "./cmd/skopeo"
(etc/"containers").install "default-policy.json" => "policy.json"
(etc/"containers/registries.d").install "default.yaml"
bash_completion.install "completions/bash/skopeo"
end
test do
cmd = "#{bin}/skopeo --override-os linux inspect docker://busybox"
output = shell_output(cmd)
assert_match "docker.io/library/busybox", output
# https://github.com/Homebrew/homebrew-core/pull/47766
# https://github.com/Homebrew/homebrew-core/pull/45834
assert_match(/Invalid destination name test: Invalid image name .+, expected colon-separated transport:reference/,
shell_output("#{bin}/skopeo copy docker://alpine test 2>&1", 1))
end
end