#!/bin/bash set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' # No Color # Spinner function spinner() { local pid=$1 local task=$2 local spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏' local i=0 while kill -0 $pid 2>/dev/null; do i=$(( (i+1) %10 )) printf "\r${BLUE}${spin:$i:1}${NC} %s..." "$task" sleep 0.1 done printf "\r" } # Configuration PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Args DVDSTYLER_URL="" DVDSTYLER_ZIP="" SKIP_DVD_TOOLS="" while [ $# -gt 0 ]; do case "$1" in --dvdstyler-url=*) DVDSTYLER_URL="${1#*=}" shift ;; --dvdstyler-url) DVDSTYLER_URL="$2" shift 2 ;; --dvdstyler-zip=*) DVDSTYLER_ZIP="${1#*=}" shift ;; --dvdstyler-zip) DVDSTYLER_ZIP="$2" shift 2 ;; --skip-dvd) SKIP_DVD_TOOLS=true shift ;; *) echo "Unknown option: $1" echo "Usage: $0 [--dvdstyler-url URL] [--dvdstyler-zip PATH] [--skip-dvd]" exit 1 ;; esac done # Platform detection UNAME_S="$(uname -s)" IS_WINDOWS=false IS_DARWIN=false IS_LINUX=false case "$UNAME_S" in MINGW*|MSYS*|CYGWIN*) IS_WINDOWS=true ;; Darwin*) IS_DARWIN=true ;; Linux*) IS_LINUX=true ;; esac INSTALL_TITLE="VideoTools Installation" if [ "$IS_WINDOWS" = true ]; then INSTALL_TITLE="VideoTools Windows Installation" elif [ "$IS_DARWIN" = true ]; then INSTALL_TITLE="VideoTools macOS Installation" elif [ "$IS_LINUX" = true ]; then INSTALL_TITLE="VideoTools Linux Installation" fi echo "════════════════════════════════════════════════════════════════" echo " $INSTALL_TITLE" echo "════════════════════════════════════════════════════════════════" echo "" # Step 1: Check if Go is installed echo -e "${CYAN}[1/2]${NC} Checking Go installation..." if ! command -v go &> /dev/null; then echo -e "${RED}✗ Error: Go is not installed or not in PATH${NC}" echo "Please install Go 1.21+ from https://go.dev/dl/" exit 1 fi GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//') echo -e "${GREEN}✓${NC} Found Go version: $GO_VERSION" # Step 2: Check authoring dependencies echo "" echo -e "${CYAN}[2/2]${NC} Checking authoring dependencies..." if [ "$IS_WINDOWS" = true ]; then echo "Detected Windows environment." if [ -z "$SKIP_DVD_TOOLS" ]; then echo "" read -p "Install DVD authoring tools (DVDStyler)? [y/N]: " dvd_choice if [[ "$dvd_choice" =~ ^[Yy]$ ]]; then SKIP_DVD_TOOLS=false else SKIP_DVD_TOOLS=true fi fi if command -v powershell.exe &> /dev/null; then PS_ARGS=() if [ "$SKIP_DVD_TOOLS" = true ]; then PS_ARGS+=("-SkipDvdStyler") fi if [ -n "$DVDSTYLER_ZIP" ]; then powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" -DvdStylerZip "$DVDSTYLER_ZIP" "${PS_ARGS[@]}" elif [ -n "$DVDSTYLER_URL" ]; then powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" -DvdStylerUrl "$DVDSTYLER_URL" "${PS_ARGS[@]}" else powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" "${PS_ARGS[@]}" fi if [ $? -ne 0 ]; then echo -e "${RED}✗ Windows dependency installer failed.${NC}" echo "If DVDStyler download failed, retry with a direct mirror:" echo "" echo "Git Bash:" echo " export VT_DVDSTYLER_URL=\"https://netcologne.dl.sourceforge.net/project/dvdstyler/DVDStyler/3.2.1/DVDStyler-3.2.1-win64.zip\"" echo " ./scripts/install.sh" echo "" echo "PowerShell:" echo " \$env:VT_DVDSTYLER_URL=\"https://netcologne.dl.sourceforge.net/project/dvdstyler/DVDStyler/3.2.1/DVDStyler-3.2.1-win64.zip\"" echo " .\\scripts\\install-deps-windows.ps1" exit 1 fi echo -e "${GREEN}✓${NC} Windows dependency installer completed" else echo -e "${RED}✗ powershell.exe not found.${NC}" echo "Please run: $PROJECT_ROOT\\scripts\\install-deps-windows.ps1" exit 1 fi else missing_deps=() if ! command -v ffmpeg &> /dev/null; then missing_deps+=("ffmpeg") fi if [ -z "$SKIP_DVD_TOOLS" ]; then echo "" read -p "Install DVD authoring tools (dvdauthor + ISO tools)? [y/N]: " dvd_choice if [[ "$dvd_choice" =~ ^[Yy]$ ]]; then SKIP_DVD_TOOLS=false else SKIP_DVD_TOOLS=true fi fi if [ "$SKIP_DVD_TOOLS" = false ]; then if ! command -v dvdauthor &> /dev/null; then missing_deps+=("dvdauthor") fi if ! command -v mkisofs &> /dev/null && ! command -v genisoimage &> /dev/null && ! command -v xorriso &> /dev/null; then missing_deps+=("iso-tool") fi fi install_deps=false if [ ${#missing_deps[@]} -gt 0 ]; then echo -e "${YELLOW}WARNING${NC} Missing dependencies: ${missing_deps[*]}" read -p "Install missing dependencies now? [y/N]: " install_choice if [[ "$install_choice" =~ ^[Yy]$ ]]; then install_deps=true fi else echo -e "${GREEN}✓${NC} All authoring dependencies found" fi if [ "$install_deps" = true ]; then if command -v apt-get &> /dev/null; then sudo apt-get update if [ "$SKIP_DVD_TOOLS" = true ]; then sudo apt-get install -y ffmpeg else sudo apt-get install -y ffmpeg dvdauthor genisoimage fi elif command -v dnf &> /dev/null; then if [ "$SKIP_DVD_TOOLS" = true ]; then sudo dnf install -y ffmpeg else sudo dnf install -y ffmpeg dvdauthor genisoimage fi elif command -v pacman &> /dev/null; then if [ "$SKIP_DVD_TOOLS" = true ]; then sudo pacman -Sy --noconfirm ffmpeg else sudo pacman -Sy --noconfirm ffmpeg dvdauthor cdrtools fi elif command -v zypper &> /dev/null; then if [ "$SKIP_DVD_TOOLS" = true ]; then sudo zypper install -y ffmpeg else sudo zypper install -y ffmpeg dvdauthor genisoimage fi elif command -v brew &> /dev/null; then if [ "$SKIP_DVD_TOOLS" = true ]; then brew install ffmpeg else brew install ffmpeg dvdauthor xorriso fi else echo -e "${RED}✗ No supported package manager found.${NC}" echo "Please install: ffmpeg, dvdauthor, and mkisofs/genisoimage/xorriso" exit 1 fi fi if ! command -v ffmpeg &> /dev/null; then echo -e "${RED}✗ Missing required dependencies after install attempt.${NC}" echo "Please install: ffmpeg" exit 1 fi if [ "$SKIP_DVD_TOOLS" = false ]; then if ! command -v dvdauthor &> /dev/null; then echo -e "${RED}✗ Missing required dependencies after install attempt.${NC}" echo "Please install: dvdauthor" exit 1 fi if ! command -v mkisofs &> /dev/null && ! command -v genisoimage &> /dev/null && ! command -v xorriso &> /dev/null; then echo -e "${RED}✗ Missing ISO creation tool after install attempt.${NC}" echo "Please install: mkisofs (cdrtools), genisoimage, or xorriso" exit 1 fi fi fi echo "" echo "════════════════════════════════════════════════════════════════" echo "Dependency Installation Complete!" echo "════════════════════════════════════════════════════════════════" echo "" echo "Next steps:" echo "" echo "1. Build VideoTools:" echo " ./scripts/build.sh" echo "" echo "2. Run VideoTools:" echo " ./scripts/run.sh" echo "" echo "For more information, see BUILD_AND_RUN.md and DVD_USER_GUIDE.md" echo ""