Empaqueta jlauncher com a .app + .dmg per a macOS
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compila jlauncher a un binario standalone con Nuitka y empaqueta un tar.gz de release.
|
||||
# Requisitos del sistema: python3-dev, gcc, patchelf (ver README).
|
||||
# Compila jlauncher con Nuitka y empaqueta un release.
|
||||
# - Linux: binario onefile + tar.gz.
|
||||
# - macOS: jlauncher.app (con icono) dentro de un .dmg arrastrable a /Applications.
|
||||
# Requisitos del sistema (no los instala el script): ver README (compilador C, git…).
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
@@ -13,7 +15,6 @@ if [ -z "$VERSION" ]; then
|
||||
fi
|
||||
ARCH="$(uname -m)"
|
||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
RELEASE_NAME="jlauncher-v${VERSION}-${OS}-${ARCH}"
|
||||
|
||||
if [ ! -d .venv ]; then
|
||||
echo "[build] creando venv…"
|
||||
@@ -39,25 +40,113 @@ echo "[build] versión: v${VERSION}"
|
||||
echo "[build] limpiando artefactos previos…"
|
||||
rm -rf dist build app.build app.dist app.onefile-build
|
||||
|
||||
echo "[build] compilando (PySide6 onefile; puede tardar varios minutos)…"
|
||||
.venv/bin/python -m nuitka \
|
||||
--onefile \
|
||||
--assume-yes-for-downloads \
|
||||
--enable-plugin=pyside6 \
|
||||
--include-package=jlauncher \
|
||||
--output-dir=dist \
|
||||
--output-filename=jlauncher \
|
||||
--remove-output \
|
||||
--lto=yes \
|
||||
app.py
|
||||
# ---------------------------------------------------------------------------
|
||||
# Construye assets/icon.icns desde assets/icon.png (regenerable con make_icon.py).
|
||||
# ---------------------------------------------------------------------------
|
||||
build_icns() {
|
||||
local png="assets/icon.png"
|
||||
local icns="assets/icon.icns"
|
||||
if [ ! -f "$png" ]; then
|
||||
echo "[build] generando icono provisional (assets/icon.png)…"
|
||||
QT_QPA_PLATFORM=offscreen .venv/bin/python assets/make_icon.py
|
||||
fi
|
||||
echo "[build] construyendo ${icns}…"
|
||||
local iconset="assets/icon.iconset"
|
||||
rm -rf "$iconset"; mkdir -p "$iconset"
|
||||
local s
|
||||
for s in 16 32 128 256 512; do
|
||||
sips -z "$s" "$s" "$png" --out "$iconset/icon_${s}x${s}.png" >/dev/null
|
||||
sips -z $((s*2)) $((s*2)) "$png" --out "$iconset/icon_${s}x${s}@2x.png" >/dev/null
|
||||
done
|
||||
iconutil -c icns "$iconset" -o "$icns"
|
||||
rm -rf "$iconset"
|
||||
}
|
||||
|
||||
echo "[build] copiando games.toml junto al binario…"
|
||||
cp games.toml dist/games.toml
|
||||
if [ "$OS" = "darwin" ]; then
|
||||
# -------------------------------------------------------------------------
|
||||
# macOS: app bundle + DMG
|
||||
# -------------------------------------------------------------------------
|
||||
build_icns
|
||||
|
||||
echo "[build] empaquetando release ${RELEASE_NAME}.tar.gz…"
|
||||
tar -czf "dist/${RELEASE_NAME}.tar.gz" -C dist jlauncher games.toml
|
||||
echo "[build] compilando jlauncher.app (PySide6; puede tardar varios minutos)…"
|
||||
.venv/bin/python -m nuitka \
|
||||
--standalone \
|
||||
--macos-create-app-bundle \
|
||||
--macos-app-icon=assets/icon.icns \
|
||||
--macos-app-name=jlauncher \
|
||||
--macos-app-version="$VERSION" \
|
||||
--macos-signed-app-name=com.jailgames.jlauncher \
|
||||
--company-name=jailgames \
|
||||
--product-name=jlauncher \
|
||||
--product-version="$VERSION" \
|
||||
--assume-yes-for-downloads \
|
||||
--enable-plugin=pyside6 \
|
||||
--include-package=jlauncher \
|
||||
--output-dir=dist \
|
||||
--output-filename=jlauncher \
|
||||
--remove-output \
|
||||
app.py
|
||||
|
||||
echo "[build] hecho:"
|
||||
ls -lh "dist/jlauncher" "dist/games.toml" "dist/${RELEASE_NAME}.tar.gz"
|
||||
echo "[build] el binario crea jlauncher_data/ y settings.json junto a sí mismo."
|
||||
echo "[build] distribuir: descomprimir el tar.gz (jlauncher + games.toml juntos)."
|
||||
# Según la versión, Nuitka nombra el bundle a partir del script de entrada
|
||||
# (app.py -> app.app). Lo normalizamos a jlauncher.app.
|
||||
APP="dist/jlauncher.app"
|
||||
if [ ! -d "$APP" ]; then
|
||||
PRODUCED="$(find dist -maxdepth 1 -name '*.app' | head -n1)"
|
||||
if [ -z "$PRODUCED" ]; then
|
||||
echo "[build] Nuitka no produjo ningún .app en dist/" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$APP"
|
||||
mv "$PRODUCED" "$APP"
|
||||
fi
|
||||
|
||||
echo "[build] sembrando games.toml en Contents/Resources…"
|
||||
cp games.toml "$APP/Contents/Resources/games.toml"
|
||||
|
||||
# Bundle ad-hoc (sin Developer ID): quitamos quarantine para abrir sin fricción local.
|
||||
xattr -dr com.apple.quarantine "$APP" 2>/dev/null || true
|
||||
|
||||
DMG="dist/jlauncher-v${VERSION}-macos-${ARCH}.dmg"
|
||||
echo "[build] empaquetando ${DMG}…"
|
||||
STAGE="$(mktemp -d)"
|
||||
cp -R "$APP" "$STAGE/"
|
||||
ln -s /Applications "$STAGE/Applications"
|
||||
rm -f "$DMG"
|
||||
hdiutil create -volname "jlauncher" -srcfolder "$STAGE" \
|
||||
-ov -format UDZO "$DMG" >/dev/null
|
||||
rm -rf "$STAGE"
|
||||
|
||||
echo "[build] hecho:"
|
||||
du -sh "$APP" | sed 's/^/[build] /'
|
||||
ls -lh "$DMG"
|
||||
echo "[build] la app guarda datos en ~/Library/Application Support/jailgames/jlauncher/."
|
||||
echo "[build] distribuir: el .dmg (arrastrar jlauncher.app a Aplicaciones)."
|
||||
echo "[build] sin firma Developer ID: primera apertura con clic derecho → Abrir."
|
||||
else
|
||||
# -------------------------------------------------------------------------
|
||||
# Linux (y resto): binario onefile + tar.gz
|
||||
# -------------------------------------------------------------------------
|
||||
RELEASE_NAME="jlauncher-v${VERSION}-${OS}-${ARCH}"
|
||||
echo "[build] compilando (PySide6 onefile; puede tardar varios minutos)…"
|
||||
.venv/bin/python -m nuitka \
|
||||
--onefile \
|
||||
--assume-yes-for-downloads \
|
||||
--enable-plugin=pyside6 \
|
||||
--include-package=jlauncher \
|
||||
--output-dir=dist \
|
||||
--output-filename=jlauncher \
|
||||
--remove-output \
|
||||
--lto=yes \
|
||||
app.py
|
||||
|
||||
echo "[build] copiando games.toml junto al binario…"
|
||||
cp games.toml dist/games.toml
|
||||
|
||||
echo "[build] empaquetando release ${RELEASE_NAME}.tar.gz…"
|
||||
tar -czf "dist/${RELEASE_NAME}.tar.gz" -C dist jlauncher games.toml
|
||||
|
||||
echo "[build] hecho:"
|
||||
ls -lh "dist/jlauncher" "dist/games.toml" "dist/${RELEASE_NAME}.tar.gz"
|
||||
echo "[build] el binario crea jlauncher_data/ y settings.json junto a sí mismo."
|
||||
echo "[build] distribuir: descomprimir el tar.gz (jlauncher + games.toml juntos)."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user