How to avoid building not-needed binary packages when building the kernel package?


When I build the kernel binaries using mock for Rocky 9, I get a bucket load of binaries that I do not need (kernel-debug, kernel-rt, python-*).

How to avoid building those?

I know mock has a “–without” option, but how to use it?

I tried: --without kernel-rt … but that did not work. To be specific, this is how I used it:

mock --without kernel-debug --without kernel-rt -r /path/to/kernel-source.rpm

Thank you.

A. I don’t have a clue
B. Google found: How do I make rpmbuild only build subpackages? - Stack Overflow

Adapt for example your spec file and add following statement

%global debug_package %{nil}

Use: --without rt, --without debug. When removing variants or options for the kernel builds, don’t use the full name, just use the variant name.

I tried that, and it did not work. mock still build all the rpms I told it not to build.

This is the exact command I used:
mock -r /etc/mock/rocky-9-x86_64.cfg --without debug --without rt --without selftests --without python3-perf --without tools --without cross ~/rpmbuild/SRPMS/kernel-5.14.0-362.24.1.el9.0.1.src.rpm
it still built the kernel-rt-* packages, and kernel-debug-* packages, and the others as well.