Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Take an unchanged kit from an older release when updating

Leonardo Lobato20e5c08fa56d
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b1b5378..90c83e4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -266,7 +266,9 @@ pre-releases). Players who enable Beta updates use the releases list, including
to this one; older versions are told to install by hand.
4. Attach `playden-update.json` and both zips to the release, then publish it. GitHub records each file's SHA-256,
and Playden checks the downloads against it. If the kit did not change, the kit zip may be left out: consoles
- that already have that kit download only the app.
+ that already have that kit download only the app, and the others take the zip from an older release that has it.
+ Playden 0.7.0 and older look only in the new release, so keep the zip while a version that old can update to it
+ without having the kit (or raise `--min-from`).
For a beta, keep the numeric version in `project()` (for example `0.7.1`) and configure with
`-DPLAYDEN_PRERELEASE=beta.1`. The package writes `playden-version` as `0.7.1-beta.1`; About, the updater and log
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index 1bfc3e4..2ff4a6a 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -583,8 +583,9 @@ void UpdateService::DoCheck(bool user_asked) {
if (local) Log("reading the release from " + config_.local_release_dir);
const bool include_betas = include_betas_.load();
std::optional<Release> release;
+ std::optional<std::vector<Release>> releases; // every release, when read: betas, or a kit zip left out
if (include_betas) {
- const auto releases = FetchReleases(&error);
+ releases = FetchReleases(&error);
if (!releases) return Fail("Playden could not read the releases on GitHub.", error);
for (const auto& candidate : *releases)
if (!candidate.draft && (!release || release->version < candidate.version)) release = candidate;
@@ -600,6 +601,7 @@ void UpdateService::DoCheck(bool user_asked) {
Log("up to date: running " + config_.current.ToString());
release_.reset();
manifest_.reset();
+ kit_zip_.reset();
Set([&](UpdateSnapshot& s) {
s.phase = UpdatePhase::kUpToDate;
s.available = release ? release->version : config_.current;
@@ -621,13 +623,29 @@ void UpdateService::DoCheck(bool user_asked) {
const auto* app = release->Find(manifest->app_asset);
const auto* kit = release->Find(manifest->kit.asset);
// A release whose kit did not change may leave the kit zip out; it is needed only when the
- // console has no copy of that kit.
+ // console has no copy of that kit, and then an older release has the same zip.
const bool kit_needed = ReadyKit(manifest->kit).empty();
+ if (kit_needed && !kit) {
+ if (!releases) {
+ std::string ignored;
+ releases = FetchReleases(&ignored);
+ }
+ if (releases)
+ for (const auto& older : *releases) {
+ if (older.draft || release->version < older.version) continue;
+ if ((kit = older.Find(manifest->kit.asset))) {
+ Log("update " + release->tag + " takes its kit " + manifest->kit.asset + " from " + older.tag);
+ break;
+ }
+ }
+ }
if (!app || (kit_needed && !kit)) return Fail("Release " + release->tag + " is missing a download.", "asset");
if (app->sha256.empty() || (kit_needed && kit->sha256.empty()))
return Fail("Release " + release->tag + " has no checksums. Install it by hand.", "digest");
release_ = *release;
manifest_ = *manifest;
+ if (kit_needed) kit_zip_ = *kit;
+ else kit_zip_.reset();
Log("update " + release->tag + " available: app " + std::to_string(app->size) + " bytes, kit " +
(kit_needed ? std::to_string(kit->size) + " bytes" : "already installed"));
std::string declined;
@@ -650,7 +668,7 @@ void UpdateService::DoInstall() {
if (!PrepareWorkRoot() || !MakeFolders(config_.work_root + "/downloads"))
return Fail("Playden could not create its update folder.", config_.work_root);
const auto* app = release.Find(manifest.app_asset);
- const auto* kit = release.Find(manifest.kit.asset);
+ const auto* kit = kit_zip_ ? &*kit_zip_ : release.Find(manifest.kit.asset);
std::string kit_folder = ReadyKit(manifest.kit);
const bool kit_needed = kit_folder.empty();
// Zip, unpacked files and some room to spare.
diff --git a/src/update/update_service.h b/src/update/update_service.h
index 9bc9fc7..fea2ab0 100644
--- a/src/update/update_service.h
+++ b/src/update/update_service.h
@@ -208,6 +208,9 @@ class UpdateService {
std::shared_ptr<Shared> shared_;
std::optional<Release> release_;
std::optional<UpdateManifest> manifest_;
+ // The kit zip release_ needs (the console has no copy of its kit): its own, or an older release's
+ // with the same name when release_ left the zip out.
+ std::optional<ReleaseAsset> kit_zip_;
// The staged update (from this run or a previous one): app folder, version, and the staged kit
// folder with its kit id (empty when the installed kit is already the release's).
std::string staged_folder_;
diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cpp
index 5b7ed89..13fd569 100644
--- a/tests/self_update_service_test.cpp
+++ b/tests/self_update_service_test.cpp
@@ -835,16 +835,45 @@ int main() {
CHECK(Read(fixture.root + "/homebrew/FAKE77031/eboot.bin") == "eboot 0.3.0");
RemoveTree(fixture.root);
}
- // Without the kit installed, a release that left its kit zip out cannot be installed.
+ // Without the kit installed, a release that left its kit zip out takes it from an older release; never from a
+ // newer one, and with no release that has it, the update cannot be installed.
{
Fixture fixture;
fixture.root = zip_fixture::TempFolder("service-nokit");
Installed(fixture.root);
+ // Each release's kit zip at its own address: only the older one's can be downloaded.
+ const auto moved = [](std::string release, const std::string& folder) {
+ const std::string from = kDownload + "playden-kit-h-r9.zip";
+ release.replace(release.find(from), from.size(), kDownload + folder + "/playden-kit-h-r9.zip");
+ return release;
+ };
+ Publish(fixture.server, "v0.2.5", "0.2.0", "00.002.005");
+ const std::string older = moved(fixture.server.latest, "older");
+ fixture.server.files[kDownload + "older/playden-kit-h-r9.zip"] = fixture.server.files[kDownload + "playden-kit-h-r9.zip"];
+ Publish(fixture.server, "v0.4.0", "0.2.0", "00.004.000");
+ const std::string newer = moved(fixture.server.latest, "newer");
Publish(fixture.server, "v0.3.0", "0.2.0", "00.003.000", false);
+ fixture.server.releases = "[" + newer + "," + fixture.server.latest + "]";
+ {
+ UpdateService service(fixture.Config({0, 2, 0}));
+ service.Check(false);
+ Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kFailed);
+ service.Shutdown();
+ }
+ fixture.server.releases = "[" + newer + "," + fixture.server.latest + "," + older + "]";
UpdateService service(fixture.Config({0, 2, 0}));
service.Check(false);
Wait(service);
- CHECK(service.Snapshot().phase == UpdatePhase::kFailed);
+ auto snapshot = service.Snapshot();
+ CHECK(snapshot.phase == UpdatePhase::kAvailable && snapshot.available == (Version{0, 3, 0}) && snapshot.kit_needed);
+ CHECK(snapshot.download_bytes == fixture.server.files[kDownload + "playden-ps5-0.3.0.zip"].size() +
+ fixture.server.files[kDownload + "playden-kit-h-r9.zip"].size());
+ service.Install();
+ Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kStaged && fixture.server.kit_downloads > 0);
+ CHECK(Read(fixture.root + "/playden/kits/.next-kitid-r9/manifest.json") == kKitSha);
+ service.Shutdown();
RemoveTree(fixture.root);
}
// Up to date, too old to update, a wrong app inside the zip, and too little free space.