From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nicolas@fjasle.eu>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: Re: [PATCH] kbuild: add script and target to generate pacman package
Date: Thu, 04 Jul 2024 21:02:50 +0200 [thread overview]
Message-ID: <63c53ab962254e49d0eb3a67a067b48023d679b0.camel@archlinux.org> (raw)
In-Reply-To: <20240704-kbuild-pacman-pkg-v1-1-ac2f63f5fa7b@weissschuh.net>
On Thu, 2024-07-04 at 18:36 +0200, Thomas Weißschuh wrote:
> diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
> new file mode 100644
> index 000000000000..29daf357edc1
> --- /dev/null
> +++ b/scripts/package/PKGBUILD
> @@ -0,0 +1,72 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
> +# Maintainer: Thomas Weißschuh <linux@weissschuh.net>
Nitpick: Normally these lines are sorted newest to oldest, with the
current maintainer(s) at the top.
> +
> +pkgbase=linux-upstream
> +pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-api-headers")
> +pkgver="${KERNELRELEASE//-/_}"
> +pkgrel="$KBUILD_REVISION"
> +pkgdesc='Linux'
> +url='https://www.kernel.org/'
> +arch=("$UTS_MACHINE")
> +options=(!strip)
You should have !debug !strip here, otherwise makepkg can attempt (and
will fail) to gather source files, creating an empty
/usr/src/debug/$pkgbase.
Might also be worth considering !buildflags (to turn off injection of
CFLAGS etc) and !makeflags (to turn off injection of MAKEFLAGS).
> +license=(GPL-2.0-only)
> +
> +build() {
> + export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
I think you can have this export at the top level instead of in each
function.
> + cd "$objtree"
> +
> + ${MAKE} -f "${srctree}/Makefile"
> +
> +}
> +
> +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"
An invocation of make that could also use ${MAKE} for consistency.
> +
> + # Used by mkinitcpio to name the kernel
> + echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
> +
> + echo "Installing modules..."
> + ${MAKE} INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
> + DEPMOD=/doesnt/exist modules_install # Suppress depmod
> +
> + # remove build link
> + rm -f "$modulesdir/build"
> +}
> +
> +package_linux-upstream-headers() {
> + pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
> +
> + export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
> + cd "$objtree"
> + local builddir="$pkgdir/usr/$MODLIB/build"
> +
> + echo "Installing build files..."
> + "$srctree/scripts/package/install-extmod-build" "$builddir"
Should we be using this script upstream as well instead of our
homegrown mess of install commands?
> +
> + echo "Adding symlink..."
> + mkdir -p "$pkgdir/usr/src"
> + ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
> +}
> +
> +package_linux-upstream-api-headers() {
> + pkgdesc="Kernel headers sanitized for use in userspace"
> + provides=(linux-api-headers)
> + conflicts=(linux-api-headers)
> +
> + export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
> + cd "$objtree"
> +
> + ${MAKE} headers_install INSTALL_HDR_PATH="$pkgdir/usr"
> +}
> +
> +# vim:set ts=8 sts=2 sw=2 et:
next prev parent reply other threads:[~2024-07-04 19:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 16:36 Thomas Weißschuh
2024-07-04 18:21 ` Nathan Chancellor
2024-07-04 18:33 ` Thomas Weißschuh
2024-07-04 19:02 ` Jan Alexander Steffens (heftig) [this message]
2024-07-04 19:33 ` Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63c53ab962254e49d0eb3a67a067b48023d679b0.camel@archlinux.org \
--to=heftig@archlinux.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®