diff mbox series

[V3] kbuild: control extra pacman packages with PACMAN_EXTRAPACKAGES

Message ID 20240813011619.13857-1-jose.fernandez@linux.dev (mailing list archive)
State New
Headers show
Series [V3] kbuild: control extra pacman packages with PACMAN_EXTRAPACKAGES | expand

Commit Message

Jose Fernandez Aug. 13, 2024, 1:16 a.m. UTC
Introduce the PACMAN_EXTRAPACKAGES variable in PKGBUILD to allow users
to specify which additional packages are built by the pacman-pkg target.

Previously, the api-headers package was always included, and the headers
package was included only if CONFIG_MODULES=y. With this change, both
headers and api-headers packages are included by default. Users can now
control this behavior by setting PACMAN_EXTRAPACKAGES to a
space-separated list of desired extra packages or leaving it empty to
exclude all.

For example, to build only the base package without extras:

make pacman-pkg PACMAN_EXTRAPACKAGES=""

Signed-off-by: Jose Fernandez <jose.fernandez@linux.dev>
Reviewed-by: Peter Jung <ptr1337@cachyos.org>
---
v1->v2:
- Build all extra packages by default
- Remove unnecessary lines
v2->v3:
- Move the default PACMAN_EXTRAPACKAGES value to PKGBUILD
- Remove all changes done to Makefile.package
- Conditionally run the install-extmod-build script if CONFIG_MODULES=y
- Add explicit `mkdir -p "${builddir}"` prior to copying System.map and .config

This patch gives users control over which extra packages are built, addressing
concerns about build time from adding a new debug package [1]. It allows
selective inclusion of extra packages before introducing an optional debug
package.

[1] https://lore.kernel.org/lkml/20240801192008.GA3923315@thelio-3990X/T/

 scripts/package/PKGBUILD | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)


base-commit: 7809144639f6c92bcb11bd3284b7806a42cc67fe

Comments

Nathan Chancellor Aug. 13, 2024, 6:59 p.m. UTC | #1
On Mon, Aug 12, 2024 at 07:16:19PM -0600, Jose Fernandez wrote:
> Introduce the PACMAN_EXTRAPACKAGES variable in PKGBUILD to allow users
> to specify which additional packages are built by the pacman-pkg target.
> 
> Previously, the api-headers package was always included, and the headers
> package was included only if CONFIG_MODULES=y. With this change, both
> headers and api-headers packages are included by default. Users can now
> control this behavior by setting PACMAN_EXTRAPACKAGES to a
> space-separated list of desired extra packages or leaving it empty to
> exclude all.
> 
> For example, to build only the base package without extras:
> 
> make pacman-pkg PACMAN_EXTRAPACKAGES=""
> 
> Signed-off-by: Jose Fernandez <jose.fernandez@linux.dev>
> Reviewed-by: Peter Jung <ptr1337@cachyos.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
> v1->v2:
> - Build all extra packages by default
> - Remove unnecessary lines
> v2->v3:
> - Move the default PACMAN_EXTRAPACKAGES value to PKGBUILD
> - Remove all changes done to Makefile.package
> - Conditionally run the install-extmod-build script if CONFIG_MODULES=y
> - Add explicit `mkdir -p "${builddir}"` prior to copying System.map and .config
> 
> This patch gives users control over which extra packages are built, addressing
> concerns about build time from adding a new debug package [1]. It allows
> selective inclusion of extra packages before introducing an optional debug
> package.
> 
> [1] https://lore.kernel.org/lkml/20240801192008.GA3923315@thelio-3990X/T/
> 
>  scripts/package/PKGBUILD | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> index 663ce300dd06..fbd7eb10a52c 100644
> --- a/scripts/package/PKGBUILD
> +++ b/scripts/package/PKGBUILD
> @@ -3,10 +3,13 @@
>  # Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
>  
>  pkgbase=${PACMAN_PKGBASE:-linux-upstream}
> -pkgname=("${pkgbase}" "${pkgbase}-api-headers")
> -if grep -q CONFIG_MODULES=y include/config/auto.conf; then
> -	pkgname+=("${pkgbase}-headers")
> -fi
> +pkgname=("${pkgbase}")
> +
> +_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
> +for pkg in $_extrapackages; do
> +	pkgname+=("${pkgbase}-${pkg}")
> +done
> +
>  pkgver="${KERNELRELEASE//-/_}"
>  # The PKGBUILD is evaluated multiple times.
>  # Running scripts/build-version from here would introduce inconsistencies.
> @@ -77,10 +80,13 @@ _package-headers() {
>  	cd "${objtree}"
>  	local builddir="${pkgdir}/usr/${MODLIB}/build"
>  
> -	echo "Installing build files..."
> -	"${srctree}/scripts/package/install-extmod-build" "${builddir}"
> +	if grep -q CONFIG_MODULES=y include/config/auto.conf; then
> +		echo "Installing build files..."
> +		"${srctree}/scripts/package/install-extmod-build" "${builddir}"
> +	fi
>  
>  	echo "Installing System.map and config..."
> +	mkdir -p "${builddir}"
>  	cp System.map "${builddir}/System.map"
>  	cp .config "${builddir}/.config"
>  
> 
> base-commit: 7809144639f6c92bcb11bd3284b7806a42cc67fe
> -- 
> 2.46.0
>
Christian Heusel Aug. 13, 2024, 8:06 p.m. UTC | #2
On 24/08/12 07:16PM, Jose Fernandez wrote:
> Introduce the PACMAN_EXTRAPACKAGES variable in PKGBUILD to allow users
> to specify which additional packages are built by the pacman-pkg target.
> 
> Previously, the api-headers package was always included, and the headers
> package was included only if CONFIG_MODULES=y. With this change, both
> headers and api-headers packages are included by default. Users can now
> control this behavior by setting PACMAN_EXTRAPACKAGES to a
> space-separated list of desired extra packages or leaving it empty to
> exclude all.
> 
> For example, to build only the base package without extras:
> 
> make pacman-pkg PACMAN_EXTRAPACKAGES=""
> 
> Signed-off-by: Jose Fernandez <jose.fernandez@linux.dev>
> Reviewed-by: Peter Jung <ptr1337@cachyos.org>

Reviewed-by: Christian Heusel <christian@heusel.eu>
Tested-by: Christian Heusel <christian@heusel.eu>
Thomas Weißschuh Aug. 13, 2024, 8:18 p.m. UTC | #3
On 2024-08-12 19:16:19+0000, Jose Fernandez wrote:
> Introduce the PACMAN_EXTRAPACKAGES variable in PKGBUILD to allow users
> to specify which additional packages are built by the pacman-pkg target.
> 
> Previously, the api-headers package was always included, and the headers
> package was included only if CONFIG_MODULES=y. With this change, both
> headers and api-headers packages are included by default. Users can now
> control this behavior by setting PACMAN_EXTRAPACKAGES to a
> space-separated list of desired extra packages or leaving it empty to
> exclude all.
> 
> For example, to build only the base package without extras:
> 
> make pacman-pkg PACMAN_EXTRAPACKAGES=""
> 
> Signed-off-by: Jose Fernandez <jose.fernandez@linux.dev>
> Reviewed-by: Peter Jung <ptr1337@cachyos.org>

Acked-by: Thomas Weißschuh <linux@weissschuh.net>

Thanks!
Masahiro Yamada Aug. 16, 2024, 1 p.m. UTC | #4
On Tue, Aug 13, 2024 at 10:17 AM Jose Fernandez
<jose.fernandez@linux.dev> wrote:
>
> Introduce the PACMAN_EXTRAPACKAGES variable in PKGBUILD to allow users
> to specify which additional packages are built by the pacman-pkg target.
>
> Previously, the api-headers package was always included, and the headers
> package was included only if CONFIG_MODULES=y. With this change, both
> headers and api-headers packages are included by default. Users can now
> control this behavior by setting PACMAN_EXTRAPACKAGES to a
> space-separated list of desired extra packages or leaving it empty to
> exclude all.
>
> For example, to build only the base package without extras:
>
> make pacman-pkg PACMAN_EXTRAPACKAGES=""
>
> Signed-off-by: Jose Fernandez <jose.fernandez@linux.dev>
> Reviewed-by: Peter Jung <ptr1337@cachyos.org>


Applied to linux-kbuild.
Thanks!


--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
index 663ce300dd06..fbd7eb10a52c 100644
--- a/scripts/package/PKGBUILD
+++ b/scripts/package/PKGBUILD
@@ -3,10 +3,13 @@ 
 # Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
 
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
-pkgname=("${pkgbase}" "${pkgbase}-api-headers")
-if grep -q CONFIG_MODULES=y include/config/auto.conf; then
-	pkgname+=("${pkgbase}-headers")
-fi
+pkgname=("${pkgbase}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+for pkg in $_extrapackages; do
+	pkgname+=("${pkgbase}-${pkg}")
+done
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
@@ -77,10 +80,13 @@  _package-headers() {
 	cd "${objtree}"
 	local builddir="${pkgdir}/usr/${MODLIB}/build"
 
-	echo "Installing build files..."
-	"${srctree}/scripts/package/install-extmod-build" "${builddir}"
+	if grep -q CONFIG_MODULES=y include/config/auto.conf; then
+		echo "Installing build files..."
+		"${srctree}/scripts/package/install-extmod-build" "${builddir}"
+	fi
 
 	echo "Installing System.map and config..."
+	mkdir -p "${builddir}"
 	cp System.map "${builddir}/System.map"
 	cp .config "${builddir}/.config"