2025-12-16 17:14:24 +01:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
set -euo pipefail
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
2025-12-16 17:14:24 +01:00
|
|
|
|
if [ -z "${BASH_VERSION:-}" ]; then
|
|
|
|
|
|
exec bash "$0" "$@"
|
|
|
|
|
|
fi
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
# Setup script for logos-blockchain-circuits
|
|
|
|
|
|
#
|
|
|
|
|
|
# Usage: scripts/setup/setup-nomos-circuits.sh [VERSION] [INSTALL_DIR]
|
|
|
|
|
|
#
|
|
|
|
|
|
# Arguments:
|
|
|
|
|
|
# VERSION Optional. Version to install (default: v0.3.2)
|
|
|
|
|
|
# INSTALL_DIR Optional. Installation directory (default: $HOME/.logos-blockchain-circuits)
|
|
|
|
|
|
#
|
|
|
|
|
|
# Examples:
|
|
|
|
|
|
# scripts/setup/setup-nomos-circuits.sh
|
|
|
|
|
|
# scripts/setup/setup-nomos-circuits.sh v0.3.2
|
|
|
|
|
|
# scripts/setup/setup-nomos-circuits.sh v0.3.2 /opt/circuits
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_CIRCUITS_VERSION="v0.3.2"
|
|
|
|
|
|
DEFAULT_INSTALL_DIR="${HOME}/.logos-blockchain-circuits"
|
|
|
|
|
|
REPO="logos-blockchain/logos-blockchain-circuits"
|
|
|
|
|
|
|
|
|
|
|
|
RED='\033[0;31m'
|
|
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
|
|
BLUE='\033[0;34m'
|
|
|
|
|
|
NC='\033[0m'
|
|
|
|
|
|
|
|
|
|
|
|
print_info() { echo -e "${BLUE}ℹ${NC} $1"; }
|
|
|
|
|
|
print_success() { echo -e "${GREEN}✓${NC} $1"; }
|
|
|
|
|
|
print_warning() { echo -e "${YELLOW}⚠${NC} $1"; }
|
|
|
|
|
|
print_error() { echo -e "${RED}✗${NC} $1"; }
|
|
|
|
|
|
|
|
|
|
|
|
VERSION="${1:-${DEFAULT_CIRCUITS_VERSION}}"
|
|
|
|
|
|
INSTALL_DIR="${2:-${DEFAULT_INSTALL_DIR}}"
|
|
|
|
|
|
|
|
|
|
|
|
# Detect OS and architecture
|
|
|
|
|
|
# Outputs: os-arch like linux-x86_64, macos-aarch64
|
|
|
|
|
|
#
|
|
|
|
|
|
# Uses same logic as the logos-blockchain-node installer.
|
|
|
|
|
|
detect_platform() {
|
2025-12-16 21:20:27 +01:00
|
|
|
|
local os="" arch=""
|
|
|
|
|
|
|
|
|
|
|
|
case "$(uname -s)" in
|
|
|
|
|
|
Linux*) os="linux" ;;
|
|
|
|
|
|
Darwin*) os="macos" ;;
|
|
|
|
|
|
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
|
2026-01-20 13:39:43 +01:00
|
|
|
|
*) print_error "Unsupported operating system: $(uname -s)"; exit 1 ;;
|
2025-12-16 21:20:27 +01:00
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
case "$(uname -m)" in
|
|
|
|
|
|
x86_64) arch="x86_64" ;;
|
|
|
|
|
|
aarch64|arm64) arch="aarch64" ;;
|
2026-01-20 13:39:43 +01:00
|
|
|
|
*) print_error "Unsupported architecture: $(uname -m)"; exit 1 ;;
|
2025-12-16 21:20:27 +01:00
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
echo "${os}-${arch}"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
check_existing_installation() {
|
2025-12-16 21:20:27 +01:00
|
|
|
|
if [ -d "${INSTALL_DIR}" ]; then
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_warning "Installation directory already exists: ${INSTALL_DIR}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
|
|
|
|
|
if [ -f "${INSTALL_DIR}/VERSION" ]; then
|
|
|
|
|
|
local current_version
|
|
|
|
|
|
current_version="$(cat "${INSTALL_DIR}/VERSION")"
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Currently installed version: ${current_version}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
if [ ! -t 0 ]; then
|
|
|
|
|
|
print_info "Non-interactive environment detected, automatically overwriting..."
|
2025-12-16 21:20:27 +01:00
|
|
|
|
else
|
|
|
|
|
|
echo
|
|
|
|
|
|
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
|
|
|
|
|
|
echo
|
|
|
|
|
|
if [[ ! ${REPLY} =~ ^[Yy]$ ]]; then
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Installation cancelled."
|
2025-12-16 21:20:27 +01:00
|
|
|
|
exit 0
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Removing existing installation..."
|
2025-12-16 21:20:27 +01:00
|
|
|
|
rm -rf "${INSTALL_DIR}"
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
download_release() {
|
2025-12-16 21:20:27 +01:00
|
|
|
|
local platform="$1"
|
2026-01-20 13:39:43 +01:00
|
|
|
|
local artifact="logos-blockchain-circuits-${VERSION}-${platform}.tar.gz"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
local url="https://github.com/${REPO}/releases/download/${VERSION}/${artifact}"
|
|
|
|
|
|
local temp_dir
|
|
|
|
|
|
temp_dir="$(mktemp -d)"
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Downloading logos-blockchain-circuits ${VERSION} for ${platform}..."
|
|
|
|
|
|
print_info "URL: ${url}"
|
2026-01-09 11:22:50 +02:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
local curl_cmd="curl -L"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
2026-01-20 13:39:43 +01:00
|
|
|
|
curl_cmd="$curl_cmd --header 'authorization: Bearer ${GITHUB_TOKEN}'"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
2026-01-20 13:39:43 +01:00
|
|
|
|
curl_cmd="$curl_cmd -o ${temp_dir}/${artifact} ${url}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
if ! eval "${curl_cmd}"; then
|
|
|
|
|
|
print_error "Failed to download release artifact"
|
|
|
|
|
|
print_error "Please check that version ${VERSION} exists for platform ${platform}"
|
|
|
|
|
|
print_error "Available releases: https://github.com/${REPO}/releases"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
rm -rf "${temp_dir}"
|
2026-01-20 13:39:43 +01:00
|
|
|
|
exit 1
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_success "Download complete"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Extracting to ${INSTALL_DIR}..."
|
2025-12-16 21:20:27 +01:00
|
|
|
|
mkdir -p "${INSTALL_DIR}"
|
|
|
|
|
|
|
|
|
|
|
|
if ! tar -xzf "${temp_dir}/${artifact}" -C "${INSTALL_DIR}" --strip-components=1; then
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_error "Failed to extract archive"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
rm -rf "${temp_dir}"
|
2026-01-20 13:39:43 +01:00
|
|
|
|
exit 1
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
rm -rf "${temp_dir}"
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_success "Extraction complete"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
handle_macos_quarantine() {
|
|
|
|
|
|
print_info "macOS detected: Removing quarantine attributes from executables..."
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
if find "${INSTALL_DIR}" -type f -perm +111 -exec xattr -d com.apple.quarantine {} \; 2>/dev/null; then
|
|
|
|
|
|
print_success "Quarantine attributes removed"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
else
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_warning "Could not remove quarantine attributes (they may not exist)"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_circuits() {
|
|
|
|
|
|
print_info "The following circuits are available:"
|
|
|
|
|
|
|
|
|
|
|
|
local dir
|
2025-12-16 21:20:27 +01:00
|
|
|
|
for dir in "${INSTALL_DIR}"/*/; do
|
2026-01-20 13:39:43 +01:00
|
|
|
|
if [ -d "${dir}" ] && [ -f "${dir}/witness_generator" ]; then
|
|
|
|
|
|
echo " • $(basename "${dir}")"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
main() {
|
|
|
|
|
|
print_info "Setting up logos-blockchain-circuits ${VERSION}"
|
|
|
|
|
|
print_info "Installation directory: ${INSTALL_DIR}"
|
|
|
|
|
|
echo
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
local platform
|
|
|
|
|
|
platform="$(detect_platform)"
|
|
|
|
|
|
print_info "Detected platform: ${platform}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
check_existing_installation
|
|
|
|
|
|
download_release "${platform}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
if [[ "${platform}" == macos-* ]]; then
|
2025-12-16 21:20:27 +01:00
|
|
|
|
echo
|
2026-01-20 13:39:43 +01:00
|
|
|
|
handle_macos_quarantine
|
2025-12-16 21:20:27 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_success "Installation complete!"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
echo
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "logos-blockchain-circuits ${VERSION} is now installed at: ${INSTALL_DIR}"
|
|
|
|
|
|
print_circuits
|
2025-12-16 21:20:27 +01:00
|
|
|
|
|
|
|
|
|
|
if [ "${INSTALL_DIR}" != "${DEFAULT_INSTALL_DIR}" ]; then
|
|
|
|
|
|
echo
|
2026-01-20 13:39:43 +01:00
|
|
|
|
print_info "Since you're using a custom installation directory, set the environment variable:"
|
|
|
|
|
|
print_info " export LOGOS_BLOCKCHAIN_CIRCUITS=${INSTALL_DIR}"
|
2025-12-16 21:20:27 +01:00
|
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 13:39:43 +01:00
|
|
|
|
main "$@"
|