diff mbox series

[v2] kbuild: control extra pacman packages with PACMAN_EXTRAPACKAGES

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

Commit Message

Jose Fernandez Aug. 7, 2024, 2:27 a.m. UTC
Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package
to control the creation of additional packages by the pacman-pkg target.

The headers and api-headers packages will be included by default if
PACMAN_EXTRAPACKAGES is not set. This changes the previous behavior
where api-headers was always included, and headers was conditionally
included if CONFIG_MODULES=y. Now, this decision is delegated to the
user.

To disable extra packages, set PACMAN_EXTRAPACKAGES to an empty value:

make pacman-pkg PACMAN_EXTRAPACKAGES=

or

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.

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 |  2 ++
 scripts/package/PKGBUILD | 11 +++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Masahiro Yamada Aug. 7, 2024, 1:37 p.m. UTC | #1
On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
>
> Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package
> to control the creation of additional packages by the pacman-pkg target.
>
> The headers and api-headers packages will be included by default if
> PACMAN_EXTRAPACKAGES is not set. This changes the previous behavior
> where api-headers was always included, and headers was conditionally
> included if CONFIG_MODULES=y. Now, this decision is delegated to the
> user.
>
> To disable extra packages, set PACMAN_EXTRAPACKAGES to an empty value:
>
> make pacman-pkg PACMAN_EXTRAPACKAGES=
>
> or
>
> 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.


I see only the main package built by default.




>
> 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 |  2 ++
>  scripts/package/PKGBUILD | 11 +++++++----
>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 4a80584ec771..ccdf8ba41f0b 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -144,6 +144,8 @@ snap-pkg:
>  # pacman-pkg
>  # ---------------------------------------------------------------------------
>
> +PACMAN_EXTRAPACKAGES ?= headers api-headers

Meaningless line.


Since 'export' is missing,
this default line is not propagated to PKGBUILD.


Nathan also mentioned 'export' would be needed if you wanted to
describe this here.

https://lore.kernel.org/linux-kbuild/20240806025853.GB1570554@thelio-3990X/




> +
>  PHONY += pacman-pkg
>  pacman-pkg:
>         @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
> diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> index 663ce300dd06..8de869f9b1d4 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:-}


Instead of adding inconsistent defaults in two places,
I would write like this:

_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}




Lastly, I will never accept new error messages
with CONFIG_MODULES=n.







> +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.
> --
> 2.46.0
>


--
Best Regards
Masahiro Yamada
Thomas Weißschuh Aug. 7, 2024, 4:40 p.m. UTC | #2
On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> >
> > Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package
> > to control the creation of additional packages by the pacman-pkg target.
> >
> > The headers and api-headers packages will be included by default if
> > PACMAN_EXTRAPACKAGES is not set. This changes the previous behavior
> > where api-headers was always included, and headers was conditionally
> > included if CONFIG_MODULES=y. Now, this decision is delegated to the
> > user.
> >
> > To disable extra packages, set PACMAN_EXTRAPACKAGES to an empty value:
> >
> > make pacman-pkg PACMAN_EXTRAPACKAGES=
> >
> > or
> >
> > 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.
> 
> 
> I see only the main package built by default.

Same.

Do we even need PACMAN_EXTRAPACKAGES in the Makefile?
IMO having it in the PKGBUILD would be enough.
It can still be overriden from the commandline.

> >
> > 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 |  2 ++
> >  scripts/package/PKGBUILD | 11 +++++++----
> >  2 files changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index 4a80584ec771..ccdf8ba41f0b 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -144,6 +144,8 @@ snap-pkg:
> >  # pacman-pkg
> >  # ---------------------------------------------------------------------------
> >
> > +PACMAN_EXTRAPACKAGES ?= headers api-headers
> 
> Meaningless line.
> 
> 
> Since 'export' is missing,
> this default line is not propagated to PKGBUILD.
> 
> 
> Nathan also mentioned 'export' would be needed if you wanted to
> describe this here.
> 
> https://lore.kernel.org/linux-kbuild/20240806025853.GB1570554@thelio-3990X/

