mirror of
https://github.com/InstanceBrick/nightcap.git
synced 2026-10-20 20:01:09 +02:00
A first launch that cannot reach the APK provider only ever showed "Mocktail could not update or verify the Roblox installation.", while the actual cause stayed in the session log. For a user that is indistinguishable between a provider outage, a rejected signature, and a full disk. Name the host in HTTP transfer failures, so "HTTPS request returned status 503" becomes "api.pureapk.com request returned status 503", and relay the updater child's stderr through the launcher: every line still reaches the session log, and the last failure it reported is now attached to the preflight result. The failure dialog shows that reason and the session log directory instead of the generic sentence.
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
|
|
#include <charconv>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace {
|
|
|
|
const char* Environment(const char* name) {
|
|
const char* value = std::getenv(name);
|
|
return value == nullptr ? "" : value;
|
|
}
|
|
|
|
int IntegerEnvironment(const char* name, int fallback) {
|
|
const std::string_view value(Environment(name));
|
|
int parsed = fallback;
|
|
const auto result =
|
|
std::from_chars(value.data(), value.data() + value.size(), parsed);
|
|
return result.ec == std::errc() && result.ptr == value.data() + value.size()
|
|
? parsed
|
|
: fallback;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc != 3 || std::string_view(argv[1]) != "update" ||
|
|
(std::string_view(argv[2]) != "--startup-preflight" &&
|
|
std::string_view(argv[2]) != "--force-run-latest")) {
|
|
return 64;
|
|
}
|
|
const char* capture = Environment("MOCKTAIL_TEST_UPDATE_CAPTURE");
|
|
if (capture[0] != '\0') {
|
|
std::ofstream output(capture);
|
|
output << Environment("MOCKTAIL_CONFIG_FILE") << '\n'
|
|
<< Environment("MOCKTAIL_DATA_ROOT") << '\n'
|
|
<< Environment("MOCKTAIL_CACHE_ROOT") << '\n'
|
|
<< Environment("MOCKTAIL_STATE_ROOT") << '\n';
|
|
if (!output) return 65;
|
|
}
|
|
const char* argument_capture =
|
|
Environment("MOCKTAIL_TEST_UPDATE_ARGUMENT_CAPTURE");
|
|
if (argument_capture[0] != '\0') {
|
|
std::ofstream output(argument_capture);
|
|
output << argv[2] << '\n';
|
|
if (!output) return 67;
|
|
}
|
|
const char* diagnostics = Environment("MOCKTAIL_TEST_UPDATE_STDERR");
|
|
if (diagnostics[0] != '\0') {
|
|
std::fputs(diagnostics, stderr);
|
|
std::fputc('\n', stderr);
|
|
std::fflush(stderr);
|
|
}
|
|
const int progress = IntegerEnvironment("MOCKTAIL_UPDATE_PROGRESS_FD", -1);
|
|
if (progress >= 0) {
|
|
constexpr std::string_view packet = "PDownloading Roblox...";
|
|
if (send(progress, packet.data(), packet.size(), MSG_NOSIGNAL) < 0) {
|
|
return 66;
|
|
}
|
|
}
|
|
return IntegerEnvironment("MOCKTAIL_TEST_UPDATE_EXIT", 0);
|
|
}
|