Skip to content

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

C++

Add opt-in beta updates

Leonardo Lobatoa6b2dd06fe7c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad3d255..1af2cf7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,16 @@
cmake_minimum_required(VERSION 3.24)
project(PlaydenLauncher VERSION 0.7.0 LANGUAGES C CXX)
+set(PLAYDEN_PRERELEASE "" CACHE STRING "Pre-release suffix: empty or beta.N (1-999999)")
+set(PLAYDEN_FULL_VERSION "${PROJECT_VERSION}")
+if(NOT PLAYDEN_PRERELEASE STREQUAL "")
+ if(NOT PLAYDEN_PRERELEASE MATCHES "^beta\\.[1-9][0-9]*$" OR
+ NOT PLAYDEN_PRERELEASE MATCHES "^beta\\.[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]$")
+ message(FATAL_ERROR "PLAYDEN_PRERELEASE must be empty or beta.N (1-999999)")
+ endif()
+ string(APPEND PLAYDEN_FULL_VERSION "-${PLAYDEN_PRERELEASE}")
+endif()
+
option(PLAYDEN_UI_SIMULATION "Package selected PS5 UI with developer simulation fixtures" OFF)
option(PLAYDEN_PLATFORM_PS5 "Build a PS5 native title" OFF)
set(PLAYDEN_PS5_TITLE_ID "" CACHE STRING "Explicit PS5 title id (required for PS5 packaging)")
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4e27511..b1b5378 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -245,7 +245,7 @@ longer apply. Rebuilding the runtime and the kit follows prospero-win's `docs/WI
## Publish a release
Playden updates itself from the latest GitHub release (`releases/latest`, which leaves out drafts and
-pre-releases), so every release needs its update manifest:
+pre-releases). Players who enable Beta updates use the releases list, including betas. 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.
@@ -268,6 +268,14 @@ pre-releases), so every release needs its update manifest:
and Playden checks the downloads against it. If the kit did not change, the kit zip may be left out: consoles
that already have that kit download only the app.
+For a beta, keep the numeric version in `project()` (for example `0.7.1`) and configure with
+`-DPLAYDEN_PRERELEASE=beta.1`. The package writes `playden-version` as `0.7.1-beta.1`; About, the updater and log
+bundles use it. PS5's `param.json` cannot represent a pre-release: `contentVersion` stays `00.007.001` for all
+0.7.1 betas and the stable release. Set `PLAYDEN_PRERELEASE` back to empty for stable builds. Name the app zip
+`playden-ps5-0.7.1-beta.1.zip`, pass `--tag v0.7.1-beta.1` to the manifest tool to verify it matches the package,
+and **mark the GitHub release as a pre-release; never use `--latest` for a beta**. `--min-from` may name a beta.
+The kit pin and trust rules are the same as for stable releases.
+
To try an update on a console without publishing, put `release.json` (from `--release-json`, with
`--allow-other-kit` for a test kit), `playden-update.json` and the zips in `/data/homebrew/FAKE77031/dev/update-local/`.
Playden then reads the release from there instead of GitHub. Delete the folder afterwards.
diff --git a/README.md b/README.md
index 29811d0..e58c94a 100644
--- a/README.md
+++ b/README.md
@@ -151,17 +151,21 @@ ShadowMountPlus adds its tile to the Home screen.
Since 0.3.0, Playden updates itself from this repository's GitHub releases:
-- **Check:** at startup, and with Settings › About › Playden updates › Check now. When a newer release is out,
+- **Check:** at startup, and with Settings › Updates › Playden updates › Check now. When a newer release is out,
Playden offers it once, with its notes, its download size, and a QR code for its release page on GitHub.
- **Download:** Download and install fetches the new app and, when the release has a new one, the runtime kit. You
can follow the download on the Queue screen and keep using Playden meanwhile.
- **Restart:** when the update is ready, Restart Playden closes Playden, puts the new version and kit in place, and
opens Playden again. If it doesn't open by itself (the payload loader on port 9021 isn't running), open it from
- the Home screen. On that first start Playden shows what's new in the version; Settings › About › Release notes
+ the Home screen. On that first start Playden shows what's new in the version; Settings › Updates › Release notes
shows it again later.
+Settings › Updates › **Beta updates** opts into test versions before their stable release. It is off by default;
+betas can have new bugs and use the same app and data. Turning it off keeps an installed beta until a newer stable
+version is available. Updates never downgrade Playden.
+
The previous app and kit are kept until the next update, in `/data/playden/self-update/backup/` and
-`/data/playden/kits/.previous-*`. Settings › About › **Go back to Playden <version>** puts them back: Playden
+`/data/playden/kits/.previous-*`. Settings › Updates › **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, if the new kit is at fault, rename the previous
diff --git a/cmake/HomebrewPS5.cmake b/cmake/HomebrewPS5.cmake
index 1d12257..af64c56 100644
--- a/cmake/HomebrewPS5.cmake
+++ b/cmake/HomebrewPS5.cmake
@@ -280,7 +280,7 @@ function(playden_add_homebrew_ps5_title)
COMMAND "${CMAKE_COMMAND}" -DAPP_DIR=${app} -DBOILERPLATE=${boilerplate}
-DASSETS_DIR=${CMAKE_SOURCE_DIR}/fixtures/ui-comparison/assets -DFONTS_DIR=${CMAKE_SOURCE_DIR}/build/homebrew-fonts
-DPARAM_SOURCE=${gl_source}/native-app/param.json -DPARAM_DEST=${app}/sce_sys/param.json
- -DTITLE_ID=${PLAYDEN_PS5_TITLE_ID} "-DTITLE_NAME=${playden_title_name}" -DAPP_VERSION=${PROJECT_VERSION}
+ -DTITLE_ID=${PLAYDEN_PS5_TITLE_ID} "-DTITLE_NAME=${playden_title_name}" -DAPP_VERSION=${PROJECT_VERSION} -DFULL_VERSION=${PLAYDEN_FULL_VERSION}
-P "${CMAKE_SOURCE_DIR}/cmake/PackagePS5.cmake"
${simulation_package_commands}
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_SOURCE_DIR}/runtime" "${app}/runtime"
diff --git a/cmake/PackagePS5.cmake b/cmake/PackagePS5.cmake
index fb6ccc1..36b0bb4 100644
--- a/cmake/PackagePS5.cmake
+++ b/cmake/PackagePS5.cmake
@@ -53,3 +53,6 @@ if(PROBE_CA_BUNDLE)
file(MAKE_DIRECTORY "${APP_DIR}/probe")
file(COPY "${PROBE_CA_BUNDLE}" DESTINATION "${APP_DIR}/probe")
endif()
+
+# The PS5 field stays numeric; the updater and log bundle use the full release version.
+file(WRITE "${APP_DIR}/playden-version" "${FULL_VERSION}\n")
diff --git a/cmake/SelfUpdate.cmake b/cmake/SelfUpdate.cmake
index 1c54612..513b4ed 100644
--- a/cmake/SelfUpdate.cmake
+++ b/cmake/SelfUpdate.cmake
@@ -15,7 +15,7 @@ add_library(playden_self_update STATIC
"${CMAKE_SOURCE_DIR}/src/update/update_service.cpp")
target_include_directories(playden_self_update PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_compile_features(playden_self_update PUBLIC cxx_std_17)
-target_compile_definitions(playden_self_update PRIVATE PLAYDEN_VERSION="${PROJECT_VERSION}")
+target_compile_definitions(playden_self_update PRIVATE PLAYDEN_VERSION="${PLAYDEN_FULL_VERSION}")
target_link_libraries(playden_self_update PUBLIC playden_miniz playden_steam_protocol playden_steam_http Threads::Threads)
if(PLAYDEN_PLATFORM_PS5)
target_compile_options(playden_self_update PRIVATE -fno-exceptions -fno-rtti)
@@ -26,7 +26,7 @@ if(BUILD_TESTING AND NOT PLAYDEN_PLATFORM_PS5)
self_update_swap self_update_service)
add_executable(${test_name}_test "${CMAKE_SOURCE_DIR}/tests/${test_name}_test.cpp")
target_link_libraries(${test_name}_test PRIVATE playden_self_update)
- target_compile_definitions(${test_name}_test PRIVATE PLAYDEN_VERSION="${PROJECT_VERSION}")
+ target_compile_definitions(${test_name}_test PRIVATE PLAYDEN_VERSION="${PLAYDEN_FULL_VERSION}")
add_test(NAME ${test_name} COMMAND ${test_name}_test)
endforeach()
endif()
diff --git a/src/app/preferences.cpp b/src/app/preferences.cpp
index 49cca18..2aa7b07 100644
--- a/src/app/preferences.cpp
+++ b/src/app/preferences.cpp
@@ -31,10 +31,20 @@ PreferencesLoadResult PreferencesStore::Load() const {
"Preferences could not be read; defaults restored: " + read.message()};
}
- const std::string serialized = ToString(read.value());
+ std::string serialized = ToString(read.value());
+ bool beta_updates = false;
+ if (serialized.rfind("version=7\n", 0) == 0) {
+ const auto suffix = serialized.rfind("beta_updates=");
+ if (suffix == std::string::npos || (serialized.substr(suffix) != "beta_updates=0\n" &&
+ serialized.substr(suffix) != "beta_updates=1\n"))
+ return {Preferences{}, PreferencesLoadStatus::kDefaultCorrupt, "Preferences could not be read; defaults restored."};
+ beta_updates = serialized.substr(suffix) == "beta_updates=1\n";
+ serialized.erase(suffix);
+ serialized.replace(0, 9, "version=6");
+ }
// Version 1 holds only reduce_motion; version 2 adds title_store_suffix; version 3 cloud_saves_auto;
// version 4 steam_sign_in_password; version 5 downloads_slow_network; version 6 steam_stay_signed_in
- // (on in files older than that).
+ // (on in files older than that). Version 7 appends beta_updates (off in older files).
for (const int motion : {0, 1}) {
if (serialized == std::string("version=1\nreduce_motion=") + char('0' + motion) + "\n") {
Preferences preferences;
@@ -105,6 +115,7 @@ PreferencesLoadResult PreferencesStore::Load() const {
preferences.steam_sign_in_password = password == 1;
preferences.downloads_slow_network = slow == 1;
preferences.steam_stay_signed_in = stay == 1;
+ preferences.beta_updates = beta_updates;
return PreferencesLoadResult{preferences, PreferencesLoadStatus::kLoaded, std::string()};
}
}
@@ -116,12 +127,13 @@ PreferencesLoadResult PreferencesStore::Load() const {
Result<void> PreferencesStore::Save(const Preferences& preferences) const {
const auto ready=storage_.EnsureRootDirectory();
if(!ready.ok()) return ready;
- const std::string text = std::string("version=6\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
+ const std::string text = std::string("version=7\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
"\ntitle_store_suffix=" + (preferences.title_store_suffix ? "1" : "0") +
"\ncloud_saves_auto=" + (preferences.cloud_saves_auto ? "1" : "0") +
"\nsteam_sign_in_password=" + (preferences.steam_sign_in_password ? "1" : "0") +
"\ndownloads_slow_network=" + (preferences.downloads_slow_network ? "1" : "0") +
- "\nsteam_stay_signed_in=" + (preferences.steam_stay_signed_in ? "1" : "0") + "\n";
+ "\nsteam_stay_signed_in=" + (preferences.steam_stay_signed_in ? "1" : "0") +
+ "\nbeta_updates=" + (preferences.beta_updates ? "1" : "0") + "\n";
return storage_.WriteAtomic(kPreferencesPath, Bytes(text.begin(), text.end()));
}
diff --git a/src/app/preferences.h b/src/app/preferences.h
index 18266a9..95db29a 100644
--- a/src/app/preferences.h
+++ b/src/app/preferences.h
@@ -22,6 +22,7 @@ struct Preferences {
// "Stay signed in" on the sign-in screen. Off, Steam's sign-in token stays in memory only and is never
// saved on the PS5, so every Playden start asks for a sign-in. On (the default) keeps it in session.v1.
bool steam_stay_signed_in = true;
+ bool beta_updates = false;
};
enum class PreferencesLoadStatus {
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 26bcb20..71fb655 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -2124,8 +2124,14 @@ void Controller::TickLicenseChanges() {
}
void Controller::TickSelfUpdate() {
if (!self_update_) return;
+ // The track starts from the saved preference (ps5.cpp); only the Settings toggle changes it, so a
+ // preference that hasn't loaded yet can't switch tracks at startup.
for (const auto& request : model_.TakeSelfUpdateRequests()) {
- if (request == "check") self_update_->Check(true);
+ if (request == "check") self_update_check_pending_ = true;
+ else if (request == "betas-on" || request == "betas-off") {
+ self_update_->SetIncludeBetas(request == "betas-on");
+ self_update_check_pending_ = true;
+ }
else if (request == "install") self_update_->Install();
else if (request == "cancel") self_update_->Cancel();
else if (request == "restart") self_update_->RequestRestart();
@@ -2135,6 +2141,11 @@ void Controller::TickSelfUpdate() {
else if (request == "kit-install") self_update_->InstallKit();
else if (request == "kit-cancel") self_update_->Cancel();
}
+ // Retain checks across busy downloads and occupied worker queues, including opt-out then cancel.
+ if (self_update_check_pending_ && !self_update_->Busy()) {
+ self_update_check_pending_ = false;
+ self_update_->Check(true);
+ }
// The runtime started without a usable kit (a first run), or with another kit than the one this
// version was made for: the running version's kit is looked for once, after the startup update
// check, before sign-in.
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index e3b1422..f593109 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -117,6 +117,7 @@ class Controller {
std::optional<std::uint64_t> seen_license_changes_;
std::optional<std::chrono::steady_clock::time_point> license_refresh_at_;
update::UpdateService* self_update_ = nullptr;
+ bool self_update_check_pending_ = false;
std::uint64_t self_update_revision_ = ~0ull;
steam::DownloadRate self_update_rate_;
std::string self_update_rate_part_;
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index d993bb2..e0b9247 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -388,6 +388,7 @@ int main() {
update_config.registered_app_root = std::string("/user/app/") + PLAYDEN_PS5_TITLE_ID;
update_config.layout_journal = "/data/playden/runtime-state/layout-0.6.json";
update_config.current = playden::update::CurrentVersion();
+ update_config.include_betas = preferences.Load().preferences.beta_updates;
update_config.fetch = [&update_http](const playden::steam::HttpRequest& request, const std::atomic<bool>& cancel) {
return update_http.Perform(request, cancel);
};
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index a52775f..85b12ce 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1697,7 +1697,7 @@ 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") {
- ModalEntry prompt{"confirmation", "Playden " + update.available + " is available", state_.navigation.focus_key,
+ 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) +
@@ -1774,6 +1774,7 @@ void Simulation::open_release_notes(bool after_update) {
const auto& update = state_.self_update;
ModalEntry notes{"confirmation",
(after_update ? "What's new in Playden " : "Playden ") + update.current +
+ (update.current.find("-beta.") != std::string::npos ? " (Beta)" : "") +
(after_update ? std::string() : std::string(" release notes")),
state_.navigation.focus_key, {"release-notes-ok"}, 0, false};
notes.body = (after_update ? "Playden was updated to " + update.current + ".\n\n" : std::string()) +
@@ -2564,7 +2565,7 @@ playden::OrganizationSnapshot Simulation::ExportOrganization() const {
playden::Preferences Simulation::ExportPreferences() const {
return {state_.reduced_motion, state_.title_store_suffix, state_.cloud_saves_auto, state_.sign_in_password,
- state_.downloads_slow_network, state_.stay_signed_in};
+ state_.downloads_slow_network, state_.stay_signed_in, state_.beta_updates};
}
void Simulation::apply_organization_snapshot(const playden::OrganizationSnapshot& snapshot) {
@@ -2789,6 +2790,7 @@ bool Simulation::ApplyPreferences(PersistenceLoadToken token,
state_.title_store_suffix = loaded.preferences.title_store_suffix;
state_.cloud_saves_auto = loaded.preferences.cloud_saves_auto;
state_.sign_in_password = loaded.preferences.steam_sign_in_password;
+ state_.beta_updates = loaded.preferences.beta_updates;
state_.downloads_slow_network = loaded.preferences.downloads_slow_network;
state_.stay_signed_in = loaded.preferences.steam_stay_signed_in;
captured_preferences_ = loaded.preferences;
@@ -2869,6 +2871,7 @@ bool Simulation::record_live_persistence() {
after_preferences.cloud_saves_auto != captured_preferences_.cloud_saves_auto ||
after_preferences.steam_sign_in_password != captured_preferences_.steam_sign_in_password ||
after_preferences.downloads_slow_network != captured_preferences_.downloads_slow_network ||
+ after_preferences.beta_updates != captured_preferences_.beta_updates ||
after_preferences.steam_stay_signed_in != captured_preferences_.steam_stay_signed_in);
if (organization_changed && !snapshot_within_model_bounds(after_organization)) {
@@ -2891,6 +2894,7 @@ bool Simulation::record_live_persistence() {
state_.title_store_suffix = captured_preferences_.title_store_suffix;
state_.cloud_saves_auto = captured_preferences_.cloud_saves_auto;
state_.sign_in_password = captured_preferences_.steam_sign_in_password;
+ state_.beta_updates = captured_preferences_.beta_updates;
state_.downloads_slow_network = captured_preferences_.downloads_slow_network;
state_.stay_signed_in = captured_preferences_.steam_stay_signed_in;
organization_journal_full_ = true;
@@ -4353,7 +4357,8 @@ void Simulation::rebuild_view() {
else if (action_key == "account-auth") { item.kind = RowKind::Status; item.value = auth_name(state_.account().authentication); item.subtitle = state_.account().error; item.enabled = false; }
else if (action_key == "account-last-sync") { item.kind = RowKind::Status; item.value = state_.account().last_sync == 0 ? "Never" : std::to_string(state_.account().last_sync); item.enabled = false; }
else if (action_key.rfind("open-game:", 0) == 0) item.title = "Open game";
- else if (action_key == "about-version") { item.kind = RowKind::Status; item.value = live() ? "Playden " + state_.self_update.current : "Simulated"; item.enabled = false; }
+ else if (action_key == "about-version") { item.kind = RowKind::Status; item.value = live() ? "Playden " + state_.self_update.current +
+ (state_.self_update.current.find("-beta.") != std::string::npos ? " (Beta)" : "") : "Simulated"; item.enabled = false; }
else if (action_key == "about-build") { item.kind = RowKind::Status; item.value = live() ? "Live service model" : "UI comparison fixture"; item.enabled = false; }
else if (action_key == "about-framework") { item.kind = RowKind::Status; item.value = "Homebrew native model + Hui"; item.enabled = false; }
else if (action_key == "about-platform") { item.kind = RowKind::Status; item.value = "Host / PS5 homebrew"; item.enabled = false; }
@@ -5162,8 +5167,11 @@ void Simulation::rebuild_view() {
controller.value = state_.controller_connected ? "Connected" : "Disconnected";
controller.subtitle = "Test the buttons and sticks";
}
- section = "About";
+ section = "Updates";
if (live()) {
+ auto& beta = add("settings-beta-updates", RowKind::Toggle, "Beta updates", "toggle-beta-updates");
+ beta.selected = state_.beta_updates;
+ beta.subtitle = "Get test versions before they are released. They can have new bugs.";
const auto& update = state_.self_update;
auto& item = add("settings-update", RowKind::Action, "Playden updates", "self-update");
if (update.phase == "checking") {
@@ -5184,10 +5192,15 @@ void Simulation::rebuild_view() {
item.subtitle = update.error;
} else {
item.value = "Check now";
- item.subtitle = update.phase == "up-to-date" ? "Version " + update.current + " is the latest"
+ item.subtitle = update.phase == "up-to-date" ? "No newer update for version " + update.current
: "Version " + update.current;
}
}
+ if (live() && !state_.beta_updates && state_.self_update.current.find("-beta.") != std::string::npos) {
+ auto& note = add("settings-beta-wait", RowKind::Status, "You have a beta", "");
+ note.subtitle = "Playden moves to the next stable version when it is out.";
+ note.enabled = false;
+ }
// The kit-only install, while it has something to offer or say.
if (live()) {
const auto& update = state_.self_update;
@@ -5224,6 +5237,7 @@ void Simulation::rebuild_view() {
auto& notes = add("settings-release-notes", RowKind::Action, "Release notes", "self-update-notes");
notes.subtitle = "What changed in Playden " + state_.self_update.current;
}
+ section = "About";
add("settings-about", RowKind::Action, "About", "about").subtitle = "Playden for PlayStation 5";
auto& logs = add("settings-logs", RowKind::Action, "Logs", live() ? "logs-pick" : "logs");
if (live()) {
@@ -7460,6 +7474,10 @@ void Simulation::activate() {
else if (action_name == "about") open_modal({"about", live() ? "About Playden" : "About Playden UI simulation", state_.navigation.focus_key,
{"about-version", "about-build", "about-framework", "about-platform", "about-kit", "about-kit-source", "about-back"}, 0, false});
else if (action_name == "about-back") close_modal();
+ else if (live() && action_name == "toggle-beta-updates") {
+ state_.beta_updates = !state_.beta_updates;
+ self_update_requests_.push_back(state_.beta_updates ? "betas-on" : "betas-off");
+ }
else if (live() && action_name == "self-update") {
const auto& phase = state_.self_update.phase;
if (phase == "available") { pending_update_prompt_ = "available"; show_update_prompt(); }
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 90f7754..9effa62 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -626,6 +626,7 @@ struct State {
bool reduced_motion = false;
bool title_store_suffix = false; // PS5 titles named "<game> (Steam)"
bool cloud_saves_auto = false; // Cloud saves move before Play, after sessions and at startup (opt-in)
+ bool beta_updates = false;
bool downloads_slow_network = false; // 8 download pieces at a time instead of 4 (Settings › Storage)
bool controller_connected = true;
ControllerState controller;
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index b0f6f3b..1bfc3e4 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -111,7 +111,7 @@ const char* KitInstallPhaseName(KitInstallPhase phase) {
return "?";
}
-UpdateService::UpdateService(UpdateConfig config) : config_(std::move(config)), shared_(std::make_shared<Shared>()) {
+UpdateService::UpdateService(UpdateConfig config) : config_(std::move(config)), include_betas_(config_.include_betas), shared_(std::make_shared<Shared>()) {
if (!config_.as_root) config_.as_root = [](const std::function<bool()>& work) { return work(); };
if (!config_.now) config_.now = [] { return static_cast<std::int64_t>(time(nullptr)); };
shared_->snapshot.current = config_.current;
@@ -539,6 +539,8 @@ void UpdateService::ConfirmApplied(const std::string& text) {
FindPrevious();
}
+bool UpdateService::SetIncludeBetas(bool enabled) { return include_betas_.exchange(enabled) != enabled; }
+
void UpdateService::Check(bool user_asked) {
{
std::lock_guard<std::mutex> lock(shared_->mutex);
@@ -551,6 +553,11 @@ void UpdateService::Check(bool user_asked) {
void UpdateService::Install() {
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()) {
+ DoCheck(false);
+ return;
+ }
if (!release_ || !manifest_) DoCheck(false);
if (Snapshot().phase != UpdatePhase::kAvailable) return;
DoInstall();
@@ -574,16 +581,28 @@ void UpdateService::DoCheck(bool user_asked) {
return std::nullopt;
};
if (local) Log("reading the release from " + config_.local_release_dir);
- const auto body = local ? read_local("release.json")
- : FetchSmall(config_.latest_release_url, 2 << 20, options, "application/vnd.github+json", &error);
- if (!body) return Fail("Playden could not reach GitHub to look for updates.", error);
- const auto release = ParseRelease(*body, &error);
- if (!release) return Fail("The latest release on GitHub could not be read.", error);
- if (release->draft || release->prerelease || !(config_.current < release->version)) {
- Log("up to date: running " + config_.current.ToString() + ", latest " + release->tag);
+ const bool include_betas = include_betas_.load();
+ std::optional<Release> release;
+ if (include_betas) {
+ const auto releases = FetchReleases(&error);
+ if (!releases) return Fail("Playden could not read the releases on GitHub.", error);
+ for (const auto& candidate : *releases)
+ if (!candidate.draft && (!release || release->version < candidate.version)) release = candidate;
+ } else {
+ const auto body = local ? read_local("release.json")
+ : FetchSmall(config_.latest_release_url, 2 << 20, options, "application/vnd.github+json", &error);
+ if (!body) return Fail("Playden could not reach GitHub to look for updates.", error);
+ release = ParseRelease(*body, &error);
+ if (!release) return Fail("The latest release on GitHub could not be read.", error);
+ if (release->draft || release->prerelease || release->version.beta) release.reset();
+ }
+ if (!release || !(config_.current < release->version)) {
+ Log("up to date: running " + config_.current.ToString());
+ release_.reset();
+ manifest_.reset();
Set([&](UpdateSnapshot& s) {
s.phase = UpdatePhase::kUpToDate;
- s.available = release->version;
+ s.available = release ? release->version : config_.current;
});
return;
}
@@ -987,8 +1006,15 @@ bool UpdateService::StageApp(const Release& release, const UpdateManifest& manif
const auto* title = param && param->is_object() ? param->Find("titleId") : nullptr;
const auto* content = param && param->is_object() ? param->Find("contentVersion") : nullptr;
const auto content_version = content && content->is_string() ? ParseVersion(content->text()) : std::nullopt;
+ std::string full_text;
+ const bool has_full = ReadSmallFile(stage + "/playden-version", &full_text, 64);
+ if (!full_text.empty() && full_text.back() == '\n') full_text.pop_back();
+ 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() != config_.title_id || !content_version ||
- *content_version != release.version || !Exists(stage + "/eboot.bin")) {
+ *content_version != numeric || !full_version || *full_version != release.version ||
+ !Exists(stage + "/eboot.bin")) {
RemoveOwnedTree(stage);
Fail("The downloaded Playden is not version " + release.version.ToString() + ".", "param.json");
return false;
diff --git a/src/update/update_service.h b/src/update/update_service.h
index 475615a..9bc9fc7 100644
--- a/src/update/update_service.h
+++ b/src/update/update_service.h
@@ -38,6 +38,7 @@ struct UpdateConfig {
// going back below 0.6.0 is refused whatever the current version. Empty: the version rule only.
std::string layout_journal;
Version current;
+ bool include_betas = false;
Fetch fetch;
std::function<std::optional<std::string>(const std::string& path)> hash_file;
// The verified kit's manifest SHA-256, or nullopt when the folder is not a complete kit.
@@ -134,6 +135,8 @@ class UpdateService {
void Start();
// Looks for a newer release in the background. Ignored while the worker is busy.
void Check(bool user_asked);
+ // Thread-safe: the worker reads the current preference at each check.
+ bool SetIncludeBetas(bool enabled); // returns whether the preference changed
// Downloads, unpacks and stages the available release in the background.
void Install();
void Cancel();
@@ -201,6 +204,7 @@ class UpdateService {
void CleanUpLeftovers();
UpdateConfig config_;
+ std::atomic<bool> include_betas_{false};
std::shared_ptr<Shared> shared_;
std::optional<Release> release_;
std::optional<UpdateManifest> manifest_;
diff --git a/src/update/version.cpp b/src/update/version.cpp
index 0fba451..f8fbbd2 100644
--- a/src/update/version.cpp
+++ b/src/update/version.cpp
@@ -7,7 +7,8 @@
namespace playden::update {
std::string Version::ToString() const {
- return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
+ return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch) +
+ (beta ? "-beta." + std::to_string(beta) : "");
}
std::optional<Version> ParseVersion(std::string_view text) {
@@ -28,8 +29,17 @@ std::optional<Version> ParseVersion(std::string_view text) {
text.remove_prefix(1);
}
}
- if (!text.empty()) return std::nullopt;
- return Version{parts[0], parts[1], parts[2]};
+ unsigned beta = 0;
+ if (!text.empty()) {
+ if (text.substr(0, 6) != "-beta.") return std::nullopt;
+ text.remove_prefix(6);
+ if (text.empty() || text.size() > 6 || text.front() == '0') return std::nullopt;
+ for (const char c : text) {
+ if (c < '0' || c > '9') return std::nullopt;
+ beta = beta * 10 + static_cast<unsigned>(c - '0');
+ }
+ }
+ return Version{parts[0], parts[1], parts[2], beta};
}
Version CurrentVersion() {
diff --git a/src/update/version.h b/src/update/version.h
index 9a45e67..15af763 100644
--- a/src/update/version.h
+++ b/src/update/version.h
@@ -12,21 +12,24 @@ struct Version {
unsigned major = 0;
unsigned minor = 0;
unsigned patch = 0;
+ unsigned beta = 0; // 0 is stable, newer than every beta of the same version.
std::string ToString() const; // "0.2.0"
friend bool operator==(const Version& a, const Version& b) {
- return a.major == b.major && a.minor == b.minor && a.patch == b.patch;
+ return a.major == b.major && a.minor == b.minor && a.patch == b.patch && a.beta == b.beta;
}
friend bool operator!=(const Version& a, const Version& b) { return !(a == b); }
friend bool operator<(const Version& a, const Version& b) {
if (a.major != b.major) return a.major < b.major;
if (a.minor != b.minor) return a.minor < b.minor;
- return a.patch < b.patch;
+ if (a.patch != b.patch) return a.patch < b.patch;
+ if (a.beta == b.beta) return false;
+ return a.beta != 0 && (b.beta == 0 || a.beta < b.beta);
}
};
// Three dot-separated numbers, with an optional leading "v". Each part is 1-6 digits (param.json
-// pads them with zeros). Anything else, such as "0.2" or "0.2.0-beta", is refused.
+// pads them with zeros). Optional suffix: -beta.N, N is 1-999999 with no leading zero.
std::optional<Version> ParseVersion(std::string_view text);
// The version this build was made from (CMake's PROJECT_VERSION).
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index bfc300f..6099443 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -1204,8 +1204,8 @@ void live_storage_section_and_installed_games() {
std::vector<std::string> sections;
for (const auto& row : model.view().rows)
if (sections.empty() || sections.back() != row.section) sections.push_back(row.section);
- check(sections == std::vector<std::string>{"Account", "Library", "Storage", "Display", "About", "Quit Playden"},
- "the rail order is Account, Library, Storage, Display, About, Quit");
+ check(sections == std::vector<std::string>{"Account", "Library", "Storage", "Display", "Updates", "About", "Quit Playden"},
+ "the rail order is Account, Library, Storage, Display, Updates, About, Quit");
const auto* empty = find_row(model, "settings-installed");
check(empty && !empty->enabled && empty->value == "None", "nothing installed says None");
check(find_row(model, "settings-kept")->value == "None" && !has_row(model, "settings-runtime-cleanup"),
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 5af4a62..c8c860c 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -812,7 +812,21 @@ void live_self_update(const std::filesystem::path& base) {
check(model.UpdateLibrary({{}, false, {}, false, true, 100}), "update: library delivered");
for (int i = 0; i < 6 && model.state().navigation.route != Route::Settings; ++i) model.action("r1");
check(model.state().navigation.route == Route::Settings, "update: settings open");
+ check(find_row(model, "settings-beta-updates") && !find_row(model, "settings-beta-updates")->selected,
+ "beta updates default off");
+ activate(model, "settings-beta-updates");
+ check(find_row(model, "settings-beta-updates")->selected, "beta updates turn on");
+ check(model.ExportPreferences().beta_updates, "beta opt-in exported for persistence");
+ check(model.TakeSelfUpdateRequests() == std::vector<std::string>{"betas-on"}, "enabling betas switches the track");
+ activate(model, "settings-beta-updates");
+ check(model.TakeSelfUpdateRequests() == std::vector<std::string>{"betas-off"}, "disabling betas switches back");
LiveSelfUpdate update;
+ update.current = "0.7.1-beta.1";
+ model.UpdateSelfUpdate(update);
+ check(find_row(model, "settings-beta-wait") &&
+ find_row(model, "settings-beta-wait")->subtitle ==
+ "Playden moves to the next stable version when it is out.",
+ "opting out on a beta explains waiting for stable");
update.current = "0.2.0";
model.UpdateSelfUpdate(update);
check(find_row(model, "settings-update") && find_row(model, "settings-update")->value == "Check now",
diff --git a/tests/preferences_test.cpp b/tests/preferences_test.cpp
index 6a3060c..b697f48 100644
--- a/tests/preferences_test.cpp
+++ b/tests/preferences_test.cpp
@@ -186,9 +186,9 @@ void SignInMethodPersistsAndVersionThreeOpensQr() {
Check(store.Save(preferences).ok(), "sign-in method preference saves");
const auto saved = storage.Read("preferences.conf");
Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()) ==
- "version=6\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
- "downloads_slow_network=0\nsteam_stay_signed_in=1\n",
- "version 6 format");
+ "version=7\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
+ "downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\n",
+ "version 7 format");
const auto loaded = store.Load();
Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.steam_sign_in_password &&
loaded.preferences.cloud_saves_auto,
@@ -201,6 +201,11 @@ void SignInMethodPersistsAndVersionThreeOpensQr() {
three.preferences.title_store_suffix && three.preferences.cloud_saves_auto &&
!three.preferences.steam_sign_in_password,
"version 3 preferences load and sign in with the QR code");
+ Check(!store.Load().preferences.beta_updates, "old preferences default to stable updates");
+ preferences.beta_updates = true;
+ Check(store.Save(preferences).ok() && store.Load().preferences.beta_updates, "beta opt-in survives restart");
+ preferences.beta_updates = false;
+ Check(store.Save(preferences).ok() && !store.Load().preferences.beta_updates, "beta opt-out survives restart");
preferences.downloads_slow_network = true;
Check(store.Save(preferences).ok() && store.Load().preferences.downloads_slow_network,
"downloads for slow networks survive restart");
diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cpp
index 2d0d7ea..5b7ed89 100644
--- a/tests/self_update_service_test.cpp
+++ b/tests/self_update_service_test.cpp
@@ -86,10 +86,11 @@ struct Server {
}
};
-std::string AppZip(const std::string& version_text, const std::string& content_version) {
+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 + "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},
@@ -104,9 +105,9 @@ 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& 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);
+ 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":"FAKE77031","min_from":")" + min_from +
@@ -197,6 +198,106 @@ void Installed(const std::string& root) {
} // namespace
int main() {
+ // Opt-in selects by version, never GitHub list order; disabling never downgrades.
+ {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("beta-track");
+ Installed(fixture.root);
+ Publish(fixture.server, "v0.7.1-beta.2", "0.7.0", "00.007.001");
+ auto beta = fixture.server.latest;
+ beta.replace(beta.find("\"prerelease\":false"), 18, "\"prerelease\":true");
+ fixture.server.releases = "[{\"tag_name\":\"v99.0.0\",\"draft\":true,\"assets\":[]}," + beta +
+ ",{\"tag_name\":\"nightly\",\"prerelease\":true,\"assets\":[]},"
+ "{\"tag_name\":\"v0.7.0\",\"assets\":[]}]";
+ fixture.server.latest = R"({"tag_name":"v0.7.0","assets":[]})";
+ auto config = fixture.Config({0, 7, 0});
+ config.include_betas = true;
+ UpdateService service(config);
+ service.Check(true); Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kAvailable);
+ CHECK(service.Snapshot().available.ToString() == "0.7.1-beta.2");
+ // A stable release wins over every beta of its version, even if listed last.
+ Publish(fixture.server, "v0.7.1", "0.7.0", "00.007.001");
+ fixture.server.releases = "[" + beta + "," + fixture.server.latest + "]";
+ service.Check(true); Wait(service);
+ CHECK(service.Snapshot().available.ToString() == "0.7.1");
+ config.current = *ParseVersion("0.7.1-beta.2");
+ config.include_betas = false;
+ Publish(fixture.server, "v0.7.0", "0.7.0", "00.007.000");
+ UpdateService stable(config);
+ stable.Check(true); Wait(stable);
+ CHECK(stable.Snapshot().phase == UpdatePhase::kUpToDate);
+ fixture.server.latest = beta;
+ stable.Check(true); Wait(stable);
+ CHECK(stable.Snapshot().phase == UpdatePhase::kUpToDate);
+ Publish(fixture.server, "v0.7.1-beta.3", "0.7.1-beta.2", "00.007.001");
+ fixture.server.releases = "[" + fixture.server.latest + "]";
+ stable.SetIncludeBetas(true);
+ stable.Check(true); Wait(stable);
+ CHECK(stable.Snapshot().available.ToString() == "0.7.1-beta.3");
+ stable.Install(); Wait(stable);
+ CHECK(stable.Snapshot().phase == UpdatePhase::kStaged);
+ // The local override uses the same opt-in rule and needs no GitHub request.
+ config.include_betas = true;
+ config.local_release_dir = fixture.root + "/local";
+ auto local_release = fixture.server.latest;
+ local_release.replace(local_release.find("\"prerelease\":false"), 18, "\"prerelease\":true");
+ Put(config.local_release_dir + "/release.json", local_release);
+ Put(config.local_release_dir + "/playden-update.json", fixture.server.files[kDownload + "playden-update.json"]);
+ const int before = fixture.server.requests;
+ UpdateService local(config);
+ local.Check(true); Wait(local);
+ CHECK(local.Snapshot().phase == UpdatePhase::kAvailable);
+ CHECK(fixture.server.requests == before);
+ // The tag must match the full manifest version, including beta number.
+ auto mismatch = fixture.server.files[kDownload + "playden-update.json"];
+ mismatch.replace(mismatch.find("0.7.1-beta.3"), 12, "0.7.1-beta.4");
+ Put(config.local_release_dir + "/playden-update.json", mismatch);
+ local.Check(true); Wait(local);
+ CHECK(local.Snapshot().phase == UpdatePhase::kFailed);
+ }
+ // Opting out during a download and cancelling must not leave a beta installable.
+ {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("beta-cancel-opt-out");
+ Installed(fixture.root);
+ Publish(fixture.server, "v0.7.1-beta.1", "0.7.0", "00.007.001");
+ fixture.server.releases = "[" + fixture.server.latest + "]";
+ fixture.server.latest = R"({"tag_name":"v0.7.0","assets":[]})";
+ auto config = fixture.Config({0, 7, 0});
+ config.include_betas = true;
+ UpdateService* running = nullptr;
+ bool cancelled = false;
+ config.fetch = [&](const HttpRequest& request, const std::atomic<bool>&) {
+ if (!cancelled && request.url.find(".zip") != std::string::npos) {
+ cancelled = true;
+ running->SetIncludeBetas(false);
+ running->Check(true);
+ running->Cancel();
+ }
+ return fixture.server(request);
+ };
+ UpdateService service(config);
+ running = &service;
+ service.Check(true); Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kAvailable);
+ service.Install(); Wait(service);
+ CHECK(cancelled && service.Snapshot().phase == UpdatePhase::kAvailable);
+ service.Install(); Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kUpToDate);
+ RemoveTree(fixture.root);
+ }
+ // Present full-version metadata must be readable and match, even for stable packages.
+ for (const auto& metadata : {std::string(65, 'x'), std::string("0.7.1-beta.9\n")}) {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("bad-full-version");
+ Installed(fixture.root);
+ Publish(fixture.server, "v0.7.1", "0.7.0", "00.007.001", true, true, "r9", metadata);
+ UpdateService service(fixture.Config({0, 7, 0}));
+ service.Install(); Wait(service);
+ CHECK(service.Snapshot().phase == UpdatePhase::kFailed);
+ RemoveTree(fixture.root);
+ }
// First run on a console without a kit: the running version's kit is found and put in place at once.
{
KitOnly test("kit-fresh", "");
diff --git a/tests/self_update_version_test.cpp b/tests/self_update_version_test.cpp
index 629d6e7..8e6e77f 100644
--- a/tests/self_update_version_test.cpp
+++ b/tests/self_update_version_test.cpp
@@ -17,5 +17,16 @@ int main() {
CHECK((Version{0, 3, 10}).ToString() == "0.3.10");
// The build's own version comes from CMake.
CHECK(ParseVersion(PLAYDEN_VERSION) && CurrentVersion() == *ParseVersion(PLAYDEN_VERSION));
+ const auto beta = ParseVersion("v0.7.1-beta.1");
+ CHECK(beta);
+ CHECK(beta->ToString() == "0.7.1-beta.1");
+ CHECK(ParseVersion(beta->ToString()) == beta);
+ CHECK(*ParseVersion("0.7.0") < *beta);
+ CHECK(*beta < *ParseVersion("0.7.1-beta.2"));
+ CHECK(*ParseVersion("0.7.1-beta.999999") < *ParseVersion("0.7.1"));
+ CHECK(*beta != *ParseVersion("0.7.1"));
+ for (const char* bad : {"0.7.1-rc.1", "0.7.1-beta.0", "0.7.1-beta.01", "0.7.1-beta.1000000",
+ "0.7.1-beta.-1", "0.7.1-beta.1+meta", "0.7.1+meta", "0.7.1-beta.1.2"})
+ CHECK(!ParseVersion(bad));
return 0;
}
diff --git a/tests/write_update_manifest_test.py b/tests/write_update_manifest_test.py
index b7cddac..697f6fe 100644
--- a/tests/write_update_manifest_test.py
+++ b/tests/write_update_manifest_test.py
@@ -59,6 +59,21 @@ def main():
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-0.13.zip"], "local release")
check(all(a["digest"].startswith("sha256:") and a["size"] > 0 for a in listing["assets"]), "digests")
+ # Full beta identity lives alongside the numeric PS5 version.
+ with zipfile.ZipFile(app, "w") as archive:
+ prefix = "playden-ps5-0.3.0/FAKE77031/"
+ archive.writestr(prefix + "sce_sys/param.json",
+ json.dumps({"titleId": "FAKE77031", "contentVersion": "00.007.001"}))
+ archive.writestr(prefix + "playden-version", "0.7.1-beta.2\n")
+ result = run(*common, "--min-from", "0.7.1-beta.1", "--tag", "v0.7.1-beta.2",
+ "--release-json", str(release))
+ check(result.returncode == 0, result.stderr)
+ check(json.loads(out.read_text())["app"]["version"] == "0.7.1-beta.2", "full beta version")
+ check(json.loads(out.read_text())["app"]["min_from"] == "0.7.1-beta.1", "beta minimum")
+ check(json.loads(release.read_text())["prerelease"], "local beta marked prerelease")
+ check(run(*common, "--tag", "v0.7.1").returncode != 0, "tag mismatch refused")
+ for bad in ("0.7.1-beta.0", "0.7.1-beta.01", "0.7.1-rc.1", "0.7.1+meta", "0.7.1\n"):
+ check(run(*common, "--min-from", bad).returncode != 0, "invalid version refused: " + repr(bad))
# 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": "playden-kit", "manifest_sha256": "0" * 64}}))
check(run(*common).returncode != 0, "unpinned kit refused")
diff --git a/tools/collect_logs.py b/tools/collect_logs.py
index d482958..c2a64a1 100644
--- a/tools/collect_logs.py
+++ b/tools/collect_logs.py
@@ -269,6 +269,10 @@ def main():
info["Playden package"] = fetch(ftp, IDENTITY).decode("utf-8", "replace").split()[-1][:12]
except ftplib.Error:
info["Playden package"] = None
+ try:
+ info["Playden version"] = fetch(ftp, "/data/homebrew/FAKE77031/playden-version").decode("ascii").strip()
+ except (ftplib.Error, UnicodeError):
+ info["Playden version"] = None
info["firmware"] = firmware([playden_logs.get("runtime.log.1", ""), playden_logs.get("runtime.log", "")])
info.update(active_kit(ftp))
info["game titles"] = ", ".join(
diff --git a/tools/write_update_manifest.py b/tools/write_update_manifest.py
index 26f77bc..e60b0a0 100755
--- a/tools/write_update_manifest.py
+++ b/tools/write_update_manifest.py
@@ -25,14 +25,14 @@ import re
import sys
import zipfile
-VERSION = re.compile(r"^v?(\d{1,6})\.(\d{1,6})\.(\d{1,6})$")
+VERSION = re.compile(r"[vV]?([0-9]{1,6})\.([0-9]{1,6})\.([0-9]{1,6})(?:-beta\.([1-9][0-9]{0,5}))?")
def version(text):
- match = VERSION.match(text)
+ match = VERSION.fullmatch(text)
if not match:
raise SystemExit(f"not a version: {text!r}")
- return ".".join(str(int(part)) for part in match.groups())
+ return ".".join(str(int(part)) for part in match.groups()[:3]) + (f"-beta.{match[4]}" if match[4] else "")
def inner_prefix(archive, marker):
@@ -74,6 +74,7 @@ def main(argv=None):
parser.add_argument("--app-zip", required=True, type=pathlib.Path)
parser.add_argument("--kit-zip", required=True, type=pathlib.Path)
parser.add_argument("--kit-revision", required=True, help='the kit version, e.g. "0.10"')
+ parser.add_argument("--tag", help="release tag; must match the packaged full version")
parser.add_argument("--min-from", required=True, help="oldest Playden version that can update to this one")
parser.add_argument("--notes", default="", help=f"a plain-text summary for the update dialog, at most {MAX_NOTES} characters")
parser.add_argument("--lock", type=pathlib.Path,
@@ -87,7 +88,16 @@ def main(argv=None):
with zipfile.ZipFile(args.app_zip) as app:
app_prefix = inner_prefix(app, "sce_sys/param.json")
param = json.loads(app.read(app_prefix + "sce_sys/param.json"))
- app_version = version(param["contentVersion"])
+ numeric_version = version(param["contentVersion"])
+ try:
+ full_text = app.read(app_prefix + "playden-version").decode("ascii")
+ app_version = version(full_text.removesuffix("\n"))
+ except KeyError:
+ app_version = numeric_version # Packages predating full version metadata.
+ if app_version.split("-", 1)[0] != numeric_version:
+ raise SystemExit("packaged version does not match param.json contentVersion")
+ if args.tag and version(args.tag) != app_version:
+ raise SystemExit("release tag does not match the packaged version")
title_id = param["titleId"]
if not re.fullmatch(r"[A-Z]{4}\d{5}", title_id):
raise SystemExit(f"unexpected title id {title_id!r}")
@@ -126,7 +136,7 @@ def main(argv=None):
assets.append({"name": path.name, "size": path.stat().st_size,
"browser_download_url": f"https://github.com/local/release/{path.name}",
"digest": "sha256:" + sha256_file(path)})
- release = {"tag_name": "v" + app_version, "draft": False, "prerelease": False, "assets": assets}
+ release = {"tag_name": "v" + app_version, "draft": False, "prerelease": "-beta." in app_version, "assets": assets}
args.release_json.write_text(json.dumps(release, indent=2) + "\n")
print(f"{args.release_json}: local release v{app_version}")
return 0