Skip to content

Commit

Permalink
Merge pull request #190846 from Homebrew/kapacitor-workaround
Browse files Browse the repository at this point in the history
kapacitor: workaround for newer Rust
  • Loading branch information
BrewTestBot committed Sep 19, 2024
2 parents b80af58 + 205d3ab commit 485c376
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Formula/k/kapacitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class Kapacitor < Formula
tag: "v1.7.4",
revision: "3470f6ae7f53acaca90459cc1128298548fdc740"

# TODO: Remove when release uses flux >= 0.195.0 to get following fix for rust >= 1.78
# Ref: https://github.com/influxdata/flux/commit/68c831c40b396f0274f6a9f97d77707c39970b02
resource "flux" do
url "https://github.com/influxdata/flux/archive/refs/tags/v0.194.5.tar.gz"
sha256 "85229c86d307fdecccc7d940902fb83bfbd7cff7a308ace831e2487d36a6a8ca"
end

# build patch to upgrade flux so that it can be built with rust 1.72.0+
# upstream PR ref, https://github.com/influxdata/kapacitor/pull/2811
patch do
Expand All @@ -32,7 +39,9 @@ class Kapacitor < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "6007b9e8d7e2b33e36510923d1989d83ef86e36e724c118686cdd61ef32d38a1"
end

depends_on "go" => :build
# Go 1.23 results in panic: failed to parse CA certificate.
# TODO: Switch to `go` when `kapacitor` updates gosnowflake
depends_on "go@1.22" => :build
depends_on "rust" => :build

on_linux do
Expand All @@ -47,6 +56,25 @@ class Kapacitor < Formula
end

def install
if build.stable?
# Check if newer `go` can be used
go_mod = (buildpath/"go.mod").read
gosnowflake_version = go_mod[%r{/influxdata/gosnowflake v(\d+(?:\.\d+)+)}, 1]
odie "Check if `go` can be used!" if gosnowflake_version.blank? || Version.new(gosnowflake_version) > "1.6.9"

# Workaround to skip dead_code lint. RUSTFLAGS workarounds didn't work.
flux_module = "github.com/influxdata/flux"
flux_version = go_mod[/#{flux_module} v(\d+(?:\.\d+)+)/, 1]
odie "Check if `flux` resource can be removed!" if flux_version.blank? || Version.new(flux_version) >= "0.195"
(buildpath/"vendored_flux").install resource("flux")
inreplace "vendored_flux/libflux/flux-core/src/lib.rs", "#![allow(\n", "\\0 dead_code,\n"
(buildpath/"go.work").write <<~EOS
go 1.22
use .
replace #{flux_module} => ./vendored_flux
EOS
end

resource("pkg-config-wrapper").stage do
system "go", "build", *std_go_args, "-o", buildpath/"bootstrap/pkg-config"
end
Expand Down

0 comments on commit 485c376

Please sign in to comment.