Add nightly auto-update

- Closes #121
This commit is contained in:
Pk11
2022-05-27 18:14:30 -05:00
committed by Dark98
parent 4474424695
commit af27709fc7
9 changed files with 90 additions and 39 deletions
+7 -4
View File
@@ -46,11 +46,14 @@ endif
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags) CURRENT_VERSION := $(shell git describe --abbrev=0 --tags)
GIT_TAG := $(shell git describe --abbrev=0 --tags)
GIT_SHA := $(shell git rev-parse --short=7 HEAD)
# If on a tagged commit, use just the tag # If on a tagged commit, use just the tag
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),) ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
GIT_VER := $(shell git tag -l --points-at HEAD) GIT_VER := $(GIT_TAG)
else else
GIT_VER := $(shell git describe --abbrev=0 --tags)-$(shell git rev-parse --short=7 HEAD) GIT_VER := $(GIT_TAG)-$(GIT_SHA)
endif endif
# Ensure version.hpp exists # Ensure version.hpp exists
@@ -61,7 +64,7 @@ endif
# Print new version if changed # Print new version if changed
ifeq (,$(findstring $(GIT_VER), $(shell cat include/version.hpp))) ifeq (,$(findstring $(GIT_VER), $(shell cat include/version.hpp)))
$(shell printf "#ifndef VERSION_HPP\n#define VERSION_HPP\n\n#define VER_NUMBER \"$(GIT_VER)\"\n\n#endif\n" > include/version.hpp) $(shell printf "#ifndef VERSION_HPP\n#define VERSION_HPP\n\n#define VER_NUMBER \"$(GIT_VER)\"\n#define GIT_SHA \"$(GIT_SHA)\"\n\n#endif\n" > include/version.hpp)
endif endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@@ -121,7 +124,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 $(CITRA)
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -larchive -lbz2 -llzma -lm -lz -lcitro2d -lcitro3d -lctru -lstdc++ LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -larchive -lbz2 -llzma -lz -lcitro2d -lcitro3d -lctru -lstdc++
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
+5 -1
View File
@@ -78,6 +78,10 @@ public:
bool updatecheck() const { return this->v_updateCheck; }; bool updatecheck() const { return this->v_updateCheck; };
void updatecheck(bool v) { this->v_updateCheck = v; if (!this->changesMade) this->changesMade = true; }; void updatecheck(bool v) { this->v_updateCheck = v; if (!this->changesMade) this->changesMade = true; };
/* Check for nightly/release on startup. */
bool updatenightly() const { return this->v_updateNightly; };
void updatenightly(bool v) { this->v_updateNightly = v; if (!this->changesMade) this->changesMade = true; };
/* DarkStore Update check on startup. */ /* DarkStore Update check on startup. */
bool usebg() const { return this->v_showBg; }; bool usebg() const { return this->v_showBg; };
void usebg(bool v) { this->v_showBg = v; if (!this->changesMade) this->changesMade = true; }; void usebg(bool v) { this->v_showBg = v; if (!this->changesMade) this->changesMade = true; };
@@ -117,7 +121,7 @@ private:
v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:/roms/nds", v_archivePath = "sdmc:", v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:/roms/nds", v_archivePath = "sdmc:",
v_shortcutPath = "sdmc:/3ds/DarkStore/shortcuts", v_firmPath = "sdmc:/luma/payloads", v_theme = "Default"; v_shortcutPath = "sdmc:/3ds/DarkStore/shortcuts", v_firmPath = "sdmc:/luma/payloads", v_theme = "Default";
bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true, bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true, v_updateNightly = false,
v_showBg = false, v_customFont = false, v_changelog = true, v_prompt = true, v_3dsxInFolder = false; v_showBg = false, v_customFont = false, v_changelog = true, v_prompt = true, v_3dsxInFolder = false;
}; };
-1
View File
@@ -30,7 +30,6 @@
#include "common.hpp" #include "common.hpp"
#define APP_TITLE "DarkStore" #define APP_TITLE "DarkStore"
#define VERSION_STRING "3.0.0"
enum DownloadError { enum DownloadError {
DL_ERROR_NONE = 0, DL_ERROR_NONE = 0,
+2 -2
View File
@@ -2,13 +2,13 @@
"DarkStore HomeBrew": { "DarkStore HomeBrew": {
"title": "DarkStore HomeBrew", "title": "DarkStore HomeBrew",
"author": "Dark98", "author": "Dark98",
"url": "https://darkstore.ml/app/darkstore-homebrew.unistore", "url": "https://ds.dark98.co.uk/app/darkstore-homebrew.unistore",
"description": "DarkStore 3DS HomeBrew" "description": "DarkStore 3DS HomeBrew"
}, },
"DarkStore-NDS":{ "DarkStore-NDS":{
"title":"DarkStore-NDS", "title":"DarkStore-NDS",
"author":"Dark98", "author":"Dark98",
"url":"https://darkstore.ml/app/darkstore-nds.unistore", "url":"https://ds.dark98.co.uk/app/darkstore-nds.unistore",
"description":"NDS Stuff" "description":"NDS Stuff"
} }
} }
+2
View File
@@ -9,6 +9,8 @@
"ASCENDING": "Ascending", "ASCENDING": "Ascending",
"ARGUMENT_INVALID": "Argument invalid.\nPlease check the xml file for proper arguments.", "ARGUMENT_INVALID": "Argument invalid.\nPlease check the xml file for proper arguments.",
"AUTHOR": "Author", "AUTHOR": "Author",
"AUTO_UPDATE_NIGHTLY": "Use nightly versions",
"AUTO_UPDATE_NIGHTLY_DESC": "Use nightly versions of Universal-Updater instead of the stable releases.",
"AUTO_UPDATE_SETTINGS": "Auto-Update Settings", "AUTO_UPDATE_SETTINGS": "Auto-Update Settings",
"AUTO_UPDATE_SETTINGS_BTN": "Auto-update settings...", "AUTO_UPDATE_SETTINGS_BTN": "Auto-update settings...",
"AUTO_UPDATE_STORE": "Auto-update Stores", "AUTO_UPDATE_STORE": "Auto-update Stores",
+18 -5
View File
@@ -56,7 +56,8 @@ static const std::vector<Structs::ButtonPos> langButtons = {
static const std::vector<Structs::ButtonPos> toggleAbles = { static const std::vector<Structs::ButtonPos> toggleAbles = {
{ 288, 44, 24, 24 }, { 288, 44, 24, 24 },
{ 288, 120, 24, 24 } { 288, 110, 24, 24 },
{ 288, 180, 24, 24 }
}; };
static const std::vector<Structs::ButtonPos> dirButtons = { static const std::vector<Structs::ButtonPos> dirButtons = {
@@ -167,10 +168,15 @@ static void DrawAutoUpdate(int selection) {
GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->autoupdate()); GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->autoupdate());
Gui::DrawString(47, 75, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_STORE_DESC"), 265, 0, font, C2D_WordWrap); Gui::DrawString(47, 75, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_STORE_DESC"), 265, 0, font, C2D_WordWrap);
Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); Gui::Draw_Rect(40, 110, 280, 24, (selection == 1 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::DrawString(47, 124, 0.5f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_DS"), 210, 0, font); Gui::DrawString(47, 114, 0.5f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_DS"), 210, 0, font);
GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->updatecheck()); GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->updatecheck());
Gui::DrawString(47, 151, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_DS_DESC"), 265, 0, font, C2D_WordWrap); Gui::DrawString(47, 141, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_DS_DESC"), 265, 0, font, C2D_WordWrap);
Gui::Draw_Rect(40, 180, 280, 24, (selection == 2 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected()));
Gui::DrawString(47, 184, 0.5f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_NIGHTLY"), 210, 0, font);
GFX::DrawToggle(toggleAbles[2].x, toggleAbles[2].y, config->updatenightly());
Gui::DrawString(47, 211, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_NIGHTLY_DESC"), 265, 0, font, C2D_WordWrap);
} }
/* /*
@@ -442,7 +448,7 @@ static void AutoUpdateLogic(int &page, int &selection) {
} }
if (hRepeat & KEY_DOWN) { if (hRepeat & KEY_DOWN) {
if (selection < 1) selection++; if (selection < 2) selection++;
} }
if (hRepeat & KEY_UP) { if (hRepeat & KEY_UP) {
@@ -459,6 +465,9 @@ static void AutoUpdateLogic(int &page, int &selection) {
} else if (touching(touch, toggleAbles[1])) { } else if (touching(touch, toggleAbles[1])) {
config->updatecheck(!config->updatecheck()); config->updatecheck(!config->updatecheck());
} else if (touching(touch, toggleAbles[2])) {
config->updatenightly(!config->updatenightly());
} }
} }
@@ -471,6 +480,10 @@ static void AutoUpdateLogic(int &page, int &selection) {
case 1: case 1:
config->updatecheck(!config->updatecheck()); config->updatecheck(!config->updatecheck());
break; break;
case 2:
config->updatenightly(!config->updatenightly());
break;
} }
} }
} }
+4 -4
View File
@@ -75,8 +75,8 @@ MainScreen::MainScreen() {
if (access("sdmc:/3ds/DarkStore/stores/darkstore-homebrew.unistore", F_OK) != 0) { if (access("sdmc:/3ds/DarkStore/stores/darkstore-homebrew.unistore", F_OK) != 0) {
if (checkWifiStatus()) { if (checkWifiStatus()) {
std::string tmp = ""; // Just a temp. std::string tmp = ""; // Just a temp.
DownloadStore("https://darkstore.ml/app/darkstore-homebrew.unistore", -1, tmp, true, true); DownloadStore("https://ds.dark98.co.uk/app/darkstore-homebrew.unistore", -1, tmp, true, true);
DownloadSpriteSheet("https://darkstore.ml/app/darkstore-homebrew.t3x", "darkstore-homebrew.t3x"); DownloadSpriteSheet("https://ds.dark98.co.uk/app/darkstore-homebrew.t3x", "darkstore-homebrew.t3x");
} else { } else {
notConnectedMsg(); notConnectedMsg();
@@ -88,8 +88,8 @@ MainScreen::MainScreen() {
if (info.Version != 3 && info.Version != _STORE_VERSION) { if (info.Version != 3 && info.Version != _STORE_VERSION) {
if (checkWifiStatus()) { if (checkWifiStatus()) {
std::string tmp = ""; // Just a temp. std::string tmp = ""; // Just a temp.
DownloadStore("https://darkstore.ml/app/darkstore-homebrew.unistore", -1, tmp, true, true); DownloadStore("https://ds.dark98.co.uk/app/darkstore-homebrew.unistore", -1, tmp, true, true);
DownloadSpriteSheet("https://darkstore.ml/app/darkstore-homebrew.t3x", "darkstore-homebrew.t3x"); DownloadSpriteSheet("https://ds.dark98.co.uk/app/darkstore-homebrew.t3x", "darkstore-homebrew.t3x");
} else { } else {
notConnectedMsg(); notConnectedMsg();
+2
View File
@@ -134,6 +134,7 @@ Config::Config() {
if (this->json.contains("Firm_Path")) this->firmPath(this->getString("Firm_Path")); if (this->json.contains("Firm_Path")) this->firmPath(this->getString("Firm_Path"));
if (this->json.contains("MetaData")) this->metadata(this->getBool("MetaData")); if (this->json.contains("MetaData")) this->metadata(this->getBool("MetaData"));
if (this->json.contains("UpdateCheck")) this->updatecheck(this->getBool("UpdateCheck")); if (this->json.contains("UpdateCheck")) this->updatecheck(this->getBool("UpdateCheck"));
if (this->json.contains("UpdateNightly")) this->updatenightly(this->getBool("UpdateNightly"));
if (this->json.contains("UseBG")) this->usebg(this->getBool("UseBG")); if (this->json.contains("UseBG")) this->usebg(this->getBool("UseBG"));
if (this->json.contains("CustomFont")) this->customfont(this->getBool("CustomFont")); if (this->json.contains("CustomFont")) this->customfont(this->getBool("CustomFont"));
if (this->json.contains("Shortcut_Path")) this->shortcut(this->getString("Shortcut_Path")); if (this->json.contains("Shortcut_Path")) this->shortcut(this->getString("Shortcut_Path"));
@@ -173,6 +174,7 @@ void Config::save() {
this->setString("Firm_Path", this->firmPath()); this->setString("Firm_Path", this->firmPath());
this->setBool("MetaData", this->metadata()); this->setBool("MetaData", this->metadata());
this->setBool("UpdateCheck", this->updatecheck()); this->setBool("UpdateCheck", this->updatecheck());
this->setBool("UpdateNightly", this->updatenightly());
this->setBool("UseBG", this->usebg()); this->setBool("UseBG", this->usebg());
this->setBool("CustomFont", this->customfont()); this->setBool("CustomFont", this->customfont());
this->setString("Shortcut_Path", this->shortcut()); this->setString("Shortcut_Path", this->shortcut());
+47 -19
View File
@@ -33,6 +33,7 @@
#include "screenshot.hpp" #include "screenshot.hpp"
#include "scriptUtils.hpp" #include "scriptUtils.hpp"
#include "stringutils.hpp" #include "stringutils.hpp"
#include "version.hpp"
#include <3ds.h> #include <3ds.h>
#include <curl/curl.h> #include <curl/curl.h>
@@ -43,7 +44,7 @@
#include <unistd.h> #include <unistd.h>
#include <vector> #include <vector>
#define USER_AGENT APP_TITLE "-" VERSION_STRING #define USER_AGENT APP_TITLE "-" VER_NUMBER
static char *result_buf = nullptr; static char *result_buf = nullptr;
static size_t result_sz = 0; static size_t result_sz = 0;
@@ -795,7 +796,11 @@ DSUpdate IsDSUpdateAvailable() {
CURL *hnd = curl_easy_init(); CURL *hnd = curl_easy_init();
ret = setupContext(hnd, "https://api.github.com/repos/DarkStore-3DS/DarkStore/releases/latest"); const char *url;
if (config->updatenightly()) url = "https://api.github.com/repos/DarkStore-3DS/DarkStore/commits";
else url = "https://api.github.com/repos/DarkStore-3DS/DarkStore/releases/latest";
ret = setupContext(hnd, url);
if (ret != 0) { if (ret != 0) {
socExit(); socExit();
free(result_buf); free(result_buf);
@@ -826,21 +831,39 @@ DSUpdate IsDSUpdateAvailable() {
if (nlohmann::json::accept(result_buf)) { if (nlohmann::json::accept(result_buf)) {
nlohmann::json parsedAPI = nlohmann::json::parse(result_buf); nlohmann::json parsedAPI = nlohmann::json::parse(result_buf);
if (parsedAPI.contains("tag_name") && parsedAPI["tag_name"].is_string()) { if (config->updatenightly()) {
DSUpdate update = { false, "", "" }; if (parsedAPI.is_array() && parsedAPI.size() > 0 && parsedAPI[0].contains("sha") && parsedAPI[0]["sha"].is_string()) {
update.Version = parsedAPI["tag_name"]; socExit();
free(result_buf);
free(socubuf);
result_buf = nullptr;
result_sz = 0;
result_written = 0;
socExit(); DSUpdate update = { false, "", "" };
free(result_buf); update.Version = parsedAPI[0]["sha"].get_ref<const std::string &>().substr(0, 7);
free(socubuf); if (parsedAPI[0].contains("commit") && parsedAPI[0]["commit"].is_object() && parsedAPI[0]["commit"].contains("message") && parsedAPI[0]["commit"]["message"].is_string())
result_buf = nullptr; update.Notes = parsedAPI[0]["commit"]["message"];
result_sz = 0; update.Notes.erase(remove(update.Notes.begin(), update.Notes.end(), '\r'), update.Notes.end()); // Remove the CRLF \r's.
result_written = 0; update.Available = strcasecmp(update.Version.c_str(), GIT_SHA) != 0;
return update;
}
} else {
if (parsedAPI.contains("tag_name") && parsedAPI["tag_name"].is_string()) {
socExit();
free(result_buf);
free(socubuf);
result_buf = nullptr;
result_sz = 0;
result_written = 0;
if (parsedAPI["body"].is_string()) update.Notes = parsedAPI["body"]; DSUpdate update = { false, "", "" };
update.Notes.erase(remove(update.Notes.begin(), update.Notes.end(), '\r'), update.Notes.end()); // Remove the CRLF \r's. update.Version = parsedAPI["tag_name"];
update.Available = strcasecmp(StringUtils::lower_case(update.Version).c_str(), StringUtils::lower_case(C_V).c_str()) > 0; if (parsedAPI["body"].is_string()) update.Notes = parsedAPI["body"];
return update; update.Notes.erase(remove(update.Notes.begin(), update.Notes.end(), '\r'), update.Notes.end()); // Remove the CRLF \r's.
update.Available = strcasecmp(update.Version.c_str(), C_V) > 0;
return update;
}
} }
} }
@@ -904,10 +927,15 @@ void UpdateAction() {
if ((down & KEY_A) || (down & KEY_B) || (down & KEY_START) || (down & KEY_TOUCH)) confirmed = true; if ((down & KEY_A) || (down & KEY_B) || (down & KEY_START) || (down & KEY_TOUCH)) confirmed = true;
} }
if (ScriptUtils::downloadRelease("DarkStore-3DS/DarkStore", (is3DSX ? "DarkStore.3dsx" : "DarkStore.cia"), Result dlRes;
(is3DSX ? _3dsxPath : "sdmc:/DarkStore.cia"), if (config->updatenightly())
false, Lang::get("DONLOADING_DARKSTORE"), true) == 0) { dlRes = ScriptUtils::downloadFile("https://raw.githubusercontent.com/DarkStore-3DS/extras/master/builds/DarkStore/DarkStore." + std::string(is3DSX ? "3dsx" : "cia"),
(is3DSX ? _3dsxPath : "sdmc:/DarkStore.cia"), Lang::get("DONLOADING_DARKSTORE"), true);
else
dlRes = ScriptUtils::downloadRelease("DarkStore-3DS/DarkStore", (is3DSX ? "DarkStore.3dsx" : "DarkStore.cia"),
(is3DSX ? _3dsxPath : "sdmc:/DarkStore.cia"), false, Lang::get("DONLOADING_DARKSTORE"), true);
if (dlRes == ScriptState::NONE) {
if (is3DSX) { if (is3DSX) {
Msg::waitMsg(Lang::get("UPDATE_DONE")); Msg::waitMsg(Lang::get("UPDATE_DONE"));
exiting = true; exiting = true;
@@ -953,7 +981,7 @@ std::vector<StoreList> FetchStores() {
CURL *hnd = curl_easy_init(); CURL *hnd = curl_easy_init();
ret = setupContext(hnd, "https://darkstore.ml/app/Stores.json"); ret = setupContext(hnd, "https://ds.dark98.co.uk/app/Stores.json");
if (ret != 0) { if (ret != 0) {
socExit(); socExit();
free(result_buf); free(result_buf);