From 666634bd9d6df719c1773cf6b116b5808a01ec38 Mon Sep 17 00:00:00 2001 From: Adriano Machado <60320+ammachado@users.noreply.github.com> Date: Fri, 14 Aug 2026 16:36:49 -0400 Subject: [PATCH] CAMEL-23703: camel-launcher - fix brew audit --strict redundant version Homebrew's brew audit --strict rejects a formula's `version` field when it merely duplicates the version brew already scans from the `url` field. formula.rb.tpl set both, so any real submission of the generated formula to homebrew-core would fail that gate. Removed the redundant `version` line. camel-validate.sh's homebrew version check previously read the expected post-install version from that same `version` field, so removing it regressed the check. It now reads the version out of the formula's own `url` before Step 2 rewrites that url to a local file:// path for the offline test-mode install. Co-Authored-By: Claude Sonnet 5 --- .../src/jreleaser/bin/camel-validate.sh | 29 +++++++++---------- .../camel-cli/brew/formula.rb.tpl | 1 - 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/dsl/camel-jbang/camel-launcher/src/jreleaser/bin/camel-validate.sh b/dsl/camel-jbang/camel-launcher/src/jreleaser/bin/camel-validate.sh index 1566fdba0c2cd..508868cae5347 100755 --- a/dsl/camel-jbang/camel-launcher/src/jreleaser/bin/camel-validate.sh +++ b/dsl/camel-jbang/camel-launcher/src/jreleaser/bin/camel-validate.sh @@ -233,6 +233,18 @@ validate_homebrew() { # failure of the audit gate below caused by the tap copy itself, not by the formula. chmod 644 "$tap_dir/Formula/${fmla}.rb" + # The formula carries no dedicated `version` field (brew audit --strict rejects one that + # merely duplicates what it already scans from the url), so the expected post-install + # version is read from the url instead - captured now, before Step 2 below may rewrite that + # same url to a local file:// path for the offline install, which would otherwise wipe out + # the "/" path segment this parses. + local expected_version + expected_version=$(sed -n 's#.*/camel-launcher/\([^/]*\)/[^/]*"$#\1#p' "$tap_dir/Formula/${fmla}.rb" | head -n1) + if [ -z "$expected_version" ]; then + echo "WARN: could not read the version from tapped formula ${fmla}.rb's url, falling back to \$RESOLVED_VERSION ($RESOLVED_VERSION)" + expected_version="$RESOLVED_VERSION" + fi + # Step 1: Homebrew style + audit, referenced by tap-qualified name (not a path). # `brew style --fix` only normalizes formatting; its output is informational. local style_output="" @@ -323,21 +335,8 @@ validate_homebrew() { # Step 3: Verify camel version after installation. A successful `brew install` exit code # is not proof the executable actually works, so a missing/empty/mismatched result here - # is a real failure, not something to warn past. - # - # Expected version comes from the formula's own `version` line, not $RESOLVED_VERSION. - # JReleaser renders the formula version from the real POM version, which in test mode is - # the -SNAPSHOT that the offline file:// install above actually installs; that differs from - # $RESOLVED_VERSION (which strips -SNAPSHOT for local-archive lookups). Reading the expected - # value back out of the tapped formula keeps this assertion correct in both the test-mode - # case and a real release (where the formula version is $RESOLVED_VERSION anyway). - local expected_version - expected_version=$(sed -n 's/^[[:space:]]*version "\(.*\)"/\1/p' "$tap_dir/Formula/${fmla}.rb" | head -n1) - if [ -z "$expected_version" ]; then - echo "WARN: could not read 'version' from tapped formula ${fmla}.rb, falling back to \$RESOLVED_VERSION ($RESOLVED_VERSION)" - expected_version="$RESOLVED_VERSION" - fi - + # is a real failure, not something to warn past. $expected_version was captured above, + # before Step 2 rewrote the formula's url to a local file:// path. local camv_output="" if ! command -v camel >/dev/null 2>&1; then echo "FAIL: camel executable not found on PATH after a successful homebrew install" diff --git a/dsl/camel-jbang/camel-launcher/src/jreleaser/distributions/camel-cli/brew/formula.rb.tpl b/dsl/camel-jbang/camel-launcher/src/jreleaser/distributions/camel-cli/brew/formula.rb.tpl index b69c286d58d0a..a995a583674c8 100644 --- a/dsl/camel-jbang/camel-launcher/src/jreleaser/distributions/camel-cli/brew/formula.rb.tpl +++ b/dsl/camel-jbang/camel-launcher/src/jreleaser/distributions/camel-cli/brew/formula.rb.tpl @@ -24,7 +24,6 @@ class {{brewFormulaName}} < Formula desc "{{projectDescription}}" homepage "{{{projectLinkHomepage}}}" url "{{{distributionUrl}}}"{{#brewDownloadStrategy}}, :using => {{.}}{{/brewDownloadStrategy}} - version "{{projectVersion}}" sha256 "{{distributionChecksumSha256}}" license "{{projectLicense}}" {{#brewVersionedFormula}}