armbian-build/patch/kernel/archive/qcs6490-6.18/0024-scripts-Add-PKGBUILD-for-testing-on-Arch-Linux-ARM.patch
2025-10-17 19:32:38 +02:00

170 lines
5.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xilin Wu <sophon@radxa.com>
Date: Wed, 18 Jun 2025 18:27:27 +0800
Subject: scripts: Add PKGBUILD for testing on Arch Linux ARM
---
scripts/Makefile.package | 13 +
scripts/package/PKGBUILD-radxa | 119 ++++++++++
2 files changed, 132 insertions(+)
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 111111111111..222222222222 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -158,6 +158,18 @@ pacman-pkg:
KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
makepkg $(MAKEPKGOPTS)
+# pacman-radxa-pkg
+# ---------------------------------------------------------------------------
+
+PHONY += pacman-radxa-pkg
+pacman-radxa-pkg:
+ @ln -srf $(srctree)/scripts/package/PKGBUILD-radxa $(objtree)/PKGBUILD
+ +BUILDDIR="$(realpath $(objtree))/pacman" \
+ CARCH="$(UTS_MACHINE)" \
+ KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \
+ KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \
+ makepkg $(MAKEPKGOPTS)
+
# dir-pkg tar*-pkg - tarball targets
# ---------------------------------------------------------------------------
@@ -239,6 +251,7 @@ help:
@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 ' pacman-radxa-pkg - Build only the binary kernel pacman package for stable testing'
@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-radxa b/scripts/package/PKGBUILD-radxa
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/scripts/package/PKGBUILD-radxa
@@ -0,0 +1,119 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Maintainer: Thomas Weißschuh <linux@weissschuh.net>
+# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
+
+pkgbase=${PACMAN_PKGBASE:-linux-radxa-qcom}
+pkgname=("${pkgbase}")
+
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+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.
+pkgrel="${KBUILD_REVISION}"
+pkgdesc='Upstream Linux Stable on Radxa Qualcomm platforms'
+url='https://www.kernel.org/'
+# Enable flexible cross-compilation
+arch=(${CARCH})
+license=(GPL-2.0-only)
+makedepends=(
+ bc
+ bison
+ flex
+ gettext
+ kmod
+ libelf
+ openssl
+ pahole
+ perl
+ python
+ rsync
+ tar
+)
+options=(!debug !strip !buildflags !makeflags)
+
+_prologue() {
+ # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild.
+ # Bypass this override with a custom variable.
+ export MAKEFLAGS="${KBUILD_MAKEFLAGS}"
+
+ # Kbuild works in the output directory, where this PKGBUILD is located.
+ cd "$(dirname "${BASH_SOURCE[0]}")"
+}
+
+build() {
+ _prologue
+
+ ${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}"
+}
+
+_package() {
+ pkgdesc="The ${pkgdesc} kernel and modules"
+
+ local modulesdir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}"
+
+ _prologue
+
+ 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
+ echo "Installing dtbs..."
+ ${MAKE} INSTALL_DTBS_PATH="${modulesdir}/dtb" dtbs_install
+ ${MAKE} INSTALL_DTBS_PATH="${pkgdir}/boot/dtb" dtbs_install
+ fi
+
+ # remove build link, will be part of -headers package
+ rm -f "${modulesdir}/build"
+}
+
+_package-headers() {
+ pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel"
+
+ local builddir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}/build"
+
+ _prologue
+
+ 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..."
+ mkdir -p "${builddir}"
+ 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-api-headers() {
+ pkgdesc="Kernel headers sanitized for use in userspace"
+ provides=(linux-api-headers="${pkgver}")
+ conflicts=(linux-api-headers)
+
+ _prologue
+
+ ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
+}
+
+for _p in "${pkgname[@]}"; do
+ eval "package_$_p() {
+ $(declare -f "_package${_p#$pkgbase}")
+ _package${_p#$pkgbase}
+ }"
+done
--
Armbian