csv-dbf-converter/scripts/build_linux.sh

135 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
# ====
# CSV zu DBF Konverter - Linux Build Script
# Version 1.0
# ====
set -e # Bei Fehlern abbrechen
echo ""
echo "===="
echo " CSV zu DBF Konverter - Linux Build"
echo " Version 1.0"
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)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_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"
exit 1
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"
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}"
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 "csv_dbf_converter_gui.py" ]; then
echo -e "${RED}[FEHLER] csv_dbf_converter_gui.py 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 für GUI-Version..."
echo ""
# PyInstaller für GUI-Version ausführen
python3 -m PyInstaller \
--onefile \
--name "csv_dbf_converter_gui" \
csv_dbf_converter_gui.py
if [ $? -ne 0 ]; then
echo ""
echo -e "${RED}[FEHLER] Build fehlgeschlagen!${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}[INFO] Build erfolgreich!${NC}"
echo ""
# Kopiere notwendige Dateien in dist-Ordner
echo "[INFO] Kopiere Konfigurationsdateien..."
mkdir -p dist/config
cp -r config/examples dist/config/
cp csv_dbf_converter.py dist/
[ -f README.md ] && cp README.md dist/
# Mache das Binary ausführbar
chmod +x dist/csv_dbf_converter_gui
# 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 && ./csv_dbf_converter_gui"
echo ""
echo "Für Distribution alle Dateien aus dist/ kopieren."
echo ""