Skip to contentSkip to conversation

kbuild: control extra pacman packages with PACMAN_EXTRAPACKAGES

PATCH Superseded Jose Fernandez 3 participants 5 messages Aug 4, 2024 – Aug 6, 2024

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: control extra pacman packages with PACMAN_EXTRAPACKAGES

Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package to control the creation of additional packages by the pacman-pkg target.

This changes the behavior of the pacman-pkg target to only create the main kernel package by default. The rest of the packages will be opt-in going forward.

In a previous patch, there was concern that adding a new debug package would increase the package time. To address this concern and provide more flexibility, this change has been added to allow users to decide which extra packages to include before introducing an optional debug package [1].

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

---
 scripts/Makefile.package |  5 +++++
 scripts/package/PKGBUILD | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
scripts/Makefile.package +5 -0
index 4a80584ec771..146e828cb4f1 100644
@@ -144,6 +144,10 @@ snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+# Space-separated list of extra packages to build
+# The available extra packages are: headers api-headers
+PACMAN_EXTRAPACKAGES ?=
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
@@ -152,6 +156,7 @@ pacman-pkg:
 		CARCH="$(UTS_MACHINE)" \
 		KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
 		KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+		PACMAN_EXTRAPACKAGES="$(PACMAN_EXTRAPACKAGES)" \
 		makepkg $(MAKEPKGOPTS)
 
 # dir-pkg tar*-pkg - tarball targets
scripts/package/PKGBUILD +8 -3
index 663ce300dd06..41bd0d387f0a 100644
@@ -3,10 +3,15 @@
 # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
 
 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}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES:-}
+if [ -n "$_extrapackages" ]; then
+	for pkg in $_extrapackages; do
+		pkgname+=("${pkgbase}-$pkg")
+	done
 fi
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
Signature · 1 line
2.46.0
#1 lore raw

Hi Jose,

Quoted 6 lines · Jose Fernandez

Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package to control the creation of additional packages by the pacman-pkg target.

This changes the behavior of the pacman-pkg target to only create the main kernel package by default. The rest of the packages will be opt-in going forward.

I had the impression that by default all extrapackages should be built. The variable can then be used by expert users where needed. Other Opinions?

Quoted 5 lines

In a previous patch, there was concern that adding a new debug package would increase the package time. To address this concern and provide more flexibility, this change has been added to allow users to decide which extra packages to include before introducing an optional debug package [1].

This paragraph seems like it shouldn't be part of the final commit. If you put it after a line with "---" it will be dropped from the commit, like so:

---

In a previous patch, ...

Quoted 15 lines

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

---
 scripts/Makefile.package |  5 +++++
 scripts/package/PKGBUILD | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
scripts/Makefile.package +0 -0
index 4a80584ec771..146e828cb4f1 100644

scripts/Makefile.package snap-pkg: · line 149

Quoted 6 lines
scripts/Makefile.package +3 -0
@@ -144,6 +144,10 @@ snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+# Space-separated list of extra packages to build
+# The available extra packages are: headers api-headers
+PACMAN_EXTRAPACKAGES ?=

The assignment doesn't do anything.
Do we need the documentation if the default enables all subpackages?

scripts/Makefile.package pacman-pkg: · line 159

Quoted 9 lines
scripts/Makefile.package +2 -0
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
@@ -152,6 +156,7 @@ pacman-pkg:
 		CARCH="$(UTS_MACHINE)" \
 		KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
 		KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+		PACMAN_EXTRAPACKAGES="$(PACMAN_EXTRAPACKAGES)" \

This line is superfluous.

Quoted 8 lines
scripts/Makefile.package +0 -0
 		makepkg $(MAKEPKGOPTS)
 
 # dir-pkg tar*-pkg - tarball targets
scripts/package/PKGBUILD +0 -0
index 663ce300dd06..41bd0d387f0a 100644

scripts/package/PKGBUILD line 9

Quoted 10 lines
scripts/package/PKGBUILD +4 -3
@@ -3,10 +3,15 @@
 # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
 
 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}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES:-}
+if [ -n "$_extrapackages" ]; then

