mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
adjust update to use new binary naming format
This commit is contained in:
parent
5efbbaa901
commit
f0861f7927
@ -7,6 +7,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <httplib.h>
|
#include <httplib.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <boost/predef.h>
|
||||||
|
|
||||||
#if defined(__linux)
|
#if defined(__linux)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -25,11 +26,6 @@ static bool ProgressReport(uint64_t current, uint64_t total) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unordered_map<std::string, std::string> sDistroMap = {
|
|
||||||
{ "debian:11", "-debian" },
|
|
||||||
{ "ubuntu:22.04", "-ubuntu" },
|
|
||||||
};
|
|
||||||
|
|
||||||
void Update::PerformUpdate(const std::string& InvokedAs) {
|
void Update::PerformUpdate(const std::string& InvokedAs) {
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
namespace http = httplib;
|
namespace http = httplib;
|
||||||
@ -87,14 +83,15 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
|
|||||||
beammp_infof("New update available, updating from v{} to v{}", Current.AsString(), NewVersion.AsString());
|
beammp_infof("New update available, updating from v{} to v{}", Current.AsString(), NewVersion.AsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// see https://github.com/cpredef/predef for information
|
std::string Arch = "";
|
||||||
#if !defined(__amd64__) \
|
|
||||||
&& !defined(__amd64) \
|
#if BOOST_ARCH_ARM && BOOST_ARCH_WORD_BITS == 64
|
||||||
&& !defined(__x86_64__) \
|
Arch = "arm64";
|
||||||
&& !defined(__x86_64) \
|
#elif BOOST_ARCH_X86_64
|
||||||
&& !defined(_M_X64) \
|
Arch = "x86_64";
|
||||||
&& !defined(_M_AMD64)
|
#else
|
||||||
beammp_errorf("BeamMP doesn't provide binaries for your CPU architecture (only x86_64). Please update manually");
|
beammp_errorf("The current architecture is not supported, please update manually.");
|
||||||
|
std::exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string Postfix = {};
|
std::string Postfix = {};
|
||||||
@ -125,19 +122,16 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
beammp_infof("Distribution: {} {}", DistroID, DistroVersion);
|
beammp_infof("Distribution: {} {}", DistroID, DistroVersion);
|
||||||
const auto Distro = DistroID + ":" + DistroVersion;
|
const auto Distro = DistroID + "." + DistroVersion;
|
||||||
|
|
||||||
if (sDistroMap.contains(Distro)) {
|
Postfix = fmt::format(".{}.{}.{}", DistroID, DistroVersion, Arch);
|
||||||
Postfix = sDistroMap[Distro];
|
|
||||||
} else {
|
|
||||||
beammp_errorf("BeamMP doesn't provide binaries for this distribution, please update manually");
|
|
||||||
std::exit(1);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
beammp_infof("BeamMP doesn't provide binaries for this platform, please update manually");
|
beammp_infof("BeamMP doesn't provide binaries for this OS, please update manually");
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
beammp_infof("Looking for BeamMP-Server{}", Postfix);
|
||||||
|
|
||||||
// check if the release exists for that platform
|
// check if the release exists for that platform
|
||||||
std::string DownloadURL = "";
|
std::string DownloadURL = "";
|
||||||
try {
|
try {
|
||||||
@ -152,7 +146,7 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
|
|||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
if (DownloadURL.empty()) {
|
if (DownloadURL.empty()) {
|
||||||
beammp_infof("BeamMP doesn't provide binaries for this platform or distribution (postfix '{}' not found in the release assets), please update manually", Postfix);
|
beammp_infof("BeamMP doesn't provide binaries for this platform or distribution (release 'BeamMP-Server{}' not found in the release assets), please update manually", Postfix);
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,5 +237,7 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
|
|||||||
|
|
||||||
// make sure the user knows that it was a success, on windows wait for return???
|
// make sure the user knows that it was a success, on windows wait for return???
|
||||||
|
|
||||||
|
beammp_infof("SUCCESSFULLY UPDATED to v{}. Please launch the server manually to start the new version!", NewVersion.AsString());
|
||||||
|
|
||||||
std::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user