From fa55dad53d1572a0f3c24c04234cfaf30ca30b95 Mon Sep 17 00:00:00 2001 From: Piraty 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 " +maintainer="Piraty " license="Public Domain" homepage="https://www.voidlinux.org" From 2bd77c2081779c6270a485ec07f9a95d008fce3f Mon Sep 17 00:00:00 2001 From: Piraty 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 " +hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex" +maintainer="Piraty " 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