From 24c3399b34a49eef03eb5fab8538f816699db349 Mon Sep 17 00:00:00 2001 From: flb Date: Sat, 12 Sep 2020 22:11:29 +0200 Subject: [PATCH] Added ability to self-update the app --- .gitignore | 1 + Makefile | 2 +- README.md | 2 +- create_release.sh | 5 +++++ include/download.hpp | 2 ++ include/ui.hpp | 2 +- source/main.cpp | 12 +++++++----- source/ui.cpp | 2 ++ 8 files changed, 20 insertions(+), 8 deletions(-) create mode 100755 create_release.sh diff --git a/.gitignore b/.gitignore index 005b3ec..0c1868c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ build/ *.nacp *.nro sigpatches-updater/ +switch/ *.zip diff --git a/Makefile b/Makefile index 794069d..e377f4f 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ INCLUDES := include libs/minizip/include #ROMFS := romfs APP_TITLE := Sigpatches Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 0.1 +APP_VERSION := 0.2 #--------------------------------------------------------------------------------- # options for code generation diff --git a/README.md b/README.md index da8a8c6..cf1e53e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A Nintendo Switch homebrew to fetch and extract the latest sigpatches ## 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). \ Note that you must use CFW to launch these applications even after installation as sigpatches are always required to do so. diff --git a/create_release.sh b/create_release.sh new file mode 100755 index 0000000..f131c4d --- /dev/null +++ b/create_release.sh @@ -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 \ No newline at end of file diff --git a/include/download.hpp b/include/download.hpp index 6da4b84..c05d556 100644 --- a/include/download.hpp +++ b/include/download.hpp @@ -8,6 +8,8 @@ #define DOWNLOAD_PATH "/config/sigpatches-updater/" #define SIGPATCHES_FILENAME "/config/sigpatches-updater/sigpatches.zip" +#define APP_URL "https://github.com/HamletDuFromage/sigpatches-updater/releases/latest/download/sigpatches-updater.zip" + #include #include diff --git a/include/ui.hpp b/include/ui.hpp index a46288c..e6ddfef 100644 --- a/include/ui.hpp +++ b/include/ui.hpp @@ -3,7 +3,7 @@ #include #include -#define VERSION "0.1" +#define VERSION "0.2" #define WIDTH 80 // The width of the console #define HEIGHT 45 // Height of the console diff --git a/source/main.cpp b/source/main.cpp index 6a929ed..d52ff9c 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -32,6 +32,8 @@ int main(int argc, char* argv[]){ bool downloaded = false; std::string results(""); 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(); if(nbItems == 0) menu = -1; 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 << 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 << 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(downloadFile(std::get<1>(items)[cursor].c_str(), SIGPATCHES_FILENAME, OFF)){ if(isArchive(SIGPATCHES_FILENAME)){ - if(extract(SIGPATCHES_FILENAME)) results += prettifyString("Successfully downloaded the sigpatches archive and successfully extracted them", "[1;32m"); - else results += "Could not extract the sigpatches archive."; + if(extract(SIGPATCHES_FILENAME)) results += prettifyString("Successfully downloaded the archive and successfully extracted it", "[1;32m"); + 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; } std::cout << results << std::endl; diff --git a/source/ui.cpp b/source/ui.cpp index d4c81fb..428fabc 100644 --- a/source/ui.cpp +++ b/source/ui.cpp @@ -2,6 +2,8 @@ void displayList(std::vector items, int cursor){ 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"); std::cout << "\033[1m" << items[i].substr(0, WIDTH - 4) << "\033[0m" << std::endl; }