Skip to content

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

C++

Install the runtime kit as playden-kit

Leonardo Lobato93e6fa6882a1
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0e54a13..4e27511 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -250,8 +250,8 @@ pre-releases), so every release needs its update manifest:
1. Raise the version in `CMakeLists.txt` (`project(PlaydenLauncher VERSION …)`) and build the PS5 package. The
version becomes `param.json`'s `contentVersion` and the version Playden compares.
2. Make the two zips as before: `playden-ps5-<version>.zip` (with the `FAKE77031` folder inside
- `playden-ps5-<version>/`) and `playden-kit-<kit version>.zip` (with the kit folder inside
- `playden-kit-<kit version>/`).
+ `playden-ps5-<version>/`) and `playden-kit-<kit version>.zip` (with the kit folder, named after its `kit_id`,
+ inside `playden-kit-<kit version>/`, for example `playden-kit-0.13/playden-kit/`).
3. Write the manifest:
```sh
diff --git a/README.md b/README.md
index d8c5260..29811d0 100644
--- a/README.md
+++ b/README.md
@@ -164,8 +164,8 @@ The previous app and kit are kept until the next update, in `/data/playden/self-
`/data/playden/kits/.previous-*`. Settings › About › **Go back to Playden <version>** puts them back: Playden
closes, swaps the previous version and its kit in, and opens again. If the swap does not take and the previous
version opens again, it says so and puts its kit back. If the new version itself fails to start, nothing can report it: reinstall Playden over FTP as
-described above (your games, sign-in and settings are kept), and put the previous kit folder back in place of
-the installed one if the new kit is at fault.
+described above (your games, sign-in and settings are kept), and, if the new kit is at fault, rename the previous
+kit folder (`.previous-<id>-<time>`) back to `<id>`, moving the installed folder of that name aside.
After the version that added import, going back to an older version keeps your old favorites, but loses the favorites
and collections you changed since. The console's organization data now lives in one file that older versions don't read.
diff --git a/cmake/ProsperoRuntime.cmake b/cmake/ProsperoRuntime.cmake
index 78f484c..ce60d5a 100644
--- a/cmake/ProsperoRuntime.cmake
+++ b/cmake/ProsperoRuntime.cmake
@@ -163,7 +163,7 @@ if(BUILD_TESTING AND NOT PLAYDEN_PLATFORM_PS5)
target_link_libraries(runtime_kit_trust_test PRIVATE playden_runtime_kit_trust)
# The packaged kit is a local build artifact; admission is checked when it exists.
add_test(NAME runtime_kit_trust COMMAND runtime_kit_trust_test
- "${CMAKE_SOURCE_DIR}/dependencies.lock.json" "${CMAKE_SOURCE_DIR}/build/kits/hl2-fw1360-dev1")
+ "${CMAKE_SOURCE_DIR}/dependencies.lock.json" "${CMAKE_SOURCE_DIR}/build/kits/playden-kit")
add_executable(prospero_kit_consumer_test
"${CMAKE_SOURCE_DIR}/tests/kit_producer_consumer_test.cpp")
target_link_libraries(prospero_kit_consumer_test PRIVATE playden_runtime_kit_admission)
diff --git a/dependencies.lock.json b/dependencies.lock.json
index 73826b4..49f74b2 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -225,12 +225,12 @@
"purpose": "Read-only native installed-title inventory; no native database writes"
},
"prospero_kit": {
- "kit_id": "hl2-fw1360-dev1",
+ "kit_id": "playden-kit",
"published": false,
- "status": "kit 0.12: kit 0.11 with libvulkan.prx (RADV from PS5_Mesa 156e555: 119.88 Hz output per title, display-paced flips) and win32u.prx (Wine patch 0983: Wine reports 120 Hz when the title asks for it) from prospero-win f729534, and the any-title shell rebuilt from f729534 (passes PS5_VIDEOOUT_REFRESH and PS5_VIDEOOUT_FRAME_RATE from the profile's [display] block); capability display-120hz; Mono, Mesa WGL/Zink and template unchanged, so bottles need no Recreate; titles from earlier kits keep 60 Hz until their next Play updates them. Released unchanged from dev kit 0.12-dev.20261019.1. Earlier kits (0.11, 0.10, H r1-r9): see this file's git history.",
+ "status": "Installed as playden-kit from kit 0.13 (kit 0.12 and earlier: hl2-fw1360-dev1; the manifest below is still kit 0.12's until kit 0.13 is packaged). kit 0.12: kit 0.11 with libvulkan.prx (RADV from PS5_Mesa 156e555: 119.88 Hz output per title, display-paced flips) and win32u.prx (Wine patch 0983: Wine reports 120 Hz when the title asks for it) from prospero-win f729534, and the any-title shell rebuilt from f729534 (passes PS5_VIDEOOUT_REFRESH and PS5_VIDEOOUT_FRAME_RATE from the profile's [display] block); capability display-120hz; Mono, Mesa WGL/Zink and template unchanged, so bottles need no Recreate; titles from earlier kits keep 60 Hz until their next Play updates them. Released unchanged from dev kit 0.12-dev.20261019.1. Earlier kits (0.11, 0.10, H r1-r9): see this file's git history.",
"manifest_sha256": "888748b21e24b566f27b128001a3fdbb28484a858069525af0775d6cd2488d28",
"files_sha256": "fd6fcb89e92d815978e309159d536fd9e79f1ef11e45e3e124578d056b7fc3db",
- "console_root": "/data/playden/kits/hl2-fw1360-dev1",
+ "console_root": "/data/playden/kits/playden-kit",
"firmware": [
"13.60"
],
diff --git a/runtime/kits/README.md b/runtime/kits/README.md
index d6b9e31..f097200 100644
--- a/runtime/kits/README.md
+++ b/runtime/kits/README.md
@@ -13,8 +13,8 @@ uploaded to the console separately; Playden builds never build Wine or download
installed kit in Settings › About. `dependencies.lock.json` (`prospero_kit`) records the same kit with its runtime
revision and how it was built; a host test checks the two agree.
-Playden uses the kit installed at `/data/playden/kits/<kit id>` as long as it is complete and its files match its own
-manifest; an incomplete or changed kit is refused at start-up.
+Playden uses the kit installed at `/data/playden/kits/<kit id>` (`playden-kit` since kit 0.13) as long as it is
+complete and its files match its own manifest; an incomplete or changed kit is refused at start-up.
## Building and packaging
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 444f856..d993bb2 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -382,6 +382,8 @@ int main() {
// The kit this build was made for: downloaded at the first start (or over a kit it can't use).
update_config.kit_id = playden::runtime::kDevelopmentKitId;
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);
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";
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index f495ef2..5b63d4a 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -854,6 +854,20 @@ std::string RuntimeHost::Direct3D12Step(Composition& c, const GameFiles& files)
return {};
}
+// Generic step: the bottle's Wine Mono path follows the kit's (a bottle copied from a kit under another id names
+// that folder). Logged, never a refusal: only .NET programs need it, and the next Play tries again.
+void RuntimeHost::KitMonoStep(Composition& c, const rt::RuntimeInstall& record, const char* when) {
+ if (!c.kit || record.data_root.empty()) return;
+ bool changed = false;
+ std::string reason;
+ const auto ok = rt::PointBottleAtKitMono((c.kit->view.root / c.kit->view.template_path).string(),
+ (HostPath(record.data_root) / "library/prefixes/game").string(),
+ config_.unix_time(), &changed, &reason);
+ if (changed || !ok)
+ Log(std::string("mono path app=") + std::to_string(record.runtime_number) + " when=" + when +
+ (ok ? " pointed at kit " + c.kit->view.kit_id : " failed=" + reason));
+}
+
// Generic step: vkd3d-proton's variables reach the game through the bottle's Environment key. Some change how
// it draws, so a bottle that exists but cannot take them stops the start; one not made yet gets them on the
// next Play.
@@ -1079,6 +1093,7 @@ std::string RuntimeHost::ApplyPreparationSteps(Composition& c, const rt::Runtime
if (auto refused = SteamworksStep(files, steam_account_known); !refused.empty()) return refused;
if (auto refused = Ue3EulaStep(files); !refused.empty()) return refused;
if (auto refused = Direct3D12Step(c, files); !refused.empty()) return refused;
+ KitMonoStep(c, record, "prepare");
if (auto refused = BottleEnvironmentStep(files); !refused.empty()) return refused;
if (auto refused = InstallScriptsStep(files); !refused.empty()) return refused;
MfcStep(files);
@@ -3853,6 +3868,12 @@ bool RuntimeHost::RunServices() {
Log("startup bottle profiles settled=" + std::to_string(settled) + " ms=" +
std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - began).count()));
}
+ // Bottles from a kit with another folder name point Wine Mono at it: games started from Home find Mono only
+ // once they name this kit's. Busy titles wait for Play.
+ if (c.kit)
+ for (const auto& record : c.repository.Snapshot())
+ if (record.state == rt::PreparationState::kReady && MaintenanceRefusal(c, record).empty())
+ KitMonoStep(c, record, "startup");
// An unowned upgrade's request cut off before its publication began (a crash, a capture
// refused on an earlier start) is dropped first: the game plays under its owned publication,
// and the pass below tries the upgrade again. Moved games and newer settings keep theirs.
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index 5622b91..3b0d3be 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -579,6 +579,7 @@ class RuntimeHost {
void MediaStep(Composition& composition, const runtime::RuntimeInstall& record);
std::string Ue3EulaStep(const GameFiles& files);
std::string Direct3D12Step(Composition& composition, const GameFiles& files);
+ void KitMonoStep(Composition& composition, const runtime::RuntimeInstall& record, const char* when); // never stops the start
std::string BottleEnvironmentStep(const GameFiles& files);
std::string RecipeRegistryStep(const GameFiles& files);
std::string DotnetHeapStep(const GameFiles& files);
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 1943672..a52775f 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -4360,7 +4360,7 @@ void Simulation::rebuild_view() {
else if (action_key == "about-kit" || action_key == "about-kit-source") {
// The kit in use, and the one this build was tested with when they differ.
LiveKitInfo kit = state_.kit;
- if (!live()) kit = {"hl2-fw1360-dev1", std::string(64, 'b'), std::string(64, 'b'), std::string(40, '2'), false, {}};
+ if (!live()) kit = {"playden-kit", std::string(64, 'b'), std::string(64, 'b'), std::string(40, '2'), false, {}};
const auto short_hash = [](const std::string& hash) { return hash.substr(0, 12); };
item.kind = RowKind::Status; item.enabled = false;
if (kit.kit_id.empty()) {
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index a36c5c0..64c988d 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -2754,6 +2754,73 @@ bool ApplyD3D12Library(const std::string& runtime_dir, const std::string& templa
return true;
}
+namespace {
+
+// The data of one value in a Wine registry file, in Wine's text form ("\"...\"" for a string), or nothing when
+// its key or the value isn't there or is written more than once.
+std::optional<std::string> RegistryData(const std::string& text, const std::string& key, const std::string& name) {
+ const auto header = RegistryHeader(key);
+ const auto line_prefix = "\"" + name + "\"=";
+ std::optional<std::string> data;
+ bool inside = false, seen = false;
+ for (std::size_t at = 0; at < text.size();) {
+ const auto newline = text.find('\n', at);
+ const auto next = newline == std::string::npos ? text.size() : newline + 1;
+ auto content_end = newline == std::string::npos ? text.size() : newline;
+ if (content_end > at && text[content_end - 1] == '\r') --content_end;
+ const std::string_view line(text.data() + at, content_end - at);
+ at = next;
+ if (!line.empty() && line.front() == '[') {
+ // Wine writes a key's header with its time after a space.
+ inside = line.size() >= header.size() && RegistryEqual(line.substr(0, header.size()), header) &&
+ (line.size() == header.size() || line[header.size()] == ' ');
+ if (inside && seen) return std::nullopt;
+ seen = seen || inside;
+ continue;
+ }
+ if (!inside || line.size() < line_prefix.size() || !RegistryEqual(line.substr(0, line_prefix.size()), line_prefix))
+ continue;
+ if (data || line.back() == '\\') return std::nullopt;
+ data = std::string(line.substr(line_prefix.size()));
+ }
+ return data;
+}
+
+} // namespace
+
+bool PointBottleAtKitMono(const std::string& template_dir, const std::string& prefix_dir, std::int64_t unix_time,
+ bool* changed, std::string* reason) {
+ const auto fail = [&](std::string why) {
+ if (reason) *reason = std::move(why);
+ return false;
+ };
+ *changed = false;
+ constexpr const char* kKey = "Software\\Wine\\Mono";
+ constexpr const char* kName = "RuntimePath";
+ constexpr std::size_t kMaxRegistryBytes = 32u * 1024u * 1024u;
+ auto bottle = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kPrivateTraversable);
+ if (!bottle) return errno == ENOENT ? true : fail("cannot open the bottle");
+ std::string bottle_reg;
+ const auto state = ReadRegularAt(*bottle, "user.reg", kMaxRegistryBytes, &bottle_reg, nullptr, true);
+ if (state == RelativeRead::kMissing) return true; // the bottle comes later
+ if (state != RelativeRead::kPresent) return fail("cannot read the bottle's user.reg");
+ const auto current = RegistryData(bottle_reg, kKey, kName);
+ // The packaged template writes Z:\data\playden\kits\<kit id>\mono\wine-mono-<version>, escaped.
+ static constexpr std::string_view kKitsFolder = R"("Z:\\data\\playden\\kits\\)";
+ if (!current || current->size() <= kKitsFolder.size() ||
+ !RegistryEqual(std::string_view(*current).substr(0, kKitsFolder.size()), kKitsFolder))
+ return true;
+ auto kit = ManagedDirectory::Open(template_dir, DirectoryPolicy::kApprovedTree);
+ std::string template_reg;
+ if (!kit || ReadRegularAt(*kit, "user.reg", kMaxRegistryBytes, &template_reg) != RelativeRead::kPresent)
+ return fail("cannot read the kit template's user.reg");
+ const auto wanted = RegistryData(template_reg, kKey, kName);
+ if (!wanted || *wanted == *current) return true;
+ if (!ApplyRegistryFileValues({{kKey, kName, *wanted}}, prefix_dir, unix_time, reason)) return false;
+ *changed = true;
+ return true;
+}
+
bool ParseUe3InstallGuid(std::string_view install_info, std::string* guid) {
static constexpr std::string_view open = "<InstallGuidString>", close = "</InstallGuidString>";
const auto start = install_info.find(open);
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index 0e41f42..1cf8dd5 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -410,6 +410,14 @@ bool ApplyMediaRegistry(const std::string& runtime_dir, const std::string& prefi
bool ApplyD3D12Library(const std::string& runtime_dir, const std::string& template_dir, const std::string& prefix_dir,
bool vkd3d_proton, std::string* reason);
+// Points the stopped bottle's Wine Mono (HKCU\Software\Wine\Mono RuntimePath) where the kit template's points: a
+// bottle copied from an earlier kit names that kit's folder, which a renamed kit (or another Mono version) no longer
+// has. Only a value that names a folder under /data/playden/kits changes; a bottle without the value (made before
+// the kit had Mono), a template without it, or a bottle not made yet is left as it is. changed tells whether
+// user.reg was written (with a user.reg.playden-backup, as ApplyBottleRegistryValues does).
+bool PointBottleAtKitMono(const std::string& template_dir, const std::string& prefix_dir, std::int64_t unix_time,
+ bool* changed, std::string* reason);
+
// The <InstallGuidString> of an Unreal Engine 3 (UDK) Binaries/InstallInfo.xml: exactly one,
// a 36-character 8-4-4-4-12 hex GUID once surrounding whitespace is trimmed.
bool ParseUe3InstallGuid(std::string_view install_info, std::string* guid);
diff --git a/src/runtime/kit_trust.h b/src/runtime/kit_trust.h
index a4714f9..57361ae 100644
--- a/src/runtime/kit_trust.h
+++ b/src/runtime/kit_trust.h
@@ -1,6 +1,7 @@
#pragma once
#include "runtime/kit_manifest.h"
#include <string>
+#include <string_view>
namespace playden::runtime {
@@ -9,11 +10,28 @@ namespace playden::runtime {
// this build was tested with; they mirror the "prospero_kit" entry in
// dependencies.lock.json (a host test checks they agree) and are only shown next to
// the installed kit (Settings > About).
-inline constexpr const char* kDevelopmentKitId = "hl2-fw1360-dev1";
-inline constexpr const char* kDevelopmentKitRoot = "/data/playden/kits/hl2-fw1360-dev1";
+inline constexpr const char* kDevelopmentKitId = "playden-kit";
+inline constexpr const char* kDevelopmentKitRoot = "/data/playden/kits/playden-kit";
inline constexpr const char* kExpectedKitManifestSha256 =
"888748b21e24b566f27b128001a3fdbb28484a858069525af0775d6cd2488d28";
+// Ids a kit had before it was renamed: its folder under /data/playden/kits and its manifest's kit_id.
+// A title, bottle or settings publication made from the earlier id belongs to the renamed kit (Update
+// refreshes it, and its publication still starts), and the earlier folder is retired once the kit is
+// installed under its new id (update::UpdateService).
+struct KitIdRename {
+ const char* from;
+ const char* to;
+};
+inline constexpr KitIdRename kKitIdRenames[] = {{"hl2-fw1360-dev1", "playden-kit"}};
+
+// Whether the kit `from` was renamed to `to`.
+inline bool KitIdRenamedTo(std::string_view from, std::string_view to) {
+ for (const auto& renamed : kKitIdRenames)
+ if (from == renamed.from && to == renamed.to) return true;
+ return false;
+}
+
// What this build accepts from a kit, on any console firmware.
KitAdmissionConfig DevelopmentKitAdmission();
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 9048276..0914b64 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -1,4 +1,5 @@
#include "runtime/package_installer.h"
+#include "runtime/kit_trust.h"
#include "runtime/private_directories.h"
#include "platform/managed_directory.h"
#include "pw_title_publication_native.h"
@@ -983,7 +984,8 @@ bool FilesystemPackageInstaller::PublicationMatches(
const bool closed = ::close(fd) == 0;
PwTitlePublication receipt{};
if (!valid || !closed || pw_title_publication_parse(reinterpret_cast<const uint8_t*>(bytes.data()), bytes.size(), &receipt) != PW_OK ||
- receipt.phase != PW_TITLE_PUBLICATION_COMMITTED || receipt.kit_id != kit_.kit_id ||
+ receipt.phase != PW_TITLE_PUBLICATION_COMMITTED ||
+ (receipt.kit_id != kit_.kit_id && !KitIdRenamedTo(receipt.kit_id, kit_.kit_id)) ||
receipt.install_id != record.install_id || receipt.title_id != record.title_id ||
receipt.runtime_bundle_id != record.runtime_bundle_id || receipt.recipe_id != record.recipe_id ||
receipt.recipe_version != record.recipe_version || receipt.settings_revision != record.settings_revision)
@@ -1521,16 +1523,18 @@ namespace {
// Marker text without the lines a respin of the same kit may change (its file
// inventory, a rebuilt runtime's revision and path, and the kit title the game's
// title is made from: a fixed one, or the one shell for every game), for
-// comparing identity.
-std::string RespinIdentity(const std::string& marker) {
+// comparing identity. A kit id the kit `kit_id` was renamed from counts as it.
+std::string RespinIdentity(const std::string& marker, const std::string& kit_id) {
std::string kept;
std::size_t start = 0;
while (start < marker.size()) {
auto end = marker.find('\n', start);
if (end == std::string::npos) end = marker.size();
const auto line = marker.substr(start, end - start);
- if (line.rfind("files_sha256=", 0) != 0 && line.rfind("runtime_revision=", 0) != 0 &&
- line.rfind("runtime_path=", 0) != 0 && line.rfind("variant_id=", 0) != 0)
+ if (line.rfind("kit_id=", 0) == 0 && KitIdRenamedTo(line.substr(7), kit_id))
+ kept += "kit_id=" + kit_id + "\n";
+ else if (line.rfind("files_sha256=", 0) != 0 && line.rfind("runtime_revision=", 0) != 0 &&
+ line.rfind("runtime_path=", 0) != 0 && line.rfind("variant_id=", 0) != 0)
kept += line + "\n";
start = end + 1;
}
@@ -1592,8 +1596,8 @@ PackageActionResult FilesystemPackageInstaller::RefreshTitle(const RuntimeInstal
if (!IsDirectoryNoSymlink(paths->title) || !IsPrivateDirectoryTree(paths->game, paths->bottle, BottleTraversal(*paths)) ||
!title_marker || !bottle_marker || !IsHexDigest(title_digest) || old_digest(bottle_marker) != title_digest ||
!WithFilesDigest(new_title, title_digest) || !WithFilesDigest(new_bottle, title_digest) ||
- RespinIdentity(new_title) != RespinIdentity(*title_marker) ||
- RespinIdentity(new_bottle) != RespinIdentity(*bottle_marker))
+ RespinIdentity(new_title, kit_.kit_id) != RespinIdentity(*title_marker, kit_.kit_id) ||
+ RespinIdentity(new_bottle, kit_.kit_id) != RespinIdentity(*bottle_marker, kit_.kit_id))
return Failed("refresh-ownership", "installed title and bottle are not this install's from a compatible kit");
if (title_digest == kit_.files_sha256 && TitleMatches(record, *paths)) return Complete();
std::vector<char> buffer(kCopyBufferBytes); // heap: console worker stacks are small
diff --git a/src/update/release.h b/src/update/release.h
index c8ae36a..ccc7c49 100644
--- a/src/update/release.h
+++ b/src/update/release.h
@@ -37,11 +37,11 @@ std::optional<Release> ParseRelease(std::string_view json, std::string* error);
std::optional<std::vector<Release>> ParseReleases(std::string_view json, std::string* error);
struct KitPart {
- std::string kit_id; // stays the same across revisions ("hl2-fw1360-dev1")
- std::string revision; // "r9"
+ std::string kit_id; // stays the same across revisions ("playden-kit")
+ std::string revision; // "0.13"
std::string manifest_sha256; // the kit's manifest.json SHA-256
std::string asset; // release asset name
- std::string prefix; // folder inside the zip ("playden-kit-0.12/hl2-fw1360-dev1/")
+ std::string prefix; // folder inside the zip ("playden-kit-0.13/playden-kit/")
};
// A kit's version: "<generation>.<revision>" ("0.12"), or a development build of one with "-dev.<YYYYMMDD>.<N>"
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index 07d6131..b0f6f3b 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <algorithm>
#include <cerrno>
#include <cstdio>
#include <utility>
@@ -217,6 +218,25 @@ void UpdateService::RemoveReplacedKits() {
}
}
+// The kit under an id it had before, which the Playden that used that id left when it updated to this
+// one (the new kit went in next to it). Once the kit is installed under its own id, the old folder
+// becomes the kit this version's update replaced, ".previous-<old id>-<time>" with the newest
+// backup's time: going back puts it back, and the next update removes it. As root, at startup,
+// before the runtime and the UI run (root is process-wide).
+void UpdateService::RetireRenamedKits() {
+ if (config_.kit_id.empty() || !Exists(config_.kits_root + "/" + config_.kit_id + "/manifest.json")) return;
+ for (const auto& id : config_.renamed_kit_ids) {
+ const std::string old_kit = config_.kits_root + "/" + id;
+ if (id.empty() || id == config_.kit_id || !IsFolder(old_kit)) continue;
+ const auto backup = LatestBackup();
+ const std::string stamp = backup ? backup->path.substr(backup->path.rfind('-') + 1) : std::to_string(config_.now());
+ std::string previous = config_.kits_root + "/.previous-" + id + "-" + stamp;
+ if (Exists(previous)) previous = config_.kits_root + "/.previous-" + id + "-" + std::to_string(config_.now());
+ const bool moved = config_.as_root([&] { return !Exists(previous) && rename(old_kit.c_str(), previous.c_str()) == 0; });
+ Log(moved ? "kit folder " + id + " retired as " + previous : "kit folder " + id + " could not be retired");
+ }
+}
+
// 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.
void UpdateService::CleanUpLeftovers() {
@@ -394,6 +414,7 @@ void UpdateService::Start() {
FindPrevious();
LoadCurrentNotes();
RemoveReplacedKits();
+ RetireRenamedKits();
std::string text;
if (!ReadSmallFile(StatePath(), &text)) {
CleanUpLeftovers(); // what a start closed before its cleanup finished left behind
@@ -996,8 +1017,15 @@ bool UpdateService::RollBackAtQuit() {
if (name.compare(0, 10, ".previous-") != 0 || name.size() <= 10 + suffix.size() ||
name.compare(name.size() - suffix.size(), suffix.size(), suffix) != 0)
continue;
- kit_id = name.substr(10, name.size() - 10 - suffix.size());
+ // A kit retired under an earlier id is the one the backed-up app used: an update from that app may also have
+ // replaced a kit under this version's id at the same time, which the older app never reads.
+ const std::string id = name.substr(10, name.size() - 10 - suffix.size());
+ const bool renamed = std::find(config_.renamed_kit_ids.begin(), config_.renamed_kit_ids.end(), id) !=
+ config_.renamed_kit_ids.end();
+ if (!previous_kit.empty() && !renamed) continue;
+ kit_id = id;
previous_kit = config_.kits_root + "/" + name;
+ if (renamed) break;
}
const std::string installed_kit = kit_id.empty() ? std::string() : config_.kits_root + "/" + kit_id;
const std::string replaced_kit = config_.kits_root + "/.replaced-" + kit_id + "-" + stamp;
@@ -1015,13 +1043,19 @@ bool UpdateService::RollBackAtQuit() {
SwapResult swap;
bool kit_swapped = false;
config_.as_root([&] {
- if (!previous_kit.empty() && Exists(installed_kit)) {
- if (rename(installed_kit.c_str(), replaced_kit.c_str()) != 0) {
- swap.error = "cannot move the current kit aside";
- return false;
+ // A previous kit under an id this version's kit no longer has (RetireRenamedKits) goes back to
+ // its own folder; this version's kit stays where it is, unused by the older Playden.
+ bool moved_aside = false;
+ if (!previous_kit.empty()) {
+ if (Exists(installed_kit)) {
+ if (rename(installed_kit.c_str(), replaced_kit.c_str()) != 0) {
+ swap.error = "cannot move the current kit aside";
+ return false;
+ }
+ moved_aside = true;
}
if (rename(previous_kit.c_str(), installed_kit.c_str()) != 0) {
- rename(replaced_kit.c_str(), installed_kit.c_str());
+ if (moved_aside) rename(replaced_kit.c_str(), installed_kit.c_str());
swap.error = "cannot put the previous kit back";
return false;
}
@@ -1032,7 +1066,7 @@ bool UpdateService::RollBackAtQuit() {
if (!swap.ok) {
if (kit_swapped) {
rename(installed_kit.c_str(), previous_kit.c_str());
- rename(replaced_kit.c_str(), installed_kit.c_str());
+ if (moved_aside) rename(replaced_kit.c_str(), installed_kit.c_str());
kit_swapped = false;
}
return false;
diff --git a/src/update/update_service.h b/src/update/update_service.h
index 42c10a0..475615a 100644
--- a/src/update/update_service.h
+++ b/src/update/update_service.h
@@ -29,6 +29,9 @@ struct UpdateConfig {
// is missing, incomplete or another one. Empty: no kit-only install.
std::string kit_id;
std::string kit_manifest_sha256;
+ // 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;
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,
@@ -194,6 +197,7 @@ class UpdateService {
bool PrepareWorkRoot();
bool RemoveOwnedTree(const std::string& path);
void RemoveReplacedKits();
+ void RetireRenamedKits();
void CleanUpLeftovers();
UpdateConfig config_;
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index 8938bb8..76bc85e 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -1368,6 +1368,47 @@ int main(int argc, char** argv) {
std::filesystem::create_symlink(root / "old/system.reg", media_manifest);
CHECK(!ApplyMediaRegistry(media_runtime.string(), (root / "old").string(), 123, &reason));
+ // A bottle copied from a kit under another folder name (hl2-fw1360-dev1 before kit 0.13) points Wine Mono at that
+ // folder: it is pointed where the kit template points, keeping its other values. A value Playden didn't write, a
+ // bottle without the value and a bottle not made yet are left as they are.
+ {
+ const auto mono_template = root / "mono-template", mono_bottle = root / "mono-bottle";
+ std::filesystem::create_directories(mono_template);
+ std::filesystem::create_directories(mono_bottle);
+ std::filesystem::permissions(mono_bottle, std::filesystem::perms::owner_all);
+ const std::string head = "WINE REGISTRY Version 2\n;; All keys relative to REGISTRY\\\\User\\\\S-1-5-21-0-0-0-1000\n\n#arch=win64\n\n";
+ const std::string drivers = "[Software\\\\Wine\\\\Drivers]\n\"Audio\"=\"ps5\"\n\n";
+ const auto mono = [](const std::string& kit, const std::string& stamp) {
+ return "[Software\\\\Wine\\\\Mono]" + stamp + "\n" + (stamp.empty() ? "" : "#time=1dc2b\n") +
+ "\"RuntimePath\"=\"Z:\\\\data\\\\playden\\\\kits\\\\" + kit + "\\\\mono\\\\wine-mono-11.3.0\"\n\n";
+ };
+ std::ofstream(mono_template / "user.reg") << head << drivers << mono("playden-kit", "");
+ const auto write_bottle = [&](const std::string& text) {
+ std::ofstream(mono_bottle / "user.reg", std::ios::trunc) << text;
+ ::chmod((mono_bottle / "user.reg").c_str(), 0600);
+ };
+ // Wine saved the bottle: its keys carry their time.
+ write_bottle(head + "[Software\\\\Wine\\\\Drivers] 1791500000\n\"Audio\"=\"ps5\"\n\n" + mono("hl2-fw1360-dev1", " 1791500000"));
+ bool changed = false;
+ CHECK(PointBottleAtKitMono(mono_template.string(), mono_bottle.string(), 1791600000, &changed, &reason) && changed);
+ CHECK(ReadText(mono_bottle / "user.reg") ==
+ head + "[Software\\\\Wine\\\\Drivers] 1791500000\n\"Audio\"=\"ps5\"\n\n" + mono("playden-kit", " 1791500000"));
+ CHECK(ReadText(mono_bottle / "user.reg.playden-backup").find("kits\\\\hl2-fw1360-dev1\\\\mono") != std::string::npos);
+ CHECK(PointBottleAtKitMono(mono_template.string(), mono_bottle.string(), 1791600000, &changed, &reason) && !changed);
+ for (const auto& kept : {head + drivers,
+ head + "[Software\\\\Wine\\\\Mono]\n\"RuntimePath\"=\"Z:\\\\opt\\\\mono\"\n"}) {
+ write_bottle(kept);
+ CHECK(PointBottleAtKitMono(mono_template.string(), mono_bottle.string(), 1791600000, &changed, &reason) && !changed);
+ CHECK(ReadText(mono_bottle / "user.reg") == kept);
+ }
+ CHECK(PointBottleAtKitMono(mono_template.string(), (root / "mono-no-bottle").string(), 1791600000, &changed, &reason) &&
+ !changed);
+ // A kit without Mono leaves the value alone.
+ std::ofstream(mono_template / "user.reg", std::ios::trunc) << head << drivers;
+ write_bottle(head + mono("hl2-fw1360-dev1", ""));
+ CHECK(PointBottleAtKitMono(mono_template.string(), mono_bottle.string(), 1791600000, &changed, &reason) && !changed);
+ }
+
// vkd3d-proton's DLLs go into both windows folders of the bottle and come out again, replaced by the template's,
// without touching a bottle whose files were never vkd3d-proton's.
{
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index db5f522..daf7529 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -698,7 +698,7 @@ void t11_preferences_failure_and_controller_modal_recovery(const std::filesystem
{
const auto& rows = restored.view().rows;
const auto kit = std::find_if(rows.begin(), rows.end(), [](const auto& row) { return row.key == "about-kit"; });
- check(kit != rows.end() && kit->value.rfind("hl2-fw1360-dev1 · ", 0) == 0 &&
+ check(kit != rows.end() && kit->value.rfind("playden-kit · ", 0) == 0 &&
kit->subtitle == "The kit this version of Playden was tested with",
"T11 About names the runtime kit and whether it is the tested one");
}
diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cpp
index fbbdaa1..7e1a953 100644
--- a/tests/runtime_package_installer_test.cpp
+++ b/tests/runtime_package_installer_test.cpp
@@ -1030,6 +1030,42 @@ void FixedTitleRefreshesToAnyTitleShell() {
(folder.st_mode & 07777) == 0755);
}
+// A kit renamed since a game was prepared (hl2-fw1360-dev1 became playden-kit with kit 0.13): Update refreshes
+// the title and bottle as the same kit's, and the publication made under the earlier id still starts the game.
+// A kit with any other id stays another kit.
+void RenamedKitRefreshesItsTitles() {
+ for (const bool renamed : {true, false}) {
+ Fixture fixture;
+ fixture.view.kit_id = renamed ? "hl2-fw1360-dev1" : "other-kit";
+ auto record = Record();
+ record.artifacts = {{"runtime", "rev", fixture.view.artifacts[0].sha256},
+ {"recipe", "steam-220-hl2-v1-1", fixture.view.artifacts[1].sha256}};
+ {
+ auto installer = fixture.Installer();
+ CHECK(installer.StageTitle(record).state == PackageActionState::kComplete);
+ CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);
+ CHECK(installer.PublishProfile(record).state == PackageActionState::kComplete && installer.Inspect(record).profile_published);
+ }
+ fixture.view.kit_id = "playden-kit";
+ fixture.view.files_sha256 = std::string(64, 'b');
+ auto installer = fixture.Installer();
+ CHECK(!installer.TitleCurrent(record) && installer.SetupFromOtherKit(record));
+ const auto refreshed = installer.RefreshTitle(record);
+ if (!renamed) {
+ CHECK(refreshed.state == PackageActionState::kFailed && refreshed.code == "refresh-ownership");
+ continue;
+ }
+ if (refreshed.state != PackageActionState::kComplete) std::fprintf(stderr, "refresh: %s %s\n", refreshed.code.c_str(), refreshed.message.c_str());
+ CHECK(refreshed.state == PackageActionState::kComplete);
+ CHECK(installer.TitleCurrent(record) && !installer.SetupFromOtherKit(record));
+ const auto title_marker = Read(fixture.host_data / "homebrew/FAKE78001/.playden-title-owner");
+ CHECK(title_marker.find("\nkit_id=playden-kit\n") != std::string::npos);
+ CHECK(Read(fixture.host_data / "playden/games/install-hl2/library/prefixes/game/.playden-template-owner")
+ .find("\nkit_id=playden-kit\n") != std::string::npos);
+ CHECK(installer.Inspect(record).profile_published);
+ }
+}
+
void PrivateTitleFoldersAreRepublished() {
Fixture fixture;
auto installer = fixture.Installer();
@@ -1497,6 +1533,7 @@ int main() {
PrivateTitleFoldersAreRepublished();
AnyTitleVariantServesEveryTitle();
FixedTitleRefreshesToAnyTitleShell();
+ RenamedKitRefreshesItsTitles();
CreatedFoldersIgnoreUmask();
RenameFailureReportsErrno();
UnwritableParentIsNotACollision();
diff --git a/tests/self_update_release_test.cpp b/tests/self_update_release_test.cpp
index 4f72142..d2c8f49 100644
--- a/tests/self_update_release_test.cpp
+++ b/tests/self_update_release_test.cpp
@@ -12,8 +12,8 @@ static std::string Manifest(const std::string& app_override = {}, const std::str
? R"({"version":"0.3.0","title_id":"FAKE77031","min_from":"0.2.0","asset":"playden-ps5-0.3.0.zip","prefix":"playden-ps5-0.3.0/FAKE77031/"})"
: app_override;
const std::string kit = kit_override.empty()
- ? R"({"kit_id":"hl2-fw1360-dev1","revision":"r9","manifest_sha256":")" + kSha +
- R"(","asset":"playden-kit-h-r9.zip","prefix":"playden-kit-h-r9/hl2-fw1360-dev1/"})"
+ ? R"({"kit_id":"playden-kit","revision":"0.13","manifest_sha256":")" + kSha +
+ R"(","asset":"playden-kit-0.13.zip","prefix":"playden-kit-0.13/playden-kit/"})"
: kit_override;
return R"({"format":1,"app":)" + app + R"(,"kit":)" + kit + R"(,"notes":"Faster downloads."})";
}
@@ -47,8 +47,8 @@ int main() {
CHECK(manifest->app_version == (Version{0, 3, 0}) && manifest->min_from == (Version{0, 2, 0}));
CHECK(manifest->title_id == "FAKE77031" && manifest->app_asset == "playden-ps5-0.3.0.zip");
CHECK(manifest->app_prefix == "playden-ps5-0.3.0/FAKE77031/");
- CHECK(manifest->kit.kit_id == "hl2-fw1360-dev1" && manifest->kit.revision == "r9" && manifest->kit.manifest_sha256 == kSha);
- CHECK(manifest->kit.prefix == "playden-kit-h-r9/hl2-fw1360-dev1/" && manifest->notes == "Faster downloads.");
+ CHECK(manifest->kit.kit_id == "playden-kit" && manifest->kit.revision == "0.13" && manifest->kit.manifest_sha256 == kSha);
+ CHECK(manifest->kit.prefix == "playden-kit-0.13/playden-kit/" && manifest->notes == "Faster downloads.");
// The notes are a plain-text summary: GitHub's line endings and control characters go, blank lines
// collapse to one, and a long text is cut at a word with an ellipsis.
@@ -84,7 +84,7 @@ int main() {
for (const auto& kit : bad_kits) CHECK(!ParseUpdateManifest(Manifest({}, kit), &error));
CHECK(IsSha256(kSha) && !IsSha256(std::string(63, 'a')) && !IsSha256(std::string(64, 'A')));
- CHECK(SafeFolderName("hl2-fw1360-dev1-r9") && !SafeFolderName("a/b") && !SafeFolderName("..") && !SafeFolderName(""));
+ CHECK(SafeFolderName("playden-kit-0.13") && !SafeFolderName("a/b") && !SafeFolderName("..") && !SafeFolderName(""));
// Kit versions: releases "0.12", development builds "0.13-dev.20261023.1" before the release they lead to.
const auto kit_version = [](const char* text) { return *ParseKitVersion(text); };
diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cpp
index 35b315d..2d0d7ea 100644
--- a/tests/self_update_service_test.cpp
+++ b/tests/self_update_service_test.cpp
@@ -464,6 +464,133 @@ int main() {
CHECK(Exists(kits + "/kitid/manifest.json"));
RemoveTree(fixture.root);
}
+ // A kit renamed between versions (0.6.0 keeps it at hl2-fw1360-dev1, 0.7.0 at playden-kit; here oldkit and kitid).
+ // The old Playden's update (ReadyKit, StageKit and ApplyAtQuit are 0.6.0's) puts the new kit in next to its own
+ // and leaves that one alone. The new Playden retires it as the previous kit: going back puts it back in its own
+ // folder (the new kit stays), and the next update removes it.
+ {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("service-renamed-kit");
+ Installed(fixture.root);
+ const std::string kits = fixture.root + "/playden/kits";
+ const std::string app = fixture.root + "/homebrew/FAKE77031";
+ CHECK(rename((kits + "/kitid").c_str(), (kits + "/oldkit").c_str()) == 0);
+ RemoveTree(kits + "/.previous-kitid-1");
+ const auto previous_kits = [&] {
+ std::vector<std::string> names;
+ for (const auto& name : ListFolder(kits))
+ if (name.rfind(".previous-", 0) == 0) names.push_back(name);
+ return names;
+ };
+ const auto renamed = [&](Version current) {
+ auto config = fixture.Config(current);
+ config.kit_id = "kitid";
+ config.kit_manifest_sha256 = kKitSha;
+ config.renamed_kit_ids = {"oldkit"};
+ return config;
+ };
+ Publish(fixture.server, "v0.3.0");
+ {
+ UpdateService old(fixture.Config({0, 2, 0}));
+ old.Start();
+ old.Check(true);
+ Wait(old);
+ CHECK(old.Snapshot().phase == UpdatePhase::kAvailable && old.Snapshot().kit_needed);
+ old.Install();
+ Wait(old);
+ CHECK(old.Snapshot().phase == UpdatePhase::kStaged && Read(kits + "/.next-kitid-r9/manifest.json") == kKitSha);
+ old.RequestRestart();
+ old.Shutdown();
+ CHECK(old.ApplyAtQuit());
+ }
+ CHECK(Read(app + "/eboot.bin") == "eboot 0.3.0" && Read(kits + "/kitid/manifest.json") == kKitSha);
+ CHECK(Read(kits + "/oldkit/manifest.json") == std::string(64, 'b') && previous_kits().empty());
+ // A version that has no kit under its own id yet keeps the old folder.
+ {
+ CHECK(rename((kits + "/kitid").c_str(), (kits + "/.aside").c_str()) == 0);
+ UpdateService waiting(renamed({0, 3, 0}));
+ waiting.Start();
+ Wait(waiting);
+ CHECK(Exists(kits + "/oldkit") && previous_kits().empty());
+ CHECK(rename((kits + "/.aside").c_str(), (kits + "/kitid").c_str()) == 0);
+ // The update is confirmed again below: the state was removed by this start.
+ CHECK(!Exists(fixture.root + "/playden/self-update/state.json"));
+ }
+ UpdateService next(renamed({0, 3, 0}));
+ next.Start();
+ CHECK(!Exists(kits + "/oldkit") && Read(kits + "/.previous-oldkit-1000/manifest.json") == std::string(64, 'b'));
+ CHECK(Read(kits + "/kitid/manifest.json") == kKitSha);
+ Wait(next);
+ CHECK(next.Snapshot().previous == "0.2.0");
+ next.RequestRollback();
+ next.Shutdown();
+ CHECK(next.ApplyAtQuit());
+ CHECK(Read(app + "/eboot.bin") == "eboot 0.2.0" && Read(kits + "/oldkit/manifest.json") == std::string(64, 'b'));
+ CHECK(Read(kits + "/kitid/manifest.json") == kKitSha && previous_kits().empty());
+ {
+ UpdateService back(fixture.Config({0, 2, 0}));
+ back.Start();
+ CHECK(back.Snapshot().finished_message == "Playden went back to version 0.2.0.");
+ Wait(back);
+ CHECK(Exists(kits + "/oldkit/runtime/wine.bin") && Exists(kits + "/kitid/runtime/wine.bin"));
+ // Updating again finds the new kit in place: only the app is downloaded.
+ back.Check(true);
+ Wait(back);
+ CHECK(back.Snapshot().phase == UpdatePhase::kAvailable && !back.Snapshot().kit_needed);
+ back.Install();
+ Wait(back);
+ back.RequestRestart();
+ back.Shutdown();
+ CHECK(back.ApplyAtQuit());
+ }
+ {
+ UpdateService again(renamed({0, 3, 0}));
+ again.Start();
+ Wait(again);
+ CHECK(!Exists(kits + "/oldkit") && previous_kits() == std::vector<std::string>{".previous-oldkit-1000"});
+ // The next update removes the retired kit with the other previous ones.
+ Publish(fixture.server, "v0.4.0", "0.2.0", "00.004.000");
+ again.Check(true);
+ Wait(again);
+ CHECK(again.Snapshot().phase == UpdatePhase::kAvailable && !again.Snapshot().kit_needed);
+ again.Install();
+ Wait(again);
+ again.RequestRestart();
+ again.Shutdown();
+ CHECK(again.ApplyAtQuit());
+ CHECK(Read(app + "/eboot.bin") == "eboot 0.4.0" && previous_kits().empty() && !Exists(kits + "/oldkit"));
+ CHECK(Read(kits + "/kitid/manifest.json") == kKitSha);
+ }
+ RemoveTree(fixture.root);
+ }
+ // Going back to a version whose kit was retired under its earlier id, when that version's update also replaced a kit
+ // under the new id (the same backup time): the retired kit is the one the older app reads, so it is restored.
+ {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("service-renamed-same-time");
+ Installed(fixture.root);
+ const std::string kits = fixture.root + "/playden/kits";
+ RemoveTree(kits + "/.previous-kitid-1");
+ Put(fixture.root + "/playden/self-update/backup/0.2.0-1000/eboot.bin", "eboot 0.2.0 backup");
+ Put(fixture.root + "/playden/self-update/backup/0.2.0-1000/sce_sys/param.json", "old param");
+ // The earlier id is listed first, as it is on the console.
+ Put(kits + "/.previous-kitid-1000/manifest.json", std::string(64, 'e'));
+ Put(kits + "/.previous-hl2kit-1000/manifest.json", std::string(64, 'f'));
+ auto config = fixture.Config({0, 3, 0});
+ config.kit_id = "kitid";
+ config.renamed_kit_ids = {"hl2kit"};
+ UpdateService service(config);
+ service.Start();
+ Wait(service);
+ CHECK(service.Snapshot().previous == "0.2.0");
+ service.RequestRollback();
+ service.Shutdown();
+ CHECK(service.ApplyAtQuit());
+ CHECK(Read(fixture.root + "/homebrew/FAKE77031/eboot.bin") == "eboot 0.2.0 backup");
+ CHECK(Read(kits + "/hl2kit/manifest.json") == std::string(64, 'f'));
+ CHECK(Read(kits + "/kitid/manifest.json") == std::string(64, 'b') && Exists(kits + "/.previous-kitid-1000"));
+ RemoveTree(fixture.root);
+ }
// A staged update survives a restart without a swap, and a swap that did not take is reported.
{
Fixture fixture;
diff --git a/tests/test_collect_logs.py b/tests/test_collect_logs.py
index 03a8397..6841d23 100644
--- a/tests/test_collect_logs.py
+++ b/tests/test_collect_logs.py
@@ -72,14 +72,20 @@ class CollectLogsTests(unittest.TestCase):
self.assertIsNone(collect_logs.firmware(['nothing']))
def test_reports_the_kit_runtime_not_its_folder_id(self):
- manifest = {'kit_id': 'hl2-fw1360-dev1', 'runtime': {'artifact_revision': 'f729534-kit-0.12'},
- 'capabilities': ['dxvk', 'wine-mono']}
+ manifests = {'old-kit': {'kit_id': 'old-kit', 'runtime': {'artifact_revision': 'f729534-kit-0.12'},
+ 'capabilities': ['dxvk', 'wine-mono']},
+ 'playden-kit': {'kit_id': 'playden-kit', 'runtime': {'artifact_revision': 'ce28942-kit-0.13'},
+ 'capabilities': ['dxvk']}}
folders, fetch = collect_logs.folders, collect_logs.fetch
- collect_logs.folders = lambda ftp, path: ['hl2-fw1360-dev1']
- collect_logs.fetch = lambda ftp, path: json.dumps(manifest).encode()
+ collect_logs.folders = lambda ftp, path: ['old-kit']
+ collect_logs.fetch = lambda ftp, path: json.dumps(manifests[path.split('/')[-2]]).encode()
try:
self.assertEqual(collect_logs.active_kit(None),
{'kit runtime': 'f729534-kit-0.12', 'kit capabilities': 'dxvk, wine-mono'})
+ # A kit left under the id it had before is not the one Playden uses.
+ collect_logs.folders = lambda ftp, path: ['.previous-x', 'old-kit', 'playden-kit']
+ self.assertEqual(collect_logs.active_kit(None), {'kit runtime': 'ce28942-kit-0.13', 'kit capabilities': 'dxvk',
+ 'other kit folders': 'old-kit'})
collect_logs.folders = lambda ftp, path: []
self.assertEqual(collect_logs.active_kit(None), {'kit runtime': None})
finally:
diff --git a/tests/write_update_manifest_test.py b/tests/write_update_manifest_test.py
index 73b3cd5..b7cddac 100644
--- a/tests/write_update_manifest_test.py
+++ b/tests/write_update_manifest_test.py
@@ -24,20 +24,20 @@ def run(*args):
def main():
with tempfile.TemporaryDirectory() as folder:
root = pathlib.Path(folder)
- manifest = json.dumps({"kit_id": "hl2-fw1360-dev1", "files": []}).encode()
+ manifest = json.dumps({"kit_id": "playden-kit", "files": []}).encode()
sha = hashlib.sha256(manifest).hexdigest()
- (root / "lock.json").write_text(json.dumps({"prospero_kit": {"kit_id": "hl2-fw1360-dev1", "manifest_sha256": sha}}))
+ (root / "lock.json").write_text(json.dumps({"prospero_kit": {"kit_id": "playden-kit", "manifest_sha256": sha}}))
app = root / "playden-ps5-0.3.0.zip"
with zipfile.ZipFile(app, "w") as archive:
archive.writestr("playden-ps5-0.3.0/tools/x.py", "")
archive.writestr("playden-ps5-0.3.0/FAKE77031/sce_sys/param.json",
json.dumps({"titleId": "FAKE77031", "contentVersion": "00.003.000"}))
- kit = root / "playden-kit-h-r9.zip"
+ kit = root / "playden-kit-0.13.zip"
with zipfile.ZipFile(kit, "w") as archive:
- archive.writestr("playden-kit-h-r9/LICENSES/a", "")
- archive.writestr("playden-kit-h-r9/hl2-fw1360-dev1/manifest.json", manifest)
+ archive.writestr("playden-kit-0.13/LICENSES/a", "")
+ archive.writestr("playden-kit-0.13/playden-kit/manifest.json", manifest)
out, release = root / "playden-update.json", root / "release.json"
- common = ["--app-zip", str(app), "--kit-zip", str(kit), "--kit-revision", "r9", "--min-from", "v0.2.0",
+ common = ["--app-zip", str(app), "--kit-zip", str(kit), "--kit-revision", "0.13", "--min-from", "v0.2.0",
"--lock", str(root / "lock.json"), "--out", str(out)]
result = run(*common, "--notes", "New things.", "--release-json", str(release))
check(result.returncode == 0, result.stderr)
@@ -45,8 +45,8 @@ def main():
check(update == {"format": 1,
"app": {"version": "0.3.0", "title_id": "FAKE77031", "min_from": "0.2.0",
"asset": "playden-ps5-0.3.0.zip", "prefix": "playden-ps5-0.3.0/FAKE77031/"},
- "kit": {"kit_id": "hl2-fw1360-dev1", "revision": "r9", "manifest_sha256": sha,
- "asset": "playden-kit-h-r9.zip", "prefix": "playden-kit-h-r9/hl2-fw1360-dev1/"},
+ "kit": {"kit_id": "playden-kit", "revision": "0.13", "manifest_sha256": sha,
+ "asset": "playden-kit-0.13.zip", "prefix": "playden-kit-0.13/playden-kit/"},
"notes": "New things."}, "manifest content")
# The notes are a short plain-text summary: Markdown and long text are refused.
check(run(*common, "--notes", "## What's new\n- Faster").returncode != 0, "markdown refused")
@@ -57,13 +57,13 @@ def main():
result = run(*common, "--notes", "New things.", "--release-json", str(release))
listing = json.loads(release.read_text())
check(listing["tag_name"] == "v0.3.0" and [a["name"] for a in listing["assets"]] ==
- ["playden-update.json", "playden-ps5-0.3.0.zip", "playden-kit-h-r9.zip"], "local release")
+ ["playden-update.json", "playden-ps5-0.3.0.zip", "playden-kit-0.13.zip"], "local release")
check(all(a["digest"].startswith("sha256:") and a["size"] > 0 for a in listing["assets"]), "digests")
# A kit the lock does not pin is refused unless a test allows it.
- (root / "lock.json").write_text(json.dumps({"prospero_kit": {"kit_id": "hl2-fw1360-dev1", "manifest_sha256": "0" * 64}}))
+ (root / "lock.json").write_text(json.dumps({"prospero_kit": {"kit_id": "playden-kit", "manifest_sha256": "0" * 64}}))
check(run(*common).returncode != 0, "unpinned kit refused")
check(run(*common, "--allow-other-kit").returncode == 0, "unpinned kit allowed for tests")
- check(run(*[a if a != "r9" else "../r9" for a in common], "--allow-other-kit").returncode != 0, "bad revision")
+ check(run(*[a if a != "0.13" else "../0.13" for a in common], "--allow-other-kit").returncode != 0, "bad revision")
print("ok")
diff --git a/tools/collect_logs.py b/tools/collect_logs.py
index 0a6f66c..d482958 100644
--- a/tools/collect_logs.py
+++ b/tools/collect_logs.py
@@ -26,6 +26,7 @@ LOGS = "/data/playden/logs"
OLD_LOGS = "/data/homebrew/FAKE77031/logs" # before 0.6.0
IDENTITY = "/data/homebrew/FAKE77031/playden-package.identity"
KITS = "/data/playden/kits"
+KIT_ID = "playden-kit"
TITLE_LOG = re.compile(r"^title-(FAKE\d{5})\.log$")
PROFILE = re.compile(r"profile=playden-steam-(\d+)")
REPORT_TIME = re.compile(r"^PW_REPORT/1 .*?\btime=(\d+)", re.MULTILINE)
@@ -179,19 +180,22 @@ def summary(info):
def active_kit(ftp):
- for name in folders(ftp, KITS):
- if name.startswith("."):
- continue
+ # The current kit folder first: a console updated from an earlier Playden may still hold the kit under the id it
+ # had before, until Playden retires it, and one gone back to that Playden uses it again. Other folders are listed.
+ names = sorted((name for name in folders(ftp, KITS) if not name.startswith(".")), key=lambda name: name != KIT_ID)
+ others = {"other kit folders": ", ".join(names[1:])} if len(names) > 1 else {}
+ for name in names:
try:
manifest = json.loads(fetch(ftp, f"{KITS}/{name}/manifest.json"))
except (ftplib.Error, ValueError):
continue
- # No kit_id: every kit release shares the same one (the install folder), so it says nothing.
+ # No kit_id: kit releases share it (the install folder), so it says nothing.
return {
"kit runtime": (manifest.get("runtime") or {}).get("artifact_revision"),
"kit capabilities": ", ".join(manifest.get("capabilities") or []),
+ **others,
}
- return {"kit runtime": None}
+ return {"kit runtime": None, **others}
def main():
diff --git a/tools/console_kit_upload.py b/tools/console_kit_upload.py
index 68cc43a..38e3630 100644
--- a/tools/console_kit_upload.py
+++ b/tools/console_kit_upload.py
@@ -169,6 +169,11 @@ def main():
print(f"deleted older copy {name}")
ftp.rename(staging, final)
print(f"verified {len(files)} files and {len(directories)} directories; installed {final}")
+ # A kit installed under another id (renamed since): Playden versions that use this id retire it at
+ # their next start, as a previous kit the next update removes; versions that use the other id keep it.
+ for name, (_, is_dir, _) in sorted(parent.items()):
+ if is_dir and not name.startswith(".") and name != kit_id:
+ print(f"note: {args.remote_parent}/{name} holds a kit under another id; it is left as it is")
ftp.quit()
return 0