Browse Source

Make auto-updater handle win32, linux builds

kiwec 2 months ago
parent
commit
852ab7d109
4 changed files with 21 additions and 31 deletions
  1. 1 1
      src/App/Osu/BanchoNetworking.h
  2. 2 27
      src/App/Osu/UpdateHandler.cpp
  3. 0 3
      src/App/Osu/UpdateHandler.h
  4. 18 0
      src/Util/cbase.h

+ 1 - 1
src/App/Osu/BanchoNetworking.h

@@ -11,7 +11,7 @@
 #define NEOSU_STREAM "release"
 #endif
 
-#define NEOSU_UPDATE_URL "https://neosu.net"
+#define NEOSU_URL "https://neosu.net"
 
 // NOTE: Full version can be something like "b20200201.2cuttingedge"
 #define OSU_VERSION "b20240425.2"

+ 2 - 27
src/App/Osu/UpdateHandler.cpp

@@ -1,10 +1,3 @@
-//================ Copyright (c) 2016, PG, All rights reserved. =================//
-//
-// Purpose:		checks if an update is available from github
-//
-// $NoKeywords: $osuupdchk
-//===============================================================================//
-
 #ifndef _WIN32
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -99,7 +92,7 @@ void UpdateHandler::_requestUpdate() {
     debugLog("UpdateHandler::requestUpdate()\n");
     m_status = STATUS::STATUS_CHECKING_FOR_UPDATE;
 
-    UString latestVersion = engine->getNetworkHandler()->httpGet(NEOSU_UPDATE_URL "/latest-version.txt");
+    UString latestVersion = engine->getNetworkHandler()->httpGet(NEOSU_URL "/update/" OS_NAME "/latest-version.txt");
     float fLatestVersion = strtof(latestVersion.toUtf8(), NULL);
     if(fLatestVersion == 0.f) {
         m_status = STATUS::STATUS_UP_TO_DATE;
@@ -115,14 +108,8 @@ void UpdateHandler::_requestUpdate() {
         return;
     }
 
-#ifdef _WIN32
-    const char *os = "windows";
-#else
-    const char *os = "linux";
-#endif
-
     debugLog("Downloading latest update... (current v%.2f, latest v%.2f)\n", current_version, fLatestVersion);
-    update_url = UString::format(NEOSU_UPDATE_URL "/update/%s-v%.2f.zip", os, fLatestVersion);
+    update_url = UString::format(NEOSU_URL "/update/" OS_NAME "/v%.2f.zip", os, fLatestVersion);
 }
 
 bool UpdateHandler::_downloadUpdate() {
@@ -277,15 +264,3 @@ void UpdateHandler::_installUpdate(std::string zipFilePath) {
     m_status = STATUS::STATUS_SUCCESS_INSTALLATION;
     env->deleteFile(zipFilePath);
 }
-
-Environment::OS UpdateHandler::stringToOS(UString osString) {
-    Environment::OS os = Environment::OS::NONE;
-    if(osString.find("windows") != -1)
-        os = Environment::OS::WINDOWS;
-    else if(osString.find("linux") != -1)
-        os = Environment::OS::LINUX;
-    else if(osString.find("macos") != -1)
-        os = Environment::OS::MACOS;
-
-    return os;
-}

+ 0 - 3
src/App/Osu/UpdateHandler.h

@@ -39,9 +39,6 @@ class UpdateHandler {
     std::thread* m_updateThread = NULL;
     bool _m_bKYS;
 
-    // releases
-    Environment::OS stringToOS(UString osString);
-
     // status
     STATUS m_status;
     int m_iNumRetries;

+ 18 - 0
src/Util/cbase.h

@@ -47,6 +47,24 @@
 
 // DEFS
 
+#ifdef _WIN32
+
+#ifdef _WIN64
+#define OS_NAME "win64"
+#else
+#define OS_NAME "win32"
+#endif
+
+#else
+
+#ifdef __x86_64
+#define OS_NAME "linux-x64"
+#else
+#define OS_NAME "linux-i686"
+#endif
+
+#endif
+
 #ifdef _WIN32
 #define reallocarray(ptr, a, b) realloc(ptr, a *b)
 #define strcasestr(a, b) StrStrIA(a, b)