Skip to content

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

C++

Offer Recreate bottle for setups an earlier kit left

Leonardo Lobatoaa4012668687
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 91d1c30..3e6a51d 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -1273,6 +1273,12 @@ void Controller::TickRuntime() {
game.status == "Needs recovery" || game.status == "Failed" || game.status == "Registration pending"))
game.status = "No kit";
if (refusal != snapshot.refusals.end() && !game.ready) game.detail = refusal->second;
+ // A setup left over from an earlier kit: what to do, not the check that failed (or the refusal saying so).
+ if (record && record->setup_other_kit && usable &&
+ (game.status == "Needs recovery" || game.status == "Failed" || game.status == "Not prepared")) {
+ game.setup_other_kit = true;
+ game.detail = "Started with an earlier kit · Recreate the bottle to finish (saves are kept)";
+ }
if (const auto refused = snapshot.play_refusals.find(NumberIn(snapshot, id)); refused != snapshot.play_refusals.end())
game.play_detail = "Could not start: " + refused->second;
const bool launching = snapshot.launch && snapshot.launch->game == id;
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index f99d757..319905d 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <set>
#include <string_view>
+#include <tuple>
#include <utility>
namespace playden::homebrew {
@@ -1311,6 +1312,12 @@ void RuntimeHost::ClearWork() {
Publish([](RuntimeSnapshot& s) { s.work_progress.reset(); });
}
+// A setup that stopped before Ready, which Prepare starts again from its saved step (Retry) or from the start.
+static bool SetupRestarts(const rt::RuntimeInstall& record) {
+ return record.state == rt::PreparationState::kFailed || record.state == rt::PreparationState::kUnavailable ||
+ record.state == rt::PreparationState::kDownloaded;
+}
+
// Whether the install is bound to exactly the installed kit's runtime artifacts.
static bool ArtifactsBound(const auto& kit_artifacts, const rt::RuntimeInstall& record) {
return record.artifacts.size() == kit_artifacts.size() &&
@@ -1323,10 +1330,11 @@ static bool ArtifactsBound(const auto& kit_artifacts, const rt::RuntimeInstall&
}
void RuntimeHost::PublishInstalls(const Composition& composition, const std::string& only) {
- std::map<std::string, std::pair<bool, bool>> checked; // title_current, runtime_current
+ std::map<std::string, std::tuple<bool, bool, bool>> checked; // title_current, runtime_current, setup_other_kit
if (!only.empty()) {
std::lock_guard<std::mutex> lock(mutex_);
- for (const auto& view : snapshot_.installs) checked[view.install_id] = {view.title_current, view.runtime_current};
+ for (const auto& view : snapshot_.installs)
+ checked[view.install_id] = {view.title_current, view.runtime_current, view.setup_other_kit};
}
std::vector<RuntimeInstallView> installs;
for (const auto& record : composition.repository.Snapshot()) {
@@ -1345,12 +1353,13 @@ void RuntimeHost::PublishInstalls(const Composition& composition, const std::str
view.failure_code = record.last_failure->code;
}
if (const auto kept = checked.find(record.install_id); !only.empty() && record.install_id != only && kept != checked.end()) {
- view.title_current = kept->second.first;
- view.runtime_current = kept->second.second;
+ std::tie(view.title_current, view.runtime_current, view.setup_other_kit) = kept->second;
} else if (record.state == rt::PreparationState::kReady && composition.kit) {
const bool files_current = composition.installer->TitleCurrent(record);
view.title_current = files_current && composition.installer->TitleMetadataCurrent(record) && TitleNameCurrent(record);
view.runtime_current = files_current && ArtifactsBound(composition.kit->view.artifacts, record);
+ } else if (composition.kit && SetupRestarts(record) && !view.moving) {
+ view.setup_other_kit = composition.installer->SetupFromOtherKit(record);
}
if (const auto found = composition.admission.find(record.install_id); found != composition.admission.end())
view.admission = found->second;
@@ -2679,8 +2688,9 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
return refused;
}
// Reservations survive a failed allow-list or metadata write. Complete these
- // prerequisites again before a fresh start. Nothing is published yet, so a
- // reservation bound to an earlier kit's artifacts is bound to this kit's.
+ // prerequisites again before a fresh start. Nothing is published yet (a title or
+ // bottle left by another kit is refused first), so a reservation bound to an
+ // earlier kit's artifacts is bound to this kit's.
const auto initialize_reserved = [&](rt::RuntimeInstall& record) -> std::string {
std::vector<rt::RuntimeArtifactIdentity> current;
for (const auto& artifact : c.kit->view.artifacts)
@@ -2843,6 +2853,13 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
if (recipe->id != existing->recipe_id || std::to_string(recipe->version) != existing->recipe_version)
return "This game's setup changed; remove its PS5 title before preparing it again.";
}
+ // A setup that stopped before a kit swap left its title or bottle made with the earlier kit. Neither
+ // Retry nor a fresh start finishes over it (both check them against this kit's), so each Try again
+ // would fail the same way: Recreate bottle removes the title and prepares the game again.
+ if (fresh_start && c.installer->SetupFromOtherKit(*existing)) {
+ Log("prepare refused app=" + std::to_string(request.runtime_number) + ": title or bottle from another kit");
+ return std::string("This game's setup was started with another compatibility kit.") + kRecreateHint;
+ }
if (fresh_start)
if (const auto initialized = initialize_reserved(*existing); !initialized.empty()) return initialized;
if (existing->state == rt::PreparationState::kFailed || existing->state == rt::PreparationState::kUnavailable)
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index 9ec6204..90cd19d 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -184,6 +184,10 @@ struct RuntimeInstallView {
// Whether the title runs the installed kit's runtime (its files and artifacts are the kit's). Unlike title_current,
// a new game name or icon does not count. Settings only the newer runtime takes (120 Hz output) wait for Update.
bool runtime_current = true;
+ // A setup that stopped before Ready (Failed, Unavailable or Downloaded) left a title or bottle made with
+ // another kit: Try again can't finish over it, and Prepare refuses. Recreate bottle (remove, then prepare)
+ // does, keeping saves and settings.
+ bool setup_other_kit = false;
// Publication admission result for Ready titles ("ok" or the refusal); a
// refusal means the next start would be refused, and Prepare repairs it.
std::string admission = "ok";
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 2c453d7..b50204a 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -506,7 +506,8 @@ std::string action_label(const std::string& key) {
{"job-pause-", "Pause download"}, {"job-resume-", "Resume download"}, {"job-retry-", "Retry download"},
{"job-cancel-", "Cancel download"}, {"job-now-", "Download now"}, {"job-up-", "Move up"}, {"job-down-", "Move down"},
{"job-open-", "Open game"}, {"job-dismiss-", "Dismiss"}, {"prep-next-", "Prepare next"},
- {"prep-open-", "Game details"}, {"prep-retry-", "Try again"}, {"prep-dismiss-", "Dismiss"},
+ {"prep-open-", "Game details"}, {"prep-retry-", "Try again"}, {"prep-recreate-", "Recreate bottle"},
+ {"prep-dismiss-", "Dismiss"},
{"uninstall-dismiss-", "Dismiss"}})
if (key.rfind(prefix, 0) == 0) return label;
std::string title = key;
@@ -515,6 +516,14 @@ std::string action_label(const std::string& key) {
return title;
}
+// Recreate bottle asks first, from Maintenance and for a setup an earlier kit left (Queue, the game page).
+ModalEntry recreate_confirmation(const std::string& title, std::string opener) {
+ ModalEntry confirmation{"confirmation", "Recreate the bottle?", std::move(opener), {"cancel", "confirm-destructive"}, 1, false};
+ confirmation.body = title + "'s Windows environment is made again from the runtime kit, with its saves and settings brought back. "
+ "The PS5 title is removed and prepared again, so the game then waits for the PS5 Home screen once more.";
+ return confirmation;
+}
+
std::string trimmed(std::string value) {
const auto first = value.find_first_not_of(" \t\r\n");
if (first == std::string::npos) return {};
@@ -4571,6 +4580,13 @@ void Simulation::rebuild_view() {
play.value.clear();
play.enabled = value.uninstall_status.empty();
}
+ // Finish setup would fail as before over a title or bottle an earlier kit made: make it again.
+ if (value.setup_other_kit) {
+ play.title = "Recreate bottle";
+ play.action = "prep-recreate-" + ToKey(game->id);
+ play.value = value.maintenance_running ? "Working…" : std::string{};
+ play.enabled = !value.maintenance_running;
+ }
if (!value.uninstall_status.empty()) {
play.value = value.uninstall_status;
play.action.clear();
@@ -4730,6 +4746,8 @@ void Simulation::rebuild_view() {
else if (status == "Removal incomplete") hint = "Removing " + game->title + " from the PS5 Home screen stopped partway.";
else if (status == "Needs repair") hint = "Some of " + game->title + "'s setup files changed.";
else if (status == "No kit") hint = "Playden needs its compatibility kit to set up games.";
+ else if (runtime && runtime->setup_other_kit)
+ hint = "Setup started with an earlier kit. Recreate bottle makes it again; saves and settings are kept.";
else if (runtime && (status == "Needs recovery" || status == "Failed")) {
const bool stopped = status == "Needs recovery";
if (runtime->failure_code.rfind("kit-", 0) == 0 ||
@@ -6263,7 +6281,10 @@ void Simulation::activate() {
if (completed_count() > 1) actions.push_back("prep-clear-completed");
} else if (key.rfind("prep-attn-", 0) == 0) {
const auto runtime = state_.runtime_games.find(selected.game_id);
- if (runtime != state_.runtime_games.end() && runtime->second.can_prepare && !runtime->second.awaiting_registration)
+ // A setup an earlier kit left fails the same way on every Try again: the bottle is made again instead.
+ if (runtime != state_.runtime_games.end() && runtime->second.setup_other_kit)
+ actions.push_back("prep-recreate-" + id);
+ else if (runtime != state_.runtime_games.end() && runtime->second.can_prepare && !runtime->second.awaiting_registration)
actions.push_back("prep-retry-" + id);
actions.push_back("prep-open-" + id);
} else if (key.rfind("prep-active-", 0) == 0) {
@@ -6288,6 +6309,19 @@ void Simulation::activate() {
close_modal();
state_.navigation.selected_game_id = id; state_.navigation.detail_id = id;
state_.navigation.detail_origin = Route::Downloads; state_.navigation.route = Route::Details;
+ } else if (action_name.rfind("prep-recreate-", 0) == 0) {
+ // The same request as Maintenance › Recreate bottle. The runtime refuses to remove a title that runs,
+ // so this doesn't wait for the console's answer on whether the game runs, as Maintenance's rows do.
+ const auto id = key_id(std::string_view(action_name).substr(std::strlen("prep-recreate-")));
+ const auto runtime = state_.runtime_games.find(id);
+ if (!live() || runtime == state_.runtime_games.end() || !runtime->second.setup_other_kit ||
+ runtime->second.maintenance_running)
+ return;
+ const auto* known = find_game(state_, id);
+ if (!state_.navigation.modals.empty() && state_.navigation.modals.back().id == "prep-actions") close_modal();
+ state_.navigation.selected_game_id = id;
+ pending_destructive_action_ = "maintenance-recreate";
+ open_modal(recreate_confirmation(known ? known->title : "the game", state_.navigation.focus_key));
} else if (action_name.rfind("prep-retry-", 0) == 0) {
const auto id = key_id(std::string_view(action_name).substr(std::strlen("prep-retry-")));
close_modal();
@@ -7021,9 +7055,9 @@ void Simulation::activate() {
heading = "Back up saves?";
body = "The Windows user folders of " + title + " are copied aside on this console. Playden keeps the newest 3 backups. Saves the game keeps in its own folder are not included.";
} else if (action_name == "maintenance-recreate") {
- heading = "Recreate the bottle?";
- body = title + "'s Windows environment is made again from the runtime kit, with its saves and settings brought back. "
- "The PS5 title is removed and prepared again, so the game then waits for the PS5 Home screen once more.";
+ pending_destructive_action_ = action_name;
+ open_modal(recreate_confirmation(title, action_name));
+ return;
} else {
return;
}
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 5f2a49d..aad62ba 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -162,6 +162,9 @@ struct LiveRuntimeGame {
// The title runs the installed kit's runtime (false while a Ready title waits for Update): settings only the
// newer runtime takes, such as 120 Hz output, can be chosen before but apply only then.
bool runtime_current = true;
+ // Its setup stopped before Ready and left a PS5 title or bottle made with an earlier kit: Try again
+ // can't finish it, Recreate bottle does (RuntimeInstallView::setup_other_kit).
+ bool setup_other_kit = false;
// Has a prepared title (Ready, perhaps with an update or repair to make): its Game
// settings and maintenance apply to it.
bool prepared = false;
diff --git a/src/runtime/install_service.h b/src/runtime/install_service.h
index 9ed8ea7..5203087 100644
--- a/src/runtime/install_service.h
+++ b/src/runtime/install_service.h
@@ -92,6 +92,10 @@ public:
}
// Whether a staged title was made from the admitted kit (cheap marker check).
virtual bool TitleCurrent(const RuntimeInstall &) { return true; }
+ // Whether this install's title, or its bottle, is there and was made from another kit (or
+ // another build of this one): owner markers that name the install but not the admitted kit.
+ // A setup stopped before Ready can't finish over it (cheap marker check).
+ virtual bool SetupFromOtherKit(const RuntimeInstall &) { return false; }
virtual PackageActionResult WriteTitleMetadata(const RuntimeInstall &, const std::string &,
const std::optional<std::string> &) {
return {PackageActionState::kFailed, "unsupported", "title metadata is unsupported"};
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 05de3d4..9048276 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -1554,6 +1554,17 @@ bool FilesystemPackageInstaller::TitleCurrent(const RuntimeInstall& record) {
MarkerEquals(paths->bottle / kTemplateOwner, OwnerMarker(record, kit_, "template"));
}
+bool FilesystemPackageInstaller::SetupFromOtherKit(const RuntimeInstall& record) {
+ const auto paths = Resolve(record);
+ if (!paths) return false;
+ // Only folders whose markers name this install count; another owner's folder is a collision, not this.
+ const auto other_kit = [&](const fs::path& folder, const char* marker, const char* kind) {
+ return IsDirectoryNoSymlink(folder) && MarkerIdentifies(folder / marker, record, kind) &&
+ !MarkerEquals(folder / marker, OwnerMarker(record, kit_, kind));
+ };
+ return other_kit(paths->title, kTitleOwner, "title") || other_kit(paths->bottle, kTemplateOwner, "template");
+}
+
PackageActionResult FilesystemPackageInstaller::RefreshTitle(const RuntimeInstall& record) {
const auto paths = Resolve(record);
if (!paths) return Failed("kit-invalid", "record or verified kit view is invalid");
diff --git a/src/runtime/package_installer.h b/src/runtime/package_installer.h
index 229458d..3a59cc2 100644
--- a/src/runtime/package_installer.h
+++ b/src/runtime/package_installer.h
@@ -188,6 +188,7 @@ class FilesystemPackageInstaller final : public PackageInstaller {
PackageActionResult ValidateArtifacts(const RuntimeInstall& record) override;
PackageActionResult PublishProfile(const RuntimeInstall& record) override;
bool TitleCurrent(const RuntimeInstall& record) override;
+ bool SetupFromOtherKit(const RuntimeInstall& record) override;
std::string AdmissionDiagnostic(const RuntimeInstall& record) override;
std::string QuickAdmission(const RuntimeInstall& record) override;
// Also settles the bottle's modes (SettleBottleModes).
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index d07d018..4c51757 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -2578,6 +2578,67 @@ void live_queue_lists_preparations_needing_attention() {
"closed, it counts what needs attention apart from the queue");
}
+// A setup an earlier kit left (its title or bottle from that kit) can't be finished by Try again: Queue and the
+// game page offer Recreate bottle instead, say so in plain words, and ask before it runs.
+void live_setup_from_an_earlier_kit_offers_recreate() {
+ using namespace playden::homebrew;
+ using Requests = std::vector<std::pair<GameId, MaintenanceKind>>;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(SteamId(34), "Spire"), game(SteamId(35), "Broke")}, false, {}, false, false, {}}),
+ "library loaded");
+ model.UpdateInstalls({}, {{SteamId(34), 600'000'000}, {SteamId(35), 600'000'000}});
+ const std::string words = "Started with an earlier kit · Recreate the bottle to finish (saves are kept)";
+ LiveRuntimeGame spire; spire.game_id = SteamId(34); spire.status = "Needs recovery"; spire.has_title = true;
+ spire.can_prepare = true; spire.setup_other_kit = true; spire.detail = words;
+ LiveRuntimeGame broke; broke.game_id = SteamId(35); broke.status = "Failed"; broke.has_title = true;
+ broke.can_prepare = true; broke.detail = "immutable artifacts or template provenance do not match";
+ model.UpdateRuntime(RuntimeState::Ready, {spire, broke});
+ model.action("r1");
+ model.action("r1");
+ check(queue_row(model, "prep-attn-34") && queue_row(model, "prep-attn-34")->value == "Interrupted" &&
+ queue_row(model, "prep-attn-34")->subtitle == words,
+ "the row says what to do, not the check that failed");
+ activate(model, "prep-attn-34");
+ check(has_row(model, "prep-recreate-34") && !has_row(model, "prep-retry-34") && has_row(model, "prep-open-34"),
+ "Recreate bottle takes Try again's place");
+ check(find_row(model, "prep-recreate-34")->title == "Recreate bottle", "the action is named");
+ activate(model, "prep-recreate-34");
+ check(model.state().navigation.modals.size() == 1 && model.state().navigation.modals.back().title == "Recreate the bottle?",
+ "it asks first, as Maintenance does");
+ model.action("circle");
+ check(model.state().navigation.modals.empty() && model.TakeMaintenanceRequests().empty(), "Cancel asks for nothing");
+ activate(model, "prep-attn-34");
+ activate(model, "prep-recreate-34");
+ activate(model, "confirm-destructive");
+ check(model.TakeMaintenanceRequests() == Requests{{SteamId(34), MaintenanceKind::RecreateBottle}} &&
+ model.TakeRuntimePrepareRequests().empty(),
+ "confirmed, it is Maintenance's Recreate bottle for that game");
+ // A setup that failed under the installed kit is still tried again, with its own words.
+ activate(model, "prep-attn-35");
+ check(has_row(model, "prep-retry-35") && !has_row(model, "prep-recreate-35"), "other failures keep Try again");
+ model.action("circle");
+ check(queue_row(model, "prep-attn-35")->subtitle == "immutable artifacts or template provenance do not match",
+ "a real integrity failure keeps its message");
+
+ // The game page: the main action and its hint.
+ spire.maintenance.reset(); spire.maintenance_running = false;
+ model.UpdateRuntime(RuntimeState::Ready, {spire, broke});
+ check(model.action("details:34"), "details open");
+ const auto* play = find_row(model, "details-play");
+ check(play && play->enabled && play->title == "Recreate bottle" && play->action == "prep-recreate-34",
+ "the game page offers Recreate bottle instead of Finish setup");
+ check(find_row(model, "details-hint") &&
+ find_row(model, "details-hint")->title ==
+ "Setup started with an earlier kit. Recreate bottle makes it again; saves and settings are kept.",
+ "the hint says why");
+ activate(model, "details-play");
+ activate(model, "confirm-destructive");
+ check(model.TakeMaintenanceRequests() == Requests{{SteamId(34), MaintenanceKind::RecreateBottle}},
+ "the game page's Recreate bottle asks for the same");
+ check(find_row(model, "details-play") && !find_row(model, "details-play")->enabled, "it waits while it runs");
+}
+
// The game page of a waiting game names the game right ahead of it and offers Prepare next.
void live_details_prepare_next() {
using namespace playden::homebrew;
@@ -3009,6 +3070,7 @@ int main() {
live_queue_counts_copies();
live_queue_history_and_empty_states();
live_queue_lists_preparations_needing_attention();
+ live_setup_from_an_earlier_kit_offers_recreate();
live_queue_lists_uninstalls();
live_details_prepare_next();
std::cout << "homebrew_library_model_test passed\n";
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index 537febb..2f6e4ee 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -961,6 +961,90 @@ void RetryAfterKitRespinBindsTheNewArtifacts() {
host.Shutdown();
}
+// A preparation that stopped after its title and bottle were made, then a kit swap: the title is the
+// earlier kit's, so every Try again would fail the same way. The snapshot says so, Prepare refuses
+// with the way out instead of retrying, and Recreate bottle (remove, then prepare) finishes it.
+// The same stop under the installed kit is not flagged: Try again finishes that one.
+void SetupFromAnEarlierKitAsksForRecreate() {
+ Fixture fixture;
+ auto config = fixture.Config();
+ config.host_namespace_prefix = fixture.root;
+ config.package_paths.console_data_root = "/data";
+ config.package_paths.host_data_root = fixture.root / "data";
+ config.package_operations.hash_file = HashArtifactFile;
+ config.package_operations.hash_bytes = HashArtifactBytes;
+ config.package_operations.free_space_unverifiable = true;
+ // The bottle fails its check at first: the preparation stops with the title and bottle made.
+ auto bottle_valid = std::make_shared<std::atomic<bool>>(false);
+ config.package_operations.validate_bottle = [bottle_valid](const fs::path& bottle) {
+ return *bottle_valid && fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");
+ };
+ unsigned uuids = 0;
+ config.uuid = [&uuids]() -> std::optional<std::string> {
+ ++uuids; return std::string("00000000-0000-4000-8000-0000000000") + (uuids < 10 ? "0" : "") + std::to_string(uuids);
+ };
+ config.unix_time = [] { return std::int64_t{1760000000}; };
+ config.removal_confirm_polls = 3;
+ config.removal_poll_interval = std::chrono::milliseconds(1);
+ config.unregister_title = [&fixture](const std::string&, const std::string&) {
+ fixture.registered = false; fixture.submitted = false;
+ return TitleRemoverResult{true, 0, "answered"};
+ };
+ Write(fixture.root / "data/homebrew/FAKE77031/games/220/hl2.exe", "existing-game", 0644);
+ const auto prepare = [](RuntimeHost& host) {
+ const auto before = host.Snapshot().prepares_handled;
+ host.Prepare(Hl2());
+ return WaitFor(host, [before](const RuntimeSnapshot& s) { return !s.preparing_app && s.prepares_handled > before; }, 60);
+ };
+ const auto kit = SyntheticKit(fixture.root / "kit");
+ {
+ auto first = config;
+ first.admit_kit = [kit](std::string*) { return std::optional<RuntimeKit>(kit); };
+ RuntimeHost host(first);
+ CHECK(host.Start());
+ WaitFor(host, Started);
+ const auto failed = prepare(host);
+ CHECK(failed.installs.size() == 1 && failed.installs[0].state == PreparationState::kFailed);
+ CHECK(fs::is_directory(fixture.root / "data/homebrew/FAKE78001"));
+ // Stopped under the installed kit: nothing from another kit, and Try again goes on as before.
+ CHECK(!failed.installs[0].setup_other_kit);
+ const auto again = prepare(host);
+ CHECK(!again.installs[0].setup_other_kit && again.installs[0].state == PreparationState::kFailed);
+ CHECK(!again.refusals.count(220) || again.refusals.at(220).find("another compatibility kit") == std::string::npos);
+ host.Shutdown();
+ }
+ *bottle_valid = true;
+ const auto save = fixture.root / "data/playden/games/steam-220/library/prefixes/game/drive_c/users/steamuser/save.dat";
+ Write(save, "player-save", 0600);
+ const auto other = SyntheticKit(fixture.root / "kit-other", "native", "kit-2", 'b');
+ auto second = config;
+ second.admit_kit = [other](std::string*) { return std::optional<RuntimeKit>(other); };
+ RuntimeHost host(second);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs.size() == 1 && started.installs[0].setup_other_kit);
+ const auto records_before = Read(fixture.root / "data/runtime-state/installs.json");
+ const auto refused = prepare(host);
+ CHECK(refused.refusals.count(220) && refused.refusals.at(220).find("another compatibility kit") != std::string::npos &&
+ refused.refusals.at(220).find("Recreate bottle") != std::string::npos);
+ CHECK(refused.installs[0].setup_other_kit && refused.installs[0].state == PreparationState::kFailed);
+ // Nothing was rebound or retried.
+ CHECK(Read(fixture.root / "data/runtime-state/installs.json") == records_before);
+
+ // Recreate bottle: the title goes through the normal removal, keeping saves, then the game is prepared again.
+ const auto removals = host.Snapshot().removals_handled;
+ host.Remove(220, false);
+ const auto removed = WaitFor(host, [removals](const RuntimeSnapshot& s) { return s.removals_handled > removals; }, 30);
+ if (removed.removal_failures.count(220)) std::fprintf(stderr, "Remove failed: %s\n", removed.removal_failures.at(220).c_str());
+ CHECK(!removed.removal_failures.count(220) && removed.installs.empty());
+ const auto done = prepare(host);
+ if (done.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(220).c_str());
+ CHECK(!done.refusals.count(220) && done.installs.size() == 1 && done.installs[0].state == PreparationState::kReady);
+ CHECK(done.installs[0].title_current && !done.installs[0].setup_other_kit);
+ CHECK(Read(save) == "player-save");
+ host.Shutdown();
+}
+
// A game run that leaves the bottle registry wider than admission accepts
// (Wine saving with umask 0) is reported at startup, and Prepare repairs it.
void RepairsBottleRegistryModes() {
@@ -5113,6 +5197,7 @@ int main(int argc, char** argv) {
ResumesInterruptedCaptureFromSavedRequest(true);
RefreshesInstalledTitleToRespunKit();
RetryAfterKitRespinBindsTheNewArtifacts();
+ SetupFromAnEarlierKitAsksForRecreate();
RepairsBottleRegistryModes();
PlaysReadyTitleThroughHandoff();
ReplacedKitAsksForRestart();
diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cpp
index 4f7b3f8..fbbdaa1 100644
--- a/tests/runtime_package_installer_test.cpp
+++ b/tests/runtime_package_installer_test.cpp
@@ -604,11 +604,22 @@ void CompletePublicationAndFreshInspection() {
Write(title / ".playden-title-owner", marker + "kit_id=other\n", 0644);
owned = installer.InspectOwnership(record);
CHECK(owned.known && owned.manifest_matches && !installer.TitleCurrent(record));
+ // This install's title from another kit: a setup stopped before Ready can't finish over it.
+ CHECK(installer.SetupFromOtherKit(record));
auto other = record; other.install_id = "another-install";
+ CHECK(!installer.SetupFromOtherKit(other)); // someone else's title is a collision, not this
Write(title / ".playden-title-owner", marker, 0644);
CHECK(!installer.InspectOwnership(other).manifest_matches);
+ CHECK(!installer.SetupFromOtherKit(record));
+ // The bottle alone from another kit counts too.
+ const auto template_marker = Read(bottle / ".playden-template-owner");
+ Write(bottle / ".playden-template-owner", template_marker + "kit_id=other\n", 0600);
+ CHECK(installer.SetupFromOtherKit(record));
+ Write(bottle / ".playden-template-owner", template_marker, 0600);
+ CHECK(!installer.SetupFromOtherKit(record));
std::filesystem::remove(title / ".playden-title-owner");
CHECK(!installer.InspectOwnership(record).manifest_matches);
+ CHECK(!installer.SetupFromOtherKit(record));
}
unsigned ModeOf(const std::filesystem::path& path) {
@@ -982,7 +993,7 @@ void FixedTitleRefreshesToAnyTitleShell() {
CHECK(installer.WriteTitleMetadata(record, own, std::nullopt).state == PackageActionState::kComplete);
CHECK(installer.StageTitle(record).state == PackageActionState::kComplete);
CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);
- CHECK(installer.TitleCurrent(record));
+ CHECK(installer.TitleCurrent(record) && !installer.SetupFromOtherKit(record));
}
Write(fixture.kit / "titles/variant/eboot.bin", "any-title-shell", 0755);
for (auto& file : fixture.view.files)
@@ -997,7 +1008,7 @@ void FixedTitleRefreshesToAnyTitleShell() {
fixture.view.files_sha256 = std::string(64, 'b');
fixture.view.variants = {{"any-title", "FAKE78000", "titles/variant", true}};
auto respun = fixture.Installer();
- CHECK(!respun.TitleCurrent(record));
+ CHECK(!respun.TitleCurrent(record) && respun.SetupFromOtherKit(record));
// The new kit does not make the title someone else's: settings still apply to it,
// while the full inspection (launch) waits for Update (#5).
const auto owned = respun.InspectOwnership(record);
@@ -1010,7 +1021,7 @@ void FixedTitleRefreshesToAnyTitleShell() {
fixture.progress.back().first == fixture.progress.back().second && fixture.progress.back().second > 0);
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(respun.TitleCurrent(record));
+ CHECK(respun.TitleCurrent(record) && !respun.SetupFromOtherKit(record));
CHECK(Read(fixture.host_data / "homebrew/FAKE78001/eboot.bin") == "any-title-shell");
CHECK(Read(fixture.host_data / "homebrew/FAKE78001/sce_sys/param.json") == own);
CHECK(Read(fixture.host_data / "homebrew/FAKE78001/win/mesa-zink/i386-windows/opengl32.dll") == "MZ zink");