homebrew-core/Formula/skopeo.rb

64 lines
2.6 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.4.1.tar.gz"
sha256 "a0fd7a509b901f0b41364985daf41268eec5cf50f7ee0bd5c6f4b9add4042589"
license "Apache-2.0"
bottle do
sha256 arm64_big_sur: "fca4da7ff76aedfd82f879ae02b50fdadf43e9533dd53e30271f94b90c2c6617"
sha256 big_sur: "33af6c3adae94860c96383da8c47539279363e0ba27c1e6dcd50eb8665f719fb"
sha256 catalina: "6064efa825c96c4ce12a97e7c46e2681ff402422690861a01bd66f83eff70ee2"
sha256 mojave: "47ff419d4f02c33802656dfe03582c0f89fb32ad42940bb3ca3cee4f10862be7"
sha256 x86_64_linux: "1c0d7f0be4019be1807585bbdbce5de05d7e1f6908c0d771dd9515e5e5dc9282"
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