From 6529febcfa285f1af7bd28849702752f7eb9d902 Mon Sep 17 00:00:00 2001 From: Smittix Date: Mon, 16 Feb 2026 21:25:15 +0000 Subject: [PATCH] fix: Overhaul setup.sh for reliability and macOS compatibility - Use pre-built SatDump DMG on macOS instead of building from source (avoids sol2/Apple Clang deprecation errors) - Fix `python: command not found` by using explicit venv/bin/python paths - Split pip install into core + optional packages to avoid all-or-nothing failures on newer Python versions - Make dumpvdl2 optional (warn instead of fail) since VDL2 is one feature - Fix Homebrew volk package name (libvolk -> volk) - Add GCC 13+ sol2 deprecation pragma patch for Debian SatDump build - Quote $(which) to handle paths with spaces - Remove macOS sed fallback from Debian-only function - Update TOTAL_STEPS counts (macOS: 22, Debian: 28) - Add hdiutil detach cleanup to SatDump DMG install trap Co-Authored-By: Claude Opus 4.6 --- setup.sh | 170 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 100 insertions(+), 70 deletions(-) diff --git a/setup.sh b/setup.sh index ad0d59a..456f0e8 100755 --- a/setup.sh +++ b/setup.sh @@ -226,7 +226,7 @@ check_tools() { check_optional "hackrf_sweep" "HackRF spectrum analyzer" hackrf_sweep check_required "dump1090" "ADS-B decoder" dump1090 check_required "acarsdec" "ACARS decoder" acarsdec - check_required "dumpvdl2" "VDL2 decoder" dumpvdl2 + check_optional "dumpvdl2" "VDL2 decoder" dumpvdl2 check_required "AIS-catcher" "AIS vessel decoder" AIS-catcher aiscatcher check_optional "satdump" "Weather satellite decoder (NOAA/Meteor)" satdump echo @@ -313,28 +313,41 @@ install_python_deps() { # shellcheck disable=SC1091 source venv/bin/activate + local PIP="venv/bin/python -m pip" + local PY="venv/bin/python" - python -m pip install --upgrade pip setuptools wheel >/dev/null 2>&1 || true + $PIP install --upgrade pip setuptools wheel >/dev/null 2>&1 || true ok "Upgraded pip tooling" progress "Installing Python dependencies" - # Try pip install, but don't fail if apt packages already satisfied deps - if ! python -m pip install -r requirements.txt 2>/dev/null; then - warn "Some pip packages failed - checking if apt packages cover them..." - # Verify critical packages are available - python -c "import flask; import requests; from flask_limiter import Limiter" 2>/dev/null || { - fail "Critical Python packages (flask, requests, flask-limiter) not installed" - echo "Try: pip install flask requests flask-limiter" - exit 1 - } - ok "Core Python dependencies available" - else - ok "Python dependencies installed" - fi - # Ensure Flask 3.0+ is installed (required for Werkzeug 3.x compatibility) - # System apt packages may have older Flask 2.x which is incompatible - python -m pip install --upgrade "flask>=3.0.0" >/dev/null 2>&1 || true + # Install critical packages first to avoid all-or-nothing failures + # (C extension packages like scipy/numpy can fail on newer Python versions + # and cause pip to roll back pure-Python packages like flask) + info "Installing core packages..." + $PIP install "flask>=3.0.0" "flask-limiter>=2.5.4" "requests>=2.28.0" \ + "Werkzeug>=3.1.5" "pyserial>=3.5" "flask-sock" "websocket-client>=1.6.0" 2>&1 \ + | tail -5 || true + + # Verify critical packages + $PY -c "import flask; import requests; from flask_limiter import Limiter" 2>/dev/null || { + fail "Critical Python packages (flask, requests, flask-limiter) not installed" + echo "Try: venv/bin/pip install flask requests flask-limiter" + exit 1 + } + ok "Core Python packages installed" + + # Install optional packages individually (some may fail on newer Python) + info "Installing optional packages..." + for pkg in "numpy>=1.24.0" "scipy>=1.10.0" "Pillow>=9.0.0" "skyfield>=1.45" \ + "bleak>=0.21.0" "psycopg2-binary>=2.9.9" "meshtastic>=2.0.0" \ + "scapy>=2.4.5" "qrcode[pil]>=7.4" "cryptography>=41.0.0"; do + pkg_name="${pkg%%>=*}" + if ! $PIP install "$pkg" 2>/dev/null; then + warn "${pkg_name} failed to install (optional - related features may be unavailable)" + fi + done + ok "Optional packages processed" echo } @@ -763,6 +776,21 @@ install_satdump_from_source_debian() { || { warn "Failed to clone SatDump"; exit 1; } cd "$tmp_dir/SatDump" + + # Patch: fix deprecated std::allocator usage for newer compilers + # GCC 13+ errors on deprecated allocator members in sol2. + # Pragmas must go in lua_utils.cpp (the instantiation site), not sol.hpp (definition site). + lua_utils="src-core/common/lua/lua_utils.cpp" + if [ -f "$lua_utils" ]; then + { + echo '#pragma GCC diagnostic push' + echo '#pragma GCC diagnostic ignored "-Wdeprecated"' + echo '#pragma GCC diagnostic ignored "-Wdeprecated-declarations"' + cat "$lua_utils" + echo '#pragma GCC diagnostic pop' + } > "${lua_utils}.patched" && mv "${lua_utils}.patched" "$lua_utils" + fi + mkdir -p build && cd build info "Compiling SatDump (this is a large C++ project and may take 10-30 minutes)..." @@ -807,62 +835,64 @@ install_satdump_from_source_debian() { ) } -install_satdump_from_source_macos() { - info "Building SatDump v1.2.2 from source (weather satellite decoder)..." +install_satdump_macos() { + info "Installing SatDump v1.2.2 from pre-built release (weather satellite decoder)..." - brew_install cmake - brew_install libpng - brew_install libtiff - brew_install jemalloc - brew_install libvolk - brew_install nng - brew_install zstd - brew_install soapysdr - brew_install hackrf - brew_install fftw + # Determine architecture + local arch + arch="$(uname -m)" + local dmg_name + if [ "$arch" = "arm64" ]; then + dmg_name="SatDump-macOS-Silicon.dmg" + else + dmg_name="SatDump-macOS-Intel.dmg" + fi + + local dmg_url="https://github.com/SatDump/SatDump/releases/download/1.2.2/${dmg_name}" + local install_dir="/usr/local/lib/satdump" # Run in subshell to isolate EXIT trap ( tmp_dir="$(mktemp -d)" - trap 'rm -rf "$tmp_dir"' EXIT + trap 'hdiutil detach "$tmp_dir/mnt" -quiet 2>/dev/null || true; rm -rf "$tmp_dir"' EXIT - info "Cloning SatDump v1.2.2..." - git clone --depth 1 --branch 1.2.2 https://github.com/SatDump/SatDump.git "$tmp_dir/SatDump" >/dev/null 2>&1 \ - || { warn "Failed to clone SatDump"; exit 1; } + info "Downloading ${dmg_name}..." + if ! curl -sL -o "$tmp_dir/satdump.dmg" "$dmg_url"; then + warn "Failed to download SatDump. Weather satellite decoding will not be available." + exit 1 + fi - cd "$tmp_dir/SatDump" - mkdir -p build && cd build + info "Installing SatDump..." + # Mount the DMG + hdiutil attach "$tmp_dir/satdump.dmg" -nobrowse -quiet -mountpoint "$tmp_dir/mnt" \ + || { warn "Failed to mount SatDump DMG"; exit 1; } - info "Compiling SatDump (this is a large C++ project and may take 10-30 minutes)..." - build_log="$tmp_dir/satdump-build.log" + local app_dir="$tmp_dir/mnt/SatDump.app" + if [ ! -d "$app_dir" ]; then + warn "SatDump.app not found in DMG" + exit 1 + fi - # Show periodic progress while building so the user knows it's not hung - ( - while true; do - sleep 30 - if [ -f "$build_log" ]; then - local_lines=$(wc -l < "$build_log" 2>/dev/null || echo 0) - printf " [*] Still compiling SatDump... (%s lines of build output so far)\n" "$local_lines" - fi - done - ) & - progress_pid=$! + # Install: copy app contents to /usr/local/lib/satdump + refresh_sudo + $SUDO mkdir -p "$install_dir" + $SUDO cp -R "$app_dir/Contents/MacOS/"* "$install_dir/" + $SUDO cp -R "$app_dir/Contents/Resources/"* "$install_dir/" - if cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF .. >"$build_log" 2>&1 \ - && make -j "$(sysctl -n hw.ncpu)" >>"$build_log" 2>&1; then - kill $progress_pid 2>/dev/null; wait $progress_pid 2>/dev/null - if [[ -w /usr/local/bin ]]; then - make install >/dev/null 2>&1 - else - refresh_sudo - $SUDO make install >/dev/null 2>&1 - fi - ok "SatDump installed successfully." + # Create wrapper script so satdump can find its resources via @executable_path + $SUDO tee /usr/local/bin/satdump >/dev/null <<'WRAPPER' +#!/bin/sh +exec /usr/local/lib/satdump/satdump "$@" +WRAPPER + $SUDO chmod +x /usr/local/bin/satdump + + hdiutil detach "$tmp_dir/mnt" -quiet 2>/dev/null + + # Verify installation + if /usr/local/lib/satdump/satdump 2>&1 | grep -q "Usage"; then + ok "SatDump v1.2.2 installed successfully." else - kill $progress_pid 2>/dev/null; wait $progress_pid 2>/dev/null - warn "Failed to build SatDump from source. Weather satellite decoding will not be available." - warn "Build log (last 30 lines):" - tail -30 "$build_log" | while IFS= read -r line; do warn " $line"; done + warn "SatDump installed but may not work correctly." fi ) } @@ -876,7 +906,7 @@ install_macos_packages() { sudo -v || { fail "sudo authentication failed"; exit 1; } fi - TOTAL_STEPS=19 + TOTAL_STEPS=22 CURRENT_STEP=0 progress "Checking Homebrew" @@ -951,7 +981,7 @@ install_macos_packages() { progress "Installing dumpvdl2" if ! cmd_exists dumpvdl2; then - install_dumpvdl2_from_source_macos || fail "dumpvdl2 installation failed. VDL2 decoding requires dumpvdl2." + install_dumpvdl2_from_source_macos || warn "dumpvdl2 not available. VDL2 decoding will not be available." else ok "dumpvdl2 already installed" fi @@ -968,7 +998,7 @@ install_macos_packages() { echo info "SatDump is used for weather satellite imagery (NOAA APT & Meteor LRPT)." if ask_yes_no "Do you want to install SatDump?"; then - install_satdump_from_source_macos || warn "SatDump build failed. Weather satellite decoding will not be available." + install_satdump_macos || warn "SatDump installation failed. Weather satellite decoding will not be available." else warn "Skipping SatDump installation. You can install it later if needed." fi @@ -1060,7 +1090,7 @@ install_dump1090_from_source_debian() { cd "$tmp_dir/dump1090" # Remove -Werror to prevent build failures on newer GCC versions - sed -i 's/-Werror//g' Makefile 2>/dev/null || sed -i '' 's/-Werror//g' Makefile + sed -i 's/-Werror//g' Makefile 2>/dev/null || true info "Compiling FlightAware dump1090..." if make BLADERF=no RTLSDR=yes >/dev/null 2>&1; then $SUDO install -m 0755 dump1090 /usr/local/bin/dump1090 @@ -1319,7 +1349,7 @@ install_debian_packages() { export NEEDRESTART_MODE=a fi - TOTAL_STEPS=26 + TOTAL_STEPS=28 CURRENT_STEP=0 progress "Updating APT package lists" @@ -1461,7 +1491,7 @@ install_debian_packages() { fi if ! cmd_exists dump1090; then if cmd_exists dump1090-mutability; then - $SUDO ln -s $(which dump1090-mutability) /usr/local/sbin/dump1090 + $SUDO ln -s "$(which dump1090-mutability)" /usr/local/sbin/dump1090 fi fi cmd_exists dump1090 || install_dump1090_from_source_debian @@ -1474,7 +1504,7 @@ install_debian_packages() { progress "Installing dumpvdl2" if ! cmd_exists dumpvdl2; then - install_dumpvdl2_from_source_debian || fail "dumpvdl2 installation failed. VDL2 decoding requires dumpvdl2." + install_dumpvdl2_from_source_debian || warn "dumpvdl2 not available. VDL2 decoding will not be available." else ok "dumpvdl2 already installed" fi