Same as above.

> > +
> >  PHONY += pacman-pkg
> >  pacman-pkg:
> >         @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
> > diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> > index 663ce300dd06..8de869f9b1d4 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:-}
> 
> 
> Instead of adding inconsistent defaults in two places,
> I would write like this:
> 
> _extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}

Agreed.

> Lastly, I will never accept new error messages
> with CONFIG_MODULES=n.

Could you elaborate?
For me this works fine with CONFIG_MODULES=n.
(After having fixed the above issues so all subpackages are built)

> > +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.
> > --
> > 2.46.0
Masahiro Yamada Aug. 7, 2024, 5:02 p.m. UTC | #3
On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> > >
> > > Introduce a new variable, PACMAN_EXTRAPACKAGES, in the Makefile.package
> > > to control the creation of additional packages by the pacman-pkg target.
> > >
> > > The headers and api-headers packages will be included by default if
> > > PACMAN_EXTRAPACKAGES is not set. This changes the previous behavior
> > > where api-headers was always included, and headers was conditionally
> > > included if CONFIG_MODULES=y. Now, this decision is delegated to the
> > > user.
> > >
> > > To disable extra packages, set PACMAN_EXTRAPACKAGES to an empty value:
> > >
> > > make pacman-pkg PACMAN_EXTRAPACKAGES=
> > >
> > > or
> > >
> > > 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.
> >
> >
> > I see only the main package built by default.
>
> Same.
>
> Do we even need PACMAN_EXTRAPACKAGES in the Makefile?
> IMO having it in the PKGBUILD would be enough.
> It can still be overriden from the commandline.
>
> > >
> > > 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 |  2 ++
> > >  scripts/package/PKGBUILD | 11 +++++++----
> > >  2 files changed, 9 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > > index 4a80584ec771..ccdf8ba41f0b 100644
> > > --- a/scripts/Makefile.package
> > > +++ b/scripts/Makefile.package
> > > @@ -144,6 +144,8 @@ snap-pkg:
> > >  # pacman-pkg
> > >  # ---------------------------------------------------------------------------
> > >
> > > +PACMAN_EXTRAPACKAGES ?= headers api-headers
> >
> > Meaningless line.
> >
> >
> > Since 'export' is missing,
> > this default line is not propagated to PKGBUILD.
> >
> >
> > Nathan also mentioned 'export' would be needed if you wanted to
> > describe this here.
> >
> > https://lore.kernel.org/linux-kbuild/20240806025853.GB1570554@thelio-3990X/
>
> Same as above.
>
> > > +
> > >  PHONY += pacman-pkg
> > >  pacman-pkg:
> > >         @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
> > > diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> > > index 663ce300dd06..8de869f9b1d4 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:-}
> >
> >
> > Instead of adding inconsistent defaults in two places,
> > I would write like this:
> >
> > _extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
>
> Agreed.
>
> > Lastly, I will never accept new error messages
> > with CONFIG_MODULES=n.
>
> Could you elaborate?
> For me this works fine with CONFIG_MODULES=n.
> (After having fixed the above issues so all subpackages are built)



$ make  allnoconfig pacman-pkg


Check the linux-headers log closely.
Thomas Weißschuh Aug. 7, 2024, 5:31 p.m. UTC | #4
On 2024-08-08 02:02:59+0000, Masahiro Yamada wrote:
> On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:

<snip>

> > > Lastly, I will never accept new error messages
> > > with CONFIG_MODULES=n.
> >
> > Could you elaborate?
> > For me this works fine with CONFIG_MODULES=n.
> > (After having fixed the above issues so all subpackages are built)
> 
> $ make  allnoconfig pacman-pkg
> 
> Check the linux-headers log closely.
 
I see now, previously I was not on kbuild/for-next and had an old
Module.symvers sitting around, hiding the issue.

==> Starting package_linux-upstream-headers()...
Installing build files...
tar: Module.symvers: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Installing System.map and config...
Adding symlink...
==> Tidying install...

(coming from scripts/package/install-extmod-build)

linux-upstream-headers also contains .config and System.map which are
useful without modules.
So either we completely disable linux-upstream-headers or skip
install-extmod-build when CONFIG_MODULES=n.
And maybe move System.map and .config to some other package,
which would then deviate from the original PKGBUILD.

Neither option feels great, but it probably won't make a big difference.
If you have a preference, let's go with that.


Thomas
Jose Fernandez Aug. 10, 2024, 12:16 a.m. UTC | #5
On 24/08/07 07:31PM, Thomas Weißschuh wrote:
> On 2024-08-08 02:02:59+0000, Masahiro Yamada wrote:
> > On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > > On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > > > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> 
> <snip>
> 
> > > > Lastly, I will never accept new error messages
> > > > with CONFIG_MODULES=n.
> > >
> > > Could you elaborate?
> > > For me this works fine with CONFIG_MODULES=n.
> > > (After having fixed the above issues so all subpackages are built)
> > 
> > $ make  allnoconfig pacman-pkg
> > 
> > Check the linux-headers log closely.
>  
> I see now, previously I was not on kbuild/for-next and had an old
> Module.symvers sitting around, hiding the issue.
> 
> ==> Starting package_linux-upstream-headers()...
> Installing build files...
> tar: Module.symvers: Cannot stat: No such file or directory
> tar: Exiting with failure status due to previous errors
> Installing System.map and config...
> Adding symlink...
> ==> Tidying install...
> 
> (coming from scripts/package/install-extmod-build)
> 
> linux-upstream-headers also contains .config and System.map which are
> useful without modules.
> So either we completely disable linux-upstream-headers or skip
> install-extmod-build when CONFIG_MODULES=n.
> And maybe move System.map and .config to some other package,
> which would then deviate from the original PKGBUILD.
> 
> Neither option feels great, but it probably won't make a big difference.
> If you have a preference, let's go with that.

Thomas, Masahiro,
Thanks for the feedback. It seems that System.map and .config are commonly
included in -header Arch packages. To avoid deviating too much and to address
the issue with install-extmod-build when CONFIG_MODULES=n, how about considering
something like this:

mkdir -p "${builddir}" # needed if install-extmod-build is not run
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..."
cp System.map "${builddir}/System.map"
cp .config "${builddir}/.config"

Thanks,
Jose
Masahiro Yamada Aug. 10, 2024, 7:41 a.m. UTC | #6
On Sat, Aug 10, 2024 at 9:16 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
>
> On 24/08/07 07:31PM, Thomas Weißschuh wrote:
> > On 2024-08-08 02:02:59+0000, Masahiro Yamada wrote:
> > > On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > > > On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > > > > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> >
> > <snip>
> >
> > > > > Lastly, I will never accept new error messages
> > > > > with CONFIG_MODULES=n.
> > > >
> > > > Could you elaborate?
> > > > For me this works fine with CONFIG_MODULES=n.
> > > > (After having fixed the above issues so all subpackages are built)
> > >
> > > $ make  allnoconfig pacman-pkg
> > >
> > > Check the linux-headers log closely.
> >
> > I see now, previously I was not on kbuild/for-next and had an old
> > Module.symvers sitting around, hiding the issue.
> >
> > ==> Starting package_linux-upstream-headers()...
> > Installing build files...
> > tar: Module.symvers: Cannot stat: No such file or directory
> > tar: Exiting with failure status due to previous errors
> > Installing System.map and config...
> > Adding symlink...
> > ==> Tidying install...
> >
> > (coming from scripts/package/install-extmod-build)
> >
> > linux-upstream-headers also contains .config and System.map which are
> > useful without modules.
> > So either we completely disable linux-upstream-headers or skip
> > install-extmod-build when CONFIG_MODULES=n.
> > And maybe move System.map and .config to some other package,
> > which would then deviate from the original PKGBUILD.
> >
> > Neither option feels great, but it probably won't make a big difference.
> > If you have a preference, let's go with that.
>
> Thomas, Masahiro,
> Thanks for the feedback. It seems that System.map and .config are commonly
> included in -header Arch packages. To avoid deviating too much and to address
> the issue with install-extmod-build when CONFIG_MODULES=n, how about considering
> something like this:


I am fine.


>
> mkdir -p "${builddir}" # needed if install-extmod-build is not run

This comment might not be necessary if you move this code
right before copying System.map.




> 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..."
> cp System.map "${builddir}/System.map"
> cp .config "${builddir}/.config"
>
> Thanks,
> Jose
Thomas Weißschuh Aug. 10, 2024, 7:54 a.m. UTC | #7
On 2024-08-09 18:16:36+0000, Jose Fernandez wrote:
> On 24/08/07 07:31PM, Thomas Weißschuh wrote:
> > On 2024-08-08 02:02:59+0000, Masahiro Yamada wrote:
> > > On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > > > On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > > > > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> > 
> > <snip>
> > 
> > > > > Lastly, I will never accept new error messages
> > > > > with CONFIG_MODULES=n.
> > > >
> > > > Could you elaborate?
> > > > For me this works fine with CONFIG_MODULES=n.
> > > > (After having fixed the above issues so all subpackages are built)
> > > 
> > > $ make  allnoconfig pacman-pkg
> > > 
> > > Check the linux-headers log closely.
> >  
> > I see now, previously I was not on kbuild/for-next and had an old
> > Module.symvers sitting around, hiding the issue.
> > 
> > ==> Starting package_linux-upstream-headers()...
> > Installing build files...
> > tar: Module.symvers: Cannot stat: No such file or directory
> > tar: Exiting with failure status due to previous errors
> > Installing System.map and config...
> > Adding symlink...
> > ==> Tidying install...
> > 
> > (coming from scripts/package/install-extmod-build)
> > 
> > linux-upstream-headers also contains .config and System.map which are
> > useful without modules.
> > So either we completely disable linux-upstream-headers or skip
> > install-extmod-build when CONFIG_MODULES=n.
> > And maybe move System.map and .config to some other package,
> > which would then deviate from the original PKGBUILD.
> > 
> > Neither option feels great, but it probably won't make a big difference.
> > If you have a preference, let's go with that.
> 
> Thomas, Masahiro,
> Thanks for the feedback. It seems that System.map and .config are commonly
> included in -header Arch packages. To avoid deviating too much and to address
> the issue with install-extmod-build when CONFIG_MODULES=n, how about considering
> something like this:
> 
> mkdir -p "${builddir}" # needed if install-extmod-build is not run
> 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..."
> cp System.map "${builddir}/System.map"
> cp .config "${builddir}/.config"

Sounds good to me.


Thomas
Jose Fernandez Aug. 11, 2024, 4:01 p.m. UTC | #8
On 24/08/10 04:41PM, Masahiro Yamada wrote:
> On Sat, Aug 10, 2024 at 9:16 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> >
> > On 24/08/07 07:31PM, Thomas Weißschuh wrote:
> > > On 2024-08-08 02:02:59+0000, Masahiro Yamada wrote:
> > > > On Thu, Aug 8, 2024 at 1:41 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > > > > On 2024-08-07 22:37:47+0000, Masahiro Yamada wrote:
> > > > > > On Wed, Aug 7, 2024 at 11:28 AM Jose Fernandez <jose.fernandez@linux.dev> wrote:
> > >
> > > <snip>
> > >
> > > > > > Lastly, I will never accept new error messages
> > > > > > with CONFIG_MODULES=n.
> > > > >
> > > > > Could you elaborate?
> > > > > For me this works fine with CONFIG_MODULES=n.
> > > > > (After having fixed the above issues so all subpackages are built)
> > > >
> > > > $ make  allnoconfig pacman-pkg
> > > >
> > > > Check the linux-headers log closely.
> > >
> > > I see now, previously I was not on kbuild/for-next and had an old
> > > Module.symvers sitting around, hiding the issue.
> > >
> > > ==> Starting package_linux-upstream-headers()...
> > > Installing build files...
> > > tar: Module.symvers: Cannot stat: No such file or directory
> > > tar: Exiting with failure status due to previous errors
> > > Installing System.map and config...
> > > Adding symlink...
> > > ==> Tidying install...
> > >
> > > (coming from scripts/package/install-extmod-build)
> > >
> > > linux-upstream-headers also contains .config and System.map which are
> > > useful without modules.
> > > So either we completely disable linux-upstream-headers or skip
> > > install-extmod-build when CONFIG_MODULES=n.
> > > And maybe move System.map and .config to some other package,
> > > which would then deviate from the original PKGBUILD.
> > >
> > > Neither option feels great, but it probably won't make a big difference.
> > > If you have a preference, let's go with that.
> >
> > Thomas, Masahiro,
> > Thanks for the feedback. It seems that System.map and .config are commonly
> > included in -header Arch packages. To avoid deviating too much and to address
> > the issue with install-extmod-build when CONFIG_MODULES=n, how about considering
> > something like this:
> 
> 
> I am fine.
> 
> 
> >
> > mkdir -p "${builddir}" # needed if install-extmod-build is not run
> 
> This comment might not be necessary if you move this code
> right before copying System.map.

Ack. I will move the command to before copying System.map and drop the comment.

> 
> > 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..."
> > cp System.map "${builddir}/System.map"
> > cp .config "${builddir}/.config"
> >
> > Thanks,
> > Jose
> 
> 
> 
> -- 
> Best Regards
> Masahiro Yamada
Jose Fernandez Aug. 11, 2024, 8:46 p.m. UTC | #9
On 24/08/07 06:40PM, Thomas Weißschuh wrote:
<snip>
> > > +
> > >  PHONY += pacman-pkg
> > >  pacman-pkg:
> > >         @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
> > > diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> > > index 663ce300dd06..8de869f9b1d4 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:-}
> > 
> > 
> > Instead of adding inconsistent defaults in two places,
> > I would write like this:
> > 
> > _extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
> 
> Agreed.
> 

Closing the loop on this topic. I removed all changes made to Makefile.package
and set the default in PKGBUILD as suggested:

 _extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}

Running the pacman-pkg target without setting PACMAN_EXTRAPACKAGES will build
all packages:

make pacman-pkg
...
==> Creating package "linux-upstream"...
...
==> Creating package "linux-upstream-headers"...
...
==> Creating package "linux-upstream-api-headers"...

Setting PACMAN_EXTRAPACKAGES to an empty value will build only the kernel
package:

make pacman-pkg PACMAN_EXTRAPACKAGES=""
objtree="/home/jose/Code/linux/linux" \
	BUILDDIR="/home/jose/Code/linux/linux/pacman" \
	CARCH="i386" \
	KBUILD_MAKEFLAGS="rR --no-print-directory -- PACMAN_EXTRAPACKAGES=" \
	KBUILD_REVISION="46" \
	makepkg 
...
==> Creating package "linux-upstream"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: linux-upstream 6.11.0_rc2+-46 (Sun 11 Aug 2024 01:13:45 PM MDT)

Make exports command line arguments as env variables to sub-processes and this
is how the PACMAN_EXTRAPACKAGES is passed to makepg without an explicit export
with this change. V3 will include this change.
diff mbox series

Patch

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 4a80584ec771..ccdf8ba41f0b 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -144,6 +144,8 @@  snap-pkg:
 # pacman-pkg
 # ---------------------------------------------------------------------------
 
+PACMAN_EXTRAPACKAGES ?= headers api-headers
+
 PHONY += pacman-pkg
 pacman-pkg:
 	@ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
index 663ce300dd06..8de869f9b1d4 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:-}
+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.