#!/bin/sh # Xbomly installer for macOS and Linux. # # curl -LsSf https://xbomly.com/install.sh | sh # # What it does, all inside your home folder (no sudo): # 1. Installs uv (Astral's Python tool installer) if you don't have it. # uv fetches its own Python 3.12 when yours is missing or older than 3.11. # 2. Installs or upgrades the cbomly command from PyPI. # 3. Installs Syft (Anchore's SBOM tool) with Homebrew, or Anchore's official script into ~/.local/bin. # 4. Runs `cbomly doctor` and adds the Xbomly app to Applications (macOS) or the app menu (Linux). # # Options (environment variables): # CBOMLY_NO_SYFT=1 skip Syft # CBOMLY_VERSION=x install a specific scanner version set -eu say() { printf '\033[1m==>\033[0m %s\n' "$*"; } warn() { printf '\033[33mwarning:\033[0m %s\n' "$*" >&2; } die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; } have() { command -v "$1" >/dev/null 2>&1; } case "$(uname -s)" in Darwin) os=mac ;; Linux) os=linux ;; *) die "this installer is for macOS and Linux. On Windows, see https://xbomly.com/download/" ;; esac if have curl; then fetch() { curl -LsSf "$1"; } elif have wget; then fetch() { wget -qO- "$1"; } else die "curl or wget is needed" fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT # Download a script to a file first, so a failed download never runs half a script. run_remote() { url=$1; shift fetch "$url" >"$tmp/script.sh" && sh "$tmp/script.sh" "$@" } bindir="$HOME/.local/bin" mkdir -p "$bindir" new_path=no case ":$PATH:" in *":$bindir:"*) ;; *) PATH="$bindir:$PATH"; export PATH; new_path=yes ;; esac # 1. uv if have uv; then uv=$(command -v uv) else say "Installing uv (Python tool installer from astral.sh)" UV_INSTALL_DIR="$bindir" UV_NO_MODIFY_PATH=1 run_remote https://astral.sh/uv/install.sh --quiet \ || die "could not install uv. See https://xbomly.com/download/ for the manual steps" uv="$bindir/uv" fi # 2. cbomly spec=cbomly [ -n "${CBOMLY_VERSION:-}" ] && spec="cbomly==$CBOMLY_VERSION" say "Installing $spec" "$uv" tool install --force --upgrade --python '>=3.11' "$spec" \ || die "could not install cbomly. Email team@xbomly.com with the output above" "$uv" tool update-shell >/dev/null 2>&1 || true # Make sure new terminals find cbomly, even if update-shell skipped the shell this user runs. tooldir=$("$uv" tool dir --bin 2>/dev/null || echo "$bindir") case "$(basename "${SHELL:-sh}")" in zsh) profiles="$HOME/.zshrc $HOME/.zprofile" ;; bash) if [ "$os" = mac ]; then profiles="$HOME/.bash_profile"; else profiles="$HOME/.bashrc"; fi ;; *) profiles="$HOME/.profile" ;; esac for f in $profiles; do if ! grep -qs "$tooldir" "$f" 2>/dev/null && ! grep -qs '\.local/bin' "$f" 2>/dev/null; then printf '\n# Added by the Xbomly installer\nexport PATH="%s:$PATH"\n' "$tooldir" >>"$f" && new_path=yes fi done # 3. Syft if [ -n "${CBOMLY_NO_SYFT:-}" ]; then say "Skipping Syft (CBOMLY_NO_SYFT is set)" elif have syft; then say "Syft is already installed: $(syft version 2>/dev/null | awk '/^Version/ {print $2}')" elif [ "$os" = mac ] && have brew; then say "Installing Syft with Homebrew" brew install syft || warn "Homebrew could not install Syft. Scans still work, without the software list" else say "Installing Syft (Anchore's official installer) into $bindir" run_remote https://raw.githubusercontent.com/anchore/syft/main/install.sh -b "$bindir" \ || warn "could not install Syft. Scans still work, without the software list" fi # 4. Check echo "$("$uv" tool dir --bin)/cbomly" doctor || true echo if "$tooldir/cbomly" app --add-shortcut >/dev/null 2>&1; then say "Done. Open Xbomly from your apps, or in a new terminal run: cbomly scan ./your-project" else say "Done. Open a new terminal, then run: cbomly scan ./your-project" fi if [ "$new_path" = yes ]; then say "Terminals that were already open won't find cbomly. Open a new one, or run: export PATH=\"$tooldir:\$PATH\"" fi