Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/packaging-guidelines/patches.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ When using `%patchlist`, you must place the patch list above `%description`. See
# covscan issues
0020-unzip-6.0-COVSCAN-fix-unterminated-string.patch
```

## Applying Patches

In the build system of openRuyi, it is generally unnecessary to apply patches manually. The build system will **automatically apply** patches during the `prep` stage.

By default, the patch strip level is set to `-p1`, which is typically suitable for patches generated by `git format-patch`. These patches usually contain `a/` and `b/` path prefixes.

You should only use `BuildOption(prep)` to pass additional arguments when the default preparation stage does not meet your requirements. For example, if the patch paths already start with relative paths from the source root directory, you should explicitly use `-p0`:

```specfile
BuildOption(prep): -p0
```

You should only write out the `%prep` section and manually apply patches if the patches require special handling that cannot be expressed through declarative fields. In such cases, you must add a comment in the spec file explaining the reason.
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ Patch0: 0001-adjusts-tests-for-setuptools-78.patch
# covscan issues
0020-unzip-6.0-COVSCAN-fix-unterminated-string.patch
```

## 应用补丁

在 openRuyi 的构建系统中。通常不需要手动应用补丁,构建系统会在 `prep` 阶段**自动应用**补丁。

默认情况下,补丁路径剥离层级为 `-p1`,通常适用于 `git format-patch` 生成的补丁。这类补丁通常包含 `a/` 和 `b/` 路径前缀。

只有当默认准备阶段不能满足需要时,才应使用 `BuildOption(prep)` 传入额外参数。例如,补丁路径已经以源码根目录下的相对路径开头时,应显式使用 `-p0`:

```specfile
BuildOption(prep): -p0
```

只有在补丁必须以特殊方式处理,且无法用声明式字段表达时,才应手写 `%prep` 并手动应用补丁。并且必须在 spec 中注释原因。