Files
clickhouse-tools/scripts/build-rpm.sh
T
unkin-agent a849c26509
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
Make build-rpm.sh executable and test completion generation
The v0.1.0 tag pipeline failed at the package step: build-rpm.sh was
committed mode 100644, so CI's ./scripts/build-rpm.sh invocation died
with permission denied before any completions were generated.

- Restore the executable bit on scripts/build-rpm.sh (mode 100755,
  matching node-lookup)
- Add TestCompletionAllEntrypointsAndShells covering bash/zsh/fish
  completion generation through the argv[0] dispatch for all four
  entrypoints (chlog/chcat/chtail/chgrep)
2026-08-23 17:29:23 +10:00

52 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Package the (already built) chlog binary into an RPM with nfpm, bundling
# chcat/chtail/chgrep symlinks and generated bash/zsh/fish shell completions.
# Usage: scripts/build-rpm.sh [version] (version defaults to $CI_COMMIT_TAG)
#
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${ROOT_DIR}"
VERSION="${1:-${CI_COMMIT_TAG:-0.0.0-dev}}"
VERSION="${VERSION#v}" # strip a leading v
BINARY="chlog"
NAMES=(chlog chcat chtail chgrep)
DIST="dist"
if [ ! -f "${DIST}/${BINARY}" ]; then
echo "ERROR: ${DIST}/${BINARY} not found; run 'make build' first" >&2
exit 1
fi
for l in chcat chtail chgrep; do
ln -sf "${BINARY}" "${DIST}/${l}"
done
# Generate shell completions per entrypoint name so they always match the
# shipped flags/subcommands (each name dispatches to its own command tree).
COMP_DIR="${DIST}/completions"
mkdir -p "${COMP_DIR}"
for b in "${NAMES[@]}"; do
"./${DIST}/${b}" completion bash >"${COMP_DIR}/${b}.bash"
"./${DIST}/${b}" completion zsh >"${COMP_DIR}/_${b}"
"./${DIST}/${b}" completion fish >"${COMP_DIR}/${b}.fish"
done
export PACKAGE_NAME="clickhouse-tools"
export PACKAGE_VERSION="${VERSION}"
export PACKAGE_RELEASE="1"
export PACKAGE_ARCH="amd64"
export PACKAGE_PLATFORM="linux"
export PACKAGE_DESCRIPTION="CLI tools for the ClickHouse log store: chlog with chcat (print), chtail (follow) and chgrep (search) entrypoints"
export PACKAGE_MAINTAINER="Ben Vincent <ben@unkin.net>"
export PACKAGE_HOMEPAGE="https://git.unkin.net/unkin/clickhouse-tools"
export PACKAGE_LICENSE="MIT"
envsubst <packaging/nfpm.yaml >"${DIST}/nfpm.yaml"
nfpm pkg --config "${DIST}/nfpm.yaml" --target "${DIST}" --packager rpm
echo "Built:"
ls -1 "${DIST}"/*.rpm