On Wed, May 31, 2023 at 1:10 PM stan via kernel
<kernel(a)lists.fedoraproject.org> wrote:
It has been ages since I wanted to patch the kernel when I built a
custom kernel. I tried putting the patch in the spec file where the
other patches were, but it doesn't apply. There is no error, or even
indication that it saw the patch, so I am obviously doing it
incorrectly.
I'm building the kernel from the srpm using rpmbuild. It builds fine
when unpatched. I can, of course, just untar the kernel tar file,
apply the patch, and tar it. But, it should be simple to do from the
spec file directly. Can anyone point me to the current procedure?
Here is what is in the spec file:
```
## Patches needed for building this package
%if !%{nopatches}
Patch1: patch-%{patchversion}-redhat.patch
Patch2: 0001-my_custom_change.patch
%endif
# empty final patch to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch
```
I tried it outside the if, still didn't work:
```
## Patches needed for building this package
%if !%{nopatches}
Patch1: patch-%{patchversion}-redhat.patch
%endif
Patch2: 0001-my_custom_change.patch
# empty final patch to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch
```
Here is the output with this version in the spec file.
+ ApplyOptionalPatch patch-6.4-redhat.patch
+ local patch=patch-6.4-redhat.patch
+ shift
+ '[' '!' -f /home/stan/rpmbuild/SOURCES/patch-6.4-redhat.patch
']'
++ wc -l /home/stan/rpmbuild/SOURCES/patch-6.4-redhat.patch
++ awk '{print $1}'
+ local C=2978
+ '[' 2978 -gt 9 ']'
+ ApplyPatch patch-6.4-redhat.patch
+ local patch=patch-6.4-redhat.patch
+ shift
+ '[' '!' -f /home/stan/rpmbuild/SOURCES/patch-6.4-redhat.patch
']'
+ case "$patch" in
+ git --work-tree=. apply
+ ApplyOptionalPatch linux-kernel-test.patch
+ local patch=linux-kernel-test.patch
+ shift
+ '[' '!' -f /home/stan/rpmbuild/SOURCES/linux-kernel-test.patch
']'
++ wc -l /home/stan/rpmbuild/SOURCES/linux-kernel-test.patch
It finds the Patch999999 patch which is empty, and in
~/rpmbuild/SOURCE like my patch, so why isn't it finding my patch?
Patch2: just adds it to the file manifest for the srpm. You have to
apply it in some manner. While we used to have a weird git routine
that set everything up as a git tree and did git am using the
manifest, that was a lot of unnecessary overhead, and of little value
when most development is done in the source tree now.
You need another line in the spec:
ApplyOptionalPatch 0001-my_custom_change.patch
Of note, the linux-kernel-test.patch is also meant to facilitate
people doing quick builds with a patch in dist-git. You could 'cat
0001-my_custom_change.patch > linux-kernel-test.patch' and not have to
touch the spec at all.
Justin
> Thanks for any help.
> _______________________________________________
> kernel mailing list -- kernel(a)lists.fedoraproject.org
> To unsubscribe send an email to kernel-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
> Do not reply to spam, report it:
https://pagure.io/fedora-infrastructure/new_issue