#!/bin/bash # Integration test for install.sh on fresh Linux systems # This script tests that install.sh works correctly on a completely fresh system # with no prerequisites installed # Supports: Debian, Ubuntu, Arch Linux set -e # Detect OS type if command -v apt-get &> /dev/null; then OS_TYPE="debian" elif command -v pacman &> /dev/null; then OS_TYPE="arch" else echo "ERROR: Unsupported OS (no apt-get or pacman found)" exit 1 fi # Configure non-interactive mode for CI/container environments if [ "$OS_TYPE" = "debian" ]; then # Debian/Ubuntu-specific environment setup export DEBIAN_FRONTEND=noninteractive export DEBCONF_NONINTERACTIVE_SEEN=true export TZ=UTC # Pre-configure timezone to prevent interactive prompts ln -fs /usr/share/zoneinfo/UTC /etc/localtime fi echo "=== Testing install.sh on fresh system ===" echo "OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d= -f2 | tr -d '"')" echo "OS Type: $OS_TYPE" echo "" echo "NOTE: install.sh will handle all prerequisites (Python, pip, Reticulum, etc.)" echo "" # Helper function: Check if a package is installed (OS-agnostic) check_package() { local pkg="$1" if [ "$OS_TYPE" = "debian" ]; then # Match package with or without architecture suffix (e.g., python3-cairo:amd64) dpkg -l | grep -q "^ii $pkg" || { echo "FAIL: $pkg not installed"; exit 1; } elif [ "$OS_TYPE" = "arch" ]; then pacman -Q "$pkg" &> /dev/null || { echo "FAIL: $pkg not installed"; exit 1; } fi } # Run installer - it now handles everything from basic packages to Reticulum echo "Running install.sh (self-contained installer)..." # Navigate to repository root (script is in tests/ directory) cd "$(dirname "$0")/.." REPO_ROOT="$(pwd)" chmod +x install.sh mkdir -p /tmp/test-config # Run non-interactively (answer 'n' to bluetooth permissions prompt) # Note: BlueZ experimental mode will be enabled by default (no prompt) ./install.sh --config /tmp/test-config < /dev/null && command -v bluetoothctl &> /dev/null; then # systemctl is available - check if experimental mode was configured if [ -f /etc/systemd/system/bluetooth.service.d/override.conf ]; then echo " ✓ Systemd override file created" if grep -q -- "-E" /etc/systemd/system/bluetooth.service.d/override.conf; then echo " ✓ Experimental mode flag (-E) configured" else echo " ⚠ WARNING: Override file exists but -E flag not found" fi else # No override file - may have been already enabled or not supported if systemctl status bluetooth 2>/dev/null | grep -q -- "-E\|--experimental"; then echo " ✓ Experimental mode already enabled (not via installer)" else echo " ⚠ WARNING: Experimental mode not configured" fi fi else # systemctl or bluetoothctl not available (container environment) echo " ℹ Systemd/BlueZ not available (container environment - OK)" fi echo "" # Test --skip-experimental flag echo "Testing --skip-experimental flag..." cd "$REPO_ROOT" # Run with --skip-experimental to verify it doesn't fail ./install.sh --config /tmp/test-config-skip --skip-experimental > /tmp/skip-test.log 2>&1 </dev/null || echo "unknown") if [[ "$ARCH" == "armhf" ]]; then echo " • System packages: python3, python3-pip, git, python3-gi, python3-dbus, python3-cairo, bluez, libffi-dev" echo " • Note: libffi-dev included for 32-bit ARM cffi compilation" else echo " • System packages: python3, python3-pip, git, python3-gi, python3-dbus, python3-cairo, bluez" fi echo " • Pip packages: rns, bleak, bluezero" echo " • Install method: System packages (no compilation)" echo " • Installation time: < 1 minute" elif [ "$OS_TYPE" = "arch" ]; then echo " • System packages: python, python-pip, git, python-dbus, python-cairo, bluez, bluez-utils, base-devel" echo " • Pip packages: rns, bleak, bluezero, PyGObject (compiled)" echo " • Install method: System packages + PyGObject compilation (version compatibility)" echo " • Installation time: ~2-3 minutes (PyGObject compilation)" fi echo ""