Skip to content

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

C++

Keep Playden as FAKE77031; remove the move to PPSA97031

Leonardo Lobatob72ada6aae8b
diff --git a/cmake/HomebrewPS5.cmake b/cmake/HomebrewPS5.cmake
index 8bcaf6d..af64c56 100644
--- a/cmake/HomebrewPS5.cmake
+++ b/cmake/HomebrewPS5.cmake
@@ -3,8 +3,8 @@ function(playden_add_homebrew_ps5_title)
if(NOT DEFINED ENV{PS5_PAYLOAD_SDK})
message(FATAL_ERROR "PS5_PAYLOAD_SDK is unset; use scripts/build-homebrew-ps5.sh")
endif()
- if(NOT PLAYDEN_PS5_TITLE_ID MATCHES "^(FAKE|PPSA)[0-9][0-9][0-9][0-9][0-9]$")
- message(FATAL_ERROR "PLAYDEN_PS5_TITLE_ID is required and must match FAKE12345 or PPSA12345")
+ if(NOT PLAYDEN_PS5_TITLE_ID MATCHES "^FAKE[0-9][0-9][0-9][0-9][0-9]$")
+ message(FATAL_ERROR "PLAYDEN_PS5_TITLE_ID is required and must match FAKE12345")
endif()
set(sdk "$ENV{PS5_PAYLOAD_SDK}")
diff --git a/cmake/WriteNativePackageIdentity.cmake b/cmake/WriteNativePackageIdentity.cmake
index 9c2f919..5296c3e 100644
--- a/cmake/WriteNativePackageIdentity.cmake
+++ b/cmake/WriteNativePackageIdentity.cmake
@@ -1,4 +1,4 @@
-if(NOT DEFINED APP_DIR OR NOT TITLE_ID MATCHES "^(FAKE|PPSA)[0-9][0-9][0-9][0-9][0-9]$")
+if(NOT DEFINED APP_DIR OR NOT TITLE_ID MATCHES "^FAKE[0-9][0-9][0-9][0-9][0-9]$")
message(FATAL_ERROR "APP_DIR and a canonical native TITLE_ID are required")
endif()
if(NOT EXISTS "${APP_DIR}/eboot.bin" OR IS_DIRECTORY "${APP_DIR}/eboot.bin" OR IS_SYMLINK "${APP_DIR}/eboot.bin")
diff --git a/dependencies.lock.json b/dependencies.lock.json
index 26fdff2..1b2531e 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -10,8 +10,7 @@
"foundation_revision": "9c0b994a048521af6fb84c73ded364504fe250e9",
"protocol_sha256": "bb02c4aa814eaba7a7a423a31b29ff41f786212c2953678cf29434e85fa0f869",
"variants": {
- "FAKE77031": "910f12157ea9ddcb3fd1c84864b02a0eee95d33133bafdf9058426f66d3dd316",
- "PPSA97031": "2ec5761c36349c53e98b10b78037e7f70916fee9750292e793cbc86ac2b41c31"
+ "FAKE77031": "910f12157ea9ddcb3fd1c84864b02a0eee95d33133bafdf9058426f66d3dd316"
},
"payload_sdk": {
"version": "v0.42",
@@ -21,7 +20,7 @@
"source": "third_party/PS5-Lapy-JB-Daemon submodule, fork branch main at owned_title_revision; build with scripts/build-lapy-helper.sh"
},
"title_remover": {
- "sha256": "5a452a90476a582b230504a841be863c6966187f998f7c29b4f222b7f2524deb",
+ "sha256": "b39725072337816d4c6d2b159849df5e5a3d86505b7450357d774cc8d8f90ca0",
"payload_sdk": "ps5_payload_sdk",
"source": "tools/title-remover/main.c; build with scripts/build-title-remover.sh (reproducible; sent by Playden to the payload loader on 127.0.0.1:9021)"
},
@@ -35,7 +34,7 @@
"purpose": "Reads release zips for Playden's self-update; writing APIs left out"
},
"self_update_relaunch": {
- "sha256": "31a4ffb53de58b0bd5e9266a79a8a2f44df33586dffd4fe0fdb0df1510b14265",
+ "sha256": "e32c635cca2d67b0a94b388e17711748c9f4955238a02914135b432d529396e2",
"payload_sdk": "ps5_payload_sdk",
"source": "tools/self-update-relaunch/main.c; build with scripts/build-self-update-relaunch.sh (reproducible; sent by Playden to the payload loader on 127.0.0.1:9021 when it quits to finish an update)"
},
diff --git a/scripts/build-homebrew-ps5.sh b/scripts/build-homebrew-ps5.sh
index 051455f..835613a 100755
--- a/scripts/build-homebrew-ps5.sh
+++ b/scripts/build-homebrew-ps5.sh
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
# Package the selected direct Hui consumer locally, without console discovery, upload or launch.
-# PLAYDEN_PS5_TITLE_ID picks the title (default FAKE77031); its Lapy helper must be pinned in dependencies.lock.json.
set -euo pipefail
-title=${PLAYDEN_PS5_TITLE_ID:-FAKE77031}
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
environment=${PLAYDEN_PS5_ENV:-"$root/scripts/with-env.sh"}
deps=${PLAYDEN_PS5_DEPS_DIR:-"$root/deps"}
@@ -10,7 +8,7 @@ hui=${PLAYDEN_HUI_SOURCE_DIR:-"$root/third_party/ps5-homebrew-ui"}
simulation=${PLAYDEN_UI_SIMULATION:-OFF}
native_access=${PLAYDEN_NATIVE_RUNTIME_ACCESS:-ON}
prospero_source=${PLAYDEN_PROSPERO_SOURCE_DIR:-"$root/third_party/prospero-win"}
-helper_build="$root/third_party/PS5-Lapy-JB-Daemon/build/owned_root_helper-$title"
+helper_build="$root/third_party/PS5-Lapy-JB-Daemon/build/owned_root_helper-FAKE77031"
lapy_helper=${PLAYDEN_LAPY_HELPER_ELF:-"$helper_build/lapy.elf"}
lapy_manifest=${PLAYDEN_LAPY_HELPER_MANIFEST:-"$helper_build/lapy-manifest.json"}
title_remover=${PLAYDEN_TITLE_REMOVER_ELF:-"$root/build/title-remover/title-remover.elf"}
@@ -40,11 +38,11 @@ if [[ ! -f "$root/scripts/network-deps/.deps/ps5/lib/libcurl.a" ]]; then
fi
bash "$environment" bash -c 'exec "$PS5_PAYLOAD_SDK/bin/prospero-cmake" "$@"' bash \
-G Ninja -S "$root" -B "$root/build/homebrew-ps5" -DCMAKE_BUILD_TYPE=Release \
- -DPLAYDEN_PLATFORM_PS5=ON -DPLAYDEN_PS5_TITLE_ID="$title" \
+ -DPLAYDEN_PLATFORM_PS5=ON -DPLAYDEN_PS5_TITLE_ID=FAKE77031 \
-DPLAYDEN_UI_SIMULATION="$simulation" \
-DPLAYDEN_NATIVE_RUNTIME_ACCESS="$native_access" -DPLAYDEN_PROSPERO_SOURCE_DIR="$prospero_source" \
-DPLAYDEN_LAPY_HELPER_ELF="$lapy_helper" -DPLAYDEN_LAPY_HELPER_MANIFEST="$lapy_manifest" \
-DPLAYDEN_TITLE_REMOVER_ELF="$title_remover" -DPLAYDEN_RELAUNCH_ELF="$relaunch" \
-DPLAYDEN_PS5_DEPS_DIR="$deps" -DPLAYDEN_HUI_SOURCE_DIR="$hui"
bash "$environment" cmake --build "$root/build/homebrew-ps5" --target playden-homebrew-ps5-package
-echo "Selected Hui package (not deployed): $root/build/homebrew-ps5/dist/$title"
+echo "Selected Hui package (not deployed): $root/build/homebrew-ps5/dist/FAKE77031"
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 64580c0..71fb655 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -2136,7 +2136,6 @@ void Controller::TickSelfUpdate() {
else if (request == "cancel") self_update_->Cancel();
else if (request == "restart") self_update_->RequestRestart();
else if (request == "rollback") self_update_->RequestRollback();
- else if (request == "open-successor") self_update_->RequestOpenSuccessor();
else if (request == "acknowledge") self_update_->AcknowledgeFinished();
else if (request == "kit-check") self_update_->CheckKit();
else if (request == "kit-install") self_update_->InstallKit();
@@ -2200,7 +2199,6 @@ void Controller::TickSelfUpdate() {
}
live.download_bytes = snapshot.download_bytes;
live.kit_needed = snapshot.kit_needed;
- live.moves = snapshot.moves;
live.user_check = snapshot.user_check;
live.error = snapshot.error;
live.previous = snapshot.previous;
@@ -2209,7 +2207,6 @@ void Controller::TickSelfUpdate() {
live.current_notes_url = snapshot.current_notes_url;
live.whats_new = snapshot.whats_new;
live.quiet = snapshot.quiet;
- live.moved_to = snapshot.moved_to;
live.finished_message = snapshot.finished_message;
live.finished_failed = snapshot.finished_failed;
live.kit_phase = update::KitInstallPhaseName(snapshot.kit.phase);
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 5c69f8a..48e3c87 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -10,7 +10,6 @@
#include "stores/local/copy_runner.h"
#include "stores/local/library_source.h"
#include "app/diagnostic_log.h"
-#include "platform/ps5/title_database.h"
#include "platform/ps5/title_registry.h"
#include "platform/ps5/title_remover.h"
#include "platform/ps5/title_runtime.h"
@@ -42,9 +41,6 @@
#include "platform/ps5/system.hpp"
#include <array>
-#include <cerrno>
-#include <chrono>
-#include <thread>
#include <atomic>
#include <cstdio>
#include <cstdlib>
@@ -399,47 +395,6 @@ int main() {
update_config.kit_manifest_sha256 = playden::runtime::kExpectedKitManifestSha256;
for (const auto& renamed : playden::runtime::kKitIdRenames)
if (std::string(renamed.to) == playden::runtime::kDevelopmentKitId) update_config.renamed_kit_ids.push_back(renamed.from);
- // Playden moves from FAKE77031 to PPSA97031, the ID ProsperoStore can install: a release whose update
- // information names PPSA97031 installs as that title, and ShadowMountPlus registers it.
- if (std::string(PLAYDEN_PS5_TITLE_ID) == "FAKE77031") {
- update_config.successor_title_id = "PPSA97031";
- update_config.successor_root = "/data/homebrew/PPSA97031";
- update_config.register_title = [](const std::string& folder) {
- const auto added = playden::ps5::ShadowMountPost("/api/v1/manual/add", "{\"path\":\"" + folder + "\"}");
- playden::ps5::ShadowMountPost("/api/v1/scan", "{}"); // deferred until no title runs
- return added && added->find("\"status\":0") != std::string::npos;
- };
- }
- // Moved here from FAKE77031: the old title's folder and tile go once it holds no player data.
- if (std::string(PLAYDEN_PS5_TITLE_ID) == "PPSA97031") {
- update_config.predecessor_title_id = "FAKE77031";
- update_config.predecessor_root = "/data/homebrew/FAKE77031";
- update_config.unregister_title = [title_root = paths.title_root](const std::string& title) {
- const auto gone = [&title] {
- struct stat info{};
- return playden::ps5::ReadNativeTitleDatabase(title).inventory == playden::runtime::TitleAvailability::kFree &&
- lstat(("/user/app/" + title).c_str(), &info) != 0 && errno == ENOENT;
- };
- // Its manual source goes first: ShadowMountPlus would add the title again from it.
- playden::ps5::ShadowMountPost("/api/v1/manual/remove", "{\"path\":\"/data/homebrew/" + title + "\"}");
- if (gone()) return true;
- // ShadowMountPlus refuses to uninstall while a title runs: the title remover payload does it.
- playden::ps5::TitleRemoverConfig remover;
- remover.payload = title_root + "/title-remover.elf";
- remover.send = playden::ps5::SendToPayloadLoader;
- char nonce[24];
- std::snprintf(nonce, sizeof nonce, "%016llx",
- static_cast<unsigned long long>(std::chrono::steady_clock::now().time_since_epoch().count()));
- // The request is written as the app's user: no other thread raises root meanwhile.
- remover.hold_user = playden::ps5::HoldEffectiveUid;
- const auto outcome = playden::ps5::RunTitleRemover(remover, title, nonce);
- playden::app::AppendLogLine(log_root, "update.log", "self-update: title remover for " + title + " sent=" +
- std::to_string(outcome.sent) + " code=" + (outcome.code ? std::to_string(*outcome.code) : "none") +
- " detail=" + outcome.detail);
- for (int poll = 0; poll < 60 && !gone(); ++poll) std::this_thread::sleep_for(std::chrono::milliseconds(250));
- return gone();
- };
- }
update_config.appmeta_root = std::string("/user/appmeta/") + PLAYDEN_PS5_TITLE_ID;
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";
@@ -970,8 +925,7 @@ int main() {
playden::app::AppendLogLine(log_root, "launch.log", "shutdown self-update start");
self_update.Shutdown();
playden::app::AppendLogLine(log_root, "launch.log", "shutdown done");
- if (self_update.Snapshot().restart_requested || self_update.Snapshot().rollback_requested ||
- self_update.Snapshot().open_successor_requested) {
+ if (self_update.Snapshot().restart_requested || self_update.Snapshot().rollback_requested) {
// The relaunch payload starts first: it waits until Playden has gone, then opens it again.
std::string elf, error;
if (FILE* file = std::fopen((paths.title_root + "/self-update-relaunch.elf").c_str(), "rb")) {
@@ -982,20 +936,12 @@ int main() {
}
const std::string request = "/data/playden/self-update/relaunch-title";
FILE* title = std::fopen(request.c_str(), "w");
- // The title to open, then this one (they differ when the update moves Playden to a new title).
- const std::string titles = self_update.RelaunchTitle() + "\n" PLAYDEN_PS5_TITLE_ID "\n";
- const bool requested = title && std::fputs(titles.c_str(), title) >= 0;
+ const bool requested = title && std::fputs(PLAYDEN_PS5_TITLE_ID "\n", title) >= 0;
if (title) std::fclose(title);
const bool sent = !elf.empty() && requested && playden::ps5::SendToPayloadLoader(elf, &error);
playden::app::AppendLogLine(log_root, "update.log", std::string("self-update: relaunch payload ") +
(sent ? "sent" : "not sent: " + (elf.empty() ? std::string("missing") : error)));
const bool swapped = self_update.ApplyAtQuit();
- // A move that did not happen reopens this title: the payload reads the request again once Playden is gone.
- if (!swapped && self_update.RelaunchTitle() != PLAYDEN_PS5_TITLE_ID)
- if (FILE* again = std::fopen(request.c_str(), "w")) {
- std::fputs(PLAYDEN_PS5_TITLE_ID "\n" PLAYDEN_PS5_TITLE_ID "\n", again);
- std::fclose(again);
- }
playden::app::AppendLogLine(log_root, "update.log", std::string("self-update: quit ") +
(swapped ? "with the new files in place" : "without changing the app"));
}
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index ded5cb7..6b9ecc7 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -498,7 +498,7 @@ std::string action_label(const std::string& key) {
{"about-version", "Version"}, {"self-update-install", "Download and install"},
{"self-update-restart", "Restart Playden"}, {"self-update-cancel", "Cancel update"},
{"kit-install", "Download"}, {"kit-cancel", "Cancel download"},
- {"self-update-back-confirm", "Go back"}, {"release-notes-ok", "OK"}, {"successor-open", "Open the new Playden"},
+ {"self-update-back-confirm", "Go back"}, {"release-notes-ok", "OK"},
{"about-build", "Build"}, {"about-framework", "Framework"}, {"about-platform", "Platform"},
{"about-kit", "Runtime kit"}, {"about-kit-source", "Built from"},
{"about-back", "Back"}, {"inject-library-refresh", "Refresh library fixture"},
@@ -1674,7 +1674,7 @@ void Simulation::UpdateSelfUpdate(const LiveSelfUpdate& update) {
before.part != update.part || before.current != update.current ||
before.bytes_per_second != update.bytes_per_second || before.previous != update.previous ||
before.quiet != update.quiet || before.current_notes_url != update.current_notes_url ||
- before.whats_new != update.whats_new || before.moved_to != update.moved_to ||
+ before.whats_new != update.whats_new ||
before.kit_phase != update.kit_phase || before.kit_done != update.kit_done ||
before.kit_total != update.kit_total || before.kit_error != update.kit_error ||
!update.finished_message.empty();
@@ -1694,9 +1694,7 @@ void Simulation::UpdateSelfUpdate(const LiveSelfUpdate& update) {
state_.self_update.finished_message.clear();
self_update_requests_.push_back("acknowledge");
}
- if (!update.moved_to.empty() && before.moved_to.empty()) {
- pending_update_prompt_ = "moved";
- } else if (update.phase == "available" && update.quiet) {
+ if (update.phase == "available" && update.quiet) {
self_update_prompted_ = "available " + update.available; // Settings still lists it
} else if (update.phase == "available" && self_update_prompted_ != "available " + update.available) {
self_update_prompted_ = "available " + update.available;
@@ -1762,18 +1760,9 @@ void Simulation::show_update_prompt() {
size + "You can sign in and keep using Playden while it downloads.";
open_modal(std::move(prompt));
} else if (pending_update_prompt_ == "available" && update.phase == "available") {
- const std::string beta = update.available.find("-beta.") != std::string::npos ? " (Beta)" : "";
- // The same version as a new app: the step that follows an update from 0.7.1-beta.2 or older.
- const bool same = update.moves && update.available == update.current;
- ModalEntry prompt{"confirmation",
- same ? std::string("Move Playden to its new app")
- : "Playden " + update.available + beta + " is available",
- state_.navigation.focus_key, {"self-update-install", "ready-later"}, 0, false};
- const std::string move = "Playden " + update.available + " installs as a new app next to this one, so "
- "ProsperoStore can install and update it. Your sign-in, games and settings stay, and "
- "this app is removed once the new one has started.\n\n";
- prompt.body = (same ? std::string() : update.notes.empty() ? std::string() : update.notes + "\n\n") +
- (update.moves ? move : std::string()) + "The download is " +
+ ModalEntry prompt{"confirmation", "Playden " + update.available + (update.available.find("-beta.") != std::string::npos ? " (Beta)" : "") + " is available", state_.navigation.focus_key,
+ {"self-update-install", "ready-later"}, 0, false};
+ prompt.body = (update.notes.empty() ? std::string() : update.notes + "\n\n") + "The download is " +
format_bytes(update.download_bytes) +
(update.kit_needed ? ", with a new runtime kit." : ".") +
" You can keep using Playden while it downloads.";
@@ -1785,15 +1774,6 @@ void Simulation::show_update_prompt() {
prompt.body = "Restart Playden to finish the update. It closes and opens again by itself; if it doesn't, "
"open it from the Home screen.";
open_modal(std::move(prompt));
- } else if (pending_update_prompt_ == "moved" && !update.moved_to.empty()) {
- // This title updated to the new one, which hasn't started yet: its tile may be missing.
- ModalEntry prompt{"confirmation", "Playden " + update.moved_to + " is a new app", state_.navigation.focus_key,
- {"successor-open", "ready-later"}, 0, false};
- prompt.body = "Playden " + update.moved_to + " was installed as a new app, and this one no longer updates. "
- "Open the new Playden from Home.\n\nIf it isn't on Home, choose Open the new Playden: this "
- "Playden closes, asks the PS5 to add the new one, and opens it. If this Playden opens again "
- "instead, restart the PS5 and look on Home.";
- open_modal(std::move(prompt));
} else if (pending_update_prompt_ == "whats-new" || pending_update_prompt_ == "release-notes") {
open_release_notes(pending_update_prompt_ == "whats-new");
}
@@ -1860,7 +1840,7 @@ void Simulation::close_game_modals() {
modals.erase(std::remove_if(modals.begin(), modals.end(), [](const ModalEntry& modal) {
return std::none_of(modal.action_keys.begin(), modal.action_keys.end(), [](const std::string& key) {
return key == "self-update-install" || key == "self-update-restart" || key == "release-notes-ok" ||
- key == "kit-install" || key == "successor-open";
+ key == "kit-install";
});
}), modals.end());
}
@@ -1884,11 +1864,6 @@ void Simulation::request_self_update_restart(const std::string& request) {
const auto& game = entry.second;
return game.status == "Preparing" || !game.uninstall_status.empty() || game.maintenance_running;
});
- if (busy && request == "open-successor") {
- show_alert("Open the new Playden later", "A game is being prepared or removed. When it is done, close Playden "
- "and open the new one from Home, or restart the PS5 if it isn't there.");
- return;
- }
if (busy) {
show_alert("Restart Playden later", "A game is being prepared or removed. Restart Playden from Settings when it is done.");
return;
@@ -5277,10 +5252,8 @@ void Simulation::rebuild_view() {
item.value = "Checking…";
item.subtitle = "Looking for a newer Playden on GitHub";
} else if (update.phase == "available") {
- item.value = update.moves && update.available == update.current ? "New app available"
- : update.available + " available";
- item.subtitle = (update.moves ? "Installs as a new app · download " : "Download ") +
- format_bytes(update.download_bytes);
+ item.value = update.available + " available";
+ item.subtitle = "Download " + format_bytes(update.download_bytes);
} else if (update.phase == "downloading" || update.phase == "unpacking") {
item.value = update.total ? std::to_string(update.done * 100 / update.total) + "%" : "Working…";
item.subtitle = update.phase == "downloading" ? "Downloading Playden " + update.available
@@ -7601,7 +7574,6 @@ void Simulation::activate() {
else if (live() && action_name == "kit-cancel") { close_modal(); self_update_requests_.push_back("kit-cancel"); }
else if (live() && action_name == "self-update-cancel") { close_modal(); self_update_requests_.push_back("cancel"); }
else if (live() && action_name == "self-update-restart") { close_modal(); request_self_update_restart(); }
- else if (live() && action_name == "successor-open") { close_modal(); request_self_update_restart("open-successor"); }
else if (live() && action_name == "self-update-notes") open_release_notes(false);
else if (action_name == "release-notes-ok") close_modal();
else if (live() && action_name == "self-update-back") {
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 213ab64..23c8001 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -110,7 +110,6 @@ struct LiveSelfUpdate {
std::optional<int> eta_seconds;
std::uint64_t download_bytes = 0;
bool kit_needed = false;
- bool moves = false; // the update installs Playden as a new app (its new title)
bool user_check = false; // the last check was asked for in Settings
std::string error;
std::string previous; // the version "go back" restores; empty when none is kept
@@ -119,7 +118,6 @@ struct LiveSelfUpdate {
std::string current_notes_url;
bool whats_new = false; // the previous run updated Playden: show its release notes once
bool quiet = false; // the available version is one the player went back from: no dialog
- std::string moved_to; // Playden moved to its new title, which hasn't started yet: its version
std::string finished_message; // the previous run's update result, shown once
bool finished_failed = false;
// The kit-only install (first run, or a kit that isn't this version's): idle, checking, not-needed,
diff --git a/src/platform/ps5/title_remover.cpp b/src/platform/ps5/title_remover.cpp
index 51633d2..c0946df 100644
--- a/src/platform/ps5/title_remover.cpp
+++ b/src/platform/ps5/title_remover.cpp
@@ -55,7 +55,6 @@ bool WriteRequest(const std::filesystem::path& directory, const std::string& tex
TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std::string& title, const std::string& nonce) {
TitleRemoverOutcome outcome;
const auto& directory = config.request_directory;
- auto held = config.hold_user ? config.hold_user() : nullptr;
// The payload trusts only a directory owned by Playden's user that others cannot write.
struct stat info{};
if (lstat(directory.c_str(), &info) != 0) {
@@ -75,7 +74,6 @@ TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std:
outcome.detail = "request could not be written";
return outcome;
}
- held.reset();
const auto payload = ReadNoFollow(config.payload, kMaxPayload);
if (!payload || payload->size() < 4 || payload->compare(0, 4, "\x7f" "ELF") != 0) {
outcome.detail = "payload missing";
diff --git a/src/platform/ps5/title_remover.h b/src/platform/ps5/title_remover.h
index d2ad37b..4b32456 100644
--- a/src/platform/ps5/title_remover.h
+++ b/src/platform/ps5/title_remover.h
@@ -5,7 +5,6 @@
#include <chrono>
#include <filesystem>
#include <functional>
-#include <memory>
#include <optional>
#include <string>
@@ -22,17 +21,14 @@ struct TitleRemoverConfig {
// Exchange directory the payload reads (0755, owned by Playden; see
// tools/title-remover/main.c) and the payload itself, shipped in Playden's title.
std::filesystem::path request_directory = "/data/playden/title-remover";
- std::filesystem::path payload; // <title root>/title-remover.elf
+ std::filesystem::path payload = "/data/homebrew/FAKE77031/title-remover.elf";
// Sends the payload's bytes to the payload loader; false with a reason on failure.
std::function<bool(const std::string& elf, std::string* error)> send;
- // Keeps root from being raised elsewhere while the request is written as the app's user (the
- // folder's owner check and the write compare against the effective UID). Optional.
- std::function<std::shared_ptr<void>()> hold_user;
int result_polls = 60;
std::chrono::milliseconds result_interval{250};
};
-// Writes the request for title_id (FAKE78xxx, or FAKE77031) and nonce, sends the payload and
+// Writes the request for title_id (FAKE78xxx) and nonce, sends the payload and
// waits (bounded) for its answer. Worker only. The answer only reports what the
// payload saw; the caller confirms removal in the console inventory.
TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std::string& title_id,
diff --git a/src/update/release.cpp b/src/update/release.cpp
index 653b82d..d298260 100644
--- a/src/update/release.cpp
+++ b/src/update/release.cpp
@@ -103,11 +103,6 @@ const ReleaseAsset* Release::Find(std::string_view name) const {
return nullptr;
}
-const ReleaseAsset* Release::Manifest() const {
- const auto* v2 = Find(kUpdateManifestAssetV2);
- return v2 ? v2 : Find(kUpdateManifestAsset);
-}
-
namespace {
std::optional<Release> ReleaseFrom(const Json* doc, std::string* error) {
diff --git a/src/update/release.h b/src/update/release.h
index 32bc2e1..ccc7c49 100644
--- a/src/update/release.h
+++ b/src/update/release.h
@@ -13,9 +13,6 @@
namespace playden::update {
inline constexpr const char* kUpdateManifestAsset = "playden-update.json";
-// From 0.8.0 a release has two: playden-update.json names a FAKE77031 build, the only one Playden 0.7.1-beta.2
-// and older can read; playden-update-v2.json names the PPSA97031 app, and newer builds read it first.
-inline constexpr const char* kUpdateManifestAssetV2 = "playden-update-v2.json";
struct ReleaseAsset {
std::string name;
@@ -32,8 +29,6 @@ struct Release {
bool prerelease = false;
std::vector<ReleaseAsset> assets;
const ReleaseAsset* Find(std::string_view name) const;
- // The update information this build reads: playden-update-v2.json when the release has one.
- const ReleaseAsset* Manifest() const;
};
// The JSON of GET /repos/<owner>/<repo>/releases/latest. The tag must be a version ("v0.3.0").
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index 96cd59a..2ff4a6a 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -1,6 +1,5 @@
#include "update/update_service.h"
-#include <dirent.h>
#include <pthread.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -22,7 +21,7 @@ struct UpdateService::Shared {
UpdateSnapshot snapshot;
std::atomic<bool> cancel{false};
std::atomic<bool> busy{false};
- std::vector<std::function<void()>> queued; // jobs asked for while another ran, in order (under mutex)
+ std::function<void()> queued; // one job asked for while another ran (under mutex)
bool thread_started = false;
pthread_t thread{};
};
@@ -181,8 +180,7 @@ void UpdateService::Fail(const std::string& message, const std::string& detail)
std::string UpdateService::StatePath() const { return config_.work_root + "/state.json"; }
bool UpdateService::SaveState(const std::string& phase, const std::string& extra) {
- // The owner: after a move both titles share the work folder, and each leaves the other's state alone.
- const std::string text = "{\"phase\":" + Quote(phase) + ",\"owner\":" + Quote(config_.title_id) + extra + "}\n";
+ const std::string text = "{\"phase\":" + Quote(phase) + extra + "}\n";
const bool ok = WriteFileAtomically(StatePath(), text);
if (!ok) Log("cannot save " + StatePath());
return ok;
@@ -191,8 +189,7 @@ bool UpdateService::SaveState(const std::string& phase, const std::string& extra
std::string UpdateService::StagedFields() const {
const auto snapshot = Snapshot();
return ",\"version\":" + Quote(staged_version_.ToString()) + ",\"from\":" + Quote(config_.current.ToString()) +
- ",\"stage\":" + Quote(staged_folder_) + ",\"title\":" + Quote(staged_title_) + ",\"kit\":" +
- Quote(staged_kit_) + ",\"kit_id\":" +
+ ",\"stage\":" + Quote(staged_folder_) + ",\"kit\":" + Quote(staged_kit_) + ",\"kit_id\":" +
Quote(staged_kit_id_) + ",\"notes\":" + Quote(snapshot.notes) + ",\"notes_url\":" + Quote(snapshot.notes_url);
}
@@ -242,16 +239,6 @@ void UpdateService::RetireRenamedKits() {
// The app user's leftovers of a confirmed update, on the worker and without root: the stage, the
// downloads, the replaced entries and the files of a kit left by going back.
-namespace {
-// The titleId in a folder's sce_sys/param.json, or empty.
-std::string ParamTitle(const std::string& folder) {
- std::string text;
- const auto param = ReadSmallFile(folder + "/sce_sys/param.json", &text) ? steam::json::Parse(text) : std::nullopt;
- const auto* title = param && param->is_object() ? param->Find("titleId") : nullptr;
- return title && title->is_string() ? title->text() : std::string();
-}
-} // namespace
-
void UpdateService::CleanUpLeftovers() {
std::vector<std::string> paths;
for (const char* name : {"/stage", "/downloads", "/replaced"})
@@ -273,10 +260,10 @@ bool UpdateService::RemoveOwnedTree(const std::string& path) {
void UpdateService::Run(std::function<void()> work) {
{
// A job asked for while another runs waits for it (the startup check behind the cleanup of a
- // confirmed update and the old title's removal, an install behind a check).
+ // confirmed update, an install behind a check); a third request replaces nothing.
std::lock_guard<std::mutex> lock(shared_->mutex);
if (shared_->busy) {
- shared_->queued.push_back(std::move(work));
+ if (!shared_->queued) shared_->queued = std::move(work);
return;
}
shared_->busy = true;
@@ -293,12 +280,12 @@ void UpdateService::Run(std::function<void()> work) {
std::function<void()> next;
{
std::lock_guard<std::mutex> lock(shared->mutex);
- if (shared->queued.empty()) {
+ next = std::move(shared->queued);
+ shared->queued = nullptr;
+ if (!next) {
shared->busy = false;
return;
}
- next = std::move(shared->queued.front());
- shared->queued.erase(shared->queued.begin());
}
if (!shared->cancel) next();
}
@@ -313,7 +300,7 @@ void UpdateService::Run(std::function<void()> work) {
{
std::lock_guard<std::mutex> lock(shared_->mutex);
shared_->busy = false;
- shared_->queued.clear();
+ shared_->queued = nullptr;
}
Fail("Playden could not start the update.", "pthread_create " + std::to_string(rc));
return;
@@ -346,9 +333,6 @@ std::optional<UpdateService::Backup> UpdateService::LatestBackup() const {
const auto version = dash == std::string::npos ? std::nullopt : ParseVersion(name.substr(0, dash));
const std::string path = config_.work_root + "/backup/" + name;
if (!version || !Exists(path + "/eboot.bin")) continue;
- // Another title's app (from before a move) never goes into this title's folder.
- const auto title = ParamTitle(path);
- if (!title.empty() && title != config_.title_id) continue;
// Names end in the swap time; the newest has the largest.
const auto stamp = name.substr(dash + 1);
if (!latest || stamp.size() > latest_name.size() || (stamp.size() == latest_name.size() && stamp > latest_name)) {
@@ -396,123 +380,6 @@ void UpdateService::RequestRestart() {
});
}
-bool UpdateService::Moving() const {
- return !staged_title_.empty() && staged_title_ != config_.title_id && staged_title_ == config_.successor_title_id &&
- !config_.successor_root.empty();
-}
-
-void UpdateService::RequestOpenSuccessor() {
- if (!superseded_) return;
- Set([](UpdateSnapshot& s) { s.open_successor_requested = true; });
-}
-
-std::string UpdateService::RelaunchTitle() const {
- const auto snapshot = Snapshot();
- if (superseded_) return snapshot.open_successor_requested ? config_.successor_title_id : config_.title_id;
- return snapshot.restart_requested && !snapshot.rollback_requested && Moving() ? staged_title_ : config_.title_id;
-}
-
-std::string UpdateService::PredecessorRefusal() const {
- const std::string& root = config_.predecessor_root;
- std::string text;
- if (!ReadSmallFile(root + "/playden-version", &text, 64)) return "no playden-version";
- if (!text.empty() && text.back() == '\n') text.pop_back();
- const auto version = ParseVersion(text);
- // Before 0.6.0 the sign-in, games and logs lived in the app folder.
- if (!version || *version < kLayoutBoundary) return "version " + text + " keeps its data in the app folder";
- // A move to the 0.6 layout that never ran (the old version was never opened) leaves them there too.
- // A folder that can't be read may hold them as well.
- for (const char* data : {"/games", "/playden-data"}) {
- DIR* folder = opendir((root + data).c_str());
- if (!folder) {
- if (errno == ENOENT) continue;
- return std::string(data + 1) + " can't be read (errno=" + std::to_string(errno) + ")";
- }
- bool empty = true;
- while (const dirent* entry = readdir(folder)) {
- const std::string name = entry->d_name;
- if (name != "." && name != ".." && name != "MOVED.txt") empty = false;
- }
- closedir(folder);
- if (!empty) return std::string(data + 1) + " is not empty";
- }
- return {};
-}
-
-void UpdateService::RetirePredecessor() {
- const std::string& title = config_.predecessor_title_id;
- if (title.empty() || config_.predecessor_root.empty() || !config_.unregister_title) return;
- const std::string retired = config_.work_root + "/retired/" + title;
- const std::string unregistered = retired + ".unregistered";
- if (Exists(unregistered)) {
- if (RemoveOwnedTree(retired)) unlink(unregistered.c_str());
- Log(Exists(retired) ? "the old " + title + " app could not be deleted" : "the old " + title + " app is deleted");
- }
- if (Exists(config_.predecessor_root + "/eboot.bin") && !Exists(retired)) {
- // Right after the move the old app stays one more start: if this title fails before it has started
- // once, the old one still works (it only points to this one).
- std::string moving;
- const auto pending = ReadSmallFile(StatePath(), &moving) ? steam::json::Parse(moving) : std::nullopt;
- const auto pending_field = [&](const char* name) -> std::string {
- const auto* value = pending && pending->is_object() ? pending->Find(name) : nullptr;
- return value && value->is_string() ? value->text() : std::string();
- };
- if (pending_field("phase") == "applied" && pending_field("moved_to") == config_.title_id) {
- Log("the old " + title + " app stays until this one has started once");
- return;
- }
- const auto refusal = PredecessorRefusal();
- if (!refusal.empty()) {
- Log(title + " left in place: " + refusal);
- return;
- }
- // ShadowMountPlus registers any folder in /data/homebrew again, so the folder leaves first. Root is
- // process-wide: it is raised here, before the runtime starts (see ConfirmApplied).
- const bool moved = MakeFolders(config_.work_root + "/retired") && config_.as_root([&] {
- return rename(config_.predecessor_root.c_str(), retired.c_str()) == 0;
- });
- Log(moved ? "the old " + title + " app left /data/homebrew" : "the old " + title + " app could not be moved");
- if (!moved) return;
- // Its backups are of the old title's app, which this title must never restore into its folder.
- for (const auto& name : ListFolder(config_.work_root + "/backup"))
- if (ParamTitle(config_.work_root + "/backup/" + name) == title) RemoveOwnedTree(config_.work_root + "/backup/" + name);
- // So is an update it staged (states from before 0.7.1 name no owner); only its move to this title stays.
- std::string text;
- const auto state = ReadSmallFile(StatePath(), &text) ? steam::json::Parse(text) : std::nullopt;
- const auto field = [&](const char* name) -> std::string {
- const auto* value = state && state->is_object() ? state->Find(name) : nullptr;
- return value && value->is_string() ? value->text() : std::string();
- };
- const bool its = field("owner").empty() || field("owner") == title;
- if (state && its && !(field("phase") == "applied" && field("moved_to") == config_.title_id)) {
- Log("the old " + title + " app's update state is removed");
- if (field("phase") == "staged") {
- if (!field("stage").empty()) RemoveOwnedTree(field("stage"));
- if (!field("kit").empty()) RemoveOwnedTree(field("kit"));
- }
- unlink(StatePath().c_str());
- }
- }
- // Its tile goes from the worker once Start's own root work is over (root is process-wide; the title
- // remover's request is written as the app's user).
- unregister_pending_ = Exists(retired) && !Exists(unregistered);
-}
-
-void UpdateService::UnregisterPredecessor() {
- const std::string& title = config_.predecessor_title_id;
- const std::string retired = config_.work_root + "/retired/" + title;
- const std::string unregistered = retired + ".unregistered";
- if (!config_.unregister_title(title)) {
- Log(title + " is still registered: tried again at the next start");
- return;
- }
- WriteFileAtomically(unregistered, "");
- // Most of the app's files are the app user's to delete; what is left goes at the next start, as root.
- RemoveTree(retired);
- if (!Exists(retired)) unlink(unregistered.c_str());
- Log(title + " is unregistered");
-}
-
DownloadOptions UpdateService::Downloads(const std::string& part) {
DownloadOptions options;
options.fetch = config_.fetch;
@@ -544,43 +411,6 @@ std::string UpdateService::ReadyKit(const KitPart& kit) const {
}
void UpdateService::Start() {
- StartState();
- if (unregister_pending_) Run([this] { UnregisterPredecessor(); });
-}
-
-void UpdateService::StartState() {
- // The successor title is installed (this title moved to it, or it came from ProsperoStore): updates,
- // kits and the shared update state are its business now, and this title points the player to it.
- if (!config_.successor_root.empty() && Exists(config_.successor_root + "/eboot.bin")) {
- superseded_ = true;
- LoadCurrentNotes();
- std::string text;
- const auto state = ReadSmallFile(StatePath(), &text) ? steam::json::Parse(text) : std::nullopt;
- const auto text_field = [&](const char* name) -> std::string {
- const auto* value = state && state->is_object() ? state->Find(name) : nullptr;
- return value && value->is_string() ? value->text() : std::string();
- };
- // The move this title made and the new title has not confirmed yet: ShadowMountPlus is asked again,
- // in case the new title has no tile yet.
- const bool unconfirmed = text_field("phase") == "applied" && text_field("moved_to") == config_.successor_title_id &&
- (text_field("owner").empty() || text_field("owner") == config_.title_id);
- Log(config_.successor_title_id + " is installed: updates are left to it" +
- (unconfirmed ? "; the move to " + text_field("version") + " is not confirmed yet" : std::string()));
- Set([&](UpdateSnapshot& s) {
- // Not started yet: a dialog says where Playden went, in case its tile is missing. Else a short notice.
- if (unconfirmed) {
- s.moved_to = text_field("version");
- } else {
- s.finished_message = "Open the new Playden from Home.";
- s.finished_failed = false;
- }
- });
- if (unconfirmed && config_.register_title)
- Run([this] { Log(config_.register_title(config_.successor_root) ? "new title registration requested"
- : "new title registration not answered"); });
- return;
- }
- RetirePredecessor();
FindPrevious();
LoadCurrentNotes();
RemoveReplacedKits();
@@ -601,13 +431,6 @@ void UpdateService::StartState() {
return value && value->is_string() ? value->text() : std::string();
};
const std::string phase = field("phase");
- // Another title's state (the two share the work folder after a move) is left alone, except the move to this one.
- // Every version of a title that replaced another names the owner; a state without one is the old title's.
- const std::string owner = field("owner").empty() ? config_.predecessor_title_id : field("owner");
- if (!owner.empty() && owner != config_.title_id && !(phase == "applied" && field("moved_to") == config_.title_id)) {
- Log("update state of " + owner + " left alone");
- return;
- }
if (phase == "applied") {
ConfirmApplied(text);
return;
@@ -616,14 +439,9 @@ void UpdateService::StartState() {
const auto version = ParseVersion(field("version"));
const std::string stage = field("stage");
const std::string kit = field("kit");
- // States from before the move to a successor title have no title: they are this one.
- const std::string title = field("title").empty() ? config_.title_id : field("title");
- const bool title_known = title == config_.title_id || (title == config_.successor_title_id && !config_.successor_root.empty());
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 &&
- title_known) {
+ if (version && config_.current < *version && !stage.empty() && Exists(stage + "/eboot.bin") && kit_present) {
staged_folder_ = stage;
- staged_title_ = title;
staged_version_ = *version;
staged_kit_ = kit;
staged_kit_id_ = field("kit_id");
@@ -724,7 +542,6 @@ void UpdateService::ConfirmApplied(const std::string& text) {
bool UpdateService::SetIncludeBetas(bool enabled) { return include_betas_.exchange(enabled) != enabled; }
void UpdateService::Check(bool user_asked) {
- if (superseded_) return;
{
std::lock_guard<std::mutex> lock(shared_->mutex);
const auto phase = shared_->snapshot.phase;
@@ -735,7 +552,6 @@ void UpdateService::Check(bool user_asked) {
}
void UpdateService::Install() {
- if (superseded_) return;
Run([this] {
// A track change can arrive while a download is being cancelled or a check is queued.
if (release_ && (release_->prerelease || release_->version.beta) && !include_betas_.load()) {
@@ -781,7 +597,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();
}
- const auto up_to_date = [&] {
+ if (!release || !(config_.current < release->version)) {
Log("up to date: running " + config_.current.ToString());
release_.reset();
manifest_.reset();
@@ -790,24 +606,16 @@ void UpdateService::DoCheck(bool user_asked) {
s.phase = UpdatePhase::kUpToDate;
s.available = release ? release->version : config_.current;
});
- };
- const bool can_move = !config_.successor_title_id.empty() && !config_.successor_root.empty();
- // This version's own release can still move Playden: the FAKE77031 build that 0.7.1-beta.2 and older update
- // to first (they read only playden-update.json) finds the same version under the successor title.
- const bool newer = release && config_.current < release->version;
- const bool same = release && release->version == config_.current;
- if (!newer && !(same && can_move && release->Find(kUpdateManifestAssetV2))) return up_to_date();
- const auto* asset = release->Manifest();
+ return;
+ }
+ const auto* asset = release->Find(kUpdateManifestAsset);
if (!asset) return Fail("Release " + release->tag + " has no update information. Install it by hand.", "no asset");
- const auto manifest_text = local ? read_local(asset->name)
+ const auto manifest_text = local ? read_local(kUpdateManifestAsset)
: FetchSmall(asset->url, 256 << 10, options, "application/octet-stream", &error);
if (!manifest_text) return Fail("Playden could not read the update information.", error);
const auto manifest = ParseUpdateManifest(*manifest_text, &error);
if (!manifest) return Fail("The update information of " + release->tag + " is not valid.", error);
- // A release under the successor title is a move: it installs next to this one.
- const bool moves = can_move && manifest->title_id == config_.successor_title_id;
- if (!newer && !moves) return up_to_date();
- if (manifest->app_version != release->version || (manifest->title_id != config_.title_id && !moves))
+ 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)
return Fail("Playden " + release->version.ToString() + " cannot update from this version. Install it by hand.",
@@ -838,8 +646,7 @@ void UpdateService::DoCheck(bool user_asked) {
manifest_ = *manifest;
if (kit_needed) kit_zip_ = *kit;
else kit_zip_.reset();
- Log("update " + release->tag + " available" + (moves ? " as " + manifest->title_id : std::string()) + ": app " +
- std::to_string(app->size) + " bytes, kit " +
+ 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;
ReadSmallFile(config_.work_root + "/declined-version", &declined, 64);
@@ -852,7 +659,6 @@ void UpdateService::DoCheck(bool user_asked) {
s.notes_url = release->page.empty() ? PageFor(release->tag) : release->page;
s.kit_needed = kit_needed;
s.download_bytes = app->size + (kit_needed ? kit->size : 0);
- s.moves = moves;
});
}
@@ -879,7 +685,6 @@ void UpdateService::DoInstall() {
kit_folder = ReadyKit(manifest.kit);
}
if (!StageApp(release, manifest)) return;
- staged_title_ = manifest.title_id;
staged_version_ = release.version;
// The installed kit already matches: nothing to swap for it.
staged_kit_ = kit_folder == config_.kits_root + "/" + manifest.kit.kit_id ? std::string() : kit_folder;
@@ -1024,13 +829,11 @@ std::optional<std::vector<Release>> UpdateService::FetchReleases(std::string* er
}
void UpdateService::CheckKit() {
- if (superseded_) return;
if (config_.kit_id.empty() || config_.kit_manifest_sha256.empty()) return;
Run([this] { DoCheckKit(); });
}
void UpdateService::InstallKit() {
- if (superseded_) return;
Run([this] {
if (!kit_asset_ || !kit_part_) DoCheckKit();
if (Snapshot().kit.phase != KitInstallPhase::kAvailable) return;
@@ -1065,19 +868,18 @@ void UpdateService::DoCheckKit() {
for (const auto& release : *releases)
if (!release.draft && release.version == config_.current) own = &release;
if (!own) return unavailable("no release has version " + config_.current.ToString());
- const auto* manifest_asset = own->Manifest();
+ const auto* manifest_asset = own->Find(kUpdateManifestAsset);
if (!manifest_asset) return unavailable("release " + own->tag + " has no update information");
auto options = Downloads("");
options.max_attempts = 2;
- const std::string local_manifest = config_.local_release_dir + "/" + manifest_asset->name;
- const bool local = !config_.local_release_dir.empty() && Exists(local_manifest);
+ const bool local = !config_.local_release_dir.empty() && Exists(config_.local_release_dir + "/" + kUpdateManifestAsset);
std::optional<std::string> manifest_text;
if (!local) {
manifest_text = FetchSmall(manifest_asset->url, 256 << 10, options, "application/octet-stream", &error);
- } else if (std::string text; ReadSmallFile(local_manifest, &text, 256 << 10)) {
+ } else if (std::string text; ReadSmallFile(config_.local_release_dir + "/" + kUpdateManifestAsset, &text, 256 << 10)) {
manifest_text = std::move(text);
} else {
- error = "cannot read " + manifest_asset->name;
+ error = std::string("cannot read ") + kUpdateManifestAsset;
}
if (!manifest_text) return FailKit("Playden could not read the kit information.", error);
const auto manifest = ParseUpdateManifest(*manifest_text, &error);
@@ -1228,7 +1030,7 @@ bool UpdateService::StageApp(const Release& release, const UpdateManifest& manif
const auto full_version = has_full ? ParseVersion(full_text)
: (Exists(stage + "/playden-version") ? std::nullopt : content_version);
const Version numeric{release.version.major, release.version.minor, release.version.patch};
- if (!title || !title->is_string() || title->text() != manifest.title_id || !content_version ||
+ if (!title || !title->is_string() || title->text() != config_.title_id || !content_version ||
*content_version != numeric || !full_version || *full_version != release.version ||
!Exists(stage + "/eboot.bin")) {
RemoveOwnedTree(stage);
@@ -1333,16 +1135,8 @@ bool UpdateService::RollBackAtQuit() {
}
bool UpdateService::ApplyAtQuit() {
- if (superseded_) {
- // Asked for from the old title: ShadowMountPlus adds the new title once this one has closed.
- if (!Snapshot().open_successor_requested) return false;
- const bool registered = config_.register_title && config_.register_title(config_.successor_root);
- Log(std::string("opening ") + config_.successor_title_id + (registered ? ", registration requested" : ", registration not answered"));
- return true;
- }
if (Snapshot().rollback_requested) return RollBackAtQuit();
if (!Snapshot().restart_requested || staged_folder_.empty()) return false;
- if (Moving()) return MoveAtQuit();
const std::string stamp = std::to_string(config_.now());
const std::string backup = config_.work_root + "/backup/" + config_.current.ToString() + "-" + stamp;
const std::string installed_kit = staged_kit_id_.empty() ? std::string() : config_.kits_root + "/" + staged_kit_id_;
@@ -1373,14 +1167,27 @@ bool UpdateService::ApplyAtQuit() {
if (name.compare(0, 10, ".previous-") == 0) RemoveTree(config_.kits_root + "/" + name);
// One transaction: the kit first, then the app; a failed app swap puts the kit back.
if (!staged_kit_.empty()) {
- if (!SwapKitIn(installed_kit, previous_kit, &swap.error)) return false;
+ if (!Exists(staged_kit_)) {
+ swap.error = "staged kit is missing";
+ return false;
+ }
+ if (Exists(installed_kit) && rename(installed_kit.c_str(), previous_kit.c_str()) != 0) {
+ swap.error = "cannot move the installed kit aside";
+ return false;
+ }
+ if (rename(staged_kit_.c_str(), installed_kit.c_str()) != 0) {
+ rename(previous_kit.c_str(), installed_kit.c_str());
+ swap.error = "cannot move the new kit in";
+ return false;
+ }
kit_swapped = true;
}
MakeFolders(config_.work_root + "/backup");
swap = SwapApp(config_.installed_root, staged_folder_, backup, log);
if (!swap.ok) {
if (kit_swapped) {
- SwapKitBack(installed_kit, previous_kit);
+ rename(installed_kit.c_str(), staged_kit_.c_str());
+ if (Exists(previous_kit)) rename(previous_kit.c_str(), installed_kit.c_str());
kit_swapped = false;
}
return false;
@@ -1402,88 +1209,4 @@ bool UpdateService::ApplyAtQuit() {
return true;
}
-bool UpdateService::SwapKitIn(const std::string& installed_kit, const std::string& previous_kit, std::string* error) {
- if (!Exists(staged_kit_)) {
- *error = "staged kit is missing";
- return false;
- }
- if (Exists(installed_kit) && rename(installed_kit.c_str(), previous_kit.c_str()) != 0) {
- *error = "cannot move the installed kit aside";
- return false;
- }
- if (rename(staged_kit_.c_str(), installed_kit.c_str()) != 0) {
- rename(previous_kit.c_str(), installed_kit.c_str());
- *error = "cannot move the new kit in";
- return false;
- }
- return true;
-}
-
-void UpdateService::SwapKitBack(const std::string& installed_kit, const std::string& previous_kit) {
- rename(installed_kit.c_str(), staged_kit_.c_str());
- if (Exists(previous_kit)) rename(previous_kit.c_str(), installed_kit.c_str());
-}
-
-// A release under the successor title goes into its own folder: this app stays as it is (it runs until
-// the process exits, and is the way back if the new title does not open). ShadowMountPlus defers its
-// scan while a title runs and registers the new title once this one has closed.
-bool UpdateService::MoveAtQuit() {
- const std::string stamp = std::to_string(config_.now());
- const std::string installed_kit = staged_kit_id_.empty() ? std::string() : config_.kits_root + "/" + staged_kit_id_;
- const std::string previous_kit = config_.kits_root + "/.previous-" + staged_kit_id_ + "-" + stamp;
- // A folder already at the successor's place (an earlier try, or a copy installed by hand) is moved aside.
- const std::string aside = config_.work_root + "/replaced/" + staged_title_ + "-" + stamp;
- const auto applied = [&](bool kit_moved) {
- return ",\"version\":" + Quote(staged_version_.ToString()) + ",\"from\":" + Quote(config_.current.ToString()) +
- ",\"moved_to\":" + Quote(staged_title_) + ",\"notes\":" + Quote(Snapshot().notes) + ",\"notes_url\":" +
- Quote(Snapshot().notes_url) + ",\"kit_id\":" + Quote(staged_kit_id_) + ",\"previous_kit\":" +
- Quote(kit_moved ? previous_kit : std::string()) + ",\"next_kit\":" +
- Quote(kit_moved ? staged_kit_ : std::string());
- };
- if (!SaveState("applied", applied(!staged_kit_.empty()))) {
- Log("move failed: cannot save the state");
- return false;
- }
- std::string error;
- bool kit_swapped = false;
- const bool moved = config_.as_root([&] {
- // As for a swap: one previous version and kit are kept. The backups are of this title's app, which
- // the new title must never restore into its own folder, so none is left.
- for (const auto& name : ListFolder(config_.work_root + "/backup")) RemoveTree(config_.work_root + "/backup/" + name);
- for (const auto& name : ListFolder(config_.kits_root))
- if (name.compare(0, 10, ".previous-") == 0) RemoveTree(config_.kits_root + "/" + name);
- if (!staged_kit_.empty()) {
- if (!SwapKitIn(installed_kit, previous_kit, &error)) return false;
- kit_swapped = true;
- }
- const bool occupied = Exists(config_.successor_root);
- if (occupied && (!MakeFolders(config_.work_root + "/replaced") ||
- rename(config_.successor_root.c_str(), aside.c_str()) != 0)) {
- error = "cannot move " + config_.successor_root + " aside";
- } else if (rename(staged_folder_.c_str(), config_.successor_root.c_str()) != 0) {
- error = "cannot move the new app to " + config_.successor_root;
- if (occupied) rename(aside.c_str(), config_.successor_root.c_str());
- } else {
- // Like an app folder deployed by hand: Playden writes in it as the app's user.
- chmod(config_.successor_root.c_str(), 0777);
- return true;
- }
- if (kit_swapped) {
- SwapKitBack(installed_kit, previous_kit);
- kit_swapped = false;
- }
- return false;
- });
- if (!moved) {
- Log("move failed: " + error);
- SaveState("staged", StagedFields()); // still staged: the next quit tries again
- return false;
- }
- SaveState("applied", applied(kit_swapped && Exists(previous_kit)));
- const bool registered = config_.register_title && config_.register_title(config_.successor_root);
- Log("moved to " + staged_title_ + " " + staged_version_.ToString() + " at " + config_.successor_root +
- (kit_swapped ? " with a new kit" : "") + (registered ? ", registration requested" : ", registration not answered"));
- return true;
-}
-
} // namespace playden::update
diff --git a/src/update/update_service.h b/src/update/update_service.h
index 76e60a9..fea2ab0 100644
--- a/src/update/update_service.h
+++ b/src/update/update_service.h
@@ -32,19 +32,6 @@ struct UpdateConfig {
// Ids the kit had before (runtime::kKitIdRenames): a Playden that used one leaves its kit at
// <kits_root>/<that id> when it updates to this one, and Start retires it as a previous kit.
std::vector<std::string> renamed_kit_ids;
- // The title Playden moves to when a release's update information names it instead of title_id
- // (FAKE77031 -> PPSA97031, the ID ProsperoStore can install). The update goes into
- // successor_root, the running app stays, and register_title asks ShadowMountPlus to add it.
- // Empty: the update information must name title_id.
- std::string successor_title_id;
- std::string successor_root; // /data/homebrew/PPSA97031
- std::function<bool(const std::string& folder)> register_title;
- // The title this one replaced (PPSA97031 builds: FAKE77031). Start moves its app folder out of
- // /data/homebrew once it holds no player data, and unregister_title removes its tile: true once the
- // console no longer lists it. The folder is deleted at the next start. Empty: nothing replaced.
- std::string predecessor_title_id;
- std::string predecessor_root; // /data/homebrew/FAKE77031
- std::function<bool(const std::string& title)> unregister_title;
std::string appmeta_root; // /user/appmeta/FAKE77031
std::string registered_app_root; // /user/app/FAKE77031
// The 0.6 layout move's record (/data/playden/runtime-state/layout-0.6.json). While it exists,
@@ -122,16 +109,12 @@ struct UpdateSnapshot {
std::uint64_t total = 0;
std::uint64_t download_bytes = 0; // what Install will download
bool kit_needed = false;
- bool moves = false; // the available release installs Playden as the successor title
std::string error; // for kFailed: one short sentence
bool user_check = false; // the last check was asked for in Settings
bool restart_requested = false;
// The version kept from the last update, which "go back" restores; empty when there is none.
std::string previous;
bool rollback_requested = false;
- // This title moved to the successor, which has not started yet: the version it moved to.
- std::string moved_to;
- bool open_successor_requested = false;
// The available version is one the player went back from: Settings lists it, no dialog offers it.
bool quiet = false;
// One-shot result of the previous run's update ("Playden was updated to 0.3.0."), shown once.
@@ -165,11 +148,6 @@ class UpdateService {
void InstallKit();
// Marks a staged update to be applied when Playden quits.
void RequestRestart();
- // The successor is installed: when Playden quits, it is registered again and opened instead.
- void RequestOpenSuccessor();
- // The title to open after quitting: the successor while a move to it is staged (or it was asked
- // for), else title_id.
- std::string RelaunchTitle() const;
// Marks the previous version (and its kit) to be put back when Playden quits.
void RequestRollback();
UpdateSnapshot Snapshot() const;
@@ -181,8 +159,7 @@ class UpdateService {
// Stops the worker (cancels a download; the bytes are kept for next time).
void Shutdown();
// Last step before the process exits, with every other service stopped: swaps the app folder
- // when a staged update was requested. Returns true when the new version is in place (or, with
- // the successor asked for, once its registration is requested).
+ // when a staged update was requested. Returns true when the new version is in place.
bool ApplyAtQuit();
// The newest app backup (".../backup/<version>-<time>") and its version, when it is complete.
struct Backup {
@@ -198,20 +175,6 @@ class UpdateService {
void DoInstall();
void ConfirmApplied(const std::string& state);
bool RollBackAtQuit();
- bool MoveAtQuit();
- // Puts the staged kit in place, the installed one going to previous_kit; as root. SwapKitBack undoes it.
- bool SwapKitIn(const std::string& installed_kit, const std::string& previous_kit, std::string* error);
- void SwapKitBack(const std::string& installed_kit, const std::string& previous_kit);
- // Whether a staged update moves Playden to the successor title.
- bool Moving() const;
- // Start without the background work it leaves for the worker.
- void StartState();
- // Removes the predecessor title: its folder leaves /data/homebrew now, its tile in the background
- // (UnregisterPredecessor, queued by Start).
- void RetirePredecessor();
- void UnregisterPredecessor();
- // Why the predecessor's folder must stay (it may hold player data), or empty.
- std::string PredecessorRefusal() const;
// Why going back to `to` is refused (it can't read the 0.6 data layout), or empty.
std::string LayoutRefusal(const Version& to) const;
void FindPrevious();
@@ -250,11 +213,7 @@ class UpdateService {
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).
- // The successor title is installed: this title no longer updates or installs kits.
- bool superseded_ = false;
- bool unregister_pending_ = false;
std::string staged_folder_;
- std::string staged_title_;
Version staged_version_;
std::string staged_kit_;
std::string staged_kit_id_;
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index ec8ea9c..88306a5 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -1006,71 +1006,6 @@ void live_self_update(const std::filesystem::path& base) {
"update: Download and install still has the focus");
}
- // The old title after the move to the new one, which hasn't started yet: a dialog says where Playden
- // went, and its button quits to open the new title (registered again at quit). It shows once.
- {
- auto old_title = make_live(base);
- old_title.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
- check(old_title.UpdateLibrary({{}, false, {}, false, true, 100}), "moved: library delivered");
- LiveSelfUpdate moved;
- moved.current = "0.7.1";
- moved.moved_to = "0.8.0";
- old_title.UpdateSelfUpdate(moved);
- check(!old_title.state().navigation.modals.empty() &&
- old_title.state().navigation.modals.back().title == "Playden 0.8.0 is a new app" &&
- old_title.state().navigation.modals.back().body.find("restart the PS5") != std::string::npos,
- "moved: the old title says where Playden went");
- playden::GameSummary game;
- game.id = SteamId(220);
- game.title = "Half-Life 2";
- check(old_title.UpdateLibrary({{game}, false, {}, false, true, 100}) &&
- !old_title.state().navigation.modals.empty(),
- "moved: the games arriving leave the dialog open");
- check(old_title.action("cross") && old_title.state().quit_requested &&
- old_title.TakeSelfUpdateRequests() == std::vector<std::string>{"open-successor"},
- "moved: Open the new Playden quits to open it");
- auto later = make_live(base);
- later.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
- check(later.UpdateLibrary({{}, false, {}, false, true, 100}), "moved: library delivered again");
- later.UpdateSelfUpdate(moved);
- check(later.action("right") && later.action("cross") && later.state().navigation.modals.empty() &&
- !later.state().quit_requested && later.TakeSelfUpdateRequests().empty(),
- "moved: Later keeps this Playden open");
- later.UpdateSelfUpdate(moved);
- check(later.state().navigation.modals.empty(), "moved: the dialog shows once");
- }
-
- // The bridge (0.8.0 as the old title) offers the same version as a new app; a newer move says so too.
- {
- auto bridge = make_live(base);
- bridge.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
- check(bridge.UpdateLibrary({{}, false, {}, false, true, 100}), "bridge: library delivered");
- LiveSelfUpdate move;
- move.current = "0.8.0";
- move.phase = "available";
- move.available = "0.8.0";
- move.moves = true;
- move.notes = "Notes already seen.";
- bridge.UpdateSelfUpdate(move);
- check(!bridge.state().navigation.modals.empty() &&
- bridge.state().navigation.modals.back().title == "Move Playden to its new app" &&
- bridge.state().navigation.modals.back().body.find("new app next to this one") != std::string::npos &&
- bridge.state().navigation.modals.back().body.find("Notes already seen.") == std::string::npos,
- "bridge: the same version is offered as a move");
- check(bridge.action("cross") && bridge.TakeSelfUpdateRequests() == std::vector<std::string>{"install"},
- "bridge: the move downloads like an update");
- auto newer = make_live(base);
- newer.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
- check(newer.UpdateLibrary({{}, false, {}, false, true, 100}), "bridge: library delivered again");
- move.current = "0.7.1";
- newer.UpdateSelfUpdate(move);
- check(!newer.state().navigation.modals.empty() &&
- newer.state().navigation.modals.back().title == "Playden 0.8.0 is available" &&
- newer.state().navigation.modals.back().body.find("Notes already seen.") != std::string::npos &&
- newer.state().navigation.modals.back().body.find("new app next to this one") != std::string::npos,
- "bridge: a newer move keeps its notes and says it is a new app");
- }
-
// A failed install says why; the previous run's result shows once.
auto failing = make_live(base);
failing.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cpp
index ada4358..13fd569 100644
--- a/tests/self_update_service_test.cpp
+++ b/tests/self_update_service_test.cpp
@@ -86,16 +86,15 @@ struct Server {
}
};
-std::string AppZip(const std::string& version_text, const std::string& content_version, const std::string& full_version = "",
- const std::string& title = "FAKE77031") {
+std::string AppZip(const std::string& version_text, const std::string& content_version, const std::string& full_version = "") {
const std::string top = "playden-ps5-" + version_text + "/";
return zip_fixture::Build({{top + "tools/console_title_deploy.py", "py"},
- {top + title + "/eboot.bin", "eboot " + version_text},
- {top + title + "/playden-version", full_version.empty() ? version_text + "\n" : full_version},
- {top + title + "/sce_sys/param.json",
- R"({"titleId":")" + title + R"(","contentVersion":")" + content_version + R"("})"},
- {top + title + "/assets/a.txt", "asset " + version_text},
- {top + title + "/logs/", "", 040755}});
+ {top + "FAKE77031/eboot.bin", "eboot " + version_text},
+ {top + "FAKE77031/playden-version", full_version.empty() ? version_text + "\n" : full_version},
+ {top + "FAKE77031/sce_sys/param.json",
+ R"({"titleId":"FAKE77031","contentVersion":")" + content_version + R"("})"},
+ {top + "FAKE77031/assets/a.txt", "asset " + version_text},
+ {top + "FAKE77031/logs/", "", 040755}});
}
std::string KitZip() {
@@ -106,15 +105,14 @@ std::string KitZip() {
void Publish(Server& server, const std::string& tag, const std::string& min_from = "0.2.0",
const std::string& content_version = "00.003.000", bool with_kit = true, bool with_digests = true,
- const std::string& kit_revision = "r9", const std::string& full_version = "",
- const std::string& title = "FAKE77031") {
+ const std::string& kit_revision = "r9", const std::string& full_version = "") {
const std::string version_text = tag.substr(1);
- const std::string app = AppZip(version_text, content_version, full_version, title);
+ const std::string app = AppZip(version_text, content_version, full_version);
const std::string kit = KitZip();
const std::string manifest =
- R"({"format":1,"app":{"version":")" + version_text + R"(","title_id":")" + title + R"(","min_from":")" + min_from +
- R"(","asset":"playden-ps5-)" + version_text + R"(.zip","prefix":"playden-ps5-)" + version_text + "/" + title +
- R"(/"},"kit":{"kit_id":"kitid","revision":")" + kit_revision + R"(","manifest_sha256":")" + kKitSha +
+ R"({"format":1,"app":{"version":")" + version_text + R"(","title_id":"FAKE77031","min_from":")" + min_from +
+ R"(","asset":"playden-ps5-)" + version_text + R"(.zip","prefix":"playden-ps5-)" + version_text +
+ R"(/FAKE77031/"},"kit":{"kit_id":"kitid","revision":")" + kit_revision + R"(","manifest_sha256":")" + kKitSha +
R"(","asset":"playden-kit-h-r9.zip","prefix":"playden-kit-h-r9/kitid/"},"notes":"New things."})";
server.files[kDownload + "playden-update.json"] = manifest;
server.files[kDownload + "playden-ps5-" + version_text + ".zip"] = app;
@@ -1001,365 +999,6 @@ int main() {
CHECK(offered.Snapshot().rollback_requested);
RemoveTree(fixture.root);
}
- // A release under the successor title installs next to this one: the running app stays, the new
- // title is registered, the old title points the player to it, and the new title confirms the update.
- {
- Fixture fixture;
- fixture.root = zip_fixture::TempFolder("service-move");
- Installed(fixture.root);
- const std::string old_app = fixture.root + "/homebrew/FAKE77031";
- const std::string new_app = fixture.root + "/homebrew/PPSA97031";
- const std::string state = fixture.root + "/playden/self-update/state.json";
- Put(fixture.root + "/playden/self-update/backup/0.7.0-900/eboot.bin", "eboot 0.7.0");
- Publish(fixture.server, "v0.8.0", "0.7.0", "00.008.000", true, true, "r9", "", "PPSA97031");
- std::vector<std::string> registered;
- std::mutex registered_mutex;
- const auto moving = [&](Version current) {
- auto config = fixture.Config(current);
- config.successor_title_id = "PPSA97031";
- config.successor_root = new_app;
- config.register_title = [&](const std::string& folder) {
- std::lock_guard<std::mutex> lock(registered_mutex);
- registered.push_back(folder);
- return true;
- };
- return config;
- };
- // Without a successor (or for another title) the release is refused, as before.
- {
- UpdateService plain(fixture.Config({0, 7, 1}));
- plain.Check(true); Wait(plain);
- CHECK(plain.Snapshot().phase == UpdatePhase::kFailed);
- auto other = moving({0, 7, 1});
- other.successor_title_id = "PPSA12345";
- UpdateService refused(other);
- refused.Check(true); Wait(refused);
- CHECK(refused.Snapshot().phase == UpdatePhase::kFailed);
- }
- {
- UpdateService service(moving({0, 7, 1}));
- service.Start();
- service.Install(); Wait(service);
- CHECK(service.Snapshot().phase == UpdatePhase::kStaged);
- CHECK(Read(state).find("\"title\":\"PPSA97031\"") != std::string::npos);
- CHECK(service.RelaunchTitle() == "FAKE77031"); // nothing asked yet
- service.RequestRestart();
- CHECK(service.RelaunchTitle() == "PPSA97031");
- service.Shutdown();
- // A start in between keeps the staged move.
- UpdateService restarted(moving({0, 7, 1}));
- restarted.Start();
- CHECK(restarted.Snapshot().phase == UpdatePhase::kStaged);
- restarted.RequestRestart();
- CHECK(restarted.RelaunchTitle() == "PPSA97031");
- restarted.Shutdown();
- // A folder that appeared at the new title's place since the start is moved aside, not merged.
- Put(new_app + "/eboot.bin", "eboot by hand");
- CHECK(restarted.ApplyAtQuit());
- }
- CHECK(Read(new_app + "/eboot.bin") == "eboot 0.8.0" && Read(new_app + "/assets/a.txt") == "asset 0.8.0");
- CHECK(Read(old_app + "/eboot.bin") == "eboot 0.2.0" && Read(old_app + "/playden-data/session") == "session");
- CHECK(Read(fixture.root + "/playden/self-update/replaced/PPSA97031-1000/eboot.bin") == "eboot by hand");
- CHECK(registered.size() == 1 && registered[0] == new_app);
- CHECK(Read(fixture.root + "/playden/kits/kitid/manifest.json") == kKitSha);
- // No backup is left: the new title must never put the old title's app into its own folder.
- CHECK(ListFolder(fixture.root + "/playden/self-update/backup").empty());
- CHECK(Read(state).find("\"moved_to\":\"PPSA97031\"") != std::string::npos);
- // The old title is opened instead: it says where the update went, keeps the state and asks again.
- {
- UpdateService old(moving({0, 7, 1}));
- old.Start();
- Wait(old);
- CHECK(old.Snapshot().moved_to == "0.8.0" && old.Snapshot().finished_message.empty());
- CHECK(!old.Snapshot().finished_failed && Exists(state) && registered.size() == 2);
- CHECK(Read(fixture.root + "/playden/kits/kitid/manifest.json") == kKitSha); // the new kit stays
- // It no longer updates or installs kits: the moved release is not offered again.
- const auto before = Read(state);
- const int requests = fixture.server.requests;
- old.Check(true);
- old.Install();
- old.CheckKit();
- Wait(old);
- CHECK(old.Snapshot().phase == UpdatePhase::kIdle && fixture.server.requests == requests && Read(state) == before);
- CHECK(!old.ApplyAtQuit() && old.RelaunchTitle() == "FAKE77031");
- // Asked from its dialog: the new title is registered again at quit and opened instead.
- old.RequestOpenSuccessor();
- CHECK(old.RelaunchTitle() == "PPSA97031");
- old.Shutdown();
- CHECK(old.ApplyAtQuit() && registered.size() == 3 && Read(state) == before);
- }
- // The new title ignores the old title's other states (only the move is addressed to it).
- {
- const auto move = Read(state);
- Put(state, R"({"phase":"staged","owner":"FAKE77031","version":"0.9.0","stage":"/nowhere","title":"FAKE77031"})");
- auto config = fixture.Config({0, 8, 0});
- config.title_id = "PPSA97031";
- config.installed_root = new_app;
- UpdateService other(config);
- other.Start();
- CHECK(other.Snapshot().phase == UpdatePhase::kIdle && Exists(state));
- Put(state, move);
- }
- // The new title starts: the update is confirmed there, with nothing to go back to.
- {
- auto config = fixture.Config({0, 8, 0});
- config.title_id = "PPSA97031";
- config.installed_root = new_app;
- config.appmeta_root = fixture.root + "/user/appmeta/PPSA97031";
- config.registered_app_root = fixture.root + "/user/app/PPSA97031";
- UpdateService next(config);
- next.Start();
- CHECK(next.Snapshot().finished_message == "Playden was updated to 0.8.0." && next.Snapshot().whats_new);
- CHECK(!Exists(state) && next.Snapshot().previous.empty());
- Wait(next);
- }
- // Later the new title updates itself and its state is "applied" when the old title opens: the old
- // title leaves it (and the new title's backup) alone, and only points to the new app.
- {
- const std::string applied = R"({"phase":"applied","owner":"PPSA97031","version":"0.8.1","from":"0.8.0","backup":")" +
- fixture.root + R"(/playden/self-update/backup/0.8.0-2000","stage":")" + fixture.root +
- R"(/playden/self-update/stage/0.8.1","kit_id":"kitid","previous_kit":"","next_kit":""})";
- Put(state, applied);
- Put(fixture.root + "/playden/self-update/backup/0.8.0-2000/eboot.bin", "eboot 0.8.0");
- UpdateService old(moving({0, 7, 1}));
- old.Start();
- Wait(old);
- CHECK(Read(state) == applied && Read(old_app + "/eboot.bin") == "eboot 0.2.0" && Read(new_app + "/eboot.bin") == "eboot 0.8.0");
- CHECK(old.Snapshot().finished_message == "Open the new Playden from Home." && old.Snapshot().moved_to.empty());
- CHECK(old.Snapshot().previous.empty() && registered.size() == 3);
- }
- RemoveTree(fixture.root);
- }
- // From 0.8.0 a release carries two manifests: playden-update.json names a FAKE77031 build (the one 0.7.1-beta.2 and
- // older read), playden-update-v2.json the PPSA97031 app. Newer builds read v2: a FAKE77031 build moves to the
- // successor from an older version or from that same version (the bridge), and the successor finds itself up to date.
- {
- Fixture fixture;
- fixture.root = zip_fixture::TempFolder("service-bridge");
- Installed(fixture.root);
- const std::string new_app = fixture.root + "/homebrew/PPSA97031";
- Publish(fixture.server, "v0.8.0", "0.7.0", "00.008.000", true, true, "r9", "", "PPSA97031");
- const std::string successor_manifest = fixture.server.files[kDownload + "playden-update.json"];
- const std::string bridge_app = AppZip("0.8.0", "00.008.000", "", "FAKE77031");
- std::string bridge_manifest = successor_manifest;
- for (std::size_t at; (at = bridge_manifest.find("PPSA97031")) != std::string::npos;)
- bridge_manifest.replace(at, 9, "FAKE77031");
- bridge_manifest.replace(bridge_manifest.find("playden-ps5-0.8.0.zip"), 21, "playden-ps5-0.8.0-FAKE77031.zip");
- const auto asset = [&](const std::string& name, const std::string& body) {
- return R"({"name":")" + name + R"(","size":)" + std::to_string(body.size()) + R"(,"digest":"sha256:)" +
- FakeSha(body) + R"(","browser_download_url":")" + kDownload + name + R"("})";
- };
- const auto publish = [&](bool with_v2) {
- fixture.server.files[kDownload + "playden-update.json"] = bridge_manifest;
- fixture.server.files[kDownload + "playden-update-v2.json"] = successor_manifest;
- fixture.server.files[kDownload + "playden-ps5-0.8.0-FAKE77031.zip"] = bridge_app;
- const auto& files = fixture.server.files;
- fixture.server.latest =
- R"({"tag_name":"v0.8.0","draft":false,"prerelease":false,"assets":[)" +
- asset("playden-update.json", bridge_manifest) + "," +
- (with_v2 ? asset("playden-update-v2.json", successor_manifest) + "," : std::string()) +
- asset("playden-ps5-0.8.0.zip", files.at(kDownload + "playden-ps5-0.8.0.zip")) + "," +
- asset("playden-ps5-0.8.0-FAKE77031.zip", bridge_app) + "," +
- asset("playden-kit-h-r9.zip", files.at(kDownload + "playden-kit-h-r9.zip")) + "]}";
- };
- const auto fake = [&](Version current) {
- auto config = fixture.Config(current);
- config.successor_title_id = "PPSA97031";
- config.successor_root = new_app;
- config.register_title = [](const std::string&) { return true; };
- return config;
- };
- publish(true);
- // 0.7.1 moves to 0.8.0 directly.
- {
- UpdateService service(fake({0, 7, 1}));
- service.Check(true); Wait(service);
- CHECK(service.Snapshot().phase == UpdatePhase::kAvailable && service.Snapshot().moves);
- CHECK(service.Snapshot().available == (Version{0, 8, 0}));
- }
- // The bridge, 0.8.0 as FAKE77031: the same version as the successor is still a move, and it takes place.
- {
- UpdateService bridge(fake({0, 8, 0}));
- bridge.Check(true); Wait(bridge);
- CHECK(bridge.Snapshot().phase == UpdatePhase::kAvailable && bridge.Snapshot().moves);
- bridge.Install(); Wait(bridge);
- CHECK(bridge.Snapshot().phase == UpdatePhase::kStaged);
- bridge.RequestRestart();
- CHECK(bridge.RelaunchTitle() == "PPSA97031");
- bridge.Shutdown();
- CHECK(bridge.ApplyAtQuit());
- CHECK(Read(new_app + "/eboot.bin") == "eboot 0.8.0");
- CHECK(Read(fixture.root + "/homebrew/FAKE77031/eboot.bin") == "eboot 0.2.0");
- }
- // The successor reads v2 too: its own version, up to date.
- {
- auto config = fixture.Config({0, 8, 0});
- config.title_id = "PPSA97031";
- config.installed_root = new_app;
- UpdateService successor(config);
- successor.Check(true); Wait(successor);
- CHECK(successor.Snapshot().phase == UpdatePhase::kUpToDate);
- }
- RemoveTree(new_app);
- RemoveTree(fixture.root + "/playden/self-update");
- // A release without v2 (0.7.x): a FAKE77031 build at that version is up to date, and an older one updates in place.
- publish(false);
- {
- UpdateService current(fake({0, 8, 0}));
- current.Check(true); Wait(current);
- CHECK(current.Snapshot().phase == UpdatePhase::kUpToDate);
- UpdateService older(fake({0, 7, 1}));
- older.Check(true); Wait(older);
- CHECK(older.Snapshot().phase == UpdatePhase::kAvailable && !older.Snapshot().moves);
- }
- RemoveTree(fixture.root);
- }
- // The new title removes the old one: its folder leaves /data/homebrew at the start, its tile in the
- // background (retried at the next start), and its files at the start after that.
- {
- Fixture fixture;
- fixture.root = zip_fixture::TempFolder("service-retire");
- const std::string old_app = fixture.root + "/homebrew/FAKE77031";
- const std::string retired = fixture.root + "/playden/self-update/retired/FAKE77031";
- const std::string state = fixture.root + "/playden/self-update/state.json";
- const std::string stage = fixture.root + "/playden/self-update/stage/0.7.2";
- const auto old_title = [&](const std::string& version) {
- Put(old_app + "/eboot.bin", "eboot old");
- Put(old_app + "/playden-version", version + "\n");
- Put(old_app + "/games-MOVED.txt", "moved");
- CHECK(MakeFolders(old_app + "/playden-data") && MakeFolders(old_app + "/logs"));
- };
- old_title("0.7.1");
- // Right after the move it stays one more start (the move is confirmed at this start).
- {
- const std::string moved = R"({"phase":"applied","owner":"FAKE77031","version":"0.8.1","from":"0.7.1","moved_to":"PPSA97031","kit_id":"kitid","previous_kit":"","next_kit":""})";
- Put(state, moved);
- auto first = fixture.Config({0, 8, 1});
- first.title_id = "PPSA97031";
- first.installed_root = fixture.root + "/homebrew/PPSA97031";
- first.predecessor_title_id = "FAKE77031";
- first.predecessor_root = old_app;
- first.unregister_title = [](const std::string&) { CHECK(false); return false; };
- first.as_root = [](const std::function<bool()>& work) { return work(); };
- UpdateService service(first);
- service.Start();
- Wait(service);
- CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired));
- CHECK(service.Snapshot().finished_message == "Playden was updated to 0.8.1." && !Exists(state));
- }
- Put(fixture.root + "/playden/self-update/backup/0.7.0-900/eboot.bin", "eboot 0.7.0");
- Put(fixture.root + "/playden/self-update/backup/0.7.0-900/sce_sys/param.json", R"({"titleId":"FAKE77031"})");
- Put(fixture.root + "/playden/self-update/backup/0.8.0-950/eboot.bin", "eboot 0.8.0");
- Put(fixture.root + "/playden/self-update/backup/0.8.0-950/sce_sys/param.json", R"({"titleId":"PPSA97031"})");
- // An update the old title staged, before states named their owner.
- Put(stage + "/eboot.bin", "eboot 0.7.2");
- Put(state, R"({"phase":"staged","version":"0.7.2","stage":")" + stage + R"("})");
- std::vector<std::string> unregistered;
- std::mutex unregistered_mutex;
- bool answer = false;
- const auto config = [&] {
- auto config = fixture.Config({0, 8, 1});
- config.title_id = "PPSA97031";
- config.installed_root = fixture.root + "/homebrew/PPSA97031";
- config.predecessor_title_id = "FAKE77031";
- config.predecessor_root = old_app;
- config.unregister_title = [&](const std::string& title) {
- std::lock_guard<std::mutex> lock(unregistered_mutex);
- unregistered.push_back(title);
- return answer;
- };
- config.as_root = [](const std::function<bool()>& work) { return work(); };
- return config;
- };
- {
- UpdateService service(config());
- service.Start();
- // Moved at once; the old app's backup and staged update go, this title's backup stays.
- CHECK(!Exists(old_app) && Read(retired + "/eboot.bin") == "eboot old");
- CHECK(!Exists(state) && !Exists(stage));
- CHECK(!Exists(fixture.root + "/playden/self-update/backup/0.7.0-900"));
- CHECK(service.Snapshot().previous == "0.8.0");
- Wait(service);
- CHECK(unregistered.size() == 1 && unregistered[0] == "FAKE77031" && Exists(retired));
- }
- answer = true;
- {
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(unregistered.size() == 2 && !Exists(retired) && !Exists(retired + ".unregistered"));
- }
- {
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(unregistered.size() == 2); // nothing left to do
- }
- // An old title that still holds player data, or keeps it in its folder, stays as it is.
- old_title("0.7.1");
- Put(old_app + "/playden-data/session.v1", "session");
- {
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
- }
- RemoveTree(old_app + "/playden-data/session.v1");
- // Games left in its folder, or a data folder that can't be read, keep it too.
- Put(old_app + "/games/220/game.exe", "game");
- {
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
- }
- RemoveTree(old_app + "/games");
- Put(old_app + "/games", "not a folder");
- {
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
- }
- RemoveTree(old_app + "/games");
- old_title("0.5.0");
- {
- // Its state names no owner and is not this title's: an applied update of the old title is left alone.
- const std::string applied = R"({"phase":"applied","version":"0.5.1","from":"0.5.0","backup":")" + fixture.root +
- R"(/playden/self-update/backup/0.5.0-800","stage":")" + stage + R"("})";
- Put(state, applied);
- Put(fixture.root + "/playden/self-update/backup/0.5.0-800/eboot.bin", "eboot 0.5.0");
- UpdateService service(config());
- service.Start();
- Wait(service);
- CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
- CHECK(Read(state) == applied && !Exists(fixture.root + "/homebrew/PPSA97031/eboot.bin"));
- CHECK(service.Snapshot().finished_message.empty());
- }
- RemoveTree(fixture.root);
- }
- // A staged move that this build can't make (no successor) is dropped.
- {
- Fixture fixture;
- fixture.root = zip_fixture::TempFolder("service-move-unknown");
- Installed(fixture.root);
- Publish(fixture.server, "v0.8.0", "0.7.0", "00.008.000", true, true, "r9", "", "PPSA97031");
- auto config = fixture.Config({0, 7, 1});
- config.successor_title_id = "PPSA97031";
- config.successor_root = fixture.root + "/homebrew/PPSA97031";
- {
- UpdateService service(config);
- service.Install(); Wait(service);
- CHECK(service.Snapshot().phase == UpdatePhase::kStaged);
- service.Shutdown();
- }
- UpdateService plain(fixture.Config({0, 7, 1}));
- plain.Start();
- CHECK(plain.Snapshot().phase == UpdatePhase::kIdle);
- CHECK(!Exists(fixture.root + "/playden/self-update/state.json"));
- CHECK(!Exists(fixture.root + "/playden/self-update/stage/0.8.0"));
- RemoveTree(fixture.root);
- }
// GitHub out of reach.
{
Fixture fixture;
diff --git a/tools/console_title_deploy.py b/tools/console_title_deploy.py
index 072b866..b069a0d 100644
--- a/tools/console_title_deploy.py
+++ b/tools/console_title_deploy.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-"""Deploy or restore the Playden package files (FAKE77031 unless --title says otherwise) over FTP.
+"""Deploy or restore the Playden FAKE77031 package files over FTP.
deploy: compares every packaged file with the console, backs up each differing
console file locally (bytes, mode, SHA-256), then replaces it through a staged
@@ -17,7 +17,6 @@ import hashlib
import io
import json
import os
-import re
from pathlib import Path, PurePosixPath
import sys
@@ -106,22 +105,14 @@ def main():
parser.add_argument("--host", default=os.environ.get("PLAYDEN_PS5_HOST"),
help="the PS5's IP address (or set PLAYDEN_PS5_HOST)")
parser.add_argument("--port", type=int, default=2120)
- parser.add_argument("--title", default="FAKE77031", help="Playden's title ID (default FAKE77031)")
args = parser.parse_args()
if not args.host:
parser.error("give the PS5's address with --host or PLAYDEN_PS5_HOST")
- if not re.fullmatch(r"(?:FAKE|PPSA)[0-9]{5}", args.title):
- parser.error("--title must be FAKE or PPSA and five digits")
- global TITLE
- TITLE = "/data/homebrew/" + args.title
ftp = ftplib.FTP()
ftp.connect(args.host, args.port, timeout=60)
ftp.login()
if args.command == "restore":
record = json.loads((args.backup / "backup.json").read_text())
- if record["title"] != TITLE:
- print(f"refusing: the backup is of {record['title']}, not {TITLE}", file=sys.stderr)
- return 1
for path, entry in record["files"].items():
remote = f"{TITLE}/{path}"
if entry["sha256"] is None:
diff --git a/tools/self-update-relaunch/main.c b/tools/self-update-relaunch/main.c
index 77ac69d..96e8f12 100644
--- a/tools/self-update-relaunch/main.c
+++ b/tools/self-update-relaunch/main.c
@@ -3,18 +3,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
// A title cannot start itself after it exits. Just before Playden quits to finish an update it
-// sends this payload to the payload loader on 127.0.0.1:9021. The payload reads the title to open
-// from REQUEST's first line ("FAKE77031\n"), and the quitting title from its second line (the same
-// title when there is none), waits until the quitting title's sandbox (/mnt/sandbox/<id>_*) is
-// gone, and starts the title with sceLncUtilLaunchApp, falling back to sceSystemServiceLaunchApp.
-// It gives up after 120 s. If the start fails, a notification asks the player to open Playden.
+// sends this payload to the payload loader on 127.0.0.1:9021. The payload reads the title id
+// from REQUEST ("FAKE77031\n"), waits until that title's sandbox (/mnt/sandbox/<id>_*) is gone,
+// and starts it again with sceLncUtilLaunchApp, falling back to sceSystemServiceLaunchApp. It
+// gives up after 120 s. If the start fails, a notification asks the player to open Playden.
// Measured in results/20261015-self-update-probes: the sandbox goes about 5 s after the quit.
-//
-// When Playden moves to another title ("PPSA97031\nFAKE77031\n"), ShadowMountPlus registers the
-// new title only once the old one has closed (results/20261025-ppsa97031-probe: about 1 s later),
-// so the payload waits up to 60 s for its /user/app/<id>/mount.lnk. If the new title can't be
-// started, it opens the old one, which tells the player where the update went. Playden rewrites
-// REQUEST when the move fails at quit, so the first line is read again once the old title is gone.
#include <dirent.h>
#include <stdint.h>
#include <stdio.h>
@@ -85,82 +78,42 @@ static void notify(const char* text) {
fprintf(out, "notify rc=0x%08x\n", sceKernelSendNotificationRequest(0, &request, sizeof request, 0));
}
-// 1 once ShadowMountPlus has registered the title (its mount.lnk), 0 when it has not after 60 s.
-static int registered(const char* title) {
- char link[64];
- snprintf(link, sizeof link, "/user/app/%s/mount.lnk", title);
- const double start = now();
- while (access(link, F_OK) != 0) {
- if (now() - start > 60) return 0;
- usleep(250000);
- }
- usleep(1000000); // the Home screen entry follows the link by about a second
- return 1;
-}
-
-static uint32_t launch(const char* title, uint32_t user) {
- launch_params params = {sizeof params, user, 0, 0, 0, 0};
- uint32_t rc = sceLncUtilLaunchApp(title, NULL, &params);
- fprintf(out, "%s sceLncUtilLaunchApp rc=0x%08x\n", title, rc);
- if (rc & 0x80000000u) {
- launch_params fallback = {sizeof fallback, user, 0, 0, 0, 1};
- rc = sceSystemServiceLaunchApp(title, NULL, &fallback);
- fprintf(out, "%s sceSystemServiceLaunchApp rc=0x%08x\n", title, rc);
- }
- return rc;
-}
-
int main(void) {
out = fopen(LOG, "w");
if (!out) return 1;
setvbuf(out, NULL, _IONBF, 0);
- char title[32] = {0}, quitting[32] = {0};
+ char title[32] = {0};
FILE* request = fopen(REQUEST, "r");
if (!request || !fgets(title, sizeof title, request)) {
fprintf(out, "no request\n");
if (request) fclose(request);
return 1;
}
- if (!fgets(quitting, sizeof quitting, request)) quitting[0] = 0;
fclose(request);
title[strcspn(title, "\r\n")] = 0;
- quitting[strcspn(quitting, "\r\n")] = 0;
- if (!quitting[0]) strcpy(quitting, title);
- if (!valid_title(title) || !valid_title(quitting)) {
+ if (!valid_title(title)) {
fprintf(out, "bad title id\n");
return 1;
}
const double start = now();
int state;
- while ((state = running(quitting)) == 1 && now() - start < 120) usleep(250000);
- fprintf(out, "title=%s quitting=%s wait state=%d s=%.2f\n", title, quitting, state, now() - start);
+ while ((state = running(title)) == 1 && now() - start < 120) usleep(250000);
+ fprintf(out, "title=%s wait state=%d s=%.2f\n", title, state, now() - start);
if (state != 0) {
notify("Playden was updated. Open it again from the Home screen.");
return 1;
}
- char final_title[32] = {0};
- if ((request = fopen(REQUEST, "r"))) {
- if (fgets(final_title, sizeof final_title, request)) {
- final_title[strcspn(final_title, "\r\n")] = 0;
- if (valid_title(final_title) && strcmp(final_title, title) != 0) {
- fprintf(out, "title changed to %s\n", final_title);
- strcpy(title, final_title);
- }
- }
- fclose(request);
- }
sceUserServiceInitialize(NULL);
uint32_t user = 0;
sceUserServiceGetForegroundUser(&user);
sceLncUtilInitialize();
- uint32_t rc = 0x80000000u;
- if (strcmp(title, quitting) == 0) {
- rc = launch(title, user);
- } else {
- const int ready = registered(title);
- fprintf(out, "%s registered=%d s=%.2f\n", title, ready, now() - start);
- if (ready) rc = launch(title, user);
- if (rc & 0x80000000u) rc = launch(quitting, user);
+ launch_params params = {sizeof params, user, 0, 0, 0, 0};
+ uint32_t rc = sceLncUtilLaunchApp(title, NULL, &params);
+ fprintf(out, "sceLncUtilLaunchApp rc=0x%08x\n", rc);
+ if (rc & 0x80000000u) {
+ launch_params fallback = {sizeof fallback, user, 0, 0, 0, 1};
+ rc = sceSystemServiceLaunchApp(title, NULL, &fallback);
+ fprintf(out, "sceSystemServiceLaunchApp rc=0x%08x\n", rc);
}
if (rc & 0x80000000u) notify("Playden was updated. Open it again from the Home screen.");
fclose(out);
diff --git a/tools/title-remover/main.c b/tools/title-remover/main.c
index 3aeedbe..e4782be 100644
--- a/tools/title-remover/main.c
+++ b/tools/title-remover/main.c
@@ -5,8 +5,7 @@
// Playden (FAKE77031) cannot load libSceAppInstUtil itself, and ShadowMountPlus
// refuses to uninstall while any title runs. This payload, which Playden sends to
// the payload loader on 127.0.0.1:9021, unregisters one of Playden's game titles
-// (FAKE78xxx), or Playden's old title FAKE77031 once Playden runs as PPSA97031,
-// and exits. It reads one request from REQUEST_DIR:
+// (FAKE78xxx) and exits. It reads one request from REQUEST_DIR:
//
// request "title=FAKE78002\nnonce=<16..64 of [0-9a-f-]>\n"
//
@@ -43,7 +42,6 @@ static int private_entry(const char *path, uid_t owner, int directory) {
}
static int valid_title(const char *title) {
- if (strcmp(title, "FAKE77031") == 0) return 1;
if (strlen(title) != 9 || strncmp(title, "FAKE78", 6) != 0) return 0;
for (int i = 6; i < 9; ++i)
if (title[i] < '0' || title[i] > '9') return 0;