Debian – Kernel compilation error recipe for target ‘deb-pkg’ failed

compilingdebianlinux-kernel

I am compiling the latest kernel cloned from Linus's git repository for a challenge. Here are the steps I followed,
1. Installed cross compilation tools

sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev  

2. cloned the latest git repository

$ git clone https://github.com/torvalds/linux.git  

3. Copied the current build configuration to the root of the source tree and updated the configuration file.

yes '' | make oldconfig  

4. make clean
5. Made the linux image and header .deb files

make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom  

After a few minutes of compilation, it shows the error

dpkg-genchanges: warning: package linux-firmware-image-4.2.0-rc3-custom listed in files list but not in control info
dpkg-genchanges: warning: package linux-headers-4.2.0-rc3-custom listed in files list but not in control info
dpkg-genchanges: warning: package linux-headers-4.3.0-rc1-eudyptula listed in files list but not in control info
dpkg-genchanges: warning: package linux-image-4.2.0-rc3-custom-dbg listed in files list but not in control info
dpkg-genchanges: warning: package linux-image-4.3.0-rc1-eudyptula listed in files list but not in control info
dpkg-genchanges: warning: package linux-image-4.2.0-rc3-custom listed in files list but not in control info
dpkg-genchanges: warning: package linux-image-4.3.0-rc1-eudyptula-dbg listed in files list but not in control info
dpkg-genchanges: warning: package linux-firmware-image-4.3.0-rc1-eudyptula listed in files list but not in control info
dpkg-genchanges: error: package linux-image-4.2.0-rc3-custom-dbg has section kernel in control file but debug in files list
scripts/package/Makefile:91: recipe for target 'deb-pkg' failed
make[1]: *** [deb-pkg] Error 255
Makefile:1226: recipe for target 'deb-pkg' failed
make: *** [deb-pkg] Error 2 

I think the error has occurred in the making of .deb package. I really don't understand the error message

 linux-image-4.2.0-rc3-custom-dbg has section kernel in control file but debug in files list  

What does it really means?. Please help!

Best Answer

First, the yes '' | make oldconfig step is more easily done by way of make olddefconfig.

Having said that,

What happens is that the kernel's Makefile generates a number of files inside a debian/ directory which are not completely following the spec. Combined with a gradual stricter enforcement of this spec in the build tools over the years, means that a hack which used to work in the past (generating .deb packages which aren't listed in debian/control, or which are listed but whose details differ) don't work anymore these days.

Personally, I recommend against the make deb-pkg method of building a Debian package of a vanilla kernel. If you want to do that, a method which works better IME is to use the kernel-package package which is part of Debian proper:

apt install kernel-package fakeroot
cd /path/to/git/checkout
make defconfig
make-kpkg --rootcmd fakeroot kernel_image

This should get you a package (with the .config file you created) that you can install on your Debian system.

Related Question