Play your Steam library's Windows games on a jailbroken PS5.
C++
Stop offering a nightly the release it is built on
Leonardo Lobatod11874481f56
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 0c45a66..39365c1 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -10,6 +10,16 @@ if(NOT PLAYDEN_PRERELEASE STREQUAL "")endif()string(APPEND PLAYDEN_FULL_VERSION "-${PLAYDEN_PRERELEASE}")endif()+# The release a nightly is built on: it isn't offered that release or an older one. Other builds ignore it.+set(PLAYDEN_NIGHTLY_BASE "" CACHE STRING "A nightly's base release: empty, X.Y.Z or X.Y.Z-beta.N")+if(NOT PLAYDEN_NIGHTLY_BASE STREQUAL "" AND+ NOT PLAYDEN_NIGHTLY_BASE MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+(-beta\\.[1-9][0-9]*)?$")+ message(FATAL_ERROR "PLAYDEN_NIGHTLY_BASE must be empty, X.Y.Z or X.Y.Z-beta.N")+endif()+set(PLAYDEN_BUILD_NIGHTLY_BASE "")+if(PLAYDEN_PRERELEASE MATCHES "^nightly\\.")+ set(PLAYDEN_BUILD_NIGHTLY_BASE "${PLAYDEN_NIGHTLY_BASE}")+endif()# The commit the build is made from, for Settings › About. Configure runs again whenever HEAD moves.set(PLAYDEN_BUILD_COMMIT "")diff --git a/cmake/SelfUpdate.cmake b/cmake/SelfUpdate.cmakeindex 403cdc8..239200c 100644--- a/cmake/SelfUpdate.cmake+++ b/cmake/SelfUpdate.cmake@@ -16,7 +16,7 @@ add_library(playden_self_update STATICtarget_include_directories(playden_self_update PUBLIC "${CMAKE_SOURCE_DIR}/src")target_compile_features(playden_self_update PUBLIC cxx_std_17)target_compile_definitions(playden_self_update PRIVATE PLAYDEN_VERSION="${PLAYDEN_FULL_VERSION}"- PLAYDEN_BUILD_COMMIT="${PLAYDEN_BUILD_COMMIT}")+ PLAYDEN_BUILD_COMMIT="${PLAYDEN_BUILD_COMMIT}" PLAYDEN_NIGHTLY_BASE="${PLAYDEN_BUILD_NIGHTLY_BASE}")target_link_libraries(playden_self_update PUBLIC playden_miniz playden_steam_protocol playden_steam_http Threads::Threads)if(PLAYDEN_PLATFORM_PS5)target_compile_options(playden_self_update PRIVATE -fno-exceptions -fno-rtti)diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cppindex b220da5..a2e618e 100644--- a/src/homebrew/ps5.cpp+++ b/src/homebrew/ps5.cpp@@ -461,6 +461,7 @@ int main() {update_config.registered_app_root = std::string("/user/app/") + PLAYDEN_PS5_TITLE_ID;update_config.layout_journal = "/data/playden/runtime-state/layout-0.6.json";update_config.current = playden::update::CurrentVersion();+ update_config.nightly_base = playden::update::NightlyBase();update_config.include_betas = preferences.Load().preferences.beta_updates;update_config.fetch = [&update_http](const playden::steam::HttpRequest& request, const std::atomic<bool>& cancel) {return update_http.Perform(request, cancel);diff --git a/src/update/update_service.cpp b/src/update/update_service.cppindex 922f4e7..96bb279 100644--- a/src/update/update_service.cpp+++ b/src/update/update_service.cpp@@ -443,7 +443,7 @@ void UpdateService::Start() {const std::string stage = field("stage");const std::string kit = field("kit");const bool kit_present = kit.empty() || (config_.verify_kit && config_.verify_kit(kit));- if (version && config_.current < *version && !stage.empty() && Exists(stage + "/eboot.bin") && kit_present) {+ if (version && UpdateFloor() < *version && !stage.empty() && Exists(stage + "/eboot.bin") && kit_present) {staged_folder_ = stage;staged_version_ = *version;staged_kit_ = kit;@@ -567,6 +567,11 @@ void UpdateService::Install() {});}+const Version& UpdateService::UpdateFloor() const {+ const auto& base = config_.nightly_base;+ return config_.current.nightly() && base && !base->nightly() && config_.current < *base ? *base : config_.current;+}+void UpdateService::DoCheck(bool user_asked) {Set([&](UpdateSnapshot& s) {s.phase = UpdatePhase::kChecking;@@ -600,7 +605,7 @@ void UpdateService::DoCheck(bool user_asked) {if (!release) return Fail("The latest release on GitHub could not be read.", error);if (release->draft || release->prerelease || release->version.beta) release.reset();}- if (!release || !(config_.current < release->version)) {+ if (!release || !(UpdateFloor() < release->version)) {Log("up to date: running " + config_.current.ToString());release_.reset();manifest_.reset();@@ -620,7 +625,7 @@ void UpdateService::DoCheck(bool user_asked) {if (!manifest) return Fail("The update information of " + release->tag + " is not valid.", error);if (manifest->app_version != release->version || manifest->title_id != config_.title_id)return Fail("The update information does not match release " + release->tag + ".", "version or title");- if (config_.current < manifest->min_from)+ if (UpdateFloor() < manifest->min_from)return Fail("Playden " + release->version.ToString() + " cannot update from this version. Install it by hand.","min_from " + manifest->min_from.ToString());const auto* app = release->Find(manifest->app_asset);@@ -867,13 +872,13 @@ void UpdateService::DoCheckKit() {std::string error;const auto releases = FetchReleases(&error);if (!releases) return FailKit("Playden could not reach GitHub to download its runtime kit.", error);- // The running version's release names its kit. A nightly has no release: the newest release before it- // stands in, and is used only if it names the same kit (checked below).+ // The running version's release names its kit. A nightly has no release: its base, or the newest release+ // before it, stands in, and is used only if it names the same kit (checked below).const Release* own = nullptr;for (const auto& release : *releases) {if (release.draft) continue;if (release.version == config_.current) own = &release;- else if (config_.current.nightly() && release.version < config_.current &&+ else if (config_.current.nightly() && !(UpdateFloor() < release.version) &&(!own || (own->version != config_.current && own->version < release.version)))own = &release;}diff --git a/src/update/update_service.h b/src/update/update_service.hindex 1310aed..88a2d33 100644--- a/src/update/update_service.h+++ b/src/update/update_service.h@@ -39,6 +39,8 @@ struct UpdateConfig {// going back below 0.6.0 is refused whatever the current version. Empty: the version rule only.std::string layout_journal;Version current;+ // A nightly's base release (NightlyBase): it already holds that release, so that one and older are no update.+ std::optional<Version> nightly_base;bool include_betas = false;Fetch fetch;std::function<std::optional<std::string>(const std::string& path)> hash_file;@@ -170,6 +172,8 @@ class UpdateService {std::optional<Backup> LatestBackup() const;private:+ // The version a release has to be newer than: the running one, or the release a nightly is built on.+ const Version& UpdateFloor() const;struct Shared;void Run(std::function<void()> work);void DoCheck(bool user_asked);diff --git a/src/update/version.cpp b/src/update/version.cppindex 02ff5d0..db9c0fa 100644--- a/src/update/version.cpp+++ b/src/update/version.cpp@@ -6,6 +6,9 @@#ifndef PLAYDEN_BUILD_COMMIT#define PLAYDEN_BUILD_COMMIT ""#endif+#ifndef PLAYDEN_NIGHTLY_BASE+#define PLAYDEN_NIGHTLY_BASE ""+#endifnamespace playden::update {@@ -71,6 +74,8 @@ Version CurrentVersion() {return version;}+std::optional<Version> NightlyBase() { return ParseVersion(PLAYDEN_NIGHTLY_BASE); }+std::string BuildCommit() { return PLAYDEN_BUILD_COMMIT; }} // namespace playden::updatediff --git a/src/update/version.h b/src/update/version.hindex 3757429..164569c 100644--- a/src/update/version.h+++ b/src/update/version.h@@ -14,7 +14,8 @@ struct Version {unsigned patch = 0;unsigned beta = 0; // 0 is stable, newer than every beta of the same version.// A nightly test build (YYYYMMDD and that day's build number), never a release. A version's nightlies- // come before its betas and its stable release, so an update to either is offered.+ // come before its betas and its stable release, so an update to either is offered, unless the nightly+ // is built on that release (NightlyBase).unsigned nightly_date = 0;unsigned nightly_build = 0;@@ -45,6 +46,9 @@ std::optional<Version> ParseVersion(std::string_view text);// The version this build was made from (CMake's PROJECT_VERSION and pre-release suffix).Version CurrentVersion();+// The release this nightly was built on (CMake's PLAYDEN_NIGHTLY_BASE), or nothing when it wasn't recorded.+std::optional<Version> NightlyBase();+// The commit this build was made from (10 hex digits), or empty when the source was not a git checkout.std::string BuildCommit();diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cppindex b7c7a5d..51d7feb 100644--- a/tests/self_update_service_test.cpp+++ b/tests/self_update_service_test.cpp@@ -301,6 +301,87 @@ int main() {stable.Check(true); Wait(stable);CHECK(stable.Snapshot().phase == UpdatePhase::kAvailable && stable.Snapshot().available.ToString() == "0.7.1");}+ // A nightly built on a release isn't offered that release or an older one, only a newer one.+ {+ Fixture fixture;+ fixture.root = zip_fixture::TempFolder("nightly-base");+ Installed(fixture.root);+ const auto beta_named = [&](const char* tag) {+ Publish(fixture.server, tag, "0.7.0", "00.007.001");+ auto beta = fixture.server.latest;+ beta.replace(beta.find("\"prerelease\":false"), 18, "\"prerelease\":true");+ return beta;+ };+ auto config = fixture.Config(*ParseVersion("0.7.1-nightly.20261027.1"));+ config.nightly_base = *ParseVersion("0.7.1-beta.1");+ config.include_betas = true;+ const auto beta1 = beta_named("v0.7.1-beta.1");+ fixture.server.releases = "[" + beta1 + "]";+ UpdateService same(config);+ same.Check(true); Wait(same);+ CHECK(same.Snapshot().phase == UpdatePhase::kUpToDate);+ const auto beta2 = beta_named("v0.7.1-beta.2");+ fixture.server.releases = "[" + beta2 + "," + beta1 + "]";+ UpdateService newer(config);+ newer.Check(true); Wait(newer);+ CHECK(newer.Snapshot().phase == UpdatePhase::kAvailable && newer.Snapshot().available.ToString() == "0.7.1-beta.2");+ Publish(fixture.server, "v0.7.1", "0.7.0", "00.007.001");+ config.include_betas = false;+ UpdateService stable(config);+ stable.Check(true); Wait(stable);+ CHECK(stable.Snapshot().phase == UpdatePhase::kAvailable && stable.Snapshot().available.ToString() == "0.7.1");+ // A base older than the nightly's own version changes nothing, and neither does one on a non-nightly build.+ auto older_base = fixture.Config(*ParseVersion("0.7.1-nightly.20261027.1"));+ older_base.nightly_base = *ParseVersion("0.7.0");+ older_base.include_betas = true;+ fixture.server.releases = "[" + beta_named("v0.7.1-beta.1") + "]";+ UpdateService older(older_base);+ older.Check(true); Wait(older);+ CHECK(older.Snapshot().phase == UpdatePhase::kAvailable && older.Snapshot().available.ToString() == "0.7.1-beta.1");+ auto not_nightly = fixture.Config(*ParseVersion("0.7.0"));+ not_nightly.nightly_base = *ParseVersion("0.7.1-beta.1");+ not_nightly.include_betas = true;+ UpdateService plain(not_nightly);+ plain.Check(true); Wait(plain);+ CHECK(plain.Snapshot().phase == UpdatePhase::kAvailable && plain.Snapshot().available.ToString() == "0.7.1-beta.1");+ // A release that updates only from the base accepts the nightly built on it, and no other nightly.+ Publish(fixture.server, "v0.7.1-beta.2", "0.7.1-beta.1", "00.007.001");+ fixture.server.releases = "[" + fixture.server.latest + "]";+ config.include_betas = true;+ UpdateService from_base(config);+ from_base.Check(true); Wait(from_base);+ CHECK(from_base.Snapshot().phase == UpdatePhase::kAvailable);+ config.nightly_base.reset();+ UpdateService no_base(config);+ no_base.Check(true); Wait(no_base);+ CHECK(no_base.Snapshot().phase == UpdatePhase::kFailed);+ }+ // An update staged before a nightly built on that release was put in place is dropped at the next start.+ {+ Fixture fixture;+ fixture.root = zip_fixture::TempFolder("nightly-base-staged");+ Installed(fixture.root);+ Publish(fixture.server, "v0.7.1-beta.1", "0.7.0", "00.007.001");+ fixture.server.releases = "[" + fixture.server.latest + "]";+ auto config = fixture.Config(*ParseVersion("0.7.1-nightly.20261027.1"));+ config.include_betas = true;+ {+ UpdateService service(config);+ service.Start();+ service.Check(true); Wait(service);+ service.Install(); Wait(service);+ CHECK(service.Snapshot().phase == UpdatePhase::kStaged);+ }+ {+ UpdateService still(config);+ still.Start(); Wait(still);+ CHECK(still.Snapshot().phase == UpdatePhase::kStaged);+ }+ config.nightly_base = *ParseVersion("0.7.1-beta.1");+ UpdateService based(config);+ based.Start(); Wait(based);+ CHECK(based.Snapshot().phase != UpdatePhase::kStaged);+ }// Opting out during a download and cancelling must not leave a beta installable.{Fixture fixture;@@ -402,6 +483,19 @@ int main() {Wait(refused);CHECK(refused.Snapshot().kit.phase == KitInstallPhase::kUnavailable);refused.Shutdown();+ // A nightly built on a release takes its kit from that release, though it sorts after the nightly.+ KitOnly based("kit-nightly-base", "");+ Publish(based.fixture.server, "v0.4.0-beta.1");+ based.fixture.server.releases = "[" + based.fixture.server.latest + "]";+ auto based_config = based.Config();+ based_config.current = *ParseVersion("0.4.0-nightly.20261027.1");+ based_config.nightly_base = *ParseVersion("0.4.0-beta.1");+ UpdateService from_base(based_config);+ from_base.Start();+ from_base.CheckKit();+ Wait(from_base);+ CHECK(from_base.Snapshot().kit.phase == KitInstallPhase::kAvailable && from_base.Snapshot().kit.version == "0.4.0-beta.1");+ from_base.Shutdown();}// Another kit is installed: the right one replaces it, and the old one is left as a ".replaced-" leftover.{diff --git a/tests/self_update_version_test.cpp b/tests/self_update_version_test.cppindex e4618b2..e77095c 100644--- a/tests/self_update_version_test.cpp+++ b/tests/self_update_version_test.cpp@@ -16,6 +16,7 @@ int main() {CHECK(!((Version{1, 0, 0}) < (Version{1, 0, 0})));CHECK((Version{0, 3, 10}).ToString() == "0.3.10");// The build's own version comes from CMake.+ if (!CurrentVersion().nightly()) CHECK(!NightlyBase()); // only a nightly records oneCHECK(ParseVersion(PLAYDEN_VERSION) && CurrentVersion() == *ParseVersion(PLAYDEN_VERSION));// And its commit from git, when the source is a checkout.CHECK(BuildCommit() == PLAYDEN_BUILD_COMMIT);