# VelaMQ RS Packaging

This directory contains the multi-platform packaging helper for `velamq-rs`.

## Files

- `package-velamq.sh`: build `web/`, compile `velamqd`, and package each target as a zip archive
- `package-fluxmq.sh`: build `web/`, compile `fluxmqd`, and package each target as a zip archive
- `package-common.sh`: shared implementation used by the brand-specific entry scripts
- `package.sh`: compatibility entry, equivalent to `package-velamq.sh`
- `release/`: sync already-built release artifacts into the Linux apt/yum repo and Homebrew tap
- `repos/`: git submodules for the publish targets (`velamq-repo` and `homebrew-velamq`)

## Usage

```bash
cd /Users/lulu/Work/velamq-rs
bash deploy/package-velamq.sh
bash deploy/package-fluxmq.sh
```

Useful variants:

```bash
# Only package the current host target
TARGETS="$(rustc -vV | sed -n 's/^host: //p')" bash deploy/package-velamq.sh

# Set a visible version string for the output archive names
VERSION=0.1.0 bash deploy/package-velamq.sh

# Package the FluxMQ brand and produce bin/fluxmqd
bash deploy/package-fluxmq.sh

# Build a native package with Oracle OCI enabled
ENABLE_ORACLE_OCI=1 TARGETS="$(rustc -vV | sed -n 's/^host: //p')" bash deploy/package-velamq.sh

# Build a host-only package tuned for the current CPU
VELAMQ_RELEASE_NATIVE_CPU=1 TARGETS="$(rustc -vV | sed -n 's/^host: //p')" bash deploy/package-velamq.sh
```

## Notes

- By default the script uses `--no-default-features`, so portable packages do not require Oracle Instant Client.
- Release packages use `opt-level=3`, thin LTO, one codegen unit, stripped symbols, and `panic=abort` by default. Override with `VELAMQ_RELEASE_OPT_LEVEL`, `VELAMQ_RELEASE_LTO`, `VELAMQ_RELEASE_CODEGEN_UNITS`, `VELAMQ_RELEASE_STRIP`, or `VELAMQ_RELEASE_PANIC`.
- Set `VELAMQ_RELEASE_NATIVE_CPU=1` only for host-target packages that will run on the same CPU family; portable multi-platform packages keep generic CPU codegen.
- Cross builds use Rust `1.91.1` by default because current AWS SDK dependencies require at least `rustc 1.91.1`; override with `VELAMQ_CROSS_RUSTUP_TOOLCHAIN=<toolchain>` when needed. `Cross.toml` passes through rustup environment settings so Docker builds do not try to self-update rustup, installs Linux `libclang-18`, `protoc`, and native C headers needed by vendored clients; the package script points bindgen-based native crates at `/usr/lib/llvm-18/lib` inside the cross image.
- On macOS, the script auto-detects `libclang.dylib` from Xcode Command Line Tools, Xcode, or Homebrew LLVM for RocksDB builds. Use `LIBCLANG_PATH=/path/to/lib` for a custom LLVM install.
- On macOS, Linux and Windows non-host targets require `cross` plus Docker.
- The produced zip file contains `bin/`, `static/`, `config.toml`, this README, and a small launch script.

## Release repository sync

After release artifacts are built, use the scripts under `deploy/release/` to
update the public installation repositories:

```bash
git submodule update --init --recursive

DOWNLOAD_BASE_URL=https://repo.velamq.com/velamq/downloads \
  bash deploy/release/publish-release.sh
```

For apt/yum repositories, convert Linux zip artifacts into deb/rpm first:

```bash
bash deploy/release/build-linux-packages.sh
```

The sync scripts create commits in the target repos by default. Set
`SYNC_PUSH=1` when you also want to push those commits.
