Issue
I am trying to modify one of the CentOS (7.6) kernel source file and recompile all of them for later installation.
I followed the guide on wiki.centos to do customized kernel: href="https://wiki.centos.org/HowTos/Custom_Kernel" rel="nofollow noreferrer">https://wiki.centos.org/HowTos/Custom_Kernel
I found that in step 5, the RPM method always unpacked source files from tar files and replaced my modification in BUILD/.
Therefore, I changed my way. I put my modification at another place and added a line in kernel.spec
file under SPECS/ to copy my file into the BUILD/. Namely, one-line with cp
command is put before %build
in the kernel.spec
(after unpacked). However, the compilation went wrong in the %build
section:
...
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.Vd6by5
BUILDING A KERNEL FOR x86_64...
USING ARCH=x86_64
...
###
### Now generating an X.509 key pair to be used for signing modules.
###
### If this takes a long time, you might wish to run rngd in the
### background to keep the supply of entropy topped up. It
### needs to be run as root, and uses a hardware random
### number generator if one is available.
###
Generating a 3072 bit RSA private key
....++
......................................................................................................................................................................................++
writing new private key to 'signing_key.priv'
-----
###
### Key pair generated.
###
- Including cert /home/user/rpmbuild/BUILD/kernel-3.10.0-957.12.2.el7/linux-3.10.0-957.12.2.el7.v2.x86_64/centos-kpatch.x509
- Including cert /home/user/rpmbuild/BUILD/kernel-3.10.0-957.12.2.el7/linux-3.10.0-957.12.2.el7.v2.x86_64/centos-ldup.x509
- Including cert signing_key.x509
RPM build errors:
Could somebody suggest me a better way to replace the source file in the compilation procedure? Thanks.
Solution
I found the solution myself. Instead of directly replacing files, we should apply patch
within RPM to indicate the differences between modified file and original file.
Firstly, use diff
command to build patch. Then, modify spec file, kernel.spec
, applying the patch to the building procedure.
This website shows the example when using this way to compile kernel: https://www.hiroom2.com/2016/05/29/centos-7-rebuild-kernel-with-src-rpm/
A more clear reference for patching files: https://rpm-packaging-guide.github.io/#patching-software
Answered By - DaveW Answer Checked By - David Goodson (WPSolving Volunteer)