|
| 1 | +class Mintoolkit < Formula |
| 2 | + desc "Minify and secure Docker images" |
| 3 | + homepage "https://slimtoolkit.org/" |
| 4 | + url "https://github.com/mintoolkit/mint/archive/refs/tags/1.41.7.tar.gz" |
| 5 | + sha256 "a5375339dda7752b8c7a1d29d25cc7e7e52c60b2badb6a3f6d816f7743fde91a" |
| 6 | + license "Apache-2.0" |
| 7 | + head "https://github.com/mintoolkit/mint.git", branch: "master" |
| 8 | + |
| 9 | + livecheck do |
| 10 | + url :stable |
| 11 | + strategy :github_latest |
| 12 | + end |
| 13 | + |
| 14 | + bottle do |
| 15 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "3191425ab42a27ac181105eb522ba926cb52c2a6a7034b9cf697e34a41506627" |
| 16 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "33e215a31ad61ca3f81951ca6863d406fd06a376ec10fd2e81f3ae058d6449e5" |
| 17 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "485651b0b4be33e48ef7907f6239b83585e3028902c266fbab797b4c39bdd46a" |
| 18 | + sha256 cellar: :any_skip_relocation, sonoma: "c9c396b50f98b248eb69cafd4c800f6ad8ae8b25ed136fbcbeff4ec0ec9bc93c" |
| 19 | + sha256 cellar: :any_skip_relocation, ventura: "fa2b6fcf6dc740377b6400639d8d1fb00af713fd86f1c7b4027bbe2285f9dcbc" |
| 20 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "dc9d72e0904771231b5c75d6444d6cbdc8d7185abeaa1cafb18257a731e98f8d" |
| 21 | + end |
| 22 | + |
| 23 | + depends_on "go" => :build |
| 24 | + |
| 25 | + on_linux do |
| 26 | + depends_on "btrfs-progs" => :build |
| 27 | + end |
| 28 | + |
| 29 | + skip_clean "bin/mint-sensor" |
| 30 | + |
| 31 | + def install |
| 32 | + system "go", "generate", "./pkg/appbom" |
| 33 | + ldflags = "-s -w -X github.com/mintoolkit/mint/pkg/version.appVersionTag=#{version}" |
| 34 | + tags = %w[ |
| 35 | + remote |
| 36 | + containers_image_openpgp |
| 37 | + containers_image_docker_daemon_stub |
| 38 | + containers_image_fulcio_stub |
| 39 | + containers_image_rekor_stub |
| 40 | + ] |
| 41 | + system "go", "build", |
| 42 | + *std_go_args(output: bin/"mint", ldflags:, tags:), |
| 43 | + "./cmd/mint" |
| 44 | + |
| 45 | + # mint-sensor is a Linux binary that is used within Docker |
| 46 | + # containers rather than directly on the macOS host. |
| 47 | + ENV["GOOS"] = "linux" |
| 48 | + system "go", "build", |
| 49 | + *std_go_args(output: bin/"mint-sensor", ldflags:, tags:), |
| 50 | + "./cmd/mint-sensor" |
| 51 | + (bin/"mint-sensor").chmod 0555 |
| 52 | + |
| 53 | + # Create backwards compatible symlinks similar to build script |
| 54 | + # https://github.com/mintoolkit/mint/blob/master/scripts/src.build.sh |
| 55 | + bin.install_symlink "mint" => "docker-slim" |
| 56 | + bin.install_symlink "mint" => "slim" |
| 57 | + end |
| 58 | + |
| 59 | + test do |
| 60 | + assert_match version.to_s, shell_output("#{bin}/mint --version") |
| 61 | + system "test", "-x", bin/"mint-sensor" |
| 62 | + |
| 63 | + (testpath/"Dockerfile").write <<~DOCKERFILE |
| 64 | + FROM alpine |
| 65 | + RUN apk add --no-cache curl |
| 66 | + DOCKERFILE |
| 67 | + |
| 68 | + output = shell_output("#{bin}/mint lint #{testpath}/Dockerfile") |
| 69 | + assert_match "Missing .dockerignore", output |
| 70 | + assert_match "Stage from latest tag", output |
| 71 | + end |
| 72 | +end |
0 commit comments