From 5987c4a65f4350f24d6fbc2ae55a98859d4396e7 Mon Sep 17 00:00:00 2001 From: Piraty Date: Mon, 22 Feb 2021 21:35:00 +0100 Subject: [PATCH 1/4] rpi-kernel: split into rpi, rpi2, rpi3 Until now, raspberry Pi variants were solely distiguished by the target architecture; this is insufficient for handling the upcoming addition of rpi4-kernel, so split them. * rpi-kernel will continue to serve raspberry Pi variants rpi0 and rpi1 for armv6l * rpi2-kernel and rpi3-kernel will serve their respective raspberry Pi variant * rpi-kernel will be an empty meta package for arch != armv6l and pull * rpi2-kernel for armv7 * rpi3-kernel for aarch64 to support the transition of existing systems to the new packaging scheme --- srcpkgs/rpi-kernel/template | 51 ++++--- srcpkgs/rpi2-kernel-headers | 1 + srcpkgs/rpi2-kernel/template | 250 +++++++++++++++++++++++++++++++++++ srcpkgs/rpi3-kernel-headers | 1 + srcpkgs/rpi3-kernel/template | 250 +++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+), 16 deletions(-) create mode 120000 srcpkgs/rpi2-kernel-headers create mode 100644 srcpkgs/rpi2-kernel/template create mode 120000 srcpkgs/rpi3-kernel-headers create mode 100644 srcpkgs/rpi3-kernel/template diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template index f9f170aedc0..6316f4188b3 100644 --- a/srcpkgs/rpi-kernel/template +++ b/srcpkgs/rpi-kernel/template @@ -10,12 +10,15 @@ _gitshort="${_githash:0:7}" pkgname=rpi-kernel version=5.4.83 -revision=1 +revision=2 +archs="armv6l*" wrksrc="linux-${_githash}" +hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex" +makedepends="ncurses-devel" 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="The Linux kernel for Raspberry Pi zero/1 (${version%.*} series [git ${_gitshort}])" distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz" checksum=4a98ea0d68c6e74d479789c12fc97619c872cb2607ae87a881a9491c1c3fbc35 python_version=2 @@ -27,10 +30,6 @@ 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" # These files could be modified when an external module is built. mutable_files=" @@ -62,15 +61,6 @@ do_configure() { # Use upstream's default configuration, no need to maintain ours. case "$XBPS_TARGET_MACHINE" in - # RPi3 - aarch64*) - target=bcmrpi3_defconfig - ;; - # RPi2 / RPi3 - armv7l*) - target=bcm2709_defconfig - ;; - # RPi1 armv6l*) target=bcmrpi_defconfig ;; @@ -252,9 +242,38 @@ rpi-kernel-headers_package() { nostrip=yes noverifyrdeps=yes noshlibprovides=yes - short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])" + short_desc="The Linux kernel headers for Raspberry Pi zero/1 (${version%.*} series [git ${_gitshort}])" pkg_install() { vmove usr/src vmove usr/lib/modules/${_kernver}/build } } + + +# support legacy systems (before rpi-kernel was split to rpi{,2,3}) +# archs != armv6* are emtpy meta packages to pull the new rpi{$n}-kernel package +archs+=" armv7l* aarch64*" +case "$XBPS_TARGET_MACHINE" in + armv6*) : ;; + *) + build_style=meta + short_desc="The Linux kernel for Raspberry Pi ( transitional dummy package)" + case "$XBPS_TARGET_MACHINE" in + armv7*) depends=rpi2-kernel ;; + aarch64*) depends=rpi3-kernel ;; + esac + pre_configure() { : ; } + do_configure() { : ; } + do_build() { : ; } + do_install() { : ; } + + rpi-kernel-headers_package() { + build_style=meta + short_desc="The Linux kernel headers for Raspberry Pi ( transitional dummy package)" + case "$XBPS_TARGET_MACHINE" in + armv7*) depends=rpi2-kernel-headers ;; + aarch64*) depends=rpi3-kernel-headers ;; + esac + } + ;; +esac diff --git a/srcpkgs/rpi2-kernel-headers b/srcpkgs/rpi2-kernel-headers new file mode 120000 index 00000000000..fbe6d91aeb7 --- /dev/null +++ b/srcpkgs/rpi2-kernel-headers @@ -0,0 +1 @@ +rpi2-kernel \ No newline at end of file diff --git a/srcpkgs/rpi2-kernel/template b/srcpkgs/rpi2-kernel/template new file mode 100644 index 00000000000..81ecc432cd6 --- /dev/null +++ b/srcpkgs/rpi2-kernel/template @@ -0,0 +1,250 @@ +# Template file for 'rpi2-kernel' +# +# We track the latest Raspberry Pi LTS kernel as that is what is used in the +# official Raspbian distribution. This is currently 5.4: +# +# https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=269769 + +_githash="76c49e60e742d0bebd798be972d67dd3fd007691" +_gitshort="${_githash:0:7}" + +pkgname=rpi2-kernel +version=5.4.83 +revision=2 +archs="armv7l*" +wrksrc="linux-${_githash}" +hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex" +makedepends="ncurses-devel" +maintainer="Piraty " +homepage="http://www.kernel.org" +license="GPL-2.0-only" +short_desc="The Linux kernel for Raspberry Pi 2 (${version%.*} series [git ${_gitshort}])" +distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz" +checksum=4a98ea0d68c6e74d479789c12fc97619c872cb2607ae87a881a9491c1c3fbc35 +python_version=2 + +_kernver="${version}_${revision}" + +nodebug=yes +nostrip=yes +noverifyrdeps=yes +noshlibprovides=yes + +triggers="kernel-hooks" +# These files could be modified when an external module is built. +mutable_files=" + /usr/lib/modules/${_kernver}/modules.dep + /usr/lib/modules/${_kernver}/modules.dep.bin + /usr/lib/modules/${_kernver}/modules.symbols + /usr/lib/modules/${_kernver}/modules.symbols.bin + /usr/lib/modules/${_kernver}/modules.alias + /usr/lib/modules/${_kernver}/modules.alias.bin + /usr/lib/modules/${_kernver}/modules.devname" + +_arch= +case "$XBPS_TARGET_MACHINE" in + arm*) _arch=arm ;; + aarch64*) _arch=arm64 ;; +esac +_cross= +if [ "$CROSS_BUILD" ]; then + _cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-" +fi + +pre_configure() { + # Remove .git directory, otherwise scripts/setkernelversion.sh + # modifies KERNELRELEASE and appends + to it. + rm -rf .git +} +do_configure() { + local target defconfig + + # Use upstream's default configuration, no need to maintain ours. + case "$XBPS_TARGET_MACHINE" in + armv7l*) + target=bcm2709_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" + echo "CONFIG_CGROUP_PIDS=y" >> "$defconfig" + + # IR Remote Support + echo "CONFIG_RC_CORE=y" >> "$defconfig" + echo "CONFIG_LIRC=y" >> "$defconfig" + echo "CONFIG_RC_DECODERS=y" >> "$defconfig" + echo "CONFIG_RC_DEVICES=y" >> "$defconfig" + echo "CONFIG_IR_RC6_DECODER=m" >> "$defconfig" + echo "CONFIG_IR_MCEUSB=m" >> "$defconfig" + + # HID Controllers + echo "CONFIG_HID_STEAM=y" >> "$defconfig" + + # LXD 4.2+ support + echo "CONFIG_BRIDGE_VLAN_FILTERING=y" >> "$defconfig" + + make ${makejobs} ${_cross} ARCH=${_arch} ${target} + + # Always use our revision to CONFIG_LOCALVERSION to match our pkg version. + vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config +} +do_build() { + local target + + case "$XBPS_TARGET_MACHINE" in + arm*) + target="zImage modules dtbs" + ;; + aarch64*) + target="Image modules dtbs" + ;; + esac + + make ${makejobs} ${_cross} ARCH=${_arch} prepare + make ${makejobs} ${_cross} ARCH=${_arch} ${target} +} +do_install() { + local hdrdest + + # Run depmod after compressing modules. + sed -i '2iexit 0' scripts/depmod.sh + + # Install kernel, firmware and modules + make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install + + # Install device tree blobs + make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install + + # move dtb that ended up in /boot/broadcom + case "$XBPS_TARGET_MACHINE" in + aarch64*) + mv ${DESTDIR}/boot/broadcom/bcm{2710,2837}-*.dtb ${DESTDIR}/boot + ;; + esac + + vmkdir boot + # Generate kernel.img and install it to destdir. + case "$XBPS_TARGET_MACHINE" in + aarch64*) + cp arch/arm64/boot/Image ${DESTDIR}/boot/kernel8.img + ;; + armv7l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel7.img + ;; + armv6l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img + ;; + esac + + hdrdest=${DESTDIR}/usr/src/${sourcepkg}-headers-${_kernver} + + # Switch to /usr. + 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 + install -Dm644 .config ${hdrdest}/.config + for file in $(find . -name Kconfig\*); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + for file in $(find arch/${_arch} -name module.lds -o -name Kbuild.platforms -o -name Platform); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + mkdir -p ${hdrdest}/include + + # Remove firmware stuff provided by the "linux-firmware" pkg. + rm -rf ${DESTDIR}/usr/lib/firmware + + for i in acpi asm-generic clocksource config crypto drm generated linux \ + math-emu media net pcmcia scsi sound trace uapi video xen; do + [ -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 + if [ "$CROSS_BUILD" ]; then + make ${makejobs} ARCH=${_arch} _mrproper_scripts + # remove host specific objects as well + find scripts -name '*.o' -delete + fi + + # Copy files necessary for later builds. + cp Module.symvers ${hdrdest} + cp -a scripts ${hdrdest} + mkdir -p ${hdrdest}/security/selinux + cp -a security/selinux/include ${hdrdest}/security/selinux + mkdir -p ${hdrdest}/tools/include + cp -a tools/include/tools ${hdrdest}/tools/include + if [ -d "arch/${_arch}/tools" ]; then + cp -a arch/${_arch}/tools ${hdrdest}/arch/${_arch} + fi + + # copy arch includes for external modules + mkdir -p ${hdrdest}/arch/${_arch} + cp -a arch/${_arch}/include ${hdrdest}/arch/${_arch} + + mkdir -p ${hdrdest}/arch/${_arch}/kernel + cp arch/${_arch}/Makefile ${hdrdest}/arch/${_arch} + cp arch/${_arch}/kernel/asm-offsets.s ${hdrdest}/arch/${_arch}/kernel + if [ "$_arch" = "arm64" ] ; then + cp -a arch/${_arch}/kernel/vdso ${hdrdest}/arch/${_arch}/kernel/ + fi + + # Add md headers + mkdir -p ${hdrdest}/drivers/md + cp drivers/md/*.h ${hdrdest}/drivers/md + + # Add inotify.h + mkdir -p ${hdrdest}/include/linux + cp include/linux/inotify.h ${hdrdest}/include/linux + + # Add wireless headers + mkdir -p ${hdrdest}/net/mac80211/ + cp net/mac80211/*.h ${hdrdest}/net/mac80211 + + # add dvb headers for external modules + mkdir -p ${hdrdest}/include/config/dvb/ + cp include/config/dvb/*.h ${hdrdest}/include/config/dvb/ + + # Remove unneeded architectures + # (save the correct one + Kconfig and delete all others) + mkdir -p arch-backup + cp -r ${hdrdest}/arch/${_arch} ${hdrdest}/arch/Kconfig arch-backup/ + rm -rf ${hdrdest}/arch + mv arch-backup ${hdrdest}/arch + # Keep arch/x86/ras/Kconfig as it is needed by drivers/ras/Kconfig + mkdir -p ${hdrdest}/arch/x86/ras + 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" + find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9 + + # ... and run depmod again. + depmod -b ${DESTDIR}/usr -F System.map ${_kernver} +} + +rpi2-kernel-headers_package() { + nostrip=yes + noverifyrdeps=yes + noshlibprovides=yes + short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])" + pkg_install() { + vmove usr/src + vmove usr/lib/modules/${_kernver}/build + } +} diff --git a/srcpkgs/rpi3-kernel-headers b/srcpkgs/rpi3-kernel-headers new file mode 120000 index 00000000000..29e9f333d66 --- /dev/null +++ b/srcpkgs/rpi3-kernel-headers @@ -0,0 +1 @@ +rpi3-kernel \ No newline at end of file diff --git a/srcpkgs/rpi3-kernel/template b/srcpkgs/rpi3-kernel/template new file mode 100644 index 00000000000..892d6ef7923 --- /dev/null +++ b/srcpkgs/rpi3-kernel/template @@ -0,0 +1,250 @@ +# Template file for 'rpi3-kernel' +# +# We track the latest Raspberry Pi LTS kernel as that is what is used in the +# official Raspbian distribution. This is currently 5.4: +# +# https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=269769 + +_githash="76c49e60e742d0bebd798be972d67dd3fd007691" +_gitshort="${_githash:0:7}" + +pkgname=rpi3-kernel +version=5.4.83 +revision=2 +archs="aarch64*" +wrksrc="linux-${_githash}" +hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex" +makedepends="ncurses-devel" +maintainer="Piraty " +homepage="http://www.kernel.org" +license="GPL-2.0-only" +short_desc="The Linux kernel for Raspberry Pi 3 (${version%.*} series [git ${_gitshort}])" +distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz" +checksum=4a98ea0d68c6e74d479789c12fc97619c872cb2607ae87a881a9491c1c3fbc35 +python_version=2 + +_kernver="${version}_${revision}" + +nodebug=yes +nostrip=yes +noverifyrdeps=yes +noshlibprovides=yes + +triggers="kernel-hooks" +# These files could be modified when an external module is built. +mutable_files=" + /usr/lib/modules/${_kernver}/modules.dep + /usr/lib/modules/${_kernver}/modules.dep.bin + /usr/lib/modules/${_kernver}/modules.symbols + /usr/lib/modules/${_kernver}/modules.symbols.bin + /usr/lib/modules/${_kernver}/modules.alias + /usr/lib/modules/${_kernver}/modules.alias.bin + /usr/lib/modules/${_kernver}/modules.devname" + +_arch= +case "$XBPS_TARGET_MACHINE" in + arm*) _arch=arm ;; + aarch64*) _arch=arm64 ;; +esac +_cross= +if [ "$CROSS_BUILD" ]; then + _cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-" +fi + +pre_configure() { + # Remove .git directory, otherwise scripts/setkernelversion.sh + # modifies KERNELRELEASE and appends + to it. + rm -rf .git +} +do_configure() { + local target defconfig + + # Use upstream's default configuration, no need to maintain ours. + case "$XBPS_TARGET_MACHINE" in + aarch64*) + target=bcmrpi3_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" + echo "CONFIG_CGROUP_PIDS=y" >> "$defconfig" + + # IR Remote Support + echo "CONFIG_RC_CORE=y" >> "$defconfig" + echo "CONFIG_LIRC=y" >> "$defconfig" + echo "CONFIG_RC_DECODERS=y" >> "$defconfig" + echo "CONFIG_RC_DEVICES=y" >> "$defconfig" + echo "CONFIG_IR_RC6_DECODER=m" >> "$defconfig" + echo "CONFIG_IR_MCEUSB=m" >> "$defconfig" + + # HID Controllers + echo "CONFIG_HID_STEAM=y" >> "$defconfig" + + # LXD 4.2+ support + echo "CONFIG_BRIDGE_VLAN_FILTERING=y" >> "$defconfig" + + make ${makejobs} ${_cross} ARCH=${_arch} ${target} + + # Always use our revision to CONFIG_LOCALVERSION to match our pkg version. + vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config +} +do_build() { + local target + + case "$XBPS_TARGET_MACHINE" in + arm*) + target="zImage modules dtbs" + ;; + aarch64*) + target="Image modules dtbs" + ;; + esac + + make ${makejobs} ${_cross} ARCH=${_arch} prepare + make ${makejobs} ${_cross} ARCH=${_arch} ${target} +} +do_install() { + local hdrdest + + # Run depmod after compressing modules. + sed -i '2iexit 0' scripts/depmod.sh + + # Install kernel, firmware and modules + make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install + + # Install device tree blobs + make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install + + # move dtb that ended up in /boot/broadcom + case "$XBPS_TARGET_MACHINE" in + aarch64*) + mv ${DESTDIR}/boot/broadcom/bcm{2710,2837}-*.dtb ${DESTDIR}/boot + ;; + esac + + vmkdir boot + # Generate kernel.img and install it to destdir. + case "$XBPS_TARGET_MACHINE" in + aarch64*) + cp arch/arm64/boot/Image ${DESTDIR}/boot/kernel8.img + ;; + armv7l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel7.img + ;; + armv6l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img + ;; + esac + + hdrdest=${DESTDIR}/usr/src/${sourcepkg}-headers-${_kernver} + + # Switch to /usr. + 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 + install -Dm644 .config ${hdrdest}/.config + for file in $(find . -name Kconfig\*); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + for file in $(find arch/${_arch} -name module.lds -o -name Kbuild.platforms -o -name Platform); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + mkdir -p ${hdrdest}/include + + # Remove firmware stuff provided by the "linux-firmware" pkg. + rm -rf ${DESTDIR}/usr/lib/firmware + + for i in acpi asm-generic clocksource config crypto drm generated linux \ + math-emu media net pcmcia scsi sound trace uapi video xen; do + [ -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 + if [ "$CROSS_BUILD" ]; then + make ${makejobs} ARCH=${_arch} _mrproper_scripts + # remove host specific objects as well + find scripts -name '*.o' -delete + fi + + # Copy files necessary for later builds. + cp Module.symvers ${hdrdest} + cp -a scripts ${hdrdest} + mkdir -p ${hdrdest}/security/selinux + cp -a security/selinux/include ${hdrdest}/security/selinux + mkdir -p ${hdrdest}/tools/include + cp -a tools/include/tools ${hdrdest}/tools/include + if [ -d "arch/${_arch}/tools" ]; then + cp -a arch/${_arch}/tools ${hdrdest}/arch/${_arch} + fi + + # copy arch includes for external modules + mkdir -p ${hdrdest}/arch/${_arch} + cp -a arch/${_arch}/include ${hdrdest}/arch/${_arch} + + mkdir -p ${hdrdest}/arch/${_arch}/kernel + cp arch/${_arch}/Makefile ${hdrdest}/arch/${_arch} + cp arch/${_arch}/kernel/asm-offsets.s ${hdrdest}/arch/${_arch}/kernel + if [ "$_arch" = "arm64" ] ; then + cp -a arch/${_arch}/kernel/vdso ${hdrdest}/arch/${_arch}/kernel/ + fi + + # Add md headers + mkdir -p ${hdrdest}/drivers/md + cp drivers/md/*.h ${hdrdest}/drivers/md + + # Add inotify.h + mkdir -p ${hdrdest}/include/linux + cp include/linux/inotify.h ${hdrdest}/include/linux + + # Add wireless headers + mkdir -p ${hdrdest}/net/mac80211/ + cp net/mac80211/*.h ${hdrdest}/net/mac80211 + + # add dvb headers for external modules + mkdir -p ${hdrdest}/include/config/dvb/ + cp include/config/dvb/*.h ${hdrdest}/include/config/dvb/ + + # Remove unneeded architectures + # (save the correct one + Kconfig and delete all others) + mkdir -p arch-backup + cp -r ${hdrdest}/arch/${_arch} ${hdrdest}/arch/Kconfig arch-backup/ + rm -rf ${hdrdest}/arch + mv arch-backup ${hdrdest}/arch + # Keep arch/x86/ras/Kconfig as it is needed by drivers/ras/Kconfig + mkdir -p ${hdrdest}/arch/x86/ras + 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" + find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9 + + # ... and run depmod again. + depmod -b ${DESTDIR}/usr -F System.map ${_kernver} +} + +rpi3-kernel-headers_package() { + nostrip=yes + noverifyrdeps=yes + noshlibprovides=yes + short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])" + pkg_install() { + vmove usr/src + vmove usr/lib/modules/${_kernver}/build + } +} From 643644789a50ece76f00e59636591d67a250753a Mon Sep 17 00:00:00 2001 From: Piraty Date: Mon, 22 Feb 2021 21:35:09 +0100 Subject: [PATCH 2/4] rpi-base: split into rpi, rpi2, rpi3 Until now, raspberry Pi variants were solely distiguished by the target architecture; this is insufficient for handling the upcoming addition of rpi4-base. Technically it'd be fine for rpi-base to not depend on rpi-kernel as it only ships a udev file but that would be bad for existing systems. For now it's sufficient to have one package provide all subpackages, to ease maintainance. rpi3-base actually existed back in 2017 (depended on mainline linux instead of rpi-kernel) and became obsolete in 2018 ; would have known back then we may have to deal with rpi>3 some day... --- srcpkgs/rpi-base/template | 53 +++++++++++++++++++++++++++++++++++++-- srcpkgs/rpi2-base | 1 + srcpkgs/rpi3-base | 1 + 3 files changed, 53 insertions(+), 2 deletions(-) create mode 120000 srcpkgs/rpi2-base create mode 120000 srcpkgs/rpi3-base diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template index 8fcf3581efd..d5ae22b2c78 100644 --- a/srcpkgs/rpi-base/template +++ b/srcpkgs/rpi-base/template @@ -1,9 +1,10 @@ # Template file for 'rpi-base' pkgname=rpi-base -version=2.6 +version=3.0 revision=1 archs="armv6l* armv7l* aarch64*" -depends="virtual?ntp-daemon rpi-firmware rpi-kernel" +_base_depends="virtual?ntp-daemon rpi-firmware" +depends="${_base_depends} rpi-kernel" short_desc="Void Linux Raspberry Pi base files" maintainer="Orphaned " license="Public Domain" @@ -12,3 +13,51 @@ homepage="https://www.voidlinux.org" do_install() { vinstall "${FILESDIR}/71-raspberrypi.rules" 644 usr/lib/udev/rules.d } + +case "$XBPS_TARGET_MACHINE" in + armv6*) + subpackages=" " + ;; + armv7*) + subpackages="rpi2-base" + ;; + aarch64*) + subpackages="rpi3-base" + ;; +esac + +# support legacy systems (before rpi-kernel was split to rpi{,2,3}) +# archs != armv6* are emtpy meta packages to pull the new rpi${n}-base package +case "$XBPS_TARGET_MACHINE" in + armv6*) : ;; + *) + build_style=meta + short_desc+=" (transitional dummy package)" + do_install() { : ; } + case "$XBPS_TARGET_MACHINE" in + armv7*) + depends="rpi2-base" + ;; + aarch64*) + depends="rpi3-base" + ;; + esac + ;; +esac + +rpi2-base_package() { + depends="${_base_depends} rpi2-kernel" + short_desc="Void Linux Raspberry Pi 2 base files" + pkg_install() { + vinstall "${FILESDIR}/71-raspberrypi.rules" 644 usr/lib/udev/rules.d + } +} + + +rpi3-base_package() { + depends="${_base_depends} rpi3-kernel" + short_desc="Void Linux Raspberry Pi 3 base files" + pkg_install() { + vinstall "${FILESDIR}/71-raspberrypi.rules" 644 usr/lib/udev/rules.d + } +} diff --git a/srcpkgs/rpi2-base b/srcpkgs/rpi2-base new file mode 120000 index 00000000000..c004915dfa8 --- /dev/null +++ b/srcpkgs/rpi2-base @@ -0,0 +1 @@ +rpi-base \ No newline at end of file diff --git a/srcpkgs/rpi3-base b/srcpkgs/rpi3-base new file mode 120000 index 00000000000..c004915dfa8 --- /dev/null +++ b/srcpkgs/rpi3-base @@ -0,0 +1 @@ +rpi-base \ No newline at end of file From 4821e78c878635625ad742d0f3df7e62ac80345c Mon Sep 17 00:00:00 2001 From: Piraty Date: Sun, 28 Feb 2021 19:52:49 +0100 Subject: [PATCH 3/4] New package: rpi4-kernel-5.4.83 --- srcpkgs/rpi4-kernel-headers | 1 + srcpkgs/rpi4-kernel/template | 250 +++++++++++++++++++++++++++++++++++ 2 files changed, 251 insertions(+) create mode 120000 srcpkgs/rpi4-kernel-headers create mode 100644 srcpkgs/rpi4-kernel/template diff --git a/srcpkgs/rpi4-kernel-headers b/srcpkgs/rpi4-kernel-headers new file mode 120000 index 00000000000..9c2fad14350 --- /dev/null +++ b/srcpkgs/rpi4-kernel-headers @@ -0,0 +1 @@ +rpi4-kernel \ No newline at end of file diff --git a/srcpkgs/rpi4-kernel/template b/srcpkgs/rpi4-kernel/template new file mode 100644 index 00000000000..d0a70bb92b2 --- /dev/null +++ b/srcpkgs/rpi4-kernel/template @@ -0,0 +1,250 @@ +# Template file for 'rpi4-kernel' +# +# We track the latest Raspberry Pi LTS kernel as that is what is used in the +# official Raspbian distribution. This is currently 5.4: +# +# https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=269769 + +_githash="76c49e60e742d0bebd798be972d67dd3fd007691" +_gitshort="${_githash:0:7}" + +pkgname=rpi4-kernel +version=5.4.83 +revision=2 +archs="aarch64*" +wrksrc="linux-${_githash}" +hostmakedepends="perl kmod uboot-mkimage libressl-devel bc bison flex" +makedepends="ncurses-devel" +maintainer="Piraty " +homepage="http://www.kernel.org" +license="GPL-2.0-only" +short_desc="The Linux kernel for Raspberry Pi 4 (${version%.*} series [git ${_gitshort}])" +distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz" +checksum=4a98ea0d68c6e74d479789c12fc97619c872cb2607ae87a881a9491c1c3fbc35 +python_version=2 + +_kernver="${version}_${revision}" + +nodebug=yes +nostrip=yes +noverifyrdeps=yes +noshlibprovides=yes + +triggers="kernel-hooks" +# These files could be modified when an external module is built. +mutable_files=" + /usr/lib/modules/${_kernver}/modules.dep + /usr/lib/modules/${_kernver}/modules.dep.bin + /usr/lib/modules/${_kernver}/modules.symbols + /usr/lib/modules/${_kernver}/modules.symbols.bin + /usr/lib/modules/${_kernver}/modules.alias + /usr/lib/modules/${_kernver}/modules.alias.bin + /usr/lib/modules/${_kernver}/modules.devname" + +_arch= +case "$XBPS_TARGET_MACHINE" in + arm*) _arch=arm ;; + aarch64*) _arch=arm64 ;; +esac +_cross= +if [ "$CROSS_BUILD" ]; then + _cross="CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-" +fi + +pre_configure() { + # Remove .git directory, otherwise scripts/setkernelversion.sh + # modifies KERNELRELEASE and appends + to it. + rm -rf .git +} +do_configure() { + local target defconfig + + # Use upstream's default configuration, no need to maintain ours. + case "$XBPS_TARGET_MACHINE" in + aarch64*) + 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" + echo "CONFIG_CGROUP_PIDS=y" >> "$defconfig" + + # IR Remote Support + echo "CONFIG_RC_CORE=y" >> "$defconfig" + echo "CONFIG_LIRC=y" >> "$defconfig" + echo "CONFIG_RC_DECODERS=y" >> "$defconfig" + echo "CONFIG_RC_DEVICES=y" >> "$defconfig" + echo "CONFIG_IR_RC6_DECODER=m" >> "$defconfig" + echo "CONFIG_IR_MCEUSB=m" >> "$defconfig" + + # HID Controllers + echo "CONFIG_HID_STEAM=y" >> "$defconfig" + + # LXD 4.2+ support + echo "CONFIG_BRIDGE_VLAN_FILTERING=y" >> "$defconfig" + + make ${makejobs} ${_cross} ARCH=${_arch} ${target} + + # Always use our revision to CONFIG_LOCALVERSION to match our pkg version. + vsed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config +} +do_build() { + local target + + case "$XBPS_TARGET_MACHINE" in + arm*) + target="zImage modules dtbs" + ;; + aarch64*) + target="Image modules dtbs" + ;; + esac + + make ${makejobs} ${_cross} ARCH=${_arch} prepare + make ${makejobs} ${_cross} ARCH=${_arch} ${target} +} +do_install() { + local hdrdest + + # Run depmod after compressing modules. + sed -i '2iexit 0' scripts/depmod.sh + + # Install kernel, firmware and modules + make ${makejobs} ARCH=${_arch} INSTALL_MOD_PATH=${DESTDIR} modules_install + + # Install device tree blobs + make ${makejobs} ARCH=${_arch} INSTALL_DTBS_PATH=${DESTDIR}/boot dtbs_install + + # move dtb that ended up in /boot/broadcom + case "$XBPS_TARGET_MACHINE" in + aarch64*) + mv ${DESTDIR}/boot/broadcom/bcm{2710,2837}-*.dtb ${DESTDIR}/boot + ;; + esac + + vmkdir boot + # Generate kernel.img and install it to destdir. + case "$XBPS_TARGET_MACHINE" in + aarch64*) + cp arch/arm64/boot/Image ${DESTDIR}/boot/kernel8.img + ;; + armv7l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel7.img + ;; + armv6l*) + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img + ;; + esac + + hdrdest=${DESTDIR}/usr/src/${sourcepkg}-headers-${_kernver} + + # Switch to /usr. + 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 + install -Dm644 .config ${hdrdest}/.config + for file in $(find . -name Kconfig\*); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + for file in $(find arch/${_arch} -name module.lds -o -name Kbuild.platforms -o -name Platform); do + mkdir -p ${hdrdest}/$(dirname $file) + install -Dm644 $file ${hdrdest}/${file} + done + mkdir -p ${hdrdest}/include + + # Remove firmware stuff provided by the "linux-firmware" pkg. + rm -rf ${DESTDIR}/usr/lib/firmware + + for i in acpi asm-generic clocksource config crypto drm generated linux \ + math-emu media net pcmcia scsi sound trace uapi video xen; do + [ -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 + if [ "$CROSS_BUILD" ]; then + make ${makejobs} ARCH=${_arch} _mrproper_scripts + # remove host specific objects as well + find scripts -name '*.o' -delete + fi + + # Copy files necessary for later builds. + cp Module.symvers ${hdrdest} + cp -a scripts ${hdrdest} + mkdir -p ${hdrdest}/security/selinux + cp -a security/selinux/include ${hdrdest}/security/selinux + mkdir -p ${hdrdest}/tools/include + cp -a tools/include/tools ${hdrdest}/tools/include + if [ -d "arch/${_arch}/tools" ]; then + cp -a arch/${_arch}/tools ${hdrdest}/arch/${_arch} + fi + + # copy arch includes for external modules + mkdir -p ${hdrdest}/arch/${_arch} + cp -a arch/${_arch}/include ${hdrdest}/arch/${_arch} + + mkdir -p ${hdrdest}/arch/${_arch}/kernel + cp arch/${_arch}/Makefile ${hdrdest}/arch/${_arch} + cp arch/${_arch}/kernel/asm-offsets.s ${hdrdest}/arch/${_arch}/kernel + if [ "$_arch" = "arm64" ] ; then + cp -a arch/${_arch}/kernel/vdso ${hdrdest}/arch/${_arch}/kernel/ + fi + + # Add md headers + mkdir -p ${hdrdest}/drivers/md + cp drivers/md/*.h ${hdrdest}/drivers/md + + # Add inotify.h + mkdir -p ${hdrdest}/include/linux + cp include/linux/inotify.h ${hdrdest}/include/linux + + # Add wireless headers + mkdir -p ${hdrdest}/net/mac80211/ + cp net/mac80211/*.h ${hdrdest}/net/mac80211 + + # add dvb headers for external modules + mkdir -p ${hdrdest}/include/config/dvb/ + cp include/config/dvb/*.h ${hdrdest}/include/config/dvb/ + + # Remove unneeded architectures + # (save the correct one + Kconfig and delete all others) + mkdir -p arch-backup + cp -r ${hdrdest}/arch/${_arch} ${hdrdest}/arch/Kconfig arch-backup/ + rm -rf ${hdrdest}/arch + mv arch-backup ${hdrdest}/arch + # Keep arch/x86/ras/Kconfig as it is needed by drivers/ras/Kconfig + mkdir -p ${hdrdest}/arch/x86/ras + 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" + find ${DESTDIR} -name '*.ko' | xargs -n1 -P0 gzip -9 + + # ... and run depmod again. + depmod -b ${DESTDIR}/usr -F System.map ${_kernver} +} + +rpi4-kernel-headers_package() { + nostrip=yes + noverifyrdeps=yes + noshlibprovides=yes + short_desc="The Linux kernel headers for Raspberry Pi (${version%.*} series [git ${_gitshort}])" + pkg_install() { + vmove usr/src + vmove usr/lib/modules/${_kernver}/build + } +} From 61aa6a9f3c3de8655bfdb4cf26d8f45a10204982 Mon Sep 17 00:00:00 2001 From: Piraty Date: Sun, 28 Feb 2021 19:56:40 +0100 Subject: [PATCH 4/4] rpi-base: add rpi4 --- srcpkgs/rpi-base/template | 13 +++++++++++-- srcpkgs/rpi4-base | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) create mode 120000 srcpkgs/rpi4-base diff --git a/srcpkgs/rpi-base/template b/srcpkgs/rpi-base/template index d5ae22b2c78..4711609bef8 100644 --- a/srcpkgs/rpi-base/template +++ b/srcpkgs/rpi-base/template @@ -1,7 +1,7 @@ # Template file for 'rpi-base' pkgname=rpi-base version=3.0 -revision=1 +revision=2 archs="armv6l* armv7l* aarch64*" _base_depends="virtual?ntp-daemon rpi-firmware" depends="${_base_depends} rpi-kernel" @@ -22,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in subpackages="rpi2-base" ;; aarch64*) - subpackages="rpi3-base" + subpackages="rpi3-base rpi4-base" ;; esac @@ -61,3 +61,12 @@ rpi3-base_package() { vinstall "${FILESDIR}/71-raspberrypi.rules" 644 usr/lib/udev/rules.d } } + +rpi4-base_package() { + depends="${_base_depends} rpi4-kernel" + short_desc="Void Linux Raspberry Pi 4 base files" + conflicts="rpi3-base" + pkg_install() { + vinstall "${FILESDIR}/71-raspberrypi.rules" 644 usr/lib/udev/rules.d + } +} diff --git a/srcpkgs/rpi4-base b/srcpkgs/rpi4-base new file mode 120000 index 00000000000..c004915dfa8 --- /dev/null +++ b/srcpkgs/rpi4-base @@ -0,0 +1 @@ +rpi-base \ No newline at end of file