All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 5/6] kbuild: deb-pkg: use dh_listpackages to know enabled packages
Date: Mon, 13 Mar 2023 05:07:30 +0900	[thread overview]
Message-ID: <20230312200731.599706-6-masahiroy@kernel.org> (raw)
In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org>

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>
---

 scripts/package/builddeb | 61 ++++++++++++++++++++++------------------
 scripts/package/mkdebian |  7 ++++-
 2 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 906889b304a4..c5ae57167d7c 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -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
-
-	deploy_libc_headers debian/linux-libc-dev
-	create_package linux-libc-dev debian/linux-libc-dev
-fi
-
-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
+packages_enabled=$(dh_listpackages)
+
+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
+
+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
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index 31b050368cd0..e80a661a79ee 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -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
-- 
2.34.1


  parent reply	other threads:[~2023-03-12 20:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 20:07 [PATCH 0/6] kbuild: fix some packaging issues, and use git-archive for source package Masahiro Yamada
2023-03-12 20:07 ` [PATCH 1/6] kbuild: deb-pkg: make debian source package working again Masahiro Yamada
2023-03-12 20:07 ` [PATCH 2/6] kbuild: deb-pkg: do not take KERNELRELEASE from the source version Masahiro Yamada
2023-03-13 11:31   ` Péter Ujfalusi
2023-03-12 20:07 ` [PATCH 3/6] kbuild: deb-pkg: set CROSS_COMPILE only when undefined Masahiro Yamada
2023-03-12 20:07 ` [PATCH 4/6] kbuild: deb-pkg: split image and debug objects staging out into functions Masahiro Yamada
2023-03-12 20:07 ` Masahiro Yamada [this message]
2023-03-12 20:07 ` [PATCH 6/6] kbuild: use git-archive for source package creation Masahiro Yamada
2023-04-06 15:25   ` youling257
2023-04-07 12:04     ` Masahiro Yamada
2023-03-12 23:26 ` [PATCH 0/6] kbuild: fix some packaging issues, and use git-archive for source package Linus Torvalds
2023-03-13  0:52   ` Masahiro Yamada
2023-03-13 17:33     ` Linus Torvalds
2023-03-16 10:22 ` Leon Romanovsky
2023-03-16 11:24   ` Nicolas Schier
2023-03-16 12:50     ` Leon Romanovsky
2023-03-19  1:12 ` Steev Klimaszewski
2023-03-19  2:19   ` Masahiro Yamada
2023-03-19  3:21     ` Steev Klimaszewski
2023-03-19  6:45       ` Steev Klimaszewski
2023-03-19  7:06       ` Masahiro Yamada
2023-03-19  7:57         ` Steev Klimaszewski
2023-03-19  7:02 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230312200731.599706-6-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.