← Back to issue list

Add a Patches Directive to Allow Custom Patching on top of the Source Tree

View original Github issue

Metadata

Project
craft-parts
Number
#1587
Type
issue
State
open
Author
bryanfraschetti
Labels
Created
Updated
Closed

Current evaluation

Feature request for a patches directive to apply local patches to the source tree during the pull stage. A maintainer gave design feedback (prefer git-based approach, override-pull), and PR #1588 is open to implement it with unresolved review comments.

Suggested action: keep open

Reason: Maintainer steinbro triaged the request on 2026-05-20, validating the motivation while redirecting the design away from the Debian patch scheme toward git-ubuntu-style patching and override-pull, and an open PR (craft-parts#1588) explicitly implements this directive and closes the issue. The work is not done (PR has 6 unresolved comments and failing CI) and no patches directive exists in the codebase, so the issue remains valid and in progress rather than stale or moot.

Impact: 45 Quick Win: 18.0 Staleness: 45 Complexity: 60 Confidence: 80 Support Request: 10

Issue body

### What needs to get done It would be beneficial if there were a patching mechanism native to the craft-parts library such that when building an artifact, for example a rock, you could define custom patches that you would like to apply atop the source from which you are pulling. This can be useful for local development, as well as performing and testing backports. ### Why it needs to get done In particular, sometimes customers hit issues in supported and released artifacts and we need to provide them with a patched version of the product. It can be messy to have loose patches floating around and then manually overriding the build to apply the patches. For example: see [this commit](https://github.com/canonical/metallb-rocks/commit/efed043c6655e05d7817db0638c61e071ec714a1#diff-61a282cc92dd2d8e7179253df11385f89e43dbe6dfef59cdebbe206dcac22c9a) to patch a rock, where the patch had to be added and specified in override-build. Note how the patch had to be manually applied with ``` git am /root/parts/patches/src/0001-L2Status-controller-refactor-to-leader-node.patch ``` After also being manually dumped into the build container with a separate part defined by ``` patches: plugin: dump source: . ``` Fortunately in this case, there was already an override-build section. However, if there wasn't already such a section, it could be difficult to figure out the correct expected build steps that the plugin applies by default and ensure the patch is applied at the right time. The proposal of this idea is to add a patches directive that takes a list of patches that are present locally and automatically apply them in the defined order during the pull stage. This is more coherent with the Debian packaging process where distro patches are added to `debian/patches/`, and the order of patch application adheres to the list of patches defined in `debian/patches/series` Maybe this functionality could also be extended to take in patches from remote sources or the local git tree, and the identifier could be a url, commit hash, or branch name (if all the patches were to be put in one branch). However, such extensibility would be quite complex and may require work to determine the details. For now, local patches would be a great start

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 18.0
Staleness: 45
Complexity: 60
Confidence: 80
Support Request: 10
keep open Feature request for a patches directive to apply local patches to the source tree during the pull stage. A maintainer gave design feedback (prefer git-based approach, override-pull), and PR #1588 is open to implement it with unresolved review comments.
qwen/qwen3.6-35b-a3b
Staleness: 30
Complexity: 60
Confidence: 75
Support Request: 10
needs triage Feature request to add a native patches directive to craft-parts for applying custom patches during the pull stage. Currently under discussion with a maintainer suggesting Git-based approaches and override-pull instead.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 65
Confidence: 85
Support Request: 10
needs triage Proposal to add a native patches directive to craft-parts for applying custom patches during the pull stage. Currently open with one maintainer comment suggesting Git-based implementation and further discussion.
qwen3.6-35b-a3b-mtp-q6
Staleness: 25
Complexity: 45
Confidence: 80
Support Request: 10
keep open Proposes a native patches directive in craft-parts to auto-apply local patches during pull. Under discussion; maintainer agrees with the motivation but recommends leveraging Git and override-pull instead of a Debian-style scheme.

Update history

No update history recorded yet.

Related work

  • Related To: craft-parts#1588 (confidence 85%)

    Open PR titled 'Add Patches Directive' that closes this issue; has 1 approval but 6 unresolved review comments, failing CI, and an open design discussion over the hardcoded -p1 flag, so it is not yet a fix.

Related issues

Issue Project State Summary Similarity
#1588 Add Patches Directive craft-parts open Adds a patches directive applying a list of patch files to the source tree during the pull stage (closes #1587). Approved by 1 reviewer, but 6 unresolved review comments, failing CI, and an open design discussion over the hardcoded -p1 flag.
84%