homebrew-core/Formula/skopeo.rb

61 lines
2.4 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.1.1.tar.gz"
sha256 "9e0fdca1f2663f5a07bc1d932fec734578c5fffdb27faa8f847a393a44b072df"
license "Apache-2.0"
bottle do
sha256 "4d31286940caac405ba936c66c5f1e5c97daaa79a761f1bb8ed715eb1da0b046" => :catalina
sha256 "87b9ee585ee1fd5d8843726425da1b4880da1d92d55844562db736f439cc3618" => :mojave
sha256 "0d716998a47a2ecfc3abca2406a9b3a9ea02137250788fcb3e8c7f0e74337b38" => :high_sierra
end
depends_on "go" => :build
depends_on "gpgme"
on_linux do
depends_on "pkg-config" => :build
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