kbuild: deb-pkg: use dh_listpackages to know enabled packages

Use dh_listpackages to get a list of all binary packages.

With this, debian/control lists which binary packages will be produced.
Previously, ARCH=um listed linux-libc-dev in debian/control, but it
was not generated because each of mkdebian and builddeb independently
maintained the if-conditionals.

Another motivation is to allow scripts/package/builddeb to get the
package name (linux-image-*, etc.) dynamically from debian/control.

This will also allow the BuildProfile to control the generation of
the binary packages.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Masahiro Yamada 2023-03-13 05:07:30 +09:00
parent b611daae5e
commit 36862e14e3
2 changed files with 37 additions and 27 deletions

View File

@ -160,7 +160,7 @@ install_linux_image_dbg () {
ln -s lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/vmlinux-${KERNELRELEASE}
}
deploy_kernel_headers () {
install_kernel_headers () {
pdir=$1
rm -rf $pdir
@ -198,7 +198,7 @@ deploy_kernel_headers () {
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
}
deploy_libc_headers () {
install_libc_headers () {
pdir=$1
rm -rf $pdir
@ -213,33 +213,38 @@ deploy_libc_headers () {
mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/
}
version=$KERNELRELEASE
packagename=linux-image-$version
dbg_packagename=$packagename-dbg
if [ "$ARCH" = "um" ] ; then
packagename=user-mode-linux-$version
fi
rm -f debian/files
if [ "$ARCH" != "um" ]; then
if is_enabled CONFIG_MODULES; then
deploy_kernel_headers debian/linux-headers
create_package linux-headers-$version debian/linux-headers
fi
packages_enabled=$(dh_listpackages)
deploy_libc_headers debian/linux-libc-dev
create_package linux-libc-dev debian/linux-libc-dev
fi
for package in ${packages_enabled}
do
case ${package} in
*-dbg)
# This must be done after linux-image, that is, we expect the
# debug package appears after linux-image in debian/control.
install_linux_image_dbg debian/linux-image-dbg debian/linux-image;;
linux-image-*|user-mode-linux-*)
install_linux_image debian/linux-image ${package};;
linux-libc-dev)
install_libc_headers debian/linux-libc-dev;;
linux-headers-*)
install_kernel_headers debian/linux-headers;;
esac
done
install_linux_image debian/linux-image "$packagename"
if is_enabled CONFIG_DEBUG_INFO; then
install_linux_image_dbg debian/linux-image-dbg debian/linux-image
create_package "$dbg_packagename" debian/linux-image-dbg
fi
create_package "$packagename" debian/linux-image
for package in ${packages_enabled}
do
case ${package} in
*-dbg)
create_package ${package} debian/linux-image-dbg;;
linux-image-*|user-mode-linux-*)
create_package ${package} debian/linux-image;;
linux-libc-dev)
create_package ${package} debian/linux-libc-dev;;
linux-headers-*)
create_package ${package} debian/linux-headers;;
esac
done
exit 0

View File

@ -192,7 +192,7 @@ Section: kernel
Priority: optional
Maintainer: $maintainer
Rules-Requires-Root: no
Build-Depends: bc, rsync, kmod, cpio, bison, flex $extra_build_depends
Build-Depends: bc, debhelper, rsync, kmod, cpio, bison, flex $extra_build_depends
Homepage: https://www.kernel.org/
Package: $packagename-$version
@ -200,6 +200,10 @@ Architecture: $debarch
Description: Linux kernel, version $version
This package contains the Linux kernel, modules and corresponding other
files, version: $version.
EOF
if [ "${SRCARCH}" != um ]; then
cat <<EOF >> debian/control
Package: linux-libc-dev
Section: devel
@ -222,6 +226,7 @@ Description: Linux kernel headers for $version on $debarch
This is useful for people who need to build external modules
EOF
fi
fi
if is_enabled CONFIG_DEBUG_INFO; then
cat <<EOF >> debian/control