Skip to content

[HLE/GUI] Convert fake .pkg packages directly into .zar archives (with in-place consume mode) - #56

Open
xnetcat wants to merge 3 commits into
mainfrom
feat/zar-inplace-recompress
Open

xnetcat wants to merge 3 commits into
mainfrom
feat/zar-inplace-recompress

Conversation

@xnetcat

@xnetcat xnetcat commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

What PR does?

  • Convert fake PS4 and PS5 .pkg packages directly into .zar archives without extracting an intermediate folder (--pkg-to-zar <file.pkg> [dest.zar] [--consume-source]).
  • Add an opt-in in-place consume mode that processes tail-first batches, journals progress with a header snapshot, and truncates the .pkg after each committed batch so peak disk usage stays near 1x.
  • Add .zar format selection, consume mode, and pause/resume flows to the GUI PKG installer.
  • Add unit tests covering PS4/PS5 conversion, space checks, crash recovery at every commit boundary, and truncation safety.

Upstream PR: sharpemu/sharpemu#1193

Before submitting

Please read our contribution guidelines before opening a pull request:

➡️ CONTRIBUTING.md

By opening this pull request, you confirm that you have read and agree to follow the contribution guidelines.

Testing

  • uvx reuse lint: 3734/3734 files compliant.
  • dotnet build SharpEmu.slnx -c Release: 0 errors.
  • dotnet test SharpEmu.slnx -c Release: 0 failures across the full solution (11,869 passed in SharpEmu.Libs.Tests including PkgZarConverterTests, 5,066 in SharpEmu.ShaderCompiler.Metal.Tests, 2,229 in SharpEmu.Gpu.Metal.Tests, 124 in SharpEmu.Application.Tests).

Checklist

By submitting this pull request, you confirm that:

  • I have read and followed CONTRIBUTING.md.
  • I tested my changes or marked the testing section as N/A.
  • I wrote this pull request description myself and did not paste AI-generated explanations.
  • I listed the game(s) I tested (or marked the testing section as N/A).

…ackage in place

SharpEmu.CLI --pkg-to-zar <file.pkg> [dest.zar] [--consume-source] converts a fake PS4
or PS5 package into a ZArchive without an extracted folder.

- PackageSource (was Ps5Source) carries every package read for both formats; it can
  record the ranges a parse reads, serve them from a snapshot over a truncated file,
  and refuses file reads past the consumed frontier.
- IPackageContent lists exactly what Extract writes (sce_sys metadata + game files,
  same name checks, later write wins) and maps any file byte range to the highest
  package offset decoding it reads (PS5: UBlocks -> outer blocks; PS4: PFS blocks ->
  PFSC extents -> XTS sectors).
- Files are laid out in source order; each 1 MiB offset-record group knows its
  source end. Direct mode writes groups in order and leaves the package untouched.
- Consume mode processes groups in descending source end, in windowed batches:
  append to .partial, F_FULLFSYNC, journal the placements, then truncate the
  package. The journal holds a snapshot of the parsed ranges and a plan fingerprint,
  so an interrupted, cancelled or out-of-space run resumes; mismatches are refused.
- ZArchiveWriter shares its block encoder and trailer with the converter; Pack
  output is byte-identical to before.
Copilot AI balanced review requested due to automatic review settings November 27, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown

📦 Build artifacts — dce0686

Platform Download
macOS (osx-x64) sharpemu-osx-x64-a2a6216
macOS app bundle (osx-x64) sharpemu-osx-x64-app-a2a6216

From build run #477. Downloads require a GitHub login and expire after 90 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants