Skip to content

Conversation

@tnsardesai
Copy link

@tnsardesai tnsardesai commented Jan 14, 2026

This is used by


Note

Adds tooling for building and installing Hypeman with more flexible paths.

  • New scripts/build-from-source.sh: Builds hypeman-api and hypeman-token, writes logs to build.log, validates absolute OUTPUT_DIR, and copies .env.example to the output dir
  • Installer enhancements (scripts/install.sh): Adds BINARY_DIR mode to install from prebuilt binaries (with validation and exec perms), makes BRANCH, VERSION, and BINARY_DIR mutually exclusive with checks, and treats CLI_VERSION=latest as auto-resolve; keeps build-from-source and release-download paths intact

Written by Cursor Bugbot for commit ebef7e8. This will update automatically on new commits. Configure here.

Copy link

@tembo tembo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition overall — BINARY_DIR support is a useful escape hatch.

A couple small robustness tweaks would make the scripts easier to debug and safer to run:

  • Consider set -euo pipefail + making the OUTPUT_DIR defaulting safe with -u.
  • Truncate build.log once per run so failures don’t get buried in previous output.
  • In install.sh’s BINARY_DIR path, validate expected files exist before copying to produce clearer errors.

# OUTPUT_DIR - Full path of directory to place built binaries (optional, default: $(pwd)/bin)
#

set -e
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enabling pipefail here so failures in piped commands don’t get masked. If you do add -u, you’ll also want the OUTPUT_DIR check below to be safe with unset vars.

Suggested change
set -e
set -euo pipefail

Comment on lines 44 to 46
if [ -z "$OUTPUT_DIR" ]; then
OUTPUT_DIR=${SOURCE_DIR}/bin
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you enable set -u, this if [ -z "$OUTPUT_DIR" ] pattern will error on an unset variable. This alternative is robust and a bit shorter.

Suggested change
if [ -z "$OUTPUT_DIR" ]; then
OUTPUT_DIR=${SOURCE_DIR}/bin
fi
: "${OUTPUT_DIR:=${SOURCE_DIR}/bin}"

# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

BUILD_LOG="${OUTPUT_DIR}/build.log"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: >> "$BUILD_LOG" appends across runs, which can make failures confusing. Truncating once at the start keeps the log scoped to the current build.

Suggested change
BUILD_LOG="${OUTPUT_DIR}/build.log"
BUILD_LOG="${OUTPUT_DIR}/build.log"
: > "$BUILD_LOG"

Comment on lines 213 to 217
info "Copying binaries from ${BINARY_DIR}..."
cp "${BINARY_DIR}/${BINARY_NAME}" "${TMP_DIR}/${BINARY_NAME}"
cp "${BINARY_DIR}/hypeman-token" "${TMP_DIR}/hypeman-token"
cp "${BINARY_DIR}/.env.example" "${TMP_DIR}/.env.example"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since BINARY_DIR is user-provided, validating the expected files exist before cp makes failures a lot clearer.

Suggested change
info "Copying binaries from ${BINARY_DIR}..."
cp "${BINARY_DIR}/${BINARY_NAME}" "${TMP_DIR}/${BINARY_NAME}"
cp "${BINARY_DIR}/hypeman-token" "${TMP_DIR}/hypeman-token"
cp "${BINARY_DIR}/.env.example" "${TMP_DIR}/.env.example"
# Copy binaries to TMP_DIR
info "Copying binaries from ${BINARY_DIR}..."
for f in "${BINARY_NAME}" hypeman-token .env.example; do
[ -f "${BINARY_DIR}/${f}" ] || error "Missing ${f} in BINARY_DIR: ${BINARY_DIR}"
done
cp "${BINARY_DIR}/${BINARY_NAME}" "${TMP_DIR}/${BINARY_NAME}"
cp "${BINARY_DIR}/hypeman-token" "${TMP_DIR}/hypeman-token"
cp "${BINARY_DIR}/.env.example" "${TMP_DIR}/.env.example"

Copy link

@Sayan- Sayan- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bot comments seem relevant - particularly the file validation before cp in the BINARY_DIR path.

separately, what's the relation between install.sh and build-from-source.sh? the build logic (make build + go build gen-jwt + copy .env.example) now exists in both scripts. wondering if BRANCH mode in install.sh could delegate to build-from-source.sh to reduce duplication.

# Usage:
# ./scripts/build-from-source.sh
#
# Options (via environment variables:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing closing parenthesis - should be (via environment variables):

# ./scripts/build-from-source.sh
#
# Options (via environment variables:
# OUTPUT_DIR - Full path of directory to place built binaries (optional, default: $(pwd)/bin)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment says $(pwd)/bin but the actual default is ${SOURCE_DIR}/bin (the repo root's bin dir, not cwd). might want to clarify.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:nod: yep I changed the default but forgot to update comment


# Count how many of BRANCH, VERSION, BINARY_DIR are set
count=0
[ -n "$BRANCH" ] && ((count++)) || true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up: if you adopt the bot's suggestion for set -u, these [ -n "$BRANCH" ] checks will fail on unset vars. would need ${BRANCH:-} syntax.

@tnsardesai
Copy link
Author

separately, what's the relation between install.sh and build-from-source.sh? the build logic (make build + go build gen-jwt + copy .env.example) now exists in both scripts. wondering if BRANCH mode in install.sh could delegate to build-from-source.sh to reduce duplication.

that is actually how I had it originally but then noticed that we suggest curl -fsSL https://raw.githubusercontent.com/kernel/hypeman/main/scripts/install.sh | bash. If we delegate to build-from-source.sh then we are breaking curl-pipe mode to run the installer. Also the BRANCH mode clones the repo but the build-from-source.sh is meant to be run in the clone repo and not via curl-pipe.

I was thinking if build-from-source.sh should just be a make command 🤔. what do you think? @Sayan-

@tnsardesai tnsardesai requested a review from Sayan- January 15, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants