[PATCH] kbuild: add package-dbg to pacman packages

1127955419@qq.com posted 1 patch 2 months ago
scripts/package/PKGBUILD | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
[PATCH] kbuild: add package-dbg to pacman packages
Posted by 1127955419@qq.com 2 months ago
From: Li XingYang <1127955419@qq.com>

The current pacman package does not include the debuginfo package
add debuginfo package that include vmlinux
vmlinux is very useful when debugging the kernel using crash

Signed-off-by: Li XingYang <1127955419@qq.com>
---
 scripts/package/PKGBUILD | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
index 663ce300dd06..4b5c435e5eaa 100644
--- a/scripts/package/PKGBUILD
+++ b/scripts/package/PKGBUILD
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}" "${pkgbase}-api-headers")
 if grep -q CONFIG_MODULES=y include/config/auto.conf; then
-	pkgname+=("${pkgbase}-headers")
+	pkgname+=("${pkgbase}-headers" "${pkgbase}-dbg")
 fi
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
@@ -100,6 +100,18 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
+_package-dbg() {
+	pkgdesc="debuginfo for the ${pkgdesc} kernel"
+
+	export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
+	cd "${objtree}"
+	local builddir="${pkgdir}/usr/${MODLIB}/build"
+	mkdir -p "${builddir}"
+
+	echo "Installing vmlinux..."
+	cp vmlinux "${builddir}/vmlinux"
+}
+
 for _p in "${pkgname[@]}"; do
 	eval "package_$_p() {
 		$(declare -f "_package${_p#$pkgbase}")
-- 
2.46.1
Re: [PATCH] kbuild: add package-dbg to pacman packages
Posted by linux@weissschuh.net 2 months ago
Hi,

Sep 23, 2024 13:58:06 1127955419@qq.com:

> From: Li XingYang <1127955419@qq.com>
>
> The current pacman package does not include the debuginfo package
> add debuginfo package that include vmlinux
> vmlinux is very useful when debugging the kernel using crash

This is already implemented in
"kbuild: add debug package to pacman PKGBUILD"
which is in the kbuild tree.

https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=4929f5b95f6b20ae10f2c409fb2ca58253e73706

>
> Signed-off-by: Li XingYang <1127955419@qq.com>
> ---
> scripts/package/PKGBUILD | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> index 663ce300dd06..4b5c435e5eaa 100644
> --- a/scripts/package/PKGBUILD
> +++ b/scripts/package/PKGBUILD
> @@ -5,7 +5,7 @@
> pkgbase=${PACMAN_PKGBASE:-linux-upstream}
> pkgname=("${pkgbase}" "${pkgbase}-api-headers")
> if grep -q CONFIG_MODULES=y include/config/auto.conf; then
> -   pkgname+=("${pkgbase}-headers")
> +   pkgname+=("${pkgbase}-headers" "${pkgbase}-dbg")
> fi
> pkgver="${KERNELRELEASE//-/_}"
> # The PKGBUILD is evaluated multiple times.
> @@ -100,6 +100,18 @@ _package-api-headers() {
>     ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
> }
>
> +_package-dbg() {
> +   pkgdesc="debuginfo for the ${pkgdesc} kernel"
> +
> +   export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
> +   cd "${objtree}"
> +   local builddir="${pkgdir}/usr/${MODLIB}/build"
> +   mkdir -p "${builddir}"
> +
> +   echo "Installing vmlinux..."
> +   cp vmlinux "${builddir}/vmlinux"
> +}
> +
> for _p in "${pkgname[@]}"; do
>     eval "package_$_p() {
>         $(declare -f "_package${_p#$pkgbase}")
> --
> 2.46.1