Skip to content

Add local docker-based build support and update documentation#43

Open
RenanGBarreto wants to merge 4 commits into
drakmor:mainfrom
PSBrew:docker-build-support
Open

Add local docker-based build support and update documentation#43
RenanGBarreto wants to merge 4 commits into
drakmor:mainfrom
PSBrew:docker-build-support

Conversation

@RenanGBarreto

@RenanGBarreto RenanGBarreto commented May 31, 2026

Copy link
Copy Markdown

This PR adds a local docker-based build workflow and aligns documentation with the current build paths.

The problem

Sometimes depevelopers can't easily install the required dependencies in order to use make.

Proposed solution

Adds a build.sh that fetches all necessary files and builds the correct payloads.

Why

  • Provide a reproducible local build path that mirrors CI behavior
  • Reduce developer setup friction
  • Keep build documentation short, clear, and maintainable

What changed

  1. Added a new root-level helper script: build.sh
  2. Added a ## Building section inside README

Result

You can now build locally with:

./build.sh

Additional information

I am working on other pull requests that will be submited soon related to PFS image mount.
If you have a specif way you want me to send the PRs or information, please let me know.

Summary by CodeRabbit

  • Chores

    • Ignore common IDE/editor dirs and a local build artifact path
    • Add a reproducible, Docker-based build workflow with cached build image and optional cache-rebuild; validates environment and verifies produced artifact
  • Documentation

    • New "Building from source" section covering direct make, Docker usage, and CI build steps
  • Bug Fixes

    • Adjusted PFS mount/image defaults to change mounting behavior for affected images

Copilot AI review requested due to automatic review settings May 31, 2026 13:39
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Docker-driven build script (build.sh), a "Building from source" README section for direct/Docker/CI builds, .gitignore entries for IDE directories and a local shared-object artifact, and small PFS mount/image-type code adjustments.

Changes

Build System & Documentation

Layer / File(s) Summary
Git ignore updates
.gitignore
Ignores IDE/editor directories and a local shared object build artifact: .idea/, .vscode/, /src/libkernel_sys_ext.so.
Build documentation
README.md
Adds "Building from source" with direct make instructions, Docker-based build steps (including SMP_FORCE_REBUILD_IMAGE), and CI notes referencing .github/workflows/ps5.yml.
build.sh: entrypoint & Docker validation
build.sh
Adds strict shell entrypoint, ROOT_DIR and base image selection, logging/help, and Docker CLI/daemon availability checks; pulls base image if missing.
build.sh: cached build-image creation
build.sh
Derives a sanitized cache tag, supports SMP_FORCE_REBUILD_IMAGE, and builds a cached image that installs build dependencies, creates a build user, clones pacbrew-repo, copies PS5 stubs, and pre-installs SDK/sqlite packages.
build.sh: container build command
build.sh
Defines the container-side build command, validates required PS5 SDK stub file, and runs make clean all with PS5_SCE_STUBS_DIR.
build.sh: run container and validate artifact
build.sh
Runs the container with host UID/GID and repo mount, executes the build, and verifies shadowmountplus.elf was produced on the host.
PFS mount defaults update
include/sm_mount_defs.h
Updates default mkeymode comment and switches PFS mount macros to DEVPFS_BUDGET_SYSTEM and DEVPFS_MKEYMODE_GD.
LVD image type change for PFS
src/sm_image.c
Changes IMAGE_FS_PFS branch to return LVD_ATTACH_IMAGE_TYPE_SINGLE for LVD attach calls.

Sequence Diagram

sequenceDiagram
  participant Host
  participant DockerDaemon
  participant BuildImage
  participant BuildContainer
  participant Make
  participant HostFS

  Host->>DockerDaemon: docker pull $SMP_DOCKER_IMAGE
  DockerDaemon->>BuildImage: build or reuse smp-build-cache:<tag>
  Host->>DockerDaemon: docker run --user UID:GID -v repo:/workspace smp-build-cache:<tag>
  DockerDaemon->>BuildContainer: start container with mounted /workspace
  BuildContainer->>Make: run `make clean all` with PS5_SCE_STUBS_DIR
  Make->>HostFS: write shadowmountplus.elf to mounted workspace
  BuildContainer->>Host: exit and expose artifact path
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped into a Docker shell so deep,
Made images cached before I sleep,
Docs and ignores tucked out of sight,
make hums softly through the night,
An ELF appears — my tiny build delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding Docker-based build support (build.sh script) and updating documentation (README.md with build instructions). It matches the core changeset focus.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch docker-build-support

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/sm_image.c

src/sm_image.c:1:10: fatal error: 'sm_platform.h' file not found
1 | #include "sm_platform.h"
| ^~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/4ec1392edfa27dbe660ee0082eb749f81868dad6-8cba3e8232027899/tmp/clang_command_.tmp.d8b6ba.txt
++Contents of '/tmp/coderabbit-infer/4ec1392edfa27dbe660ee0082eb749f81868dad6-8cba3e8232027899/tmp/clang_command_.tmp.d8b6ba.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-clea

... [truncated 682 characters] ...

"/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/8cba3e8232027899/file.o" "-x" "c" "src/sm_image.c"
"-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Around line 11-12: The .gitignore currently ignores /pacbrew-repo/ and
/src/libkernel_sys_ext.so but not the SDK checkout; update the .gitignore to
also ignore the PS5 SDK checkout directory by adding an entry for ps5-sdk/
(e.g., ps5-sdk/ or /ps5-sdk/) so the directory created by build.sh (ps5-sdk) is
treated as untracked and not shown after Docker builds.

In `@build.sh`:
- Around line 80-93: The cloned /workspace/pacbrew-repo and /workspace/ps5-sdk
are created as root but makepkg is executed under su - "$BUILDER_USER", causing
permission errors; fix by ensuring the repo directories are owned by
BUILDER_USER before running makepkg (either chown -R
"$BUILDER_USER":"$BUILDER_USER" /workspace/pacbrew-repo and /workspace/ps5-sdk
after each clone, or perform the git clone as the BUILDER_USER), so that su -
"$BUILDER_USER" -c 'cd /workspace/pacbrew-repo/sdk && makepkg ...' and the
subsequent makepkg in /workspace/pacbrew-repo/sqlite can write build artifacts
successfully.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c7feb30-99c8-4c88-a2c1-691dac273af0

📥 Commits

Reviewing files that changed from the base of the PR and between e0b41b3 and cc4d33d.

📒 Files selected for processing (3)
  • .gitignore
  • README.md
  • build.sh

Comment thread .gitignore Outdated
Comment thread build.sh Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
README.md (1)

340-344: 💤 Low value

Add a language to the fenced code block.

The example block on Line 342 has no language hint (markdownlint MD040). Use bash for consistency with the other examples in this section.

📝 Proposed fix
 **Optional:**
 - `SMP_FORCE_REBUILD_IMAGE=1` to rebuild the cached Docker image before building  
-  ```
+  ```bash
     SMP_FORCE_REBUILD_IMAGE=1 ./build.sh
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @README.md around lines 340 - 344, The fenced code block showing the example
"SMP_FORCE_REBUILD_IMAGE=1 ./build.sh" is missing a language hint; update that
code fence to use bash by changing the opening fence from tobash so the
block becomes bash\nSMP_FORCE_REBUILD_IMAGE=1 ./build.sh\n (ensure
spacing/indentation matches surrounding examples).


</details>

</blockquote></details>
<details>
<summary>build.sh (1)</summary><blockquote>

`89-91`: _⚖️ Poor tradeoff_

**Pin SDK/SQLite sources for reproducibility.**

`--depth 1` clones track the moving default branch, so the cached image content varies over time and across rebuilds — at odds with the PR's reproducible-build goal. Consider pinning to a tag or commit SHA (e.g., `git clone --depth 1 --branch <tag> ...` or clone + `git checkout <sha>`).

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.sh` around lines 89 - 91, The three RUN git clone lines (cloning
pacbrew-repo and sdk with --depth 1) should be made reproducible by pinning to a
specific tag or commit: replace the shallow moving-branch clones with either git
clone --depth 1 --branch <tag-or-release> ... or keep the clone and immediately
run git checkout <commit-sha> (and optionally git reset --hard) for both
https://github.com/ps5-payload-dev/pacbrew-repo and
https://github.com/ps5-payload-dev/sdk; keep the subsequent chown -R
smpbuilder:smpbuilder /opt/pacbrew-repo /opt/ps5-sdk as-is. Ensure the chosen
tags or SHAs are inserted into the appropriate RUN lines so rebuilds are
deterministic.
```

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @build.sh:

  • Around line 83-97: The FORCE rebuild logic currently calls docker build for
    LOCAL_BUILD_IMAGE but reuses cache so cloned SDK/sqlite layers aren't refreshed;
    modify the branch where FORCE_REBUILD_IMAGE (or SMP_FORCE_REBUILD_IMAGE) is true
    so the docker build invocation for LOCAL_BUILD_IMAGE adds the --no-cache flag
    (only when the force condition is set) to ensure all layers (the RUN git clone /
    makepkg steps) are rebuilt and fresh sources are fetched.
  • Around line 104-119: The build script sets
    PS5_SCE_STUBS_DIR="/opt/ps5-sdk/sce_stubs" inside BUILD_CMD and then runs "make
    clean all", but the Makefile requires $(PS5_SCE_STUBS_DIR)/libkernel_sys.c; add
    a pre-flight check or stub population step inside BUILD_CMD (before invoking
    make clean all) to either generate/populate the sce_stubs (using the upstream
    stubs generator or copying populated stubs into /opt/ps5-sdk/sce_stubs) or fail
    fast with a clear error if /opt/ps5-sdk/sce_stubs/libkernel_sys.c is missing;
    update BUILD_CMD (and/or the Docker image build) so that PS5_SCE_STUBS_DIR
    points to a directory that contains libkernel_sys.c before running make.

Nitpick comments:
In @build.sh:

  • Around line 89-91: The three RUN git clone lines (cloning pacbrew-repo and sdk
    with --depth 1) should be made reproducible by pinning to a specific tag or
    commit: replace the shallow moving-branch clones with either git clone --depth 1
    --branch ... or keep the clone and immediately run git checkout
    (and optionally git reset --hard) for both
    https://github.com/ps5-payload-dev/pacbrew-repo and
    https://github.com/ps5-payload-dev/sdk; keep the subsequent chown -R
    smpbuilder:smpbuilder /opt/pacbrew-repo /opt/ps5-sdk as-is. Ensure the chosen
    tags or SHAs are inserted into the appropriate RUN lines so rebuilds are
    deterministic.

In @README.md:

  • Around line 340-344: The fenced code block showing the example
    "SMP_FORCE_REBUILD_IMAGE=1 ./build.sh" is missing a language hint; update that
    code fence to use bash by changing the opening fence from tobash so the
    block becomes bash\nSMP_FORCE_REBUILD_IMAGE=1 ./build.sh\n (ensure
    spacing/indentation matches surrounding examples).

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro Plus

**Run ID**: `aee88ed0-297b-4fb7-bb5c-0f67165f1106`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between cc4d33dd7da3871bcc6855db0e76b52236c6a4b3 and c5572165a239c39b9a2fadb6e62d5834b19105f3.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `.gitignore`
* `README.md`
* `build.sh`

</details>

<details>
<summary>💤 Files with no reviewable changes (1)</summary>

* .gitignore

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread build.sh
Comment thread build.sh
@RenanGBarreto

Copy link
Copy Markdown
Author

I've made a new commit to address the bot's suggestions.
In addition, I added an image caching feature that makes local rebuilds much faster after the first run. Subsequent builds now take only about 7 seconds.

I believe this feature is ready to be merged, so I’ll move on to the next one.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@include/sm_mount_defs.h`:
- Line 61: The comment documenting default mkeymode is inconsistent with the
code: the comment says "AC" but the constant PFS_MOUNT_MKEYMODE is set to
DEVPFS_MKEYMODE_GD (which maps to "GD"); update one to match the other. Either
change the comment to document "GD" to reflect the current definition of
PFS_MOUNT_MKEYMODE/DEVPFS_MKEYMODE_GD, or if "AC" was intended, change
PFS_MOUNT_MKEYMODE to use the DEVPFS_MKEYMODE_AC symbol instead so the code and
comment agree.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 30076350-32c4-4007-8df1-544a508621c6

📥 Commits

Reviewing files that changed from the base of the PR and between 912c682 and 4ec1392.

📒 Files selected for processing (4)
  • README.md
  • build.sh
  • include/sm_mount_defs.h
  • src/sm_image.c
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • build.sh

Comment thread include/sm_mount_defs.h Outdated
// PFS nmount key/value variants observed in refs:
// - fstype: "pfs", "transaction_pfs", "ppr_pfs"
// - mkeymode: "SD"
// - mkeymode: "AC"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Documentation inconsistency: comment claims "AC" but code uses "GD".

The comment on line 61 documents the default mkeymode as "AC", but line 72 defines PFS_MOUNT_MKEYMODE as DEVPFS_MKEYMODE_GD (which resolves to "GD" per line 69). These are distinct master key modes.

📝 Proposed fix to align documentation with code
-// - mkeymode: "AC"
+// - mkeymode: "GD"

If "AC" was the intended mode, then line 72 should be changed instead:

-#define PFS_MOUNT_MKEYMODE DEVPFS_MKEYMODE_GD
+#define PFS_MOUNT_MKEYMODE DEVPFS_MKEYMODE_AC
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// - mkeymode: "AC"
// - mkeymode: "GD"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@include/sm_mount_defs.h` at line 61, The comment documenting default mkeymode
is inconsistent with the code: the comment says "AC" but the constant
PFS_MOUNT_MKEYMODE is set to DEVPFS_MKEYMODE_GD (which maps to "GD"); update one
to match the other. Either change the comment to document "GD" to reflect the
current definition of PFS_MOUNT_MKEYMODE/DEVPFS_MKEYMODE_GD, or if "AC" was
intended, change PFS_MOUNT_MKEYMODE to use the DEVPFS_MKEYMODE_AC symbol instead
so the code and comment agree.

@RenanGBarreto RenanGBarreto force-pushed the docker-build-support branch from 4ec1392 to b6f4316 Compare June 4, 2026 02:27
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.

1 participant