[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNARGWu8q5dAW5tYzfiSKKtZ9t8Dm9FzRoaoZhU4d-TWswQ@mail.gmail.com>
Date: Wed, 17 Jul 2024 17:51:21 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
Nicolas Schier <nicolas@...sle.eu>,
"Jan Alexander Steffens (heftig)" <heftig@...hlinux.org>, linux-kernel@...r.kernel.org,
linux-kbuild@...r.kernel.org
Subject: Re: [PATCH v6] kbuild: add script and target to generate pacman package
On Wed, Jul 17, 2024 at 5:34 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> On Wed, Jul 17, 2024 at 10:15 AM Nathan Chancellor <nathan@...nel.org> wrote:
> >
> > Hi Thomas,
> >
> > On Tue, Jul 16, 2024 at 07:52:14PM +0200, Thomas Weißschuh wrote:
> > > pacman is the package manager used by Arch Linux and its derivates.
> > > Creating native packages from the kernel tree has multiple advantages:
> > >
> > > * The package triggers the correct hooks for initramfs generation and
> > > bootloader configuration
> > > * Uninstallation is complete and also invokes the relevant hooks
> > > * New UAPI headers can be installed without any manual bookkeeping
> > >
> > > The PKGBUILD file is a simplified version of the one used for the
> > > downstream Arch Linux "linux" package.
> > > Extra steps that should not be necessary for a development kernel have
> > > been removed and an UAPI header package has been added.
> > >
> > > Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> > > Reviewed-by: Nathan Chancellor <nathan@...nel.org>
> > > Tested-by: Nathan Chancellor <nathan@...nel.org>
> > > Reviewed-by: Nicolas Schier <nicolas@...sle.eu>
> > > ---
> > > Changes in v6:
> > > - Drop reference to srctree/Makefile
> > > - Drop $(realpath $(srctree))
> > > - Make use of the fact that $(objtree) is always "."
> > > - Align coding style to kernel and drop vim config line
> > > - Drop indirection through `$MAKE run-command`
> > > - Unify shell variable syntax to "${var}"
> > > - Add explanations to custom variables
> > > - Add makedepends
> > > - Link to v5: https://lore.kernel.org/r/20240714-kbuild-pacman-pkg-v5-1-0598460bc918@weissschuh.net
> > >
> > > Changes in v5:
> > > - Rebase onto kbuild/for-next
> > > - Use new path to build-version script (from kbuild/for-next)
> > > - Ensure submake jobserver delegation works
> > > - Simplify $modulesdir/pkgbase file creation
> > > - Add Reviewed-by from Nicolas
> > > - Link to v4: https://lore.kernel.org/r/20240710-kbuild-pacman-pkg-v4-1-507bb5b79b2a@weissschuh.net
> > >
> > > Changes in v4:
> > > - Update MRPROPER_FILES
> > > - Unify shell variable syntax
> > > - Link to v3: https://lore.kernel.org/r/20240708-kbuild-pacman-pkg-v3-1-885df3cbc740@weissschuh.net
> > >
> > > Changes in v3:
> > > - Enforce matching architectures for installation
> > > - Add Reviewed-by and Tested-by from Nathan
> > > - Link to v2: https://lore.kernel.org/r/20240706-kbuild-pacman-pkg-v2-1-613422a03a7a@weissschuh.net
> > >
> > > Changes in v2:
> > > - Replace ${MAKE} with $MAKE for consistency with other variables
> > > - Use $MAKE for "-s image_name"
> > > - Avoid permission warnings from build directory
> > > - Clarify reason for /build symlink removal
> > > - Install System.map and config
> > > - Install dtbs where available
> > > - Allow cross-build through arch=any
> > > - Sort Contributor/Maintainer chronologically
> > > - Disable some unneeded makepkg options
> > > - Use DEPMOD=true for consistency with rpm-package
> > > - Link to v1: https://lore.kernel.org/r/20240704-kbuild-pacman-pkg-v1-1-ac2f63f5fa7b@weissschuh.net
> > > ---
> > > .gitignore | 6 +++
> > > Makefile | 2 +-
> > > scripts/Makefile.package | 14 +++++++
> > > scripts/package/PKGBUILD | 99 ++++++++++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 120 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/.gitignore b/.gitignore
> > > index c59dc60ba62e..7902adf4f7f1 100644
> > > --- a/.gitignore
> > > +++ b/.gitignore
> > > @@ -92,6 +92,12 @@ modules.order
> > > #
> > > /tar-install/
> > >
> > > +#
> > > +# pacman files (make pacman-pkg)
> > > +#
> > > +/PKGBUILD
> > > +/pacman/
> > > +
> > > #
> > > # We don't want to ignore the following even if they are dot-files
> > > #
> > > diff --git a/Makefile b/Makefile
> > > index 7372ea45ed3f..768d3dc107f8 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1481,7 +1481,7 @@ CLEAN_FILES += vmlinux.symvers modules-only.symvers \
> > > # Directories & files removed with 'make mrproper'
> > > MRPROPER_FILES += include/config include/generated \
> > > arch/$(SRCARCH)/include/generated .objdiff \
> > > - debian snap tar-install \
> > > + debian snap tar-install PKGBUILD pacman \
> > > .config .config.old .version \
> > > Module.symvers \
> > > certs/signing_key.pem \
> > > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > > index bf016af8bf8a..0aaa0832279c 100644
> > > --- a/scripts/Makefile.package
> > > +++ b/scripts/Makefile.package
> > > @@ -141,6 +141,19 @@ snap-pkg:
> > > cd $(objtree)/snap && \
> > > snapcraft --target-arch=$(UTS_MACHINE)
> > >
> > > +# pacman-pkg
> > > +# ---------------------------------------------------------------------------
> > > +
> > > +PHONY += pacman-pkg
> > > +pacman-pkg:
> > > + @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD
> > > + +objtree="$(realpath $(objtree))" \
> > > + BUILDDIR=pacman \
> > > + CARCH="$(UTS_MACHINE)" \
> > > + KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
> > > + KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
> > > + makepkg
> > > +
> > > # dir-pkg tar*-pkg - tarball targets
> > > # ---------------------------------------------------------------------------
> > >
> > > @@ -221,6 +234,7 @@ help:
> > > @echo ' bindeb-pkg - Build only the binary kernel deb package'
> > > @echo ' snap-pkg - Build only the binary kernel snap package'
> > > @echo ' (will connect to external hosts)'
> > > + @echo ' pacman-pkg - Build only the binary kernel pacman package'
> > > @echo ' dir-pkg - Build the kernel as a plain directory structure'
> > > @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
> > > @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
> > > diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> > > new file mode 100644
> > > index 000000000000..eb3957fad915
> > > --- /dev/null
> > > +++ b/scripts/package/PKGBUILD
> > > @@ -0,0 +1,99 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only
> > > +# Maintainer: Thomas Weißschuh <linux@...ssschuh.net>
> > > +# Contributor: Jan Alexander Steffens (heftig) <heftig@...hlinux.org>
> > > +
> > > +pkgbase=linux-upstream
> > > +pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-api-headers")
> > > +pkgver="${KERNELRELEASE//-/_}"
> > > +# The PKGBUILD is evaluated multiple times.
> > > +# Running scripts/build-version from here would introduce inconsistencies.
> > > +pkgrel="${KBUILD_REVISION}"
> > > +pkgdesc='Linux'
> > > +url='https://www.kernel.org/'
> > > +# Enable flexible cross-compilation
> > > +arch=(${CARCH})
> > > +license=(GPL-2.0-only)
> > > +makedepends=(
> > > + base-devel
> > > + bc
> > > + cpio
> > > + gettext
> > > + libelf
> > > + openssl
> > > + pahole
> > > + perl
> > > + python
> > > + rsync
> > > + tar
> > > +)
> > > +options=(!debug !strip !buildflags !makeflags)
> > > +
> > > +build() {
> > > + # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild.
> > > + # Bypass this override with a custom variable.
> > > + export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
> > > + cd "${objtree}"
> > > +
> > > + # makepkg does a "chmod a-srw", triggering warnings during kbuild
> > > + chmod 0755 "${pkgdirbase}" || true
> > > +
> > > + ${MAKE}
> > > +}
> > > +
> > > +package_linux-upstream() {
> > > + pkgdesc="The ${pkgdesc} kernel and modules"
> > > +
> > > + export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
> > > + cd "${objtree}"
> > > + local modulesdir="${pkgdir}/usr/${MODLIB}"
> > > +
> > > + echo "Installing boot image..."
> > > + # systemd expects to find the kernel here to allow hibernation
> > > + # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
> > > + install -Dm644 "$(${MAKE} -s image_name)" "${modulesdir}/vmlinuz"
> > > +
> > > + # Used by mkinitcpio to name the kernel
> > > + echo "${pkgbase}" > "${modulesdir}/pkgbase"
> > > +
> > > + echo "Installing modules..."
> > > + ${MAKE} INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 \
> > > + DEPMOD=true modules_install
> > > +
> > > + if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
> >
> > Does this reference to srctree...
>
>
> 'srctree' is exported by the top Makefile.
>
>
> This is based on the assumption that we always run
> 'make pacman-pkg', and we never do 'makepkg' directly.
>
>
> Do you mean PKGBUILD should be self-contained
> so that 'makepkg' works from the command line?
>
Perhaps, this may make sense.
Currently,
pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-api-headers")
is hard-coded.
I do not think linux-upstream-headers make sense
when CONFIG_MODULE is disabled.
scripts/package/mkspec turns off with_devel
when CONFIG_MODULE is disabled.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists