Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFE] Use file path in %patch macro #629

Closed

Conversation

pemensik
Copy link
Contributor

@pemensik pemensik commented Feb 6, 2019

Moves single %patchX from RPM code to macros. This can be then
redefined.

Similar to apply_patch, but allows all custom flags that can be passed
to %__patch utility. Forwards also name and number of a patch.

Rename to _apply_patchx{common,plain,uncompress}

Use single macro in two variants, cleanup some parts.
Remove default patch flags, they are in common part already.

Moves single %patchX from RPM code to macros. This can be then
redefined.

Similar to apply_patch, but allows all custom flags that can be passed
to %__patch utility. Forwards also name and number of a patch.

Rename to __apply_patchx_{common,plain,uncompress}

Use single macro in two variants, cleanup some parts.
Remove default patch flags, they are in common part already.
@pemensik
Copy link
Contributor Author

pemensik commented Feb 6, 2019

Hi. This is my test approach to allow redefinition of patch application in old plain spec files. All references with

%patch1 -p1
%patch2 -p1

etc. cannot be redefined. There is quite nice %apply_patch macro and %autopatch, which allows applying all patches in automated way. Unfortunately, it is not always so simple. One try to solve that is request #626. This is another improvement, but with more complicated solution. It moves %patchX handling from rpmbuild to macro definitions. It is then possible to apply patches with SCM method.

# Switch to scm method. Pass file name and file number to patch as arguments.
%__apply_patchx_plain(b:d:o:F:REp:m:)\
%{apply_patch %{-p} -m "%{1}" %{1} %{2}}
%__apply_patchx_uncompress(b:d:o:F:REp:m:)\
%{apply_patch %{-p} -m "%{1}" %{1} %{2}}

This allows rebase tool to mark each commit, by patch name it comes from and patch number. It could allow creation of git repository, where commits could be marked with original file. After git driven rebase, all patches could be exported back to patches used by spec, in automated way. Currently, it is impossible, because patch number is dropped in rpmbuild.

@pemensik pemensik changed the title Use file path in %patch macro [RFE] Use file path in %patch macro Feb 6, 2019
@pmatilai
Copy link
Member

Hmm, this is presented as an alternative to #626 but since that was solved, is there something here that you still need?

I'm all for simplifying (and even eliminating) the built-in %patch related code, but this seems more like complicating the situation further by adding even more related macros...

@pemensik
Copy link
Contributor Author

pemensik commented Mar 13, 2019

Hmm, maybe I am just missing shorter alternative to %patch123 macro. I can use %apply_patch, but I have to provide both path to patch and number as arguments to that. Is there something like %apply 123 that can be used as simple way to use just one patch?

I think I can use
%autopatch -m 123 -M 123
It would work now, but seems a little bit unfriendly and repeating. Would it make sense to support also another parameter to use just patch with specified number? Like %autopatch -n 123?

I think some shortcut to %apply_patch %{PATCH%{1}} %{1} might be useful instead of original. Would allow simple change of spec from %patchX sets to apply_patch based changes.

@Conan-Kudo
Copy link
Member

Conan-Kudo commented Mar 14, 2019

@pemensik You can use %patch -P 123

This can also be combined in "fun" ways:

%patch -p1 -P 0001 0002 0003 0004
%patch -p2 -P 0101 0102 0103 0104
%patch -p0 -P 2001

@pemensik
Copy link
Contributor Author

@pemensik You can use %patch -P 123
I can, but it does not work well with %autosetup -N -S git, which is my point. I want to apply one patch like %apply_patch, with support for %__scm macro. But simple and short way. My patch allows to override %patch -p1 -P 0001 with custom macro, where %scm can be used.

@pmatilai
Copy link
Member

Somewhere in the meanwhile this use-case was solved in a different manner: %autopatch now accepts individual patches as arguments (see commits f101c8c and c495d73)

Thanks for the patch though!

@pmatilai pmatilai closed this Jan 25, 2022
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.

None yet

3 participants