mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 12:40:21 +02:00
Fix Switch OTA launcher self-update via a bootstrap NRO.
A running launcher cannot replace its own NRO on sdmc/FAT; stage the new binary and chainload a tiny helper from romfs to swap it in before loading the game.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Tiny one-shot helper: swap a staged launcher NRO into place, then load the game.
|
||||
* The main OTA launcher chainloads here because a running NRO cannot replace itself
|
||||
* on sdmc/FAT.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__SWITCH__)
|
||||
#include <switch.h>
|
||||
#endif
|
||||
|
||||
#define INSTALL_DIR "sdmc:/switch/gen1recomp"
|
||||
#define STAGED INSTALL_DIR "/gen1recomp.nro.staged"
|
||||
#define LAUNCHER INSTALL_DIR "/gen1recomp.nro"
|
||||
#define GAME INSTALL_DIR "/gen1recomp-game.nro"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
#if defined(__SWITCH__)
|
||||
remove(LAUNCHER);
|
||||
if (rename(STAGED, LAUNCHER) != 0) {
|
||||
return 1;
|
||||
}
|
||||
Result rc = envSetNextLoad(GAME, GAME);
|
||||
if (R_FAILED(rc)) return 1;
|
||||
return 0;
|
||||
#else
|
||||
fprintf(stderr, "ota-bootstrap: host stub (would rename %s -> %s, load %s)\n", STAGED, LAUNCHER,
|
||||
GAME);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user