No need for this check. The loop over an empty variable work fine.

scripts/package/PKGBUILD line 11

Quoted 2 lines
scripts/package/PKGBUILD +2 -0
+	for pkg in $_extrapackages; do
+		pkgname+=("${pkgbase}-$pkg")

Use consistent variable references: "${pkgbase}-${pkg}"

Quoted 9 lines
scripts/package/PKGBUILD +2 -0
+	done
 fi
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
Signature · 1 line
2.46.0
#2 lore raw
Quoted 7 lines · Thomas Weißschuh
Quoted 3 lines

This changes the behavior of the pacman-pkg target to only create the main kernel package by default. The rest of the packages will be opt-in going forward.

I had the impression that by default all extrapackages should be built. The variable can then be used by expert users where needed. Other Opinions?

I think switching to defaulting to all packages is a good idea. One concern I had was how regular users would discover the customization options. Expert users will likely look at the Makefile and figure out how to opt out.

I will plan to make this change for v2 unless there are any objections.

Quoted 6 lines
Quoted 5 lines

In a previous patch, there was concern that adding a new debug package would increase the package time. To address this concern and provide more flexibility, this change has been added to allow users to decide which extra packages to include before introducing an optional debug package [1].

Quoted 7 lines

This paragraph seems like it shouldn't be part of the final commit. If you put it after a line with "---" it will be dropped from the commit, like so:

---

In a previous patch, ...

Agreed, I will move this paragraph to below --- for v2.

Quoted 26 lines
Quoted 16 lines

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

---
 scripts/Makefile.package |  5 +++++
 scripts/package/PKGBUILD | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
scripts/Makefile.package +0 -0
index 4a80584ec771..146e828cb4f1 100644

scripts/Makefile.package snap-pkg: · line 149

Quoted 6 lines
scripts/Makefile.package +3 -0
@@ -144,6 +144,10 @@ snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+# Space-separated list of extra packages to build
+# The available extra packages are: headers api-headers
+PACMAN_EXTRAPACKAGES ?=

The assignment doesn't do anything.
Do we need the documentation if the default enables all subpackages?

Quoted 11 lines

scripts/Makefile.package pacman-pkg: · line 159

Quoted 9 lines
scripts/Makefile.package +2 -0
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
@@ -152,6 +156,7 @@ pacman-pkg:
 		CARCH="$(UTS_MACHINE)" \
 		KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
 		KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+		PACMAN_EXTRAPACKAGES="$(PACMAN_EXTRAPACKAGES)" \

This line is superfluous.

Ack.

Quoted 10 lines
Quoted 10 lines
scripts/Makefile.package +0 -0
 		makepkg $(MAKEPKGOPTS)
 
 # dir-pkg tar*-pkg - tarball targets
scripts/package/PKGBUILD +0 -0
index 663ce300dd06..41bd0d387f0a 100644
@@ -3,10 +3,15 @@
 # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
 
Quoted 10 lines

scripts/package/PKGBUILD line 9

Quoted 8 lines
scripts/package/PKGBUILD +4 -3
 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}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES:-}
+if [ -n "$_extrapackages" ]; then

No need for this check. The loop over an empty variable work fine.

Ack. Will update in v2.

Quoted 4 lines

scripts/package/PKGBUILD line 11

Quoted 2 lines
scripts/package/PKGBUILD +2 -0
+	for pkg in $_extrapackages; do
+		pkgname+=("${pkgbase}-$pkg")

Use consistent variable references: "${pkgbase}-${pkg}"

Ack. Will update in v2.

Quoted 9 lines
Quoted 9 lines
scripts/package/PKGBUILD +2 -0
+	done
 fi
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
Signature · 1 line
2.46.0
#3 lore raw
Quoted 5 lines · Jose Fernandez
Quoted 4 lines · Thomas Weißschuh
Quoted 3 lines

This changes the behavior of the pacman-pkg target to only create the main kernel package by default. The rest of the packages will be opt-in going forward.

Quoted 7 lines
Quoted 3 lines

I had the impression that by default all extrapackages should be built. The variable can then be used by expert users where needed. Other Opinions?

I think switching to defaulting to all packages is a good idea. One concern I had was how regular users would discover the customization options. Expert users will likely look at the Makefile and figure out how to opt out.

I think that most users will likely want all of the packages built by default. I think leaving this to be discovered by power users in the Makefile is reasonable.

Quoted 54 lines
Quoted 6 lines
Quoted 5 lines

In a previous patch, there was concern that adding a new debug package would increase t.he package time. To address this concern and provide more flexibility, this change has been added to allow users to decide which extra packages to include before introducing an optional debug package [1].

Quoted 7 lines

This paragraph seems like it shouldn't be part of the final commit. If you put it after a line with "---" it will be dropped from the commit, like so:

---

In a previous patch, ...

Agreed, I will move this paragraph to below --- for v2.

Quoted 26 lines
Quoted 16 lines

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

---
 scripts/Makefile.package |  5 +++++
 scripts/package/PKGBUILD | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
scripts/Makefile.package +0 -0
index 4a80584ec771..146e828cb4f1 100644

scripts/Makefile.package snap-pkg: · line 149

Quoted 6 lines
scripts/Makefile.package +3 -0
@@ -144,6 +144,10 @@ snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+# Space-separated list of extra packages to build
+# The available extra packages are: headers api-headers
+PACMAN_EXTRAPACKAGES ?=

The assignment doesn't do anything.
Do we need the documentation if the default enables all subpackages?

Quoted 11 lines

scripts/Makefile.package pacman-pkg: · line 159

Quoted 9 lines
scripts/Makefile.package +2 -0
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
@@ -152,6 +156,7 @@ pacman-pkg:
 		CARCH="$(UTS_MACHINE)" \
 		KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
 		KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+		PACMAN_EXTRAPACKAGES="$(PACMAN_EXTRAPACKAGES)" \

This line is superfluous.

Quoted 1 line

Ack.

Is it superfluous if PACMAN_EXTRAPACKAGES is not exported to makepkg? If I remove this while changing the default of PACMAN_EXTRAPACKAGES in scripts/Makefile.package, its value is not visible in makepkg, so only the default package gets built. I think

export PACMAN_EXTRAPACKAGES

is needed after the '?=' assignment line.

Quoted 39 lines
Quoted 10 lines
Quoted 10 lines
scripts/Makefile.package +0 -0
 		makepkg $(MAKEPKGOPTS)
 
 # dir-pkg tar*-pkg - tarball targets
scripts/package/PKGBUILD +0 -0
index 663ce300dd06..41bd0d387f0a 100644
@@ -3,10 +3,15 @@
 # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
 
Quoted 10 lines

scripts/package/PKGBUILD line 9

Quoted 8 lines
scripts/package/PKGBUILD +4 -3
 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}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES:-}
+if [ -n "$_extrapackages" ]; then

No need for this check. The loop over an empty variable work fine.

Ack. Will update in v2.

Quoted 4 lines

scripts/package/PKGBUILD line 11

Quoted 2 lines
scripts/package/PKGBUILD +2 -0
+	for pkg in $_extrapackages; do
+		pkgname+=("${pkgbase}-$pkg")

Use consistent variable references: "${pkgbase}-${pkg}"

Ack. Will update in v2.

Quoted 9 lines
Quoted 9 lines
scripts/package/PKGBUILD +2 -0
+	done
 fi
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
Signature · 1 line
2.46.0
#4 lore raw
Quoted 10 lines · Nathan Chancellor
Quoted 9 lines · Jose Fernandez
Quoted 7 lines · Thomas Weißschuh
Quoted 3 lines

This changes the behavior of the pacman-pkg target to only create the main kernel package by default. The rest of the packages will be opt-in going forward.

I had the impression that by default all extrapackages should be built. The variable can then be used by expert users where needed. Other Opinions?

Quoted 7 lines
Quoted 3 lines

I think switching to defaulting to all packages is a good idea. One concern I had was how regular users would discover the customization options. Expert users will likely look at the Makefile and figure out how to opt out.

I think that most users will likely want all of the packages built by default. I think leaving this to be discovered by power users in the Makefile is reasonable.

Sounds good!

Quoted 56 lines
Quoted 54 lines
Quoted 6 lines
Quoted 5 lines

In a previous patch, there was concern that adding a new debug package would increase t.he package time. To address this concern and provide more flexibility, this change has been added to allow users to decide which extra packages to include before introducing an optional debug package [1].

Quoted 7 lines

This paragraph seems like it shouldn't be part of the final commit. If you put it after a line with "---" it will be dropped from the commit, like so:

---

In a previous patch, ...

Agreed, I will move this paragraph to below --- for v2.

Quoted 26 lines
Quoted 16 lines

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

---
 scripts/Makefile.package |  5 +++++
 scripts/package/PKGBUILD | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
scripts/Makefile.package +0 -0
index 4a80584ec771..146e828cb4f1 100644

scripts/Makefile.package snap-pkg: · line 149

Quoted 6 lines
scripts/Makefile.package +3 -0
@@ -144,6 +144,10 @@ snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+# Space-separated list of extra packages to build
+# The available extra packages are: headers api-headers
+PACMAN_EXTRAPACKAGES ?=

The assignment doesn't do anything.
Do we need the documentation if the default enables all subpackages?

Quoted 11 lines

scripts/Makefile.package pacman-pkg: · line 159

Quoted 9 lines
scripts/Makefile.package +2 -0
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
@@ -152,6 +156,7 @@ pacman-pkg:
 		CARCH="$(UTS_MACHINE)" \
 		KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
 		KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+		PACMAN_EXTRAPACKAGES="$(PACMAN_EXTRAPACKAGES)" \

This line is superfluous.

Quoted 1 line

Ack.

Quoted 8 lines

Is it superfluous if PACMAN_EXTRAPACKAGES is not exported to makepkg? If I remove this while changing the default of PACMAN_EXTRAPACKAGES in scripts/Makefile.package, its value is not visible in makepkg, so only the default package gets built. I think

export PACMAN_EXTRAPACKAGES

is needed after the '?=' assignment line.

Nathan, I removed the line and it appears to work as expected.

If I set the default packages to:

PACMAN_EXTRAPACKAGES ?= headers api-headers

Then any of these commands builds only the main kernel package:

make pacman-pkg PACMAN_EXTRAPACKAGES=
make pacman-pkg PACMAN_EXTRAPACKAGES=""

This command builds the main package + headers package:

make pacman-pkg PACMAN_EXTRAPACKAGES="headers"

I'm not quite sure how PACMAN_EXTRAPACKAGES makes it to makepkg without that line. But it appears like it does.

Quoted 40 lines
Quoted 40 lines
Quoted 11 lines
Quoted 11 lines
scripts/Makefile.package +0 -0
 		makepkg $(MAKEPKGOPTS)
 
 # dir-pkg tar*-pkg - tarball targets
scripts/package/PKGBUILD +0 -0
index 663ce300dd06..41bd0d387f0a 100644
@@ -3,10 +3,15 @@
 # Contributor: Jan Alexander Steffens (heftig) <[email protected]>
 
Quoted 10 lines

scripts/package/PKGBUILD line 9

Quoted 8 lines
scripts/package/PKGBUILD +4 -3
 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}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES:-}
+if [ -n "$_extrapackages" ]; then

No need for this check. The loop over an empty variable work fine.

Ack. Will update in v2.

Quoted 4 lines

scripts/package/PKGBUILD line 11

Quoted 2 lines
scripts/package/PKGBUILD +2 -0
+	for pkg in $_extrapackages; do
+		pkgname+=("${pkgbase}-$pkg")

Use consistent variable references: "${pkgbase}-${pkg}"

Ack. Will update in v2.

Quoted 9 lines
Quoted 9 lines
scripts/package/PKGBUILD +2 -0
+	done
 fi
+
 pkgver="${KERNELRELEASE//-/_}"
 # The PKGBUILD is evaluated multiple times.
 # Running scripts/build-version from here would introduce inconsistencies.
Signature · 1 line
2.46.0