#!/bin/bash # ============================================ # PointCab Renamer - Linux Build Script # Version 4.2.1 # ============================================ set -e # Bei Fehlern abbrechen echo "" echo "===================================" echo " PointCab Renamer - Linux Build" echo " Version 4.2.1" echo "===================================" echo "" # Farben für Ausgabe RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Arbeitsverzeichnis SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" echo -e "${BLUE}[1/6] Prüfe Voraussetzungen...${NC}" # Prüfe ob Python3 installiert ist if ! command -v python3 &> /dev/null; then echo -e "${RED}[FEHLER] Python3 ist nicht installiert.${NC}" echo "" echo "Installation:" echo " Ubuntu/Debian: sudo apt install python3 python3-pip python3-tk" echo " Fedora: sudo dnf install python3 python3-pip python3-tkinter" exit 1 fi PYTHON_VERSION=$(python3 --version 2>&1) echo -e "${GREEN}✓ Python3 gefunden: $PYTHON_VERSION${NC}" # Prüfe ob tkinter installiert ist echo -e "${BLUE}[2/6] Prüfe tkinter...${NC}" if ! python3 -c "import tkinter" 2>/dev/null; then echo -e "${YELLOW}[WARNUNG] tkinter nicht gefunden.${NC}" echo "" echo "Installation von tkinter:" echo " Ubuntu/Debian: sudo apt install python3-tk" echo " Fedora: sudo dnf install python3-tkinter" echo "" # Versuche automatische Installation (nur wenn sudo verfügbar) if command -v apt &> /dev/null && [ -w /etc/apt ]; then echo "Versuche automatische Installation..." sudo apt install -y python3-tk || { echo -e "${RED}[FEHLER] Automatische Installation fehlgeschlagen.${NC}" echo "Bitte manuell installieren: sudo apt install python3-tk" exit 1 } else echo -e "${RED}[FEHLER] tkinter muss manuell installiert werden.${NC}" exit 1 fi fi echo -e "${GREEN}✓ tkinter verfügbar${NC}" # Prüfe ob pip installiert ist echo -e "${BLUE}[3/6] Prüfe pip...${NC}" if ! command -v pip3 &> /dev/null && ! python3 -m pip --version &> /dev/null; then echo -e "${YELLOW}[INFO] pip3 nicht gefunden.${NC}" echo "" echo "Installation von pip:" echo " Ubuntu/Debian: sudo apt install python3-pip" echo " Fedora: sudo dnf install python3-pip" echo " Oder: python3 -m ensurepip --upgrade" exit 1 fi echo -e "${GREEN}✓ pip verfügbar${NC}" # Prüfe ob PyInstaller installiert ist echo -e "${BLUE}[4/6] Prüfe PyInstaller...${NC}" if ! python3 -m PyInstaller --version &> /dev/null 2>&1; then echo -e "${YELLOW}[INFO] PyInstaller nicht gefunden. Installiere...${NC}" python3 -m pip install --user pyinstaller || { echo -e "${RED}[FEHLER] PyInstaller konnte nicht installiert werden.${NC}" echo "Versuche: pip3 install pyinstaller" exit 1 } fi PYINSTALLER_VERSION=$(python3 -m PyInstaller --version 2>&1) echo -e "${GREEN}✓ PyInstaller installiert: $PYINSTALLER_VERSION${NC}" # Prüfe Projektdateien echo -e "${BLUE}[5/6] Prüfe Projektdateien...${NC}" if [ ! -f "pointcab_renamer.py" ]; then echo -e "${RED}[FEHLER] pointcab_renamer.py nicht gefunden!${NC}" echo "Bitte führen Sie das Skript im Projektverzeichnis aus." exit 1 fi if [ ! -f "cluster_cleanup.txt" ]; then echo -e "${RED}[FEHLER] cluster_cleanup.txt nicht gefunden!${NC}" exit 1 fi echo -e "${GREEN}✓ Projektdateien vorhanden${NC}" # Lösche alte Build-Verzeichnisse echo "" echo -e "${BLUE}[6/6] Starte Build-Prozess...${NC}" echo "[INFO] Räume alte Build-Dateien auf..." rm -rf build dist *.spec 2>/dev/null || true echo "[INFO] Erstelle Linux-Binary..." echo "" # PyInstaller ausführen python3 -m PyInstaller \ --onefile \ --name "pointcab_renamer" \ --add-data "cluster_cleanup.txt:." \ pointcab_renamer.py if [ $? -ne 0 ]; then echo "" echo -e "${RED}[FEHLER] Build fehlgeschlagen!${NC}" echo "" echo "Mögliche Ursachen:" echo " - PyInstaller-Version inkompatibel" echo " - Fehlende Abhängigkeiten" echo "" echo "Versuche: pip3 install --upgrade pyinstaller" exit 1 fi echo "" echo -e "${GREEN}[INFO] Build erfolgreich!${NC}" echo "" # Kopiere notwendige Dateien in dist-Ordner echo "[INFO] Kopiere zusätzliche Dateien..." cp cluster_cleanup.txt dist/ [ -f BENUTZERHANDBUCH.md ] && cp BENUTZERHANDBUCH.md dist/ # Mache das Binary ausführbar chmod +x dist/pointcab_renamer # Zeige Ergebnis echo "" echo -e "${GREEN}===================================${NC}" echo -e "${GREEN} BUILD ERFOLGREICH!${NC}" echo -e "${GREEN}===================================${NC}" echo "" echo "Erstellte Dateien:" ls -lh dist/ echo "" echo "Verwendung:" echo " cd dist && ./pointcab_renamer" echo "" echo "Für Distribution alle Dateien aus dist/ kopieren." echo ""