Files
cescobar 2219b3abc0 Commit inicial: G Radio Remoto (gr-client)
Cliente remoto GTK4 para G Radio Player: se conecta al servidor TCP
embebido en radio-player para controlar el reproductor y editar
programación (pautaje, parrilla, botonera, buscador, reportes) desde
otra máquina de la LAN.
2026-08-23 01:15:15 -05:00

156 lines
6.4 KiB
Bash
Executable File

#!/bin/bash
# package-deb.sh — Empaqueta G Radio Client como .deb instalable
# Requiere: binario ya compilado en target/release/
# Uso: ./package-deb.sh [versión] (default: 0.1.1)
set -e
VERSION="${1:-0.1.1}"
ARCH="$(dpkg --print-architecture)"
PKG_NAME="gr-client"
PKG_DIR="${PKG_NAME}_${VERSION}_${ARCH}"
ROOT="$(cd "$(dirname "$0")" && pwd)"
# ── Verificar que el binario existe ───────────────────────────────────────────
if [ ! -f "$ROOT/target/release/gr-client" ]; then
echo "[!] Binario faltante: target/release/gr-client"
echo " Ejecuta primero: cargo build --release"
exit 1
fi
echo "========================================"
echo " Empaquetando $PKG_NAME $VERSION ($ARCH)"
echo "========================================"
# ── Limpiar directorio anterior ───────────────────────────────────────────────
rm -rf "$PKG_DIR"
# ── Estructura de directorios ─────────────────────────────────────────────────
mkdir -p "$PKG_DIR/DEBIAN"
mkdir -p "$PKG_DIR/usr/local/bin"
mkdir -p "$PKG_DIR/usr/share/applications"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/48x48/apps"
# ── Copiar binario ────────────────────────────────────────────────────────────
echo "[*] Copiando binario..."
cp "$ROOT/target/release/gr-client" "$PKG_DIR/usr/local/bin/gr-client"
chmod 755 "$PKG_DIR/usr/local/bin/gr-client"
# ── Icono (reutiliza el del server si está disponible, sino genérico) ─────────
SERVER_ICON="../radio-player/assets/gradio.png"
if [ -f "$ROOT/assets/gr-client.png" ]; then
cp "$ROOT/assets/gr-client.png" \
"$PKG_DIR/usr/share/icons/hicolor/48x48/apps/gr-client.png"
elif [ -f "$ROOT/$SERVER_ICON" ]; then
cp "$ROOT/$SERVER_ICON" \
"$PKG_DIR/usr/share/icons/hicolor/48x48/apps/gr-client.png"
fi
# ── Entrada de escritorio ─────────────────────────────────────────────────────
echo "[*] Creando entrada de escritorio..."
cat > "$PKG_DIR/usr/share/applications/gr-client.desktop" << DESKTOP
[Desktop Entry]
Type=Application
Name=G Radio Client
GenericName=Radio Remote Client
Comment=Cliente remoto para G Radio Player
Exec=/usr/local/bin/gr-client
Icon=gr-client
Categories=AudioVideo;Audio;
Terminal=false
StartupNotify=true
Keywords=radio;audio;remote;client;
DESKTOP
# ── DEBIAN/control ────────────────────────────────────────────────────────────
echo "[*] Generando DEBIAN/control..."
INSTALLED_SIZE=$(du -sk "$PKG_DIR/usr" | cut -f1)
cat > "$PKG_DIR/DEBIAN/control" << CONTROL
Package: gr-client
Version: ${VERSION}
Architecture: ${ARCH}
Maintainer: G Radio <gradio@example.com>
Installed-Size: ${INSTALLED_SIZE}
Depends: libgtk-4-1 (>= 4.6),
libglib2.0-0 (>= 2.72),
ffmpeg,
mlocate | plocate,
libc6 (>= 2.17)
Recommends: gradio-player (>= 0.2.8)
Section: sound
Priority: optional
Description: G Radio Client — cliente remoto para G Radio Player
Panel GTK4 que permite controlar remotamente un servidor G Radio Player
via TCP (LAN o internet con relay). Incluye player básico con drag-and-drop,
editor de pautaje y parrilla, buscador de audio, botonera y visor de reportes.
.
Requiere un servidor G Radio Player (gradio-player >= 0.2.8) accesible
en la red local en el puerto configurado (default: 7777).
CONTROL
# ── DEBIAN/postinst ───────────────────────────────────────────────────────────
cat > "$PKG_DIR/DEBIAN/postinst" << 'POSTINST'
#!/bin/bash
set -e
# Crear directorio de datos si no existe
mkdir -p "$HOME/.gradio/data" 2>/dev/null || true
if command -v gtk-update-icon-cache &>/dev/null; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true
fi
if command -v update-desktop-database &>/dev/null; then
update-desktop-database /usr/share/applications 2>/dev/null || true
fi
echo ""
echo "G Radio Client instalado correctamente."
echo "Ejecutar: gr-client o buscar 'G Radio Client' en el menú."
echo ""
echo "Nota: el índice de búsqueda se genera la primera vez que presionas"
echo "'⟳ Índice' en el buscador (no requiere sudo)."
POSTINST
chmod 755 "$PKG_DIR/DEBIAN/postinst"
# ── DEBIAN/prerm ──────────────────────────────────────────────────────────────
cat > "$PKG_DIR/DEBIAN/prerm" << 'PRERM'
#!/bin/bash
set -e
pkill -f "gr-client" 2>/dev/null || true
PRERM
chmod 755 "$PKG_DIR/DEBIAN/prerm"
# ── DEBIAN/postrm ─────────────────────────────────────────────────────────────
cat > "$PKG_DIR/DEBIAN/postrm" << 'POSTRM'
#!/bin/bash
rm -f /usr/local/bin/gr-client
rm -f /usr/share/applications/gr-client.desktop
rm -f /usr/share/icons/hicolor/48x48/apps/gr-client.png
if command -v gtk-update-icon-cache &>/dev/null; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true
fi
if command -v update-desktop-database &>/dev/null; then
update-desktop-database /usr/share/applications 2>/dev/null || true
fi
POSTRM
chmod 755 "$PKG_DIR/DEBIAN/postrm"
# ── Construir el .deb ─────────────────────────────────────────────────────────
echo "[*] Construyendo paquete .deb..."
dpkg-deb --build --root-owner-group "$PKG_DIR"
DEB_FILE="${PKG_DIR}.deb"
SIZE=$(du -sh "$DEB_FILE" | cut -f1)
echo ""
echo "========================================"
echo " Paquete listo: $DEB_FILE ($SIZE)"
echo "========================================"
echo ""
echo " Instalar: sudo dpkg -i $DEB_FILE"
echo " O con apt: sudo apt install ./$DEB_FILE"
echo ""
echo " Desinstalar: sudo apt remove gr-client"
echo ""