From 8a4337ebb28f153789095dc9ac897c5401b41d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Aug 2021 11:59:50 -0300 Subject: [PATCH 1/2] common/build-style: add rpi-kernel. --- common/build-style/rpi-kernel.sh | 160 +++++++++++++++++++ common/environment/build-style/rpi-kernel.sh | 29 ++++ 2 files changed, 189 insertions(+) create mode 100644 common/build-style/rpi-kernel.sh create mode 100644 common/environment/build-style/rpi-kernel.sh diff --git a/common/build-style/rpi-kernel.sh b/common/build-style/rpi-kernel.sh new file mode 100644 index 000000000000..0456a6b6dadc --- /dev/null +++ b/common/build-style/rpi-kernel.sh @@ -0,0 +1,160 @@ +do_configure() { + local target defconfig + + # Use upstream's default configuration, no need to maintain ours. + target=$kernel_target + + 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 + + # Generate kernel.img and install it to destdir. + vmkdir boot + cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img + + 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} scripts -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 vdso 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} +} diff --git a/common/environment/build-style/rpi-kernel.sh b/common/environment/build-style/rpi-kernel.sh new file mode 100644 index 000000000000..7234e7d40bfc --- /dev/null +++ b/common/environment/build-style/rpi-kernel.sh @@ -0,0 +1,29 @@ +_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 + +python_version=3 From f2b96208511073cb39954e3b671a21e986ef2f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Aug 2021 12:00:07 -0300 Subject: [PATCH 2/2] rpi-kernel: use rpi-kernel build style. And remove gitshort from short_desc. --- srcpkgs/rpi-kernel/template | 203 +----------------------------------- 1 file changed, 3 insertions(+), 200 deletions(-) diff --git a/srcpkgs/rpi-kernel/template b/srcpkgs/rpi-kernel/template index 81a8c484d0a3..f704a13b3602 100644 --- a/srcpkgs/rpi-kernel/template +++ b/srcpkgs/rpi-kernel/template @@ -13,220 +13,23 @@ # WARNING: keep all rpi*-kernel packages in sync _githash="86729e78125d4f3d203457940feee8bc97b11f6c" -_gitshort="${_githash:0:7}" pkgname=rpi-kernel version=5.10.52 revision=1 archs="armv6l*" +build_style=rpi-kernel wrksrc="linux-${_githash}" hostmakedepends="perl kmod uboot-mkimage openssl-devel bc bison flex" makedepends="ncurses-devel" maintainer="Piraty " homepage="http://www.kernel.org" license="GPL-2.0-only" -short_desc="Linux kernel for Raspberry Pi zero/1 (${version%.*} series [git ${_gitshort}])" +short_desc="Linux kernel for Raspberry Pi zero/1 (${version%.*} series)" distfiles="https://github.com/raspberrypi/linux/archive/${_githash}.tar.gz" checksum=a25a7dfce4c2ca5bdca39ddab5e43539d9b04900b0dbefe19f4f9b053e59968c -python_version=3 -_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 - armv6l*) - target=bcmrpi_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 - - # Generate kernel.img and install it to destdir. - vmkdir boot - cp arch/arm/boot/zImage ${DESTDIR}/boot/kernel.img - - 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} scripts -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 vdso 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} -} +kernel_target=bcmrpi_defconfig rpi-kernel-headers_package() { nostrip=yes