homebrew-core/Formula/skopeo.rb

65 lines
2.7 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.8.0.tar.gz"
sha256 "287cd989aba76691bf028b4eb3fccd012abc0cab7556a7d11aebac62c4d01342"
license "Apache-2.0"
bottle do
sha256 arm64_monterey: "c71c157090f9d45b441920b4c82839eb2db70db546d2e46c29808306d2e5467f"
sha256 arm64_big_sur: "f1b1b22a30874f2f7f733a34cc6daca67a6e70d2f59ca059b3c558078aa545ae"
sha256 monterey: "e64d6e03d2fd39d2238a2565a1e4c645c588fb6f56fc99418a52d13c08e04715"
sha256 big_sur: "3180d507c7587131156a2a358de04ae062e0a4ce13923e35d7f6999ed9638690"
sha256 catalina: "26207c8814a7740eb080a9da484ec316d24b37032003e333dd94cd53913eec37"
sha256 x86_64_linux: "87c925b150e9c974c706b20c4c31fc983a76fc00051537b056d8d4b229d9924e"
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