Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4
@ 2020-10-31 16:17 Piraty
  2020-10-31 16:27 ` [PR PATCH] [Updated] " Piraty
                   ` (49 more replies)
  0 siblings, 50 replies; 51+ messages in thread
From: Piraty @ 2020-10-31 16:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

There is a new pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

rpi-kernel: build a subpackage for each flavor, add rpi4




@Duncaen @pbui 

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 12904 bytes --]

From b2c22ecad05932e3a954132e78574fe0ff29943e Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index a1e15b06280..c1115087cd5 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -1,14 +1,14 @@
 # Template file for 'rpi-base'
 pkgname=rpi-base
 version=2.5
-revision=4
+revision=5
 homepage="http://www.voidlinux.org"
 short_desc="Void Linux RaspberryPi base files"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="Public Domain"
 
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 
 do_install() {
 	case "$XBPS_TARGET_MACHINE" in

From 944112b26a867dc330beecdeecf30f8369055798 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

add rpi4

[ci skip]
---
 srcpkgs/rpi-kernel/template | 236 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 210 insertions(+), 34 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..2a62cc192d1 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
 maintainer="Peter Bui <pbui@github.bx612.space>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,12 +208,16 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	#move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-rpi-4-b.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
 	vmkdir boot
 	# Generate kernel.img and install it to destdir.
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers} (transitional)"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR PATCH] [Updated] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
@ 2020-10-31 16:27 ` Piraty
  2020-10-31 16:36 ` Piraty
                   ` (48 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-10-31 16:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

There is an updated pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

rpi-kernel: build a subpackage for each flavor, add rpi4
see: https://github.com/void-linux/void-mklive/pull/153


@Duncaen @pbui 

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 13374 bytes --]

From b2c22ecad05932e3a954132e78574fe0ff29943e Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index a1e15b06280..c1115087cd5 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -1,14 +1,14 @@
 # Template file for 'rpi-base'
 pkgname=rpi-base
 version=2.5
-revision=4
+revision=5
 homepage="http://www.voidlinux.org"
 short_desc="Void Linux RaspberryPi base files"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="Public Domain"
 
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 
 do_install() {
 	case "$XBPS_TARGET_MACHINE" in

From f9e560483eb6341c5df85310087b5edc7a4b2084 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4

[ci skip]
---
 srcpkgs/rpi-kernel/template | 236 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 210 insertions(+), 34 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..2a62cc192d1 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
 maintainer="Peter Bui <pbui@github.bx612.space>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,12 +208,16 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	#move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-rpi-4-b.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
 	vmkdir boot
 	# Generate kernel.img and install it to destdir.
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers} (transitional)"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR PATCH] [Updated] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
  2020-10-31 16:27 ` [PR PATCH] [Updated] " Piraty
@ 2020-10-31 16:36 ` Piraty
  2020-11-06 23:34 ` [NEEDS TESTERS] " liketechnik
                   ` (47 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-10-31 16:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

There is an updated pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

rpi-kernel: build a subpackage for each flavor, add rpi4
see: https://github.com/void-linux/void-mklive/pull/153


@Duncaen @pbui 

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 13510 bytes --]

From ad1db8b74ffcaf583bace3dcd790f639ea16910a Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index a1e15b06280..8e156d679cf 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -1,14 +1,14 @@
 # Template file for 'rpi-base'
 pkgname=rpi-base
 version=2.5
-revision=4
+revision=5
 homepage="http://www.voidlinux.org"
 short_desc="Void Linux RaspberryPi base files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Piraty <piraty1@inbox.ru>"
 license="Public Domain"
 
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 
 do_install() {
 	case "$XBPS_TARGET_MACHINE" in

From 47229809163e2902e9f0f81fc81ef4508b41c170 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4
* adopt, as suggested by former maintainer Peter Bui.

[ci skip]
---
 srcpkgs/rpi-kernel/template | 238 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 211 insertions(+), 35 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..f08b65a33ea 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
-maintainer="Peter Bui <pbui@github.bx612.space>"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
+maintainer="Piraty <piraty1@inbox.ru>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,12 +208,16 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	#move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-rpi-4-b.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
 	vmkdir boot
 	# Generate kernel.img and install it to destdir.
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers} (transitional)"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
  2020-10-31 16:27 ` [PR PATCH] [Updated] " Piraty
  2020-10-31 16:36 ` Piraty
@ 2020-11-06 23:34 ` liketechnik
  2020-11-16  3:32 ` [PR REVIEW] " agausmann
                   ` (46 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: liketechnik @ 2020-11-06 23:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

New comment by liketechnik on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-723346459

Comment:
(I hope it's appropriate to ask here)
I'd love to help testing, but I'm not sure how/what.

I'm currently running void (64bit) on a rpi4 (currently put void's kernel packages on hold an manually copied the latest release from the rpi firmware repository). I also have a rpi3 available, although I'd need some more time to buy an SD-card for it and set the system up on it.

What would be the next steps for me? (e. g. what pre-requisites do I need [local repository to compile the packages?] and what would I need to change on my rpi [which packages would be updated/installed new)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (2 preceding siblings ...)
  2020-11-06 23:34 ` [NEEDS TESTERS] " liketechnik
@ 2020-11-16  3:32 ` agausmann
  2020-11-16  3:34 ` agausmann
                   ` (45 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

New review comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r523882387

Comment:
These dependencies are also set for the flavor packages, causing for example `rpi4-kernel` to depend on `rpi3-kernel`, since `rpi4-kernel` is built for `aarch64`. This is definitely unwanted, and causes problems with `./mkplatformfs.sh rpi4 ...` when it attempts to install both `rpi3-kernel` and `rpi4-kernel`, as the files will conflict.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (3 preceding siblings ...)
  2020-11-16  3:32 ` [PR REVIEW] " agausmann
@ 2020-11-16  3:34 ` agausmann
  2020-11-16  3:36 ` agausmann
                   ` (44 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

New review comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r523882694

Comment:
Same issue as on [line 71](#diff-7c06a56d03c82f4f91449e0b8baba00fa54433735eee8b84183aa75909a25b34R71)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (4 preceding siblings ...)
  2020-11-16  3:34 ` agausmann
@ 2020-11-16  3:36 ` agausmann
  2020-11-16  3:57 ` agausmann
                   ` (43 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

New review comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r523882387

Comment:
These dependencies are also set for the flavor packages, causing for example `rpi4-kernel` to depend on `rpi3-kernel`, since `rpi4-kernel` is built for `aarch64`. This is definitely unwanted, and causes problems with `./mkplatformfs.sh rpi4 ...` when it attempts to install both `rpi3-kernel` and `rpi4-kernel`, as the files will conflict.

My guess is this also happens for `rpi{1,2,3}-kernel`, which will depend on themselves, though that didn't cause any noticeable problems.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (5 preceding siblings ...)
  2020-11-16  3:36 ` agausmann
@ 2020-11-16  3:57 ` agausmann
  2020-11-16  3:58 ` agausmann
                   ` (42 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

New comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-727720492

Comment:
Tested on my rpi1, builds and boots to a login shell successfully. USB, video and networking all seem to be fine; didn't expect much to change there, but just for the sake of completeness.

Also tried to test on rpi4, but ran into issues while building, which I have detailed above.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (6 preceding siblings ...)
  2020-11-16  3:57 ` agausmann
@ 2020-11-16  3:58 ` agausmann
  2020-11-16  3:59 ` agausmann
                   ` (41 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

New comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-727720492

Comment:
Tested on my rpi1, builds and boots to a login shell successfully. Ran into one issue with the changes to mklive, but I made a comment there for it. USB, video and networking all seem to be fine; didn't expect much to change there, but just for the sake of completeness.

Also tried to test on rpi4, but ran into issues while building, which I have detailed above.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (7 preceding siblings ...)
  2020-11-16  3:58 ` agausmann
@ 2020-11-16  3:59 ` agausmann
  2020-11-17  9:10 ` [PR REVIEW] " Piraty
                   ` (40 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-16  3:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

New comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-727720492

Comment:
Tested on my rpi1, builds and boots to a login shell successfully. Ran into one issue with the changes to mklive, but I made a comment there for it. USB, video and networking all seem to be fine; didn't expect much to change at that level anyway.

Also tried to test on rpi4, but ran into issues while building, which I have detailed above.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (8 preceding siblings ...)
  2020-11-16  3:59 ` agausmann
@ 2020-11-17  9:10 ` Piraty
  2020-11-22 18:23 ` Piraty
                   ` (39 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-11-17  9:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 205 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r524993731

Comment:
oh right. will fix it. transition handling is not ideal yet

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (9 preceding siblings ...)
  2020-11-17  9:10 ` [PR REVIEW] " Piraty
@ 2020-11-22 18:23 ` Piraty
  2020-11-22 19:48 ` Piraty
                   ` (38 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-11-22 18:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r528384827

Comment:
i cannot confirm. `depends=` is not inherited by subpakages. the toplevel declaration you refereced only affects the meta packages, see below (notice `run_depends`)
```
$ XBPS_TARGET_ARCH=aarch64-musl xbps-query --repository=$HOME/src/void-packages/hostdir/binpkgs -M -R rpi4-kernel                                                                                       
architecture: aarch64-musl
filename-sha256: 422a8449148b60cf6dd53f80f61f2b556b4bb505cc6588e6c5877721e6273054
filename-size: 28MB
homepage: http://www.kernel.org
installed_size: 39MB
license: GPL-2.0-only
maintainer: Piraty <piraty1@inbox.ru>
pkgname: rpi4-kernel
pkgver: rpi4-kernel-5.4.68_1
repository: /home/piraty/src/void-packages/hostdir/binpkgs
short_desc: Linux kernel for Raspberry Pi 4 (5.4 [git e82816d])

$ XBPS_TARGET_ARCH=aarch64-musl xbps-query --repository=$HOME/src/void-packages/hostdir/binpkgs -M -R rpi-kernel
architecture: aarch64-musl
filename-sha256: 0686ecf163d116935cac4c2f744ff3d00e2baf023ff952cd4c4c143ba4752a24
filename-size: 529B
homepage: http://www.kernel.org
installed_size: 0B
license: GPL-2.0-only
maintainer: Piraty <piraty1@inbox.ru>
pkgname: rpi-kernel
pkgver: rpi-kernel-5.4.68_1
repository: /home/piraty/src/void-packages/hostdir/binpkgs
run_depends:
        rpi3-kernel>=0
short_desc: Linux kernel for Raspberry Pi (5.4 series [git e82816d])
```

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (10 preceding siblings ...)
  2020-11-22 18:23 ` Piraty
@ 2020-11-22 19:48 ` Piraty
  2020-11-22 20:58 ` agausmann
                   ` (37 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-11-22 19:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r528395022

Comment:
that doesn't make sense. this is set on the subpackage only, i don't see how rpi3-kernel-headers would pull rpi4-kernel-headers

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (11 preceding siblings ...)
  2020-11-22 19:48 ` Piraty
@ 2020-11-22 20:58 ` agausmann
  2020-12-29  7:49 ` manneorama
                   ` (36 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: agausmann @ 2020-11-22 20:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]

New review comment by agausmann on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r528403377

Comment:
Yes, I get the same result that you do. However this is still somehow a problem, even if this isn't the source. When I run `./xbps-src -a aarch64 pkg rpi4-kernel`, for some reason. it also builds `rpi-kernel`, `rpi-kernel-headers`, and transitively, `rpi3-kernel` and `rpi3-kernel-headers`. And then, for some reason, `./mkplatformfs.sh rpi4 ...` attempts to install them.

```
$ ls hostdir/binpkgs/rpi-kernel-flavor-subpackage/
aarch64-repodata                          rpi3-kernel-headers-5.4.68_1.aarch64.xbps
rpi-kernel-5.4.68_1.aarch64.xbps          rpi4-kernel-5.4.68_1.aarch64.xbps
rpi-kernel-headers-5.4.68_1.aarch64.xbps  rpi4-kernel-headers-5.4.68_1.aarch64.xbps
rpi3-kernel-5.4.68_1.aarch64.xbps
```
see also: the [build log](https://termbin.com/9he0z) for `./xbps-src -a aarch64 pkg rpi4-kernel`, which builds both rpi3-kernel and rpi4-kernel.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (12 preceding siblings ...)
  2020-11-22 20:58 ` agausmann
@ 2020-12-29  7:49 ` manneorama
  2020-12-29  7:59 ` manneorama
                   ` (35 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29  7:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (13 preceding siblings ...)
  2020-12-29  7:49 ` manneorama
@ 2020-12-29  7:59 ` manneorama
  2020-12-29  8:10 ` manneorama
                   ` (34 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29  7:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1269 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

UPDATE:
Building `libelf` from master at `f66d93e241420fbb17f8c1fffadf897bba676382` works fine. So there may be something in these two commits causing the issue.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (14 preceding siblings ...)
  2020-12-29  7:59 ` manneorama
@ 2020-12-29  8:10 ` manneorama
  2020-12-29  9:03 ` manneorama
                   ` (33 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29  8:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

**UPDATE:**
Building `libelf` from master at `f66d93e241420fbb17f8c1fffadf897bba676382` works fine. So there may be something in these two commits causing the issue.

**UPDATE 2:**
Building `libelf` standalone (`./xbps-src -a aarch64 pkg libelf`) works fine even from the rebased branch so I'm guessing this is because, as opposed to using `-N pkg base-system`, the standalone build will use upstream packages for dependency resolution instead of local ones?

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (15 preceding siblings ...)
  2020-12-29  8:10 ` manneorama
@ 2020-12-29  9:03 ` manneorama
  2020-12-29  9:48 ` manneorama
                   ` (32 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29  9:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2491 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

**UPDATE:**
Building `libelf` from master at `f66d93e241420fbb17f8c1fffadf897bba676382` works fine. So there may be something in these two commits causing the issue.

**UPDATE 2:**
Building `libelf` standalone (`./xbps-src -a aarch64 pkg libelf`) works fine even from the rebased branch so I'm guessing this is because, as opposed to using `-N pkg base-system`, the standalone build will use upstream packages for dependency resolution instead of local ones?

**UPDATE 3:**
Manually adding `-lz` to `masterdir/builddir/elfutils-0.182/debuginfod/Makefile +475` hacks around the missing symbol above. But then new errors, related to `zstd` instead, appears.

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libdw/libdw.so: undefined reference to symbol 'ZSTD_decompressStream'
/usr/bin/ld: /lib64/libzstd.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:19
```

I can't quickly hack around this because adding `-lzstd` the linker is unable to find the lib. Currently stuck.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (16 preceding siblings ...)
  2020-12-29  9:03 ` manneorama
@ 2020-12-29  9:48 ` manneorama
  2020-12-29 10:53 ` manneorama
                   ` (31 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29  9:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2495 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

**UPDATE:**
Building `libelf` from master at `f66d93e241420fbb17f8c1fffadf897bba676382` works fine. ~~So there may be something in these two commits causing the issue.~~

**UPDATE 2:**
Building `libelf` standalone (`./xbps-src -a aarch64 pkg libelf`) works fine even from the rebased branch so I'm guessing this is because, as opposed to using `-N pkg base-system`, the standalone build will use upstream packages for dependency resolution instead of local ones?

**UPDATE 3:**
Manually adding `-lz` to `masterdir/builddir/elfutils-0.182/debuginfod/Makefile +475` hacks around the missing symbol above. But then new errors, related to `zstd` instead, appears.

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libdw/libdw.so: undefined reference to symbol 'ZSTD_decompressStream'
/usr/bin/ld: /lib64/libzstd.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:19
```

I can't quickly hack around this because adding `-lzstd` the linker is unable to find the lib. Currently stuck.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (17 preceding siblings ...)
  2020-12-29  9:48 ` manneorama
@ 2020-12-29 10:53 ` manneorama
  2020-12-31  1:42 ` [PR PATCH] [Updated] " Piraty
                   ` (30 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2020-12-29 10:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2704 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-751984525

Comment:
Currently trying to test this rebased on top of the current void-packages master (on top of `f66d93e241420fbb17f8c1fffadf897bba676382` to be specific). Kernel package builds fine but during building of base-system I run into a strange error while building `elfutils`. 

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libelf/libelf.so: undefined reference to symbol 'inflateEnd'
/usr/bin/ld: /lib64/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13
```

I'm not exactly sure where to start digging, but I will do my best. Any help is appreciated.

**UPDATE:**
Building `libelf` from master at `f66d93e241420fbb17f8c1fffadf897bba676382` works fine. ~~So there may be something in these two commits causing the issue.~~

**UPDATE 2:**
Building `libelf` standalone (`./xbps-src -a aarch64 pkg libelf`) works fine even from the rebased branch so I'm guessing this is because, as opposed to using `-N pkg base-system`, the standalone build will use upstream packages for dependency resolution instead of local ones?

**UPDATE 3:**
Manually adding `-lz` to `masterdir/builddir/elfutils-0.182/debuginfod/Makefile +475` hacks around the missing symbol above. But then new errors, related to `zstd` instead, appears.

```
Making all in debuginfod
  CXXLD    debuginfod
/usr/bin/ld: ../libdw/libdw.so: undefined reference to symbol 'ZSTD_decompressStream'
/usr/bin/ld: /lib64/libzstd.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:581: debuginfod] Error 1
make[1]: *** [Makefile:502: all-recursive] Error 1
make: *** [Makefile:418: all] Error 2
=> ERROR: elfutils-0.182_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:19
```

I can't quickly hack around this because adding `-lzstd` the linker is unable to find the lib. Currently stuck.

As far as I can determine, all packages relevant to this issue define the correct dependencies. But I’m unsure how transitive deps are handled and where/how link flags and options are defined/inherited. 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR PATCH] [Updated] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (18 preceding siblings ...)
  2020-12-29 10:53 ` manneorama
@ 2020-12-31  1:42 ` Piraty
  2021-01-03 23:08 ` manneorama
                   ` (29 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2020-12-31  1:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

There is an updated pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

[NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4

----
see: https://github.com/void-linux/void-mklive/pull/153 as well


@Duncaen @pbui 

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 13949 bytes --]

From c5c6d57085bbe270b845d795d5784397ae305277 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/INSTALL.mgs | 10 ++++++++++
 srcpkgs/rpi-base/template    |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/rpi-base/INSTALL.mgs

diff --git a/srcpkgs/rpi-base/INSTALL.mgs b/srcpkgs/rpi-base/INSTALL.mgs
new file mode 100644
index 00000000000..e6c0dc26c4e
--- /dev/null
+++ b/srcpkgs/rpi-base/INSTALL.mgs
@@ -0,0 +1,10 @@
+WARNING
+
+rpi-base dropped the dependency on rpi-kernel which very likely made rpi-kernel
+an orphan package on your system.
+
+To mark rpi-kernel as 'manual' (so you don't accidentally remove it during
+system cleanup), please run:
+
+	xbps-pkgdb -m manual rpi-kernel
+
diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index 8fcf3581efd..81c2925c0c6 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -3,9 +3,9 @@ pkgname=rpi-base
 version=2.6
 revision=1
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 short_desc="Void Linux Raspberry Pi base files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Piraty <piraty1@inbox.ru>"
 license="Public Domain"
 homepage="https://www.voidlinux.org"
 

From 92349692477d765f60d7176dff757d89c6ae1398 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4
* adopt, as suggested by former maintainer Peter Bui.

[ci skip]
---
 srcpkgs/rpi-kernel/template | 238 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 211 insertions(+), 35 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..1033650cdfc 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
-maintainer="Peter Bui <pbui@github.bx612.space>"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
+maintainer="Piraty <piraty1@inbox.ru>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi - transitional dummy package"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,12 +208,16 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	#move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-rpi-4-b.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
 	vmkdir boot
 	# Generate kernel.img and install it to destdir.
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers}"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (19 preceding siblings ...)
  2020-12-31  1:42 ` [PR PATCH] [Updated] " Piraty
@ 2021-01-03 23:08 ` manneorama
  2021-01-05  9:36 ` Anachron
                   ` (28 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2021-01-03 23:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 799 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-753689713

Comment:
I finally gave in and simply built everything on an existing rpi4 installation instead of going the cross compile route. With the small modification I mentioned in the `void-mklive` PR I could successfully build an image and boot off of it. 

I don’t know if my host setup or the cross compilation in `xbps-src` is broken for rpi4, but something is wrong at least. I was able to get around the original issue by just starting over (?). But then I had other issues and at one point the compiler somehow disappeared which is when I gave up. I will have another, more structured, go at the cross compilation once I’m done testing the image I now have. 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (20 preceding siblings ...)
  2021-01-03 23:08 ` manneorama
@ 2021-01-05  9:36 ` Anachron
  2021-01-05 19:48 ` LeamHall
                   ` (27 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Anachron @ 2021-01-05  9:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

New comment by Anachron on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-754522438

Comment:
Has someone replaced their RPI 3 B+ install with this PR yet? I'm thinking about copying the sdcard and modifying the install here and there to not need to reinstall and reconfigure everything. 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (21 preceding siblings ...)
  2021-01-05  9:36 ` Anachron
@ 2021-01-05 19:48 ` LeamHall
  2021-01-06 19:21 ` manneorama
                   ` (26 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: LeamHall @ 2021-01-05 19:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

New comment by LeamHall on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-754859314

Comment:
Noob question; is there a mailing list or IRC channel I can get on to watch this? my RPi 4 should be here tomorrow.  :)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (22 preceding siblings ...)
  2021-01-05 19:48 ` LeamHall
@ 2021-01-06 19:21 ` manneorama
  2021-01-07  1:18 ` CMB
                   ` (25 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: manneorama @ 2021-01-06 19:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

New comment by manneorama on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-755551540

Comment:
I've been running this on my Pi 4B's for a few days now and so far it's rock solid. All my pi's are headless so I have not tested graphical output, but networking (wired and wireless) and everything else seems to work as expected.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (23 preceding siblings ...)
  2021-01-06 19:21 ` manneorama
@ 2021-01-07  1:18 ` CMB
  2021-01-07  2:04 ` LeamHall
                   ` (24 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: CMB @ 2021-01-07  1:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

New comment by CMB on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-755821843

Comment:
I built this and then made an image for my Pi 4 using the void-mklive
pull request, updating the case statement for selecting the kernel,
as discussed in that PR.  It appears to be working quite well.


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (24 preceding siblings ...)
  2021-01-07  1:18 ` CMB
@ 2021-01-07  2:04 ` LeamHall
  2021-01-07  2:20 ` LeamHall
                   ` (23 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: LeamHall @ 2021-01-07  2:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

New comment by LeamHall on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-754859314

Comment:
Noob question; is there a mailing list or IRC channel I can get on to watch this? my RPi 4 should be here tomorrow.  :)

**Addendum:** Trying to follow the directions above, and it looks like i'm not set up for builds? Is there a setup document I can study?

./xbps-src -a aarch64-musl pkg rpi-base
=> ERROR: rpi-base is not a bootstrap package and cannot be built without it.
=> ERROR: Please install bootstrap packages and try again.


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (25 preceding siblings ...)
  2021-01-07  2:04 ` LeamHall
@ 2021-01-07  2:20 ` LeamHall
  2021-01-11  0:24 ` [PR REVIEW] " ahesford
                   ` (22 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: LeamHall @ 2021-01-07  2:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 710 bytes --]

New comment by LeamHall on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-754859314

Comment:
Noob question; is there a mailing list or IRC channel I can get on to watch this? my RPi 4 should be here tomorrow.  :)

**Addendum:** Trying to follow the directions above, and it looks like i'm not set up for builds? Is there a setup document I can study?

./xbps-src -a aarch64-musl pkg rpi-base
=> ERROR: rpi-base is not a bootstrap package and cannot be built without it.
=> ERROR: Please install bootstrap packages and try again.

**Addendum 2:** Found some stuff, working through it. Any pointers from people who do this a lot would be appreciated.   :)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (26 preceding siblings ...)
  2021-01-07  2:20 ` LeamHall
@ 2021-01-11  0:24 ` ahesford
  2021-01-11  2:02 ` ericonr
                   ` (21 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ahesford @ 2021-01-11  0:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554646048

Comment:
Revbump for the dependency drop

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (27 preceding siblings ...)
  2021-01-11  0:24 ` [PR REVIEW] " ahesford
@ 2021-01-11  2:02 ` ericonr
  2021-01-11  2:02 ` ericonr
                   ` (20 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-11  2:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554659214

Comment:
I still think current users shouldn't have to change anything about their current systems to get things working. The amount of information contained in this package is small enough that a `rpi4-base` package wouldn't be undue maintenance in almost any way.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (28 preceding siblings ...)
  2021-01-11  2:02 ` ericonr
@ 2021-01-11  2:02 ` ericonr
  2021-01-11  2:57 ` jsumners
                   ` (19 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-11  2:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554659214

Comment:
I still think current users shouldn't have to change anything about their current systems to get (and keep) things working. The amount of information contained in this package is small enough that a `rpi4-base` package wouldn't be undue maintenance in almost any way.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (29 preceding siblings ...)
  2021-01-11  2:02 ` ericonr
@ 2021-01-11  2:57 ` jsumners
  2021-01-11  3:17 ` ericonr
                   ` (18 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: jsumners @ 2021-01-11  2:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 236 bytes --]

New review comment by jsumners on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554668135

Comment:
What current systems? Void does not currently support RPI4 without a lot of manual work.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (30 preceding siblings ...)
  2021-01-11  2:57 ` jsumners
@ 2021-01-11  3:17 ` ericonr
  2021-01-11  3:51 ` jsumners
                   ` (17 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-11  3:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554671598

Comment:
Current users of the `rpi-base` packages, so rpi zero, 1, 2 and 3 owners.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (31 preceding siblings ...)
  2021-01-11  3:17 ` ericonr
@ 2021-01-11  3:51 ` jsumners
  2021-01-11  4:14 ` ericonr
                   ` (16 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: jsumners @ 2021-01-11  3:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

New review comment by jsumners on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554677973

Comment:
Those are technically different architectures. I wouldn't think it wise to try and run an install targeting any of those on any other device.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (32 preceding siblings ...)
  2021-01-11  3:51 ` jsumners
@ 2021-01-11  4:14 ` ericonr
  2021-01-11  5:04 ` ahesford
                   ` (15 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-11  4:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554693233

Comment:
I'm not sure I get what you mean.

My point is that `rpi-base` currently works and pulls all dependencies for current rpi users. With this change, they will also have to download the kernel for their specific board. It would be simpler for them, without much more work on our side, to have a `rpi4-base` package for rpi4 users (it could even be a subpackage here), while current users don't get an orphaned kernel package or have to remember to install new systems with `rpi-base` *and* `rpi$something-kernel`. 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (33 preceding siblings ...)
  2021-01-11  4:14 ` ericonr
@ 2021-01-11  5:04 ` ahesford
  2021-01-11 11:19 ` Piraty
                   ` (14 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ahesford @ 2021-01-11  5:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554727891

Comment:
I don't like the idea of a separate `rpi4-base` because the distinction is arbitrary. The problem compounds when there is a Raspberry Pi 5 and so on. Suddenly every new hardware release that requires a different kernel gets paired with a new `-base` just to pull in that kernel.

The only difference needed to move from rpi3 to rpi4 is the kernel, so let's decouple the kernel from the base and keep things consistent.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (34 preceding siblings ...)
  2021-01-11  5:04 ` ahesford
@ 2021-01-11 11:19 ` Piraty
  2021-01-11 11:21 ` Piraty
                   ` (13 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-11 11:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554977740

Comment:
that was my point, yet i didn't come up with a solution that doesn't require user intervention for existing install (1rpi{0,1,2,3}1)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (35 preceding siblings ...)
  2021-01-11 11:19 ` Piraty
@ 2021-01-11 11:21 ` Piraty
  2021-01-11 11:25 ` Piraty
                   ` (12 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-11 11:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554977740

Comment:
that was my point, yet i didn't come up with a solution that doesn't require user intervention for existing install (`rpi{0,1,2,3}`)

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (36 preceding siblings ...)
  2021-01-11 11:21 ` Piraty
@ 2021-01-11 11:25 ` Piraty
  2021-01-11 13:17 ` ahesford
                   ` (11 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-11 11:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r554977740

Comment:
maybe rpi{0,1,2,3,4}-base is what we need then to make it more obvious and have a single point of entry?

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (37 preceding siblings ...)
  2021-01-11 11:25 ` Piraty
@ 2021-01-11 13:17 ` ahesford
  2021-01-11 13:20 ` ericonr
                   ` (10 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ahesford @ 2021-01-11 13:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r555039334

Comment:
Having per-model bases seems better than playing "one of these things is not like the other" with `rpi-base` and `rpi4-base`. I don't think there's a lot of added value in making the `-base` depend on the kernel, but if there is agreement with the position of @ericonr, might as well split them all if we're splitting one.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (38 preceding siblings ...)
  2021-01-11 13:17 ` ahesford
@ 2021-01-11 13:20 ` ericonr
  2021-01-12 20:19 ` [PR PATCH] [Updated] " Piraty
                   ` (9 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-11 13:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r555040991

Comment:
For what it's worth, rpi0 and rpi1 would be the same package.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR PATCH] [Updated] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (39 preceding siblings ...)
  2021-01-11 13:20 ` ericonr
@ 2021-01-12 20:19 ` Piraty
  2021-01-13  2:42 ` [PR REVIEW] " ahesford
                   ` (8 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-12 20:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

There is an updated pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

[NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4

see: https://github.com/void-linux/void-mklive/pull/153 as well
@Duncaen @pbui 

---

### How to
Build packages
```
cd void-packages
./xbps-src -m masterdir.rpi4 binary-bootstrap
./xbps-src -m masterdir.rpi4 -a aarch64-musl pkg rpi-base
./xbps-src -m masterdir.rpi4 -a aarch64-musl pkg rpi-kernel
```
Build images (from branch https://github.com/void-linux/void-mklive/pull/153)
```
cd void-mklive
d=$(date '+%Y%m%d')
repo=$(xdistdir)/hostdir/binpkgs/
make XBPS_REPOSITORY="-r $repo" void-aarch64-musl-ROOTFS-$d.tar.xz void-rpi3-musl-$d.img.xz void-rpi4-musl-$d.img.xz
```

---

### Remaining issues
- [ ] change to `rpi-base` require manual action for existing instals (`rpi{0,1,2,3}`). (rpi-kernel will result in an orphan) is there a better way?

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 14253 bytes --]

From fa55dad53d1572a0f3c24c04234cfaf30ca30b95 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/INSTALL.mgs | 17 +++++++++++++++++
 srcpkgs/rpi-base/template    |  4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/rpi-base/INSTALL.mgs

diff --git a/srcpkgs/rpi-base/INSTALL.mgs b/srcpkgs/rpi-base/INSTALL.mgs
new file mode 100644
index 00000000000..62f3d772b8d
--- /dev/null
+++ b/srcpkgs/rpi-base/INSTALL.mgs
@@ -0,0 +1,17 @@
+WARNING
+
+If you read this on one of rpi0,rpi1,rpi2,rpi3, manual action may be required!
+
+rpi-base dropped the dependency on rpi-kernel which very likely made rpi-kernel
+an orphan package on your system.
+Instead, flavor-dependant kernel packages were introduced.
+
+To mark rpi-kernel as 'manual' (so you don't accidentally remove it during
+orphan removal), please run:
+
+	# check if the kernel package is an orphan
+	xbps-query -O | grep 'rpi[123]-kernel'
+
+	# mark it as explicitly installed
+	xbps-pkgdb -m manual $(xbps-query -O | grep 'rpi[123]-kernel')
+
diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index 8fcf3581efd..81c2925c0c6 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -3,9 +3,9 @@ pkgname=rpi-base
 version=2.6
 revision=1
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 short_desc="Void Linux Raspberry Pi base files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Piraty <piraty1@inbox.ru>"
 license="Public Domain"
 homepage="https://www.voidlinux.org"
 

From 2bd77c2081779c6270a485ec07f9a95d008fce3f Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4
* adopt, as suggested by former maintainer Peter Bui.

[ci skip]
---
 srcpkgs/rpi-kernel/template | 238 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 211 insertions(+), 35 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..1033650cdfc 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
-maintainer="Peter Bui <pbui@github.bx612.space>"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
+maintainer="Piraty <piraty1@inbox.ru>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi - transitional dummy package"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,12 +208,16 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	#move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-rpi-4-b.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
 	vmkdir boot
 	# Generate kernel.img and install it to destdir.
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers}"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (40 preceding siblings ...)
  2021-01-12 20:19 ` [PR PATCH] [Updated] " Piraty
@ 2021-01-13  2:42 ` ahesford
  2021-01-16 22:38 ` CameronNemo
                   ` (7 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: ahesford @ 2021-01-13  2:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r556227141

Comment:
This block causes problems because some dtb files are missing in `rpi3-kernel` and `rpi4-kernel` (the same problem affects the current `rpi3-kernel` package). For example, on my 3b+ which tries to use NFS root with kernel IP configuration, the Ethernet adapter gets a new, random MAC address with every boot. The `smsc95xx.macaddr` kernel command-line argument makes no difference. The problem is resolved by copying `/boot/broadcom/bcm2710-rpi-3-b-plus.dtb` and `/boot/broadcom/bcm2837-rpi-3-b-plus.dtb` to `/boot`.

I think the right thing here is to copy all of the relevant family and SoC dtb files (see [this table](https://openwrt.org/toh/raspberry_pi_foundation/raspberry_pi#hardware)):

```bash
case "$rpi_flavor in
	rpi3)
		mv ${DESTDIR}/boot/broadcom/bcm{2710,2837}-*.dtb ${DESTDIR}/boot
		;;
	rpi4)
		mv ${DESTDIR}/boot/broadcom/bcm2711-*.dtb ${DESTDIR}/boot
		;;
esac
rm -rf ${DESTDIR}/broadcom
```
This should capture all of the proper DTBs for `rpi3`-class hardware. For `rpi4`, there is currently only one DTB, but it looks like there are more `bcm2711-*` DTBs for the RPi 400 and CM4 [coming in 5.10.x](https://github.com/raspberrypi/linux/tree/rpi-5.10.y/arch/arm/boot/dts), so doing a glob probably saves us some trouble later.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (41 preceding siblings ...)
  2021-01-13  2:42 ` [PR REVIEW] " ahesford
@ 2021-01-16 22:38 ` CameronNemo
  2021-01-16 23:36 ` [PR PATCH] [Updated] " Piraty
                   ` (6 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: CameronNemo @ 2021-01-16 22:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r559048276

Comment:
@agausmann the behavior you described for building subpackages is expected. You build a source package, and all of its subpackages get built. If there are issues with how mkplatformfs handles things, then we can iron it out in the PR over there.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR PATCH] [Updated] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (42 preceding siblings ...)
  2021-01-16 22:38 ` CameronNemo
@ 2021-01-16 23:36 ` Piraty
  2021-01-16 23:37 ` [PR REVIEW] " Piraty
                   ` (5 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-16 23:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

There is an updated pull request by Piraty against master on the void-packages repository

https://github.com/Piraty/void-packages rpi-kernel-flavor-subpackage
https://github.com/void-linux/void-packages/pull/26000

[NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4

see: https://github.com/void-linux/void-mklive/pull/153 as well
@Duncaen @pbui 

---

### How to
Build packages
```
cd void-packages
./xbps-src -m masterdir.rpi4 binary-bootstrap
./xbps-src -m masterdir.rpi4 -a aarch64-musl pkg rpi-base
./xbps-src -m masterdir.rpi4 -a aarch64-musl pkg rpi-kernel
```
Build images (from branch https://github.com/void-linux/void-mklive/pull/153)
```
cd void-mklive
d=$(date '+%Y%m%d')
repo=$(xdistdir)/hostdir/binpkgs/
make XBPS_REPOSITORY="-r $repo" void-aarch64-musl-ROOTFS-$d.tar.xz void-rpi3-musl-$d.img.xz void-rpi4-musl-$d.img.xz
```

---

### Remaining issues
- [ ] change to `rpi-base` require manual action for existing instals (`rpi{0,1,2,3}`). (rpi-kernel will result in an orphan) is there a better way?

A patch file from https://github.com/void-linux/void-packages/pull/26000.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rpi-kernel-flavor-subpackage-26000.patch --]
[-- Type: text/x-diff, Size: 14364 bytes --]

From 5b70f6488ad43a3e6663b66b56248c8c58124c62 Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 26 Oct 2020 21:33:08 +0100
Subject: [PATCH 1/2] rpi-base: don't depend on rpi-kernel anymore

Now that we have rpi4 it's not sufficient to determine the rpi variant
by looking at XBPS_TARGET_MACHINE anymore.

In case rpi-base requires modification for a specific variant that has
the same XBPS_TARGET_MACHINE as another variant, rpi-base needs to be
split into rpi{N}-base; then rpi{N}-base can depend on rpi{N}-kernel
again.
---
 srcpkgs/rpi-base/INSTALL.mgs | 17 +++++++++++++++++
 srcpkgs/rpi-base/template    |  4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/rpi-base/INSTALL.mgs

diff --git a/srcpkgs/rpi-base/INSTALL.mgs b/srcpkgs/rpi-base/INSTALL.mgs
new file mode 100644
index 00000000000..62f3d772b8d
--- /dev/null
+++ b/srcpkgs/rpi-base/INSTALL.mgs
@@ -0,0 +1,17 @@
+WARNING
+
+If you read this on one of rpi0,rpi1,rpi2,rpi3, manual action may be required!
+
+rpi-base dropped the dependency on rpi-kernel which very likely made rpi-kernel
+an orphan package on your system.
+Instead, flavor-dependant kernel packages were introduced.
+
+To mark rpi-kernel as 'manual' (so you don't accidentally remove it during
+orphan removal), please run:
+
+	# check if the kernel package is an orphan
+	xbps-query -O | grep 'rpi[123]-kernel'
+
+	# mark it as explicitly installed
+	xbps-pkgdb -m manual $(xbps-query -O | grep 'rpi[123]-kernel')
+
diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template
index 8fcf3581efd..81c2925c0c6 100644
--- a/srcpkgs/rpi-base/template
+++ b/srcpkgs/rpi-base/template
@@ -3,9 +3,9 @@ pkgname=rpi-base
 version=2.6
 revision=1
 archs="armv6l* armv7l* aarch64*"
-depends="virtual?ntp-daemon rpi-firmware rpi-kernel"
+depends="virtual?ntp-daemon rpi-firmware"
 short_desc="Void Linux Raspberry Pi base files"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Piraty <piraty1@inbox.ru>"
 license="Public Domain"
 homepage="https://www.voidlinux.org"
 

From 6af31dd6fe48fcbd0f921a26b13e92177a67f08d Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Sun, 18 Oct 2020 22:04:24 +0200
Subject: [PATCH 2/2] rpi-kernel: build a subpackage for each flavor

This enables building all Raspberry Pi kernels from a single template by
using individual builddir/destdir for each flavor and performing all
stages independently with help of the `_flavor_stage()` function.

* rpi-kernel is a meta package now that is built by default for every
  arch and continues to serve legacy installations as it depends on the
  respective (former one-per-arch) rpi{1,2,3}-kernel package.
* subpackages are enabled conditionally for each arch.
* add rpi4
* adopt, as suggested by former maintainer Peter Bui.

[ci skip]
---
 srcpkgs/rpi-kernel/template | 240 ++++++++++++++++++++++++++++++------
 srcpkgs/rpi1-kernel         |   1 +
 srcpkgs/rpi1-kernel-headers |   1 +
 srcpkgs/rpi2-kernel         |   1 +
 srcpkgs/rpi2-kernel-headers |   1 +
 srcpkgs/rpi3-kernel         |   1 +
 srcpkgs/rpi3-kernel-headers |   1 +
 srcpkgs/rpi4-kernel         |   1 +
 srcpkgs/rpi4-kernel-headers |   1 +
 9 files changed, 212 insertions(+), 36 deletions(-)
 create mode 120000 srcpkgs/rpi1-kernel
 create mode 120000 srcpkgs/rpi1-kernel-headers
 create mode 120000 srcpkgs/rpi2-kernel
 create mode 120000 srcpkgs/rpi2-kernel-headers
 create mode 120000 srcpkgs/rpi3-kernel
 create mode 120000 srcpkgs/rpi3-kernel-headers
 create mode 120000 srcpkgs/rpi4-kernel
 create mode 120000 srcpkgs/rpi4-kernel-headers

diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template
index 7bce019015f..ba07081190a 100644
--- a/srcpkgs/rpi-kernel/template
+++ b/srcpkgs/rpi-kernel/template
@@ -11,11 +11,14 @@ _gitshort="${_githash:0:7}"
 pkgname=rpi-kernel
 version=5.4.68
 revision=1
+build_style=meta
+archs="armv6l* armv7l* aarch64*"
 wrksrc="linux-${_githash}"
-maintainer="Peter Bui <pbui@github.bx612.space>"
+hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
+maintainer="Piraty <piraty1@inbox.ru>"
 homepage="http://www.kernel.org"
 license="GPL-2.0-only"
-short_desc="The Linux kernel for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+short_desc="Linux kernel for Raspberry Pi - transitional dummy package"
 distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz"
 checksum=e0dc98befadb4c8c66aa0e73d9d79f10b20e29fb758ab870a0c6c708e3a0abb7
 python_version=2
@@ -27,13 +30,9 @@ nostrip=yes
 noverifyrdeps=yes
 noshlibprovides=yes
 
-# RPi, RPi2, RPi3
-archs="armv6l* armv7l* aarch64*"
-hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex"
-makedepends="ncurses-devel"
-triggers="kernel-hooks"
+_triggers="kernel-hooks"
 # These files could be modified when an external module is built.
-mutable_files="
+_mutable_files="
 	/usr/lib/modules/${_kernver}/modules.dep
 	/usr/lib/modules/${_kernver}/modules.dep.bin
 	/usr/lib/modules/${_kernver}/modules.symbols
@@ -52,31 +51,109 @@ if [ "$CROSS_BUILD" ]; then
 	_cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-"
 fi
 
+# handle all raspberry pi flavors
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) _flavors=rpi1 ;;
+	armv7*) _flavors=rpi2 ;;
+	aarch64*) _flavors="rpi3 rpi4" ;;
+esac
+
+subpackages="rpi-kernel-headers"
+for _f in $_flavors; do
+	subpackages+=" ${_f}-kernel-headers ${_f}-kernel"
+done
+
+# support legacy installations. don't drop before 2021-12 !!
+# make the meta packages depend on the new flavor packages
+case "$XBPS_TARGET_MACHINE" in
+	armv6*) depends=rpi1-kernel ;;
+	armv7*) depends=rpi2-kernel ;;
+	aarch64*) depends=rpi3-kernel ;;
+esac
+
+_flavor_stage() {
+	stage="$1"
+
+	for _f in $_flavors ; do
+		msg_normal "$_f: $stage\n"
+		(
+		case "$stage" in
+			pre_configure)
+				msg_normal "$_f: prepare build dir, please wait...\n"
+				cp -a "$wrksrc" "$wrksrc/../$_f"
+				;;
+			configure)
+				cd "$wrksrc/../$_f"
+				_configure $_f
+				;;
+			build)
+				cd "$wrksrc/../$_f"
+				_build
+				;;
+			install)
+				cd "$wrksrc/../$_f"
+				_install $_f
+				mv "$DESTDIR" "$DESTDIR/../$_f"
+				mkdir -p "$DESTDIR" 
+				;;
+		esac
+		)
+	done
+}
+
+_flavor_subpkg_install_kernel() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove /boot
+		vmove /usr/lib
+	)
+}
+_flavor_subpkg_install_headers() {
+	(
+		export DESTDIR="$DESTDIR/../$1"
+		vmove usr/src
+		vmove usr/lib/modules/${_kernver}/build
+	)
+}
+
+
 pre_configure() {
-	# Remove .git directory, otherwise scripts/setkernelversion.sh
-	# modifies KERNELRELEASE and appends + to it.
-	rm -rf .git
+	_flavor_stage pre_configure
 }
+
 do_configure() {
+	_flavor_stage configure
+}
+
+do_build() {
+	_flavor_stage build
+}
+
+do_install() {
+	_flavor_stage install
+}
+
+_configure() {
+	local rpi_flavor="$1"
 	local target defconfig
 
 	# Use upstream's default configuration, no need to maintain ours.
-	case "$XBPS_TARGET_MACHINE" in
-		# RPi3
-		aarch64*)
-			target=bcmrpi3_defconfig
+	case "$rpi_flavor" in
+		rpi1)
+			target=bcmrpi_defconfig
 			;;
-		# RPi2 / RPi3
-		armv7l*)
+		rpi2)
 			target=bcm2709_defconfig
 			;;
-		# RPi1
-		armv6l*)
-			target=bcmrpi_defconfig
+		rpi3)
+			target=bcmrpi3_defconfig
+			;;
+		rpi4)
+			target=bcm2711_defconfig
 			;;
 	esac
-
 	defconfig="arch/${_arch}/configs/${target}"
+
 	echo "CONFIG_CONNECTOR=y" >> "$defconfig"
 	echo "CONFIG_PROC_EVENTS=y" >> "$defconfig"
 	echo "CONFIG_F2FS_FS_SECURITY=y" >> "$defconfig"
@@ -101,7 +178,8 @@ do_configure() {
 	# Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
 	vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
 }
-do_build() {
+
+_build() {
 	local target
 
 	case "$XBPS_TARGET_MACHINE" in
@@ -116,11 +194,13 @@ do_build() {
 	make ${makejobs} ${_cross} ARCH=${_arch} prepare
 	make ${makejobs} ${_cross} ARCH=${_arch} ${target}
 }
-do_install() {
+
+_install() {
+	local rpi_flavor="$1"
 	local hdrdest
 
 	# Run depmod after compressing modules.
-	sed -i '2iexit 0' scripts/depmod.sh
+	vsed -i '2iexit 0' scripts/depmod.sh
 
 	# Install kernel, firmware and modules
 	make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
@@ -128,15 +208,19 @@ do_install() {
 	# Install device tree blobs
 	make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install
 
-	#move rpi3's dtb that ended up in /boot/broadcom
-	case "$XBPS_TARGET_MACHINE" in
-	aarch64*)
-		mv ${DESTDIR}/boot/broadcom/bcm2710-rpi-3-b.dtb ${DESTDIR}/boot
-		;;
+	# move dtb that ended up in /boot/broadcom
+	case "$rpi_flavor" in
+		rpi3)
+			mv ${DESTDIR}/boot/broadcom/bcm{2710,2837}-*.dtb ${DESTDIR}/boot
+			;;
+		rpi4)
+			mv ${DESTDIR}/boot/broadcom/bcm2711-*.dtb ${DESTDIR}/boot
+			;;
 	esac
+	rm -rf ${DESTDIR}/boot/broadcom
 
-	vmkdir boot
 	# Generate kernel.img and install it to destdir.
+	vmkdir boot
 	case "$XBPS_TARGET_MACHINE" in
 	aarch64*)
 		cp arch/arm64/boot/Image ${DESTDIR}/boot/kernel8.img
@@ -155,11 +239,12 @@ do_install() {
 	vmkdir usr
 	mv ${DESTDIR}/lib ${DESTDIR}/usr
 
+	(
 	cd ${DESTDIR}/usr/lib/modules/${_kernver}
 	rm -f source build
 	ln -sf ../../../src/${sourcepkg}-headers-${_kernver} build
+	)
 
-	cd ${wrksrc}
 	# Install required headers to build external modules
 	install -Dm644 Makefile ${hdrdest}/Makefile
 	install -Dm644 kernel/Makefile ${hdrdest}/kernel/Makefile
@@ -182,7 +267,6 @@ do_install() {
 		[ -d include/$i ] && cp -a include/$i ${hdrdest}/include
 	done
 
-	cd ${wrksrc}
 	# Remove helper binaries built for host,
 	# if generated files from the scripts/ directory need to be included,
 	# they need to be copied to ${hdrdest} before this step
@@ -241,20 +325,104 @@ do_install() {
 	cp -a arch/x86/ras/Kconfig ${hdrdest}/arch/x86/ras/Kconfig
 
 	# Compress all modules with xz to save a few MBs.
-	msg_normal "$pkgver: compressing kernel modules with gzip, please wait...\n"
+	msg_normal "$rpi_flavor: compressing kernel modules with gzip, please wait...\n"
 	find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9
 
 	# ... and run depmod again.
 	depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
 }
 
+# legacy
 rpi-kernel-headers_package() {
+	short_desc="${short_desc/kernel/kernel headers}"
+	build_style=meta
+	case "$XBPS_TARGET_MACHINE" in
+		armv6*) depends=rpi1-kernel-headers ;;
+		armv7*) depends=rpi2-kernel-headers ;;
+		aarch64*) depends=rpi3-kernel-headers ;;
+	esac
+}
+
+rpi1-kernel_package() {
 	nostrip=yes
 	noverifyrdeps=yes
 	noshlibprovides=yes
-	short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])"
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
 	pkg_install() {
-		vmove usr/src
-		vmove usr/lib/modules/${_kernver}/build
+		_flavor_subpkg_install_kernel rpi1
+	}
+}
+rpi1-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 1 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi1
+	}
+}
+
+rpi2-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	triggers="$_triggers"
+	mutable_files="$_mutable_files"
+	short_desc="Linux kernel for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi2
+	}
+}
+rpi2-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 2 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi2
+	}
+}
+
+rpi3-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi3
+	}
+}
+rpi3-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 3 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi3
+	}
+}
+
+rpi4-kernel_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	mutable_files="$_mutable_files"
+	triggers="$_triggers"
+	short_desc="Linux kernel for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_kernel rpi4
+	}
+}
+rpi4-kernel-headers_package() {
+	nostrip=yes
+	noverifyrdeps=yes
+	noshlibprovides=yes
+	short_desc="Linux kernel headers for Raspberry Pi 4 (${version%.*} [git ${_gitshort}])"
+	pkg_install() {
+		_flavor_subpkg_install_headers rpi4
 	}
 }
diff --git a/srcpkgs/rpi1-kernel b/srcpkgs/rpi1-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi1-kernel-headers b/srcpkgs/rpi1-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi1-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel b/srcpkgs/rpi2-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi2-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel b/srcpkgs/rpi3-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi3-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel b/srcpkgs/rpi4-kernel
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file
diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers
new file mode 120000
index 00000000000..3b4ec073331
--- /dev/null
+++ b/srcpkgs/rpi4-kernel-headers
@@ -0,0 +1 @@
+rpi-kernel
\ No newline at end of file

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (43 preceding siblings ...)
  2021-01-16 23:36 ` [PR PATCH] [Updated] " Piraty
@ 2021-01-16 23:37 ` Piraty
  2021-01-16 23:49 ` Piraty
                   ` (4 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-16 23:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r559053155

Comment:
good catch @ahesford , thank you

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (44 preceding siblings ...)
  2021-01-16 23:37 ` [PR REVIEW] " Piraty
@ 2021-01-16 23:49 ` Piraty
  2021-01-16 23:49 ` Piraty
                   ` (3 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-16 23:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-761699486

Comment:
to sum up current state of discussion:
- is building all flavors in the rpi-kernel template fine with everyone? (split into disinct templates could be done later anyway).
  - pro: one commit per update
  - con: unnecessarily long build times if i just need rpi3 but build rpi4 as well in the same run
- as with the current patch, rpi-kernel will become an orphan for installed rpi{0,1,2,3} systmes but pull in the new rpi{1,2,3}-kernel. an appropriate INSTALL.msg is provided
- how to handle rpi0 (as pointed out by @ericonr [here](https://github.com/void-linux/void-packages/pull/26000#discussion_r555040991))? just implicitly assume to run rpi1-kernel?
- better split rpi-base into rpi{1,2,3,4}-base as well? that might resolve the rpi-kernel orphan situation as the transitional dummy rpi-base could pull rpi{1,2,3}-base as per target arch mapping which ensures the dependency chain is kept intact
  -

@the-maldridge @pbui @ahesford @ericonr @void-linux/pkg-committers 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [NEEDS TESTERS] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (45 preceding siblings ...)
  2021-01-16 23:49 ` Piraty
@ 2021-01-16 23:49 ` Piraty
  2021-01-17  0:22 ` [WIP] " ahesford
                   ` (2 subsequent siblings)
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-16 23:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1117 bytes --]

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-761699486

Comment:
to sum up current state of discussion:
- is building all flavors in the rpi-kernel template fine with everyone? (split into disinct templates could be done later anyway).
  - pro: one commit per update
  - con: unnecessarily long build times if i just need rpi3 but build rpi4 as well in the same run
- as with the current patch, rpi-kernel will become an orphan for installed rpi{0,1,2,3} systmes but pull in the new rpi{1,2,3}-kernel. an appropriate INSTALL.msg is provided
- how to handle rpi0 (as pointed out by @ericonr [here](https://github.com/void-linux/void-packages/pull/26000#discussion_r555040991))? just implicitly assume to run rpi1-kernel?
- better split rpi-base into rpi{1,2,3,4}-base as well? that might resolve the rpi-kernel orphan situation as the transitional dummy rpi-base could pull rpi{1,2,3}-base as per target arch mapping which ensures the dependency chain is kept intact

@the-maldridge @pbui @ahesford @ericonr @void-linux/pkg-committers 

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [WIP] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (46 preceding siblings ...)
  2021-01-16 23:49 ` Piraty
@ 2021-01-17  0:22 ` ahesford
  2021-01-18  9:44 ` [PR REVIEW] " Piraty
  2021-01-18 21:48 ` ericonr
  49 siblings, 0 replies; 51+ messages in thread
From: ahesford @ 2021-01-17  0:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-761703372

Comment:
I think it's OK for the Zero to require `rpi1-kernel` because it's a first-generation RPi SoC. By the same token, I believe a few later RPi 2 designs should be able to run`rpi3-kernel` (with the dtb copy fix, anyway) because those are effectively third-generation SoCs in the second-generation form factor (not that we should advertise this---sufficiently knowledgeable users can find their way).

I don't have a strong opinion about splitting `rpi-base`. As @ericonr points out, this would let people simply pick the right base to grab what they need. (Should these depend on one of `base-{minimal,voidstrap,system}` to provide a more proper "base"?) On the other hand, the only difference is in the kernel dependency, so the HOWTO isn't made much more complicated by telling users to install `rpi-base` plus the kernel for their hardware generation.

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PR REVIEW] [WIP] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (47 preceding siblings ...)
  2021-01-17  0:22 ` [WIP] " ahesford
@ 2021-01-18  9:44 ` Piraty
  2021-01-18 21:48 ` ericonr
  49 siblings, 0 replies; 51+ messages in thread
From: Piraty @ 2021-01-18  9:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

New review comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#discussion_r559053155

Comment:
good catch @ahesford , applied

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [WIP] rpi-kernel: build a subpackage for each flavor, add rpi4
  2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
                   ` (48 preceding siblings ...)
  2021-01-18  9:44 ` [PR REVIEW] " Piraty
@ 2021-01-18 21:48 ` ericonr
  49 siblings, 0 replies; 51+ messages in thread
From: ericonr @ 2021-01-18 21:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26000#issuecomment-762484641

Comment:
> is building all flavors in the rpi-kernel template fine with everyone? (split into disinct templates could be done later anyway).

maybe make a build option (or one build option for each) to enable either one, if possible/simple? That way the day-to-day maintenance remains simple, but someone wanting to build locally can select just one.

> how to handle rpi0 (as pointed out by @ericonr here)? just implicitly assume to run rpi1-kernel?

Yes. Just make the `short_desc` for `rpi1-base` and `rpi1-kernel` mention "raspberrypi zero and 1" or similar).

> better split rpi-base into rpi{1,2,3,4}-base as well? that might resolve the rpi-kernel orphan situation as the transitional dummy rpi-base could pull rpi{1,2,3}-base as per target arch mapping which ensures the dependency chain is kept intact

This is my preference.

^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2021-01-18 21:48 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 16:17 [PR PATCH] rpi-kernel: build a subpackage for each flavor, add rpi4 Piraty
2020-10-31 16:27 ` [PR PATCH] [Updated] " Piraty
2020-10-31 16:36 ` Piraty
2020-11-06 23:34 ` [NEEDS TESTERS] " liketechnik
2020-11-16  3:32 ` [PR REVIEW] " agausmann
2020-11-16  3:34 ` agausmann
2020-11-16  3:36 ` agausmann
2020-11-16  3:57 ` agausmann
2020-11-16  3:58 ` agausmann
2020-11-16  3:59 ` agausmann
2020-11-17  9:10 ` [PR REVIEW] " Piraty
2020-11-22 18:23 ` Piraty
2020-11-22 19:48 ` Piraty
2020-11-22 20:58 ` agausmann
2020-12-29  7:49 ` manneorama
2020-12-29  7:59 ` manneorama
2020-12-29  8:10 ` manneorama
2020-12-29  9:03 ` manneorama
2020-12-29  9:48 ` manneorama
2020-12-29 10:53 ` manneorama
2020-12-31  1:42 ` [PR PATCH] [Updated] " Piraty
2021-01-03 23:08 ` manneorama
2021-01-05  9:36 ` Anachron
2021-01-05 19:48 ` LeamHall
2021-01-06 19:21 ` manneorama
2021-01-07  1:18 ` CMB
2021-01-07  2:04 ` LeamHall
2021-01-07  2:20 ` LeamHall
2021-01-11  0:24 ` [PR REVIEW] " ahesford
2021-01-11  2:02 ` ericonr
2021-01-11  2:02 ` ericonr
2021-01-11  2:57 ` jsumners
2021-01-11  3:17 ` ericonr
2021-01-11  3:51 ` jsumners
2021-01-11  4:14 ` ericonr
2021-01-11  5:04 ` ahesford
2021-01-11 11:19 ` Piraty
2021-01-11 11:21 ` Piraty
2021-01-11 11:25 ` Piraty
2021-01-11 13:17 ` ahesford
2021-01-11 13:20 ` ericonr
2021-01-12 20:19 ` [PR PATCH] [Updated] " Piraty
2021-01-13  2:42 ` [PR REVIEW] " ahesford
2021-01-16 22:38 ` CameronNemo
2021-01-16 23:36 ` [PR PATCH] [Updated] " Piraty
2021-01-16 23:37 ` [PR REVIEW] " Piraty
2021-01-16 23:49 ` Piraty
2021-01-16 23:49 ` Piraty
2021-01-17  0:22 ` [WIP] " ahesford
2021-01-18  9:44 ` [PR REVIEW] " Piraty
2021-01-18 21:48 ` ericonr

Github messages for voidlinux

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/voidlinux-github

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 voidlinux-github voidlinux-github/ http://inbox.vuxu.org/voidlinux-github \
		voidlinux-github@inbox.vuxu.org
	public-inbox-index voidlinux-github

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.github.voidlinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git