From 29a02265a118f4eb63951cc2fdb9630b9a50767b Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Tue, 6 Jan 2026 15:24:54 -0500 Subject: [PATCH] Restructure setup.sh for optimized tarball detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move repo clone to step 4 (before pyenv) to check for tarball early - Set USE_PREBUILT flag immediately after cloning - Python compile only happens if not already installed (fallback) - Better progress messages during install This ensures pre-built venv detection happens before expensive Python compile step, and skips compile entirely on repeat installs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- rpi/setup.sh | 58 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/rpi/setup.sh b/rpi/setup.sh index d98601f..36f7e93 100755 --- a/rpi/setup.sh +++ b/rpi/setup.sh @@ -165,7 +165,31 @@ else echo " gum already installed" fi -echo -e "${GREEN}[4/12]${NC} Installing pyenv and Python $PYTHON_VERSION..." +echo -e "${GREEN}[4/12]${NC} Cloning Stegasoo..." + +# Clone Stegasoo first (needed to check for pre-built tarball) +if [ -d "$INSTALL_DIR/.git" ]; then + echo " Stegasoo directory exists, updating..." + cd "$INSTALL_DIR" + git fetch origin + git checkout "$STEGASOO_BRANCH" + git pull origin "$STEGASOO_BRANCH" +else + git clone -b "$STEGASOO_BRANCH" "$STEGASOO_REPO" "$INSTALL_DIR" + cd "$INSTALL_DIR" +fi + +# Check for pre-built venv tarball (skips 20+ min compile time) +PREBUILT_VENV="$INSTALL_DIR/rpi/stegasoo-venv-pi-arm64.tar.zst" +PREBUILT_VENV_URL="${PREBUILT_VENV_URL:-}" # Optional: URL to download from +USE_PREBUILT=false + +if [ -f "$PREBUILT_VENV" ] || [ -n "$PREBUILT_VENV_URL" ]; then + USE_PREBUILT=true + echo -e "${GREEN}Found pre-built venv tarball - fast install mode${NC}" +fi + +echo -e "${GREEN}[5/12]${NC} Installing pyenv and Python $PYTHON_VERSION..." # Install pyenv if not present if [ ! -d "$HOME/.pyenv" ]; then @@ -185,16 +209,21 @@ if [ ! -d "$HOME/.pyenv" ]; then echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc fi else - echo "pyenv already installed, skipping..." + echo " pyenv already installed" export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" fi -# Install Python 3.12 if not present +# Install Python 3.12 if not present (required even for pre-built venv) if ! pyenv versions | grep -q "$PYTHON_VERSION"; then - echo "Building Python $PYTHON_VERSION (this takes ~10 minutes)..." + if [ "$USE_PREBUILT" = true ]; then + echo -e " ${YELLOW}Note: Python $PYTHON_VERSION needed for pre-built venv${NC}" + fi + echo " Building Python $PYTHON_VERSION (this takes ~10 minutes)..." pyenv install $PYTHON_VERSION +else + echo " Python $PYTHON_VERSION already installed" fi pyenv global $PYTHON_VERSION @@ -205,25 +234,8 @@ if [ "$INSTALLED_PY" != "$PYTHON_VERSION" ]; then exit 1 fi -echo -e "${GREEN}[5/12]${NC} Cloning Stegasoo..." - -# Clone Stegasoo first (needed for jpegio patch script) -if [ -d "$INSTALL_DIR/.git" ]; then - echo " Stegasoo directory exists, updating..." - cd "$INSTALL_DIR" - git fetch origin - git checkout "$STEGASOO_BRANCH" - git pull origin "$STEGASOO_BRANCH" -else - git clone -b "$STEGASOO_BRANCH" "$STEGASOO_REPO" "$INSTALL_DIR" - cd "$INSTALL_DIR" -fi - -# Check for pre-built venv tarball (skips 20+ min compile time) -PREBUILT_VENV="$INSTALL_DIR/rpi/stegasoo-venv-pi-arm64.tar.zst" -PREBUILT_VENV_URL="${PREBUILT_VENV_URL:-}" # Optional: URL to download from - -if [ -f "$PREBUILT_VENV" ] || [ -n "$PREBUILT_VENV_URL" ]; then +# Fast path: use pre-built venv if available +if [ "$USE_PREBUILT" = true ]; then echo -e "${GREEN}[6/8]${NC} Installing pre-built Python environment..." # Download if URL provided and local file doesn't exist