mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 20:50:21 +02:00
Add Switch OTA launcher with unified SD zip and quiet UI.
Ships a dual-NRO native launcher that checks GitHub Releases, updates both NROs from gen1recomp-*-switch.zip with matching NACP versions, and stays silent unless an update needs confirm.
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the native Switch OTA launcher NRO (DEVKITPRO or Docker).
|
||||
#
|
||||
# Usage: scripts/switch/build_ota_launcher.sh [OUT_NRO] [VERSION]
|
||||
#
|
||||
# Default OUT_NRO: dist/switch/gen1recomp-launcher.nro
|
||||
# VERSION (optional X.Y.Z) is written into the NACP so hbmenu shows the
|
||||
# same release as the fused game; defaults to 0.0.0 when omitted.
|
||||
# Host-only protocol check: always runs `make host-test` first.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
# shellcheck source=common.sh
|
||||
. "$SCRIPT_DIR/common.sh"
|
||||
|
||||
LAUNCHER_DIR="$ROOT/native/switch-ota-launcher"
|
||||
OUT_NRO="${1:-$ROOT/dist/switch/gen1recomp-launcher.nro}"
|
||||
APP_VERSION="${2:-${GEN1_LAUNCHER_VERSION:-0.0.0}}"
|
||||
DKP_IMAGE_FILE="$ROOT/scripts/switch/dkp-docker.image"
|
||||
|
||||
[ -d "$LAUNCHER_DIR" ] || fail "missing $LAUNCHER_DIR"
|
||||
[ -f "$LAUNCHER_DIR/Makefile" ] || fail "missing Makefile"
|
||||
|
||||
say "host-test ota_protocol (no DEVKITPRO required)"
|
||||
make -C "$LAUNCHER_DIR" host-test
|
||||
|
||||
mkdir -p "$(dirname "$OUT_NRO")"
|
||||
|
||||
if [ -n "${DEVKITPRO:-}" ] && [ -f "$DEVKITPRO/libnx/switch_rules" ]; then
|
||||
say "building launcher NRO with native DEVKITPRO (NACP $APP_VERSION)"
|
||||
make -C "$LAUNCHER_DIR" clean || true
|
||||
make -C "$LAUNCHER_DIR" all APP_VERSION="$APP_VERSION"
|
||||
cp "$LAUNCHER_DIR/gen1recomp.nro" "$OUT_NRO"
|
||||
say "wrote $OUT_NRO"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
resolve_dkp_image() {
|
||||
if [ -n "${GEN1_DKP_IMAGE:-}" ]; then
|
||||
printf '%s' "$GEN1_DKP_IMAGE"
|
||||
return 0
|
||||
fi
|
||||
[ -f "$DKP_IMAGE_FILE" ] || fail "missing Docker image pin: $DKP_IMAGE_FILE"
|
||||
local line
|
||||
line="$(grep -v '^[[:space:]]*#' "$DKP_IMAGE_FILE" | grep -v '^[[:space:]]*$' | head -1 || true)"
|
||||
[ -n "$line" ] || fail "empty Docker image pin: $DKP_IMAGE_FILE"
|
||||
printf '%s' "$line"
|
||||
}
|
||||
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
image="$(resolve_dkp_image)"
|
||||
say "building launcher NRO via Docker ($image, NACP $APP_VERSION)"
|
||||
docker run --rm \
|
||||
-v "$ROOT:/work" \
|
||||
-w /work/native/switch-ota-launcher \
|
||||
-e "APP_VERSION=$APP_VERSION" \
|
||||
"$image" \
|
||||
bash -lc 'pacman -Sy --noconfirm switch-curl switch-mbedtls switch-zlib switch-zziplib >/dev/null 2>&1 || true; make clean; make all APP_VERSION="$APP_VERSION"'
|
||||
cp "$LAUNCHER_DIR/gen1recomp.nro" "$OUT_NRO"
|
||||
say "wrote $OUT_NRO"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fail "$(cat <<EOF
|
||||
Cannot build Switch OTA launcher NRO: DEVKITPRO unset and Docker unavailable.
|
||||
|
||||
Host protocol tests already passed (make host-test).
|
||||
Install DEVKITPRO switch-dev + switch-curl, or Docker, then re-run:
|
||||
scripts/switch/build_ota_launcher.sh
|
||||
|
||||
See native/switch-ota-launcher/README.md and docs/switch-build.md.
|
||||
EOF
|
||||
)"
|
||||
Reference in New Issue
Block a user