karafka-rdkafka 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +1 -0
- data/dist/{librdkafka-2.11.0.tar.gz → librdkafka-2.11.1.tar.gz} +0 -0
- data/karafka-rdkafka.gemspec +33 -6
- data/lib/rdkafka/version.rb +3 -3
- data/renovate.json +5 -17
- metadata +3 -67
- data/.github/CODEOWNERS +0 -3
- data/.github/FUNDING.yml +0 -1
- data/.github/workflows/ci_linux_alpine_x86_64_musl.yml +0 -197
- data/.github/workflows/ci_linux_alpine_x86_64_musl_complementary.yml +0 -264
- data/.github/workflows/ci_linux_debian_x86_64_gnu.yml +0 -271
- data/.github/workflows/ci_linux_debian_x86_64_gnu_complementary.yml +0 -334
- data/.github/workflows/ci_linux_ubuntu_aarch64_gnu.yml +0 -271
- data/.github/workflows/ci_linux_ubuntu_aarch64_gnu_complementary.yml +0 -295
- data/.github/workflows/ci_linux_ubuntu_x86_64_gnu.yml +0 -281
- data/.github/workflows/ci_linux_ubuntu_x86_64_gnu_complementary.yml +0 -294
- data/.github/workflows/ci_macos_arm64.yml +0 -284
- data/.github/workflows/push_linux_aarch64_gnu.yml +0 -65
- data/.github/workflows/push_linux_x86_64_gnu.yml +0 -65
- data/.github/workflows/push_linux_x86_64_musl.yml +0 -79
- data/.github/workflows/push_macos_arm64.yml +0 -54
- data/.github/workflows/push_ruby.yml +0 -37
- data/.github/workflows/trigger-wiki-refresh.yml +0 -30
- data/.github/workflows/verify-action-pins.yml +0 -16
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -2
- data/dist/cyrus-sasl-2.1.28.tar.gz +0 -0
- data/dist/krb5-1.21.3.tar.gz +0 -0
- data/dist/openssl-3.0.16.tar.gz +0 -0
- data/dist/zlib-1.3.1.tar.gz +0 -0
- data/dist/zstd-1.5.7.tar.gz +0 -0
- data/ext/README.md +0 -19
- data/ext/build_common.sh +0 -376
- data/ext/build_linux_aarch64_gnu.sh +0 -326
- data/ext/build_linux_x86_64_gnu.sh +0 -317
- data/ext/build_linux_x86_64_musl.sh +0 -773
- data/ext/build_macos_arm64.sh +0 -557
- data/ext/generate-ssl-certs.sh +0 -109
- data/spec/integrations/ssl_stress_spec.rb +0 -121
- data/spec/lib/rdkafka/abstract_handle_spec.rb +0 -117
- data/spec/lib/rdkafka/admin/create_acl_handle_spec.rb +0 -56
- data/spec/lib/rdkafka/admin/create_acl_report_spec.rb +0 -18
- data/spec/lib/rdkafka/admin/create_topic_handle_spec.rb +0 -54
- data/spec/lib/rdkafka/admin/create_topic_report_spec.rb +0 -16
- data/spec/lib/rdkafka/admin/delete_acl_handle_spec.rb +0 -85
- data/spec/lib/rdkafka/admin/delete_acl_report_spec.rb +0 -72
- data/spec/lib/rdkafka/admin/delete_topic_handle_spec.rb +0 -54
- data/spec/lib/rdkafka/admin/delete_topic_report_spec.rb +0 -16
- data/spec/lib/rdkafka/admin/describe_acl_handle_spec.rb +0 -85
- data/spec/lib/rdkafka/admin/describe_acl_report_spec.rb +0 -73
- data/spec/lib/rdkafka/admin_spec.rb +0 -982
- data/spec/lib/rdkafka/bindings_spec.rb +0 -198
- data/spec/lib/rdkafka/callbacks_spec.rb +0 -20
- data/spec/lib/rdkafka/config_spec.rb +0 -258
- data/spec/lib/rdkafka/consumer/headers_spec.rb +0 -73
- data/spec/lib/rdkafka/consumer/message_spec.rb +0 -139
- data/spec/lib/rdkafka/consumer/partition_spec.rb +0 -57
- data/spec/lib/rdkafka/consumer/topic_partition_list_spec.rb +0 -248
- data/spec/lib/rdkafka/consumer_spec.rb +0 -1343
- data/spec/lib/rdkafka/error_spec.rb +0 -95
- data/spec/lib/rdkafka/metadata_spec.rb +0 -79
- data/spec/lib/rdkafka/native_kafka_spec.rb +0 -130
- data/spec/lib/rdkafka/producer/delivery_handle_spec.rb +0 -60
- data/spec/lib/rdkafka/producer/delivery_report_spec.rb +0 -25
- data/spec/lib/rdkafka/producer/partitions_count_cache_spec.rb +0 -359
- data/spec/lib/rdkafka/producer_spec.rb +0 -1527
- data/spec/spec_helper.rb +0 -230
@@ -1,79 +0,0 @@
|
|
1
|
-
name: Push Linux x86_64 musl Platform Gem
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
tags:
|
5
|
-
- v*
|
6
|
-
permissions:
|
7
|
-
contents: read
|
8
|
-
env:
|
9
|
-
BUNDLE_RETRY: 6
|
10
|
-
BUNDLE_JOBS: 4
|
11
|
-
jobs:
|
12
|
-
build:
|
13
|
-
if: github.repository_owner == 'karafka'
|
14
|
-
timeout-minutes: 30
|
15
|
-
runs-on: ubuntu-latest
|
16
|
-
environment: deployment
|
17
|
-
container:
|
18
|
-
# Same as CI, we build on the oldest possible for ABI compatibility
|
19
|
-
image: alpine:3.18@sha256:de0eb0b3f2a47ba1eb89389859a9bd88b28e82f5826b6969ad604979713c2d4f # renovate: ignore
|
20
|
-
steps:
|
21
|
-
- name: Install dependencies
|
22
|
-
run: |
|
23
|
-
apk add --no-cache git curl ca-certificates build-base linux-headers \
|
24
|
-
pkgconf perl autoconf automake libtool bison flex file bash wget zstd-dev \
|
25
|
-
openssl-dev cyrus-sasl-dev cyrus-sasl cyrus-sasl-login \
|
26
|
-
cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapiv2 cyrus-sasl-scram \
|
27
|
-
krb5-libs openssl zlib zlib-dev zstd-libs
|
28
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
29
|
-
with:
|
30
|
-
fetch-depth: 0
|
31
|
-
- name: Configure git safe directory
|
32
|
-
run: git config --global --add safe.directory /__w/karafka-rdkafka/karafka-rdkafka
|
33
|
-
- name: Cache build-tmp directory
|
34
|
-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
|
35
|
-
with:
|
36
|
-
path: ext/build-tmp-musl
|
37
|
-
key: build-tmp-musl-${{ runner.os }}-${{ hashFiles('ext/*.sh', 'ext/Rakefile') }}-v2
|
38
|
-
- name: Build precompiled librdkafka.so
|
39
|
-
run: |
|
40
|
-
cd ext
|
41
|
-
bash ./build_linux_x86_64_musl.sh
|
42
|
-
- name: Upload precompiled library
|
43
|
-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
44
|
-
with:
|
45
|
-
name: librdkafka-precompiled-musl
|
46
|
-
path: ext/
|
47
|
-
retention-days: 1
|
48
|
-
|
49
|
-
push:
|
50
|
-
if: github.repository_owner == 'karafka'
|
51
|
-
timeout-minutes: 30
|
52
|
-
runs-on: ubuntu-latest
|
53
|
-
needs: build
|
54
|
-
environment: deployment
|
55
|
-
permissions:
|
56
|
-
contents: write
|
57
|
-
id-token: write
|
58
|
-
steps:
|
59
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
60
|
-
with:
|
61
|
-
fetch-depth: 0
|
62
|
-
- name: Download precompiled library
|
63
|
-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
64
|
-
with:
|
65
|
-
name: librdkafka-precompiled-musl
|
66
|
-
path: ext/
|
67
|
-
- name: Set up Ruby
|
68
|
-
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
|
69
|
-
with:
|
70
|
-
ruby-version: '3.4'
|
71
|
-
bundler-cache: false
|
72
|
-
- name: Configure trusted publishing credentials
|
73
|
-
uses: rubygems/configure-rubygems-credentials@bc6dd217f8a4f919d6835fcfefd470ef821f5c44 # v1.0.0
|
74
|
-
- name: Build and push platform-specific gem
|
75
|
-
run: |
|
76
|
-
gem build *.gemspec
|
77
|
-
gem push *.gem
|
78
|
-
env:
|
79
|
-
RUBY_PLATFORM: 'x86_64-linux-musl'
|
@@ -1,54 +0,0 @@
|
|
1
|
-
name: Push macOS ARM64 Platform Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- v*
|
7
|
-
|
8
|
-
permissions:
|
9
|
-
contents: read
|
10
|
-
|
11
|
-
env:
|
12
|
-
BUNDLE_RETRY: 6
|
13
|
-
BUNDLE_JOBS: 4
|
14
|
-
|
15
|
-
jobs:
|
16
|
-
push:
|
17
|
-
if: github.repository_owner == 'karafka'
|
18
|
-
timeout-minutes: 30
|
19
|
-
runs-on: macos-14
|
20
|
-
environment: deployment
|
21
|
-
permissions:
|
22
|
-
contents: write
|
23
|
-
id-token: write
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
26
|
-
with:
|
27
|
-
fetch-depth: 0
|
28
|
-
- name: Install Bash 4+ and Kerberos
|
29
|
-
run: |
|
30
|
-
brew install bash
|
31
|
-
brew list krb5 &>/dev/null || brew install krb5
|
32
|
-
echo "/opt/homebrew/bin" >> $GITHUB_PATH
|
33
|
-
- name: Cache build-tmp directory
|
34
|
-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
|
35
|
-
with:
|
36
|
-
path: ext/build-tmp-macos
|
37
|
-
key: build-tmp-${{ runner.os }}-${{ hashFiles('ext/*.sh', 'ext/Rakefile') }}-v2
|
38
|
-
- name: Set up Ruby
|
39
|
-
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
|
40
|
-
with:
|
41
|
-
ruby-version: '3.4'
|
42
|
-
bundler-cache: false
|
43
|
-
- name: Build precompiled librdkafka for macOS ARM64
|
44
|
-
run: |
|
45
|
-
cd ext
|
46
|
-
/opt/homebrew/bin/bash ./build_macos_arm64.sh
|
47
|
-
- name: Configure trusted publishing credentials
|
48
|
-
uses: rubygems/configure-rubygems-credentials@bc6dd217f8a4f919d6835fcfefd470ef821f5c44 # v1.0.0
|
49
|
-
- name: Build and push platform-specific gem
|
50
|
-
run: |
|
51
|
-
gem build *.gemspec
|
52
|
-
gem push *.gem
|
53
|
-
env:
|
54
|
-
RUBY_PLATFORM: 'arm64-darwin'
|
@@ -1,37 +0,0 @@
|
|
1
|
-
name: Push Ruby Platform Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- v*
|
7
|
-
|
8
|
-
permissions:
|
9
|
-
contents: read
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
push:
|
13
|
-
if: github.repository_owner == 'karafka'
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
environment: deployment
|
16
|
-
|
17
|
-
permissions:
|
18
|
-
contents: write
|
19
|
-
id-token: write
|
20
|
-
|
21
|
-
steps:
|
22
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
23
|
-
with:
|
24
|
-
fetch-depth: 0
|
25
|
-
|
26
|
-
- name: Set up Ruby
|
27
|
-
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
|
28
|
-
with:
|
29
|
-
bundler-cache: false
|
30
|
-
|
31
|
-
- name: Build rdkafka-ruby
|
32
|
-
run: |
|
33
|
-
set -e
|
34
|
-
bundle install
|
35
|
-
cd ext && bundle exec rake
|
36
|
-
|
37
|
-
- uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
|
@@ -1,30 +0,0 @@
|
|
1
|
-
name: Trigger Wiki Refresh
|
2
|
-
|
3
|
-
on:
|
4
|
-
release:
|
5
|
-
types: [published]
|
6
|
-
push:
|
7
|
-
branches: [main]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
trigger-wiki-refresh:
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
environment: wiki-trigger
|
13
|
-
if: github.repository_owner == 'karafka'
|
14
|
-
steps:
|
15
|
-
- name: Trigger wiki refresh
|
16
|
-
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
|
17
|
-
with:
|
18
|
-
token: ${{ secrets.WIKI_REPO_TOKEN }}
|
19
|
-
repository: karafka/wiki
|
20
|
-
event-type: sync-trigger
|
21
|
-
client-payload: |
|
22
|
-
{
|
23
|
-
"repository": "${{ github.repository }}",
|
24
|
-
"event_name": "${{ github.event_name }}",
|
25
|
-
"release_tag": "${{ github.event.release.tag_name || '' }}",
|
26
|
-
"release_name": "${{ github.event.release.name || '' }}",
|
27
|
-
"commit_sha": "${{ github.sha }}",
|
28
|
-
"commit_message": "Trigger Wiki Refresh",
|
29
|
-
"triggered_by": "${{ github.actor }}"
|
30
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
name: Verify Action Pins
|
2
|
-
on:
|
3
|
-
pull_request:
|
4
|
-
paths:
|
5
|
-
- '.github/workflows/**'
|
6
|
-
jobs:
|
7
|
-
verify_action_pins:
|
8
|
-
runs-on: ubuntu-latest
|
9
|
-
steps:
|
10
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
11
|
-
- name: Check SHA pins
|
12
|
-
run: |
|
13
|
-
if grep -E -r "uses: .*/.*@(v[0-9]+|main|master)($|[[:space:]]|$)" --include="*.yml" --include="*.yaml" .github/workflows/ | grep -v "#"; then
|
14
|
-
echo "::error::Actions should use SHA pins, not tags or branch names"
|
15
|
-
exit 1
|
16
|
-
fi
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rdkafka-ruby
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.4.5
|
data/.yardopts
DELETED
Binary file
|
data/dist/krb5-1.21.3.tar.gz
DELETED
Binary file
|
data/dist/openssl-3.0.16.tar.gz
DELETED
Binary file
|
data/dist/zlib-1.3.1.tar.gz
DELETED
Binary file
|
data/dist/zstd-1.5.7.tar.gz
DELETED
Binary file
|
data/ext/README.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Ext
|
2
|
-
|
3
|
-
This gem depends on the `librdkafka` C library. It is downloaded, stored in
|
4
|
-
`dist/` directory, and checked into source control.
|
5
|
-
|
6
|
-
To update the `librdkafka` version follow the following steps:
|
7
|
-
|
8
|
-
* Go to https://github.com/confluentinc/librdkafka/releases to get the new
|
9
|
-
version number and asset checksum for `tar.gz`.
|
10
|
-
* Change the version in `lib/rdkafka/version.rb`
|
11
|
-
* Change the `sha256` in `lib/rdkafka/version.rb`
|
12
|
-
* Run `bundle exec rake dist:download` in the `ext` directory to download the
|
13
|
-
new release and place it in the `dist/` for you
|
14
|
-
* Run `bundle exec rake` in the `ext` directory to build the new version
|
15
|
-
* Run `docker-compose pull` in the main gem directory to ensure the docker
|
16
|
-
images used by the tests and run `docker-compose up`
|
17
|
-
* Finally, run `bundle exec rspec` in the main gem directory to execute
|
18
|
-
the test suite to detect any regressions that may have been introduced
|
19
|
-
by the update
|
data/ext/build_common.sh
DELETED
@@ -1,376 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
#
|
3
|
-
# Common functions and constants for librdkafka builds
|
4
|
-
# This file should be sourced by platform-specific build scripts
|
5
|
-
#
|
6
|
-
# Usage: source "$(dirname "${BASH_SOURCE[0]}")/build_common.sh"
|
7
|
-
#
|
8
|
-
|
9
|
-
# Prevent multiple sourcing
|
10
|
-
if [[ "${BUILD_COMMON_SOURCED:-}" == "1" ]]; then
|
11
|
-
return 0
|
12
|
-
fi
|
13
|
-
|
14
|
-
BUILD_COMMON_SOURCED=1
|
15
|
-
|
16
|
-
# Version constants - update these to upgrade dependencies
|
17
|
-
readonly OPENSSL_VERSION="3.0.16"
|
18
|
-
readonly CYRUS_SASL_VERSION="2.1.28"
|
19
|
-
readonly ZLIB_VERSION="1.3.1"
|
20
|
-
readonly ZSTD_VERSION="1.5.7"
|
21
|
-
readonly KRB5_VERSION="1.21.3"
|
22
|
-
readonly LIBRDKAFKA_VERSION="2.11.0"
|
23
|
-
|
24
|
-
# SHA256 checksums for supply chain security
|
25
|
-
# Update these when upgrading versions
|
26
|
-
declare -A CHECKSUMS=(
|
27
|
-
["openssl-${OPENSSL_VERSION}.tar.gz"]="57e03c50feab5d31b152af2b764f10379aecd8ee92f16c985983ce4a99f7ef86"
|
28
|
-
["cyrus-sasl-${CYRUS_SASL_VERSION}.tar.gz"]="7ccfc6abd01ed67c1a0924b353e526f1b766b21f42d4562ee635a8ebfc5bb38c"
|
29
|
-
["zlib-1.3.1.tar.gz"]="9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23"
|
30
|
-
["zstd-${ZSTD_VERSION}.tar.gz"]="eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3"
|
31
|
-
["krb5-${KRB5_VERSION}.tar.gz"]="b7a4cd5ead67fb08b980b21abd150ff7217e85ea320c9ed0c6dadd304840ad35"
|
32
|
-
["librdkafka-${LIBRDKAFKA_VERSION}.tar.gz"]="592a823dc7c09ad4ded1bc8f700da6d4e0c88ffaf267815c6f25e7450b9395ca"
|
33
|
-
)
|
34
|
-
|
35
|
-
# Colors for output
|
36
|
-
readonly RED='\033[0;31m'
|
37
|
-
readonly GREEN='\033[0;32m'
|
38
|
-
readonly YELLOW='\033[1;33m'
|
39
|
-
readonly BLUE='\033[0;34m'
|
40
|
-
readonly NC='\033[0m' # No Color
|
41
|
-
|
42
|
-
# Logging functions
|
43
|
-
log() {
|
44
|
-
echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
|
45
|
-
}
|
46
|
-
|
47
|
-
warn() {
|
48
|
-
echo -e "${YELLOW}[WARNING] $1${NC}"
|
49
|
-
}
|
50
|
-
|
51
|
-
error() {
|
52
|
-
echo -e "${RED}[ERROR] $1${NC}"
|
53
|
-
exit 1
|
54
|
-
}
|
55
|
-
|
56
|
-
security_log() {
|
57
|
-
echo -e "${BLUE}[SECURITY] $1${NC}"
|
58
|
-
}
|
59
|
-
|
60
|
-
# Function to verify checksums
|
61
|
-
verify_checksum() {
|
62
|
-
local file="$1"
|
63
|
-
local expected_checksum="${CHECKSUMS[$file]}"
|
64
|
-
|
65
|
-
if [ -z "$expected_checksum" ]; then
|
66
|
-
error "No checksum defined for $file - this is a security risk!"
|
67
|
-
fi
|
68
|
-
|
69
|
-
security_log "Verifying checksum for $file..."
|
70
|
-
local actual_checksum
|
71
|
-
|
72
|
-
# Use platform-appropriate checksum command
|
73
|
-
if command -v sha256sum &> /dev/null; then
|
74
|
-
actual_checksum=$(sha256sum "$file" | cut -d' ' -f1)
|
75
|
-
elif command -v shasum &> /dev/null; then
|
76
|
-
actual_checksum=$(shasum -a 256 "$file" | cut -d' ' -f1)
|
77
|
-
else
|
78
|
-
error "No SHA256 checksum utility found (tried sha256sum, shasum)"
|
79
|
-
fi
|
80
|
-
|
81
|
-
if [ "$actual_checksum" = "$expected_checksum" ]; then
|
82
|
-
security_log "✅ Checksum verified for $file"
|
83
|
-
return 0
|
84
|
-
else
|
85
|
-
error "❌ CHECKSUM MISMATCH for $file!
|
86
|
-
Expected: $expected_checksum
|
87
|
-
Actual: $actual_checksum
|
88
|
-
This could indicate a supply chain attack or corrupted download!"
|
89
|
-
fi
|
90
|
-
}
|
91
|
-
|
92
|
-
# Function to securely download and verify files
|
93
|
-
secure_download() {
|
94
|
-
local url="$1"
|
95
|
-
local filename="$2"
|
96
|
-
|
97
|
-
# Check if file already exists in current directory (may have been already downloaded)
|
98
|
-
if [ -f "$filename" ]; then
|
99
|
-
log "File $filename already exists, verifying checksum..."
|
100
|
-
verify_checksum "$filename"
|
101
|
-
return 0
|
102
|
-
fi
|
103
|
-
|
104
|
-
# Check dist directory relative to script location
|
105
|
-
local script_dir
|
106
|
-
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
107
|
-
local dist_file="$script_dir/../dist/$filename"
|
108
|
-
|
109
|
-
if [ -f "$dist_file" ]; then
|
110
|
-
log "Using distributed $filename from dist/"
|
111
|
-
cp "$dist_file" "$filename"
|
112
|
-
verify_checksum "$filename"
|
113
|
-
return 0
|
114
|
-
fi
|
115
|
-
|
116
|
-
log "Downloading $filename from $url..."
|
117
|
-
|
118
|
-
# Use platform-appropriate download command
|
119
|
-
if command -v wget &> /dev/null; then
|
120
|
-
# Linux - use wget with security options
|
121
|
-
if ! wget --secure-protocol=TLSv1_2 \
|
122
|
-
--https-only \
|
123
|
-
--timeout=30 \
|
124
|
-
--tries=3 \
|
125
|
-
--progress=bar \
|
126
|
-
"$url" \
|
127
|
-
-O "$filename"; then
|
128
|
-
error "Failed to download $filename from $url"
|
129
|
-
fi
|
130
|
-
elif command -v curl &> /dev/null; then
|
131
|
-
# macOS/fallback - use curl with security options
|
132
|
-
if ! curl -L \
|
133
|
-
--tlsv1.2 \
|
134
|
-
--connect-timeout 30 \
|
135
|
-
--max-time 300 \
|
136
|
-
--retry 3 \
|
137
|
-
--progress-bar \
|
138
|
-
"$url" \
|
139
|
-
-o "$filename"; then
|
140
|
-
error "Failed to download $filename from $url"
|
141
|
-
fi
|
142
|
-
else
|
143
|
-
error "No download utility found (tried wget, curl)"
|
144
|
-
fi
|
145
|
-
|
146
|
-
# Verify checksum immediately after download
|
147
|
-
verify_checksum "$filename"
|
148
|
-
}
|
149
|
-
|
150
|
-
# Function to detect CPU count for parallel builds
|
151
|
-
get_cpu_count() {
|
152
|
-
if command -v nproc &> /dev/null; then
|
153
|
-
nproc
|
154
|
-
elif command -v sysctl &> /dev/null; then
|
155
|
-
sysctl -n hw.ncpu
|
156
|
-
else
|
157
|
-
echo "4" # fallback
|
158
|
-
fi
|
159
|
-
}
|
160
|
-
|
161
|
-
# Function to auto-detect librdkafka tarball
|
162
|
-
find_librdkafka_tarball() {
|
163
|
-
local dist_dir="$1"
|
164
|
-
local tarball="$dist_dir/librdkafka-${LIBRDKAFKA_VERSION}.tar.gz"
|
165
|
-
|
166
|
-
if [ ! -f "$tarball" ]; then
|
167
|
-
error "librdkafka-${LIBRDKAFKA_VERSION}.tar.gz not found in $dist_dir"
|
168
|
-
fi
|
169
|
-
|
170
|
-
echo "$tarball"
|
171
|
-
}
|
172
|
-
|
173
|
-
# Function to find and validate patches
|
174
|
-
find_patches() {
|
175
|
-
local patches_dir="$1"
|
176
|
-
local -n patches_array=$2 # nameref to output array
|
177
|
-
|
178
|
-
patches_array=()
|
179
|
-
|
180
|
-
if [ -d "$patches_dir" ]; then
|
181
|
-
while IFS= read -r -d '' patch; do
|
182
|
-
patches_array+=("$patch")
|
183
|
-
done < <(find "$patches_dir" -name "*.patch" -type f -print0 | sort -z)
|
184
|
-
|
185
|
-
if [ ${#patches_array[@]} -gt 0 ]; then
|
186
|
-
log "Found ${#patches_array[@]} patches to apply:"
|
187
|
-
for patch in "${patches_array[@]}"; do
|
188
|
-
log " - $(basename "$patch")"
|
189
|
-
done
|
190
|
-
else
|
191
|
-
log "No patches found in $patches_dir"
|
192
|
-
fi
|
193
|
-
else
|
194
|
-
log "No patches directory found: $patches_dir"
|
195
|
-
fi
|
196
|
-
}
|
197
|
-
|
198
|
-
# Function to apply patches
|
199
|
-
apply_patches() {
|
200
|
-
local -n patches_array=$1 # nameref to patches array
|
201
|
-
|
202
|
-
if [ ${#patches_array[@]} -gt 0 ]; then
|
203
|
-
log "Applying Ruby-specific patches..."
|
204
|
-
for patch in "${patches_array[@]}"; do
|
205
|
-
log "Applying patch: $(basename "$patch")"
|
206
|
-
if patch -p1 < "$patch"; then
|
207
|
-
log "✅ Successfully applied $(basename "$patch")"
|
208
|
-
else
|
209
|
-
error "❌ Failed to apply patch: $(basename "$patch")"
|
210
|
-
fi
|
211
|
-
done
|
212
|
-
log "All patches applied successfully"
|
213
|
-
fi
|
214
|
-
}
|
215
|
-
|
216
|
-
# Function to verify librdkafka tarball checksum if available
|
217
|
-
verify_librdkafka_checksum() {
|
218
|
-
local tarball="$1"
|
219
|
-
local filename
|
220
|
-
filename=$(basename "$tarball")
|
221
|
-
|
222
|
-
if [ -n "${CHECKSUMS[$filename]:-}" ]; then
|
223
|
-
local current_dir
|
224
|
-
current_dir=$(pwd)
|
225
|
-
cd "$(dirname "$tarball")"
|
226
|
-
verify_checksum "$filename"
|
227
|
-
cd "$current_dir"
|
228
|
-
else
|
229
|
-
warn "No checksum defined for $filename - consider adding one for security"
|
230
|
-
fi
|
231
|
-
}
|
232
|
-
|
233
|
-
# Function to set execute permissions on configure scripts
|
234
|
-
fix_configure_permissions() {
|
235
|
-
log "Setting execute permissions on configure scripts..."
|
236
|
-
chmod +x configure* 2>/dev/null || true
|
237
|
-
chmod +x mklove/modules/configure.* 2>/dev/null || true
|
238
|
-
}
|
239
|
-
|
240
|
-
# Function to print security summary
|
241
|
-
print_security_summary() {
|
242
|
-
security_log "🔒 SECURITY VERIFICATION COMPLETE"
|
243
|
-
security_log "All dependencies downloaded and verified with SHA256 checksums"
|
244
|
-
security_log "Supply chain integrity maintained throughout build process"
|
245
|
-
}
|
246
|
-
|
247
|
-
# Function to print build summary
|
248
|
-
print_build_summary() {
|
249
|
-
local platform="$1"
|
250
|
-
local arch="$2"
|
251
|
-
local output_dir="$3"
|
252
|
-
local library_name="$4"
|
253
|
-
|
254
|
-
log "Build completed successfully!"
|
255
|
-
log "📦 Self-contained librdkafka built for $platform $arch:"
|
256
|
-
log " ✅ OpenSSL $OPENSSL_VERSION (SSL/TLS support) - checksum verified"
|
257
|
-
log " ✅ Cyrus SASL $CYRUS_SASL_VERSION (authentication for AWS MSK) - checksum verified"
|
258
|
-
log " ✅ MIT Kerberos $KRB5_VERSION (GSSAPI/Kerberos authentication) - checksum verified"
|
259
|
-
log " ✅ zlib $ZLIB_VERSION (compression) - checksum verified"
|
260
|
-
log " ✅ ZStd $ZSTD_VERSION (high-performance compression) - checksum verified"
|
261
|
-
log ""
|
262
|
-
log "🎯 Ready for deployment on $platform systems"
|
263
|
-
log "☁️ Compatible with AWS MSK and other secured Kafka clusters"
|
264
|
-
log "🔐 Supply chain security: All dependencies cryptographically verified"
|
265
|
-
log ""
|
266
|
-
log "Location: $output_dir/$library_name"
|
267
|
-
}
|
268
|
-
|
269
|
-
# Function to clean up build directory with user prompt (except .tar.gz files in CI)
|
270
|
-
cleanup_build_dir() {
|
271
|
-
local build_dir="$1"
|
272
|
-
|
273
|
-
if [ "${CI:-}" = "true" ]; then
|
274
|
-
# In CI: remove everything except .tar.gz files without prompting
|
275
|
-
echo "CI detected: cleaning up $build_dir (preserving .tar.gz files for caching)"
|
276
|
-
|
277
|
-
# First, find and move all .tar.gz files to a temp location
|
278
|
-
temp_dir=$(mktemp -d)
|
279
|
-
find "$build_dir" -name "*.tar.gz" -exec mv {} "$temp_dir/" \; 2>/dev/null || true
|
280
|
-
|
281
|
-
# Remove everything in build_dir
|
282
|
-
rm -rf "$build_dir"/* 2>/dev/null || true
|
283
|
-
rm -rf "$build_dir"/.* 2>/dev/null || true
|
284
|
-
|
285
|
-
# Move .tar.gz files back
|
286
|
-
mv "$temp_dir"/* "$build_dir/" 2>/dev/null || true
|
287
|
-
rmdir "$temp_dir" 2>/dev/null || true
|
288
|
-
|
289
|
-
log "Build directory cleaned up (preserved .tar.gz files)"
|
290
|
-
else
|
291
|
-
# Interactive mode: prompt user
|
292
|
-
echo
|
293
|
-
read -p "Remove build directory $build_dir? (y/N): " -n 1 -r
|
294
|
-
echo
|
295
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
296
|
-
rm -rf "$build_dir"
|
297
|
-
log "Build directory cleaned up"
|
298
|
-
fi
|
299
|
-
fi
|
300
|
-
}
|
301
|
-
|
302
|
-
# Function to validate build environment
|
303
|
-
check_common_dependencies() {
|
304
|
-
log "Checking common build dependencies..."
|
305
|
-
|
306
|
-
local missing_tools=()
|
307
|
-
|
308
|
-
command -v tar &> /dev/null || missing_tools+=("tar")
|
309
|
-
command -v make &> /dev/null || missing_tools+=("make")
|
310
|
-
command -v patch &> /dev/null || missing_tools+=("patch")
|
311
|
-
|
312
|
-
# Check for download tools
|
313
|
-
if ! command -v wget &> /dev/null && ! command -v curl &> /dev/null; then
|
314
|
-
missing_tools+=("wget or curl")
|
315
|
-
fi
|
316
|
-
|
317
|
-
# Check for checksum tools
|
318
|
-
if ! command -v sha256sum &> /dev/null && ! command -v shasum &> /dev/null; then
|
319
|
-
missing_tools+=("sha256sum or shasum")
|
320
|
-
fi
|
321
|
-
|
322
|
-
if [ ${#missing_tools[@]} -gt 0 ]; then
|
323
|
-
error "Missing required tools: ${missing_tools[*]}"
|
324
|
-
fi
|
325
|
-
|
326
|
-
log "✅ Common build tools found"
|
327
|
-
}
|
328
|
-
|
329
|
-
# Function to extract tarball if directory doesn't exist
|
330
|
-
extract_if_needed() {
|
331
|
-
local tarball="$1"
|
332
|
-
local expected_dir="$2"
|
333
|
-
|
334
|
-
if [ ! -d "$expected_dir" ]; then
|
335
|
-
log "Extracting $(basename "$tarball")..."
|
336
|
-
tar xzf "$tarball"
|
337
|
-
else
|
338
|
-
log "Directory $expected_dir already exists, skipping extraction"
|
339
|
-
fi
|
340
|
-
}
|
341
|
-
|
342
|
-
# Download URLs for dependencies
|
343
|
-
get_openssl_url() {
|
344
|
-
echo "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
|
345
|
-
}
|
346
|
-
|
347
|
-
get_sasl_url() {
|
348
|
-
echo "https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-${CYRUS_SASL_VERSION}/cyrus-sasl-${CYRUS_SASL_VERSION}.tar.gz"
|
349
|
-
}
|
350
|
-
|
351
|
-
get_zlib_url() {
|
352
|
-
echo "https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz"
|
353
|
-
}
|
354
|
-
|
355
|
-
get_zstd_url() {
|
356
|
-
echo "https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz"
|
357
|
-
}
|
358
|
-
|
359
|
-
get_krb5_url() {
|
360
|
-
# Using MIT mirror since kerberos.org is down
|
361
|
-
# echo "https://kerberos.org/dist/krb5/${KRB5_VERSION%.*}/krb5-${KRB5_VERSION}.tar.gz"
|
362
|
-
echo "https://web.mit.edu/kerberos/dist/krb5/${KRB5_VERSION%.*}/krb5-${KRB5_VERSION}.tar.gz"
|
363
|
-
}
|
364
|
-
|
365
|
-
# Export functions and variables that scripts will need
|
366
|
-
export -f log warn error security_log
|
367
|
-
export -f verify_checksum secure_download get_cpu_count
|
368
|
-
export -f find_librdkafka_tarball find_patches apply_patches
|
369
|
-
export -f verify_librdkafka_checksum fix_configure_permissions
|
370
|
-
export -f print_security_summary print_build_summary cleanup_build_dir
|
371
|
-
export -f check_common_dependencies extract_if_needed
|
372
|
-
export -f get_openssl_url get_sasl_url get_zlib_url get_zstd_url get_krb5_url
|
373
|
-
|
374
|
-
# Export constants
|
375
|
-
export OPENSSL_VERSION CYRUS_SASL_VERSION ZLIB_VERSION ZSTD_VERSION KRB5_VERSION
|
376
|
-
export RED GREEN YELLOW BLUE NC
|