@@ -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
#
@@ -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 \
@@ -141,6 +141,21 @@ 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
+ +cd $(objtree) && \
+ srctree="$(realpath $(srctree))" \
+ objtree="$(realpath $(objtree))" \
+ BUILDDIR="$(realpath $(objtree))/pacman" \
+ CARCH="$(UTS_MACHINE)" \
+ KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
+ KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+ makepkg
+
# dir-pkg tar*-pkg - tarball targets
# ---------------------------------------------------------------------------
@@ -221,6 +236,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'
new file mode 100644
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Maintainer: Thomas Weißschuh <linux@weissschuh.net>
+# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
+
+pkgbase=linux-upstream
+pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-api-headers")
+pkgver="${KERNELRELEASE//-/_}"
+pkgrel="$KBUILD_REVISION"
+pkgdesc='Linux'
+url='https://www.kernel.org/'
+arch=($CARCH)
+options=(!debug !strip !buildflags !makeflags)
+license=(GPL-2.0-only)
+
+build() {
+ export MAKEFLAGS="$KBUILD_MAKEFLAGS"
+ cd "$objtree"
+
+ # makepkg does a "chmod a-srw", triggering warnings during kbuild
+ chmod 0755 "$pkgdirbase" || true
+
+ $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"
+
+ # 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 $MAKE run-command KBUILD_RUN_COMMAND='test -d $srctree/arch/$SRCARCH/boot/dts' 2>/dev/null; then
+ echo "Installing dtbs..."
+ $MAKE INSTALL_DTBS_PATH="$modulesdir/dtb" dtbs_install
+ fi
+
+ # remove build link, will be part of -headers package
+ 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"
+
+ echo "Installing System.map and config..."
+ cp System.map "$builddir/System.map"
+ cp .config "$builddir/.config"
+
+ 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: