Skip to content

fix(build): fall back to patch(1) when git apply fails - #764

Merged
ReenigneArcher merged 1 commit into
LizardByte:masterfrom
luanweslley77:fix/patch-fallback-non-git
Aug 30, 2026
Merged

fix(build): fall back to patch(1) when git apply fails#764
ReenigneArcher merged 1 commit into
LizardByte:masterfrom
luanweslley77:fix/patch-fallback-non-git

Conversation

@luanweslley77

@luanweslley77 luanweslley77 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Description

_main.cmake duplicates the nested third-party/FFmpeg trees into the build directory with file(COPY ...), which carries the submodules' .git gitdir pointer files along. Those pointers are relative to the source checkout, so they stay valid only while the build directory mirrors the source layout — the default in-tree build used by CI, where the released artifacts confirm all patches apply.

For any other layout — e.g. an out-of-tree build directory whose path does not mirror the source depth — the copied pointer no longer resolves and every git command inside the copy fails with fatal: not a git repository. A present-but-invalid .git makes git apply --check abort even though git apply works fine without any .git at all, so all FFmpeg patches get silently skipped — and on CMake >= 4 the unpatched x265 then hard-errors on cmake_policy(SET CMP0025 OLD).

This falls back to patch(1), which needs no repository, when git apply --check fails, keeping the check output visible. The patch(1) dry-run output is captured: applicable patches are applied, already-applied patches stay silent, and a patch that cannot apply is reported with its reason instead of being skipped silently.

Validated on a fresh out-of-tree build (CMake 4.3, Fedora 44): pristine submodules, no manual steps — configure applies all FFmpeg and x265 patches through the fallback and the full Sunshine test suite (395 tests) passes against the built FFmpeg.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes to affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@luanweslley77
luanweslley77 force-pushed the fix/patch-fallback-non-git branch from 2b0f744 to d817437 Compare August 29, 2026 13:42
@luanweslley77
luanweslley77 marked this pull request as ready for review August 29, 2026 14:08
@luanweslley77
luanweslley77 force-pushed the fix/patch-fallback-non-git branch from d817437 to 7cf407d Compare August 30, 2026 09:41
file(COPY) duplicates the nested submodule trees into the build
directory, carrying their .git gitdir pointer files. In build layouts
where the copy does not mirror the source depth, the pointer breaks
and git apply --check aborts with "fatal: not a git repository",
silently skipping every patch. Keep the check output visible and fall
back to patch(1), which needs no repository, when the check fails.

The patch(1) dry-run output is captured: applicable patches are
applied, already-applied patches stay silent, and a patch that cannot
apply is reported with its reason instead of being skipped silently.
@ReenigneArcher
ReenigneArcher force-pushed the fix/patch-fallback-non-git branch from 7cf407d to ee3d9dc Compare August 30, 2026 13:23
@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher merged commit 0e35069 into LizardByte:master Aug 30, 2026
20 checks passed
luanweslley77 added a commit to luanweslley77/build-deps that referenced this pull request Sep 1, 2026
…#764) + x265 multilib -j3

- Cherry-pick LizardByte#764: fallback to patch(1) when git
  apply fails in binary dir (file(COPY) breaks gitdir pointer), fixing
  'fatal: not a git repository' silent skip for all FFmpeg/x265 patches.
  This restores 01-cmake-minimum_required.patch etc for CMake 4.3.
- Keep x265 multilib 8/10/12-bit with -j3 and CMAKE_POLICY_VERSION_MINIMUM
  3.5 / POLICY_DEFAULT for CMP0025/0054. Manual sed remains as extra
  safety for already-copied source.
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 1, 2026
…h-fallback + x265 multilib -j3)

- Inclui LizardByte/build-deps#764 MERGED (fix/build fallback patch(1) when git
  apply fails in binary dir) que voce apontou - agora todos os patches
  FFmpeg/x265_git aplicam corretamente mesmo com file(COPY) gitdir quebrado.
  Resolve o Configuring incomplete para x265-12bit/10bit no CMake 4.3.
- Mantem x265 multilib 8/10/12-bit -j3 com CMAKE_POLICY 3.5
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 1, 2026
…h-fallback + x265 multilib -j3)

- Inclui LizardByte/build-deps#764 MERGED (fix/build fallback patch(1) when git
  apply fails in binary dir) que voce apontou - agora todos os patches
  FFmpeg/x265_git aplicam corretamente mesmo com file(COPY) gitdir quebrado.
  Resolve o Configuring incomplete para x265-12bit/10bit no CMake 4.3.
- Mantem x265 multilib 8/10/12-bit -j3 com CMAKE_POLICY 3.5
luanweslley77 added a commit to luanweslley77/build-deps that referenced this pull request Sep 2, 2026
- Build 12-bit (HIGH_BIT_DEPTH+MAIN12) -> 10-bit (HIGH_BIT_DEPTH) -> 8-bit
  (EXTRA_LIB=x265_main10.a;x265_main12.a LINKED_10BIT/12BIT) via ExternalProject
- Combine via ar -M with WORKING_DIRECTORY 8bit, x265_config.h from 8bit,
  x265.pc via true, idempotent libx265_main.a handling
- Enables yuv420p10le for HEVC Main10 P010 software encoding, fixes
  validate_config -1 for libx265. 27M libx265.a. Requires
  LizardByte#764 patch fallback for CMake 4.3.
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 2, 2026
- Add x265 multilib 8/10/12-bit via ExternalProject for yuv420p10le
  HEVC Main10 P010, 27M libx265.a, requires LizardByte/build-deps#764
  patch fallback for CMake 4.3
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 2, 2026
- Add x265 multilib 8/10/12-bit via ExternalProject for yuv420p10le
  HEVC Main10 P010, 27M libx265.a, requires LizardByte/build-deps#764
  patch fallback for CMake 4.3
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 2, 2026
- Add x265 multilib 8/10/12-bit via ExternalProject for yuv420p10le
  HEVC Main10 P010, 27M libx265.a, requires LizardByte/build-deps#764
  patch fallback for CMake 4.3
luanweslley77 added a commit to luanweslley77/Sunshine that referenced this pull request Sep 2, 2026
- Add x265 multilib 8/10/12-bit via ExternalProject for yuv420p10le
  HEVC Main10 P010, 27M libx265.a, requires LizardByte/build-deps#764
  patch fallback for CMake 4.3
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