1
0
Fork 0
mirror of https://github.com/HamletDuFromage/sigpatches-updater.git synced 2024-09-19 13:33:27 +01:00

Added ability to self-update the app

This commit is contained in:
flb 2020-09-12 22:11:29 +02:00
parent 3064375eb0
commit 24c3399b34
8 changed files with 20 additions and 8 deletions

1
.gitignore vendored
View file

@ -5,4 +5,5 @@ build/
*.nacp *.nacp
*.nro *.nro
sigpatches-updater/ sigpatches-updater/
switch/
*.zip *.zip

View file

@ -45,7 +45,7 @@ INCLUDES := include libs/minizip/include
#ROMFS := romfs #ROMFS := romfs
APP_TITLE := Sigpatches Updater APP_TITLE := Sigpatches Updater
APP_AUTHOR := HamletDuFromage APP_AUTHOR := HamletDuFromage
APP_VERSION := 0.1 APP_VERSION := 0.2
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation

View file

@ -13,7 +13,7 @@ A Nintendo Switch homebrew to fetch and extract the latest sigpatches
## FAQ ## FAQ
### What are sigpatches ### What are sigpatches?
Sigpatches allow your Switch to install and run unofficial NSP file (digital titles that appear on the home menu). \ Sigpatches allow your Switch to install and run unofficial NSP file (digital titles that appear on the home menu). \
Note that you must use CFW to launch these applications even after installation as sigpatches are always required to do so. Note that you must use CFW to launch these applications even after installation as sigpatches are always required to do so.

5
create_release.sh Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
#rm -r switch/
mkdir -p switch/sigpatches-updater/
mv sigpatches-updater.nro switch/sigpatches-updater/sigpatches-updater.nro
zip -r sigpatches-updater.zip switch

View file

@ -8,6 +8,8 @@
#define DOWNLOAD_PATH "/config/sigpatches-updater/" #define DOWNLOAD_PATH "/config/sigpatches-updater/"
#define SIGPATCHES_FILENAME "/config/sigpatches-updater/sigpatches.zip" #define SIGPATCHES_FILENAME "/config/sigpatches-updater/sigpatches.zip"
#define APP_URL "https://github.com/HamletDuFromage/sigpatches-updater/releases/latest/download/sigpatches-updater.zip"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>

View file

@ -3,7 +3,7 @@
#include <vector> #include <vector>
#include <switch.h> #include <switch.h>
#define VERSION "0.1" #define VERSION "0.2"
#define WIDTH 80 // The width of the console #define WIDTH 80 // The width of the console
#define HEIGHT 45 // Height of the console #define HEIGHT 45 // Height of the console

View file

@ -32,6 +32,8 @@ int main(int argc, char* argv[]){
bool downloaded = false; bool downloaded = false;
std::string results(""); std::string results("");
auto items = fetchLinks(SIGPATCHES_URL); auto items = fetchLinks(SIGPATCHES_URL);
std::get<0>(items).push_back("Update the sigpatches-updater app");
std::get<1>(items).push_back(std::string(APP_URL));
int nbItems = std::get<0>(items).size(); int nbItems = std::get<0>(items).size();
if(nbItems == 0) menu = -1; if(nbItems == 0) menu = -1;
while (appletMainLoop()) while (appletMainLoop())
@ -61,7 +63,7 @@ int main(int argc, char* argv[]){
std::cout << "Press [B] go back to the main screen" << std::endl; std::cout << "Press [B] go back to the main screen" << std::endl;
std::cout << std::endl << std::endl; std::cout << std::endl << std::endl;
std::cout << "The following sigpatches will be downloaded: " << std::endl; std::cout << "The following package will be downloaded: " << std::endl;
std::cout << prettifyString("Name:\n", "[1;36m") << std::get<0>(items)[cursor] << std::endl; std::cout << prettifyString("Name:\n", "[1;36m") << std::get<0>(items)[cursor] << std::endl;
std::cout << std::endl; std::cout << std::endl;
std::cout << prettifyString("Download url:\n", "[1;36m")<< std::get<1>(items)[cursor] << std::endl; std::cout << prettifyString("Download url:\n", "[1;36m")<< std::get<1>(items)[cursor] << std::endl;
@ -75,12 +77,12 @@ int main(int argc, char* argv[]){
//if(1){ //if(1){
if(downloadFile(std::get<1>(items)[cursor].c_str(), SIGPATCHES_FILENAME, OFF)){ if(downloadFile(std::get<1>(items)[cursor].c_str(), SIGPATCHES_FILENAME, OFF)){
if(isArchive(SIGPATCHES_FILENAME)){ if(isArchive(SIGPATCHES_FILENAME)){
if(extract(SIGPATCHES_FILENAME)) results += prettifyString("Successfully downloaded the sigpatches archive and successfully extracted them", "[1;32m"); if(extract(SIGPATCHES_FILENAME)) results += prettifyString("Successfully downloaded the archive and successfully extracted it", "[1;32m");
else results += "Could not extract the sigpatches archive."; else results += "Could not extract the archive.";
} }
else results += "The download link is broken. If the issue persists after a day, leave a comment on the Gbatemp thread or open an issue on github.com/HamletDuFromage/sigpatches-updater"; else results += "The download link is broken. If the issue persists after a couple of hours, leave a comment on the Gbatemp thread or open an issue on github.com/HamletDuFromage/sigpatches-updater";
} }
else results += "Couldn't download the sigpatches archive"; else results += "Couldn't download the archive";
downloaded = true; downloaded = true;
} }
std::cout << results << std::endl; std::cout << results << std::endl;

View file

@ -2,6 +2,8 @@
void displayList(std::vector<std::string> items, int cursor){ void displayList(std::vector<std::string> items, int cursor){
for (int i = 0; i < (int) items.size(); i++){ for (int i = 0; i < (int) items.size(); i++){
if(i == items.size() - 1 ) std::cout << std::endl;
if(cursor == i) std::cout << prettifyString(">> ", "[1;36m"); if(cursor == i) std::cout << prettifyString(">> ", "[1;36m");
std::cout << "\033[1m" << items[i].substr(0, WIDTH - 4) << "\033[0m" << std::endl; std::cout << "\033[1m" << items[i].substr(0, WIDTH - 4) << "\033[0m" << std::endl;
} }