# Maintainer: Azkali Manad Name: l4s-bsp-kernel Version: 32.3.1 Release: 5 License: GPL-3.0-only Summary: L4S custom BSP BuildRequires: uboot-tools # Sources SOURCE0: https://gitlab.com/api/v4/projects/58434590/jobs/artifacts/master/download?job=32.3.1#/artifacts.zip %prep unzip %{SOURCE0} %define kernel switch-kernel %define kernel_ver 4.9.140 %description %{summary}. # Kernel packages %package -n %{kernel}-core Summary: Linux %{kernel_ver} Kernel Image Version: %{kernel_ver} Release: %{release} Requires: %{kernel}-modules = %{kernel_ver}-%{release} Requires: switch-bootfiles %description -n %{kernel}-core %{summary}. %package -n %{kernel}-headers Summary: Linux %{kernel_ver} Kernel headers Version: %{kernel_ver} Release: %{release} Requires: %{kernel}-core = %{kernel_ver}-%{release} Provides: kernel-headers Requires: switch-bootfiles %description -n %{kernel}-headers %{summary}. %package -n %{kernel}-modules Summary: Linux %{kernel_ver} Kernel modules Version: %{kernel_ver} Release: %{release} Requires: %{kernel}-core = %{kernel_ver}-%{release} Provides: kernel-modules Requires: switch-bootfiles %description -n %{kernel}-modules %{summary}. %package -n %{kernel}-devel Summary: Linux %{kernel_ver} Kernel devel package Version: %{kernel_ver} Release: %{release} Requires: %{kernel}-core = %{kernel_ver}-%{release} Provides: kernel-devel AutoReq: 0 Requires: switch-bootfiles %description -n %{kernel}-devel %{summary}. %package -n %{kernel}-switch-device-tree Summary: Switch device-tree Version: %{kernel_ver} Release: %{release} Requires: %{kernel}-core = %{kernel_ver}-%{release} Requires: switch-bootfiles %description -n %{kernel}-switch-device-tree %{summary}. %install cd %{buildroot} mkdir -p %{buildroot}/boot/switchroot %{buildroot}%{_exec_prefix}/lib %{buildroot}%{_usrsrc} %{buildroot}%{_exec_prefix}/lib/aarch64-linux-gnu/tegra/ %{buildroot}/etc/ld.so.conf.d/ # Kernel install -m 755 %{_builddir}/uImage %{buildroot}/boot/switchroot install -m 644 %{_builddir}/nx-plat.dtimg %{buildroot}/boot/switchroot # Kernel modules tar xf %{_builddir}/modules.tar.gz -C %{buildroot}%{_exec_prefix}/lib/ find %{buildroot}%{_exec_prefix}/lib/ \( -type f -o -type l \) | awk -F %{buildroot} '{print $2}' > %{_builddir}/swr-%{kernel}-modules # Kernel headers tar xf %{_builddir}/update.tar.gz -C %{buildroot} find %{buildroot}%{_includedir} \( -type f -o -type l \) | awk -F %{buildroot} '{print $2}' > %{_builddir}/swr-%{kernel}-headers %pre -n %{kernel}-core if [[ ! $(ls /dev/mmcblk0*) ]]; then echo "Running in repo skipping boot dir mount"; exit 0; fi mkdir -p /boot/switchroot /.boot if ! mountpoint -q /.boot && ! mountpoint -q /boot/switchroot; then MMC_BLK="$(cat /proc/cmdline | awk -F 'boot_m=' '{print substr($2,0,1)}' | tr -d '\n')" MMC_PART="$(cat /proc/cmdline | awk -F 'boot_p=' '{print substr($2,0,1)}' | tr -d '\n')" [ -z "${MMC_PART}" ] && MMC_PART=1 if [ -e /dev/mmcblk1 ]; then if [ -n "${MMC_BLK}" ]; then umount /dev/mmcblk"${MMC_BLK}"p"${MMC_PART}" sleep 1 if mount /dev/mmcblk"${MMC_BLK}"p"${MMC_PART}" /.boot/; then BOOT_DEV_FOUND="true"; fi else umount /dev/mmcblk1p1 sleep 1 if mount /dev/mmcblk1p1 /.boot; then BOOT_DEV_FOUND="true"; fi fi else umount /dev/mmcblk0p"${MMC_PART}" sleep 1 if mount /dev/mmcblk0p"${MMC_PART}" /.boot; then BOOT_DEV_FOUND="true"; fi fi if [ "${BOOT_DEV_FOUND}" != "true" ]; then exit 1; fi mount --bind /.boot/switchroot/fedora /boot/switchroot || exit 1 fi %pre -n %{kernel}-switch-device-tree if [[ ! $(ls /dev/mmcblk0*) ]]; then echo "Running in repo skipping boot dir mount"; exit 0; fi mkdir -p /boot/switchroot /.boot if ! mountpoint -q /.boot && ! mountpoint -q /boot/switchroot; then MMC_BLK="$(cat /proc/cmdline | awk -F 'boot_m=' '{print substr($2,0,1)}' | tr -d '\n')" MMC_PART="$(cat /proc/cmdline | awk -F 'boot_p=' '{print substr($2,0,1)}' | tr -d '\n')" [ -z "${MMC_PART}" ] && MMC_PART=1 if [ -e /dev/mmcblk1 ]; then if [ -n "${MMC_BLK}" ]; then umount /dev/mmcblk"${MMC_BLK}"p"${MMC_PART}" sleep 1 if mount /dev/mmcblk"${MMC_BLK}"p"${MMC_PART}" /.boot/; then BOOT_DEV_FOUND="true"; fi else umount /dev/mmcblk1p1 sleep 1 if mount /dev/mmcblk1p1 /.boot; then BOOT_DEV_FOUND="true"; fi fi else umount /dev/mmcblk0p"${MMC_PART}" sleep 1 if mount /dev/mmcblk0p"${MMC_PART}" /.boot; then BOOT_DEV_FOUND="true"; fi fi if [ "${BOOT_DEV_FOUND}" != "true" ]; then exit 1; fi mount --bind /.boot/switchroot/fedora /boot/switchroot || exit 1 fi # Initramfs %posttrans -n %{kernel}-core dracut --kver '%{kernel_ver}-l4t+' --force -H --hostonly-mode=strict --kernel-cmdline="rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0" /boot/switchroot/initramfs.tmp mkimage -A arm64 -O linux -T ramdisk -C gzip -d /boot/switchroot/initramfs.tmp /boot/switchroot/initramfs rm /boot/switchroot/initramfs.tmp %posttrans -n %{kernel}-devel ln -sfn kernel-4.9 %{_usrsrc}linux %files -n %{kernel}-core /boot/switchroot/uImage %files -n %{kernel}-switch-device-tree /boot/switchroot/nx-plat.dtimg %files -n %{kernel}-devel %{_usrsrc} %files -n %{kernel}-headers -f %{_builddir}/swr-%{kernel}-headers %files -n %{kernel}-modules -f %{_builddir}/swr-%{kernel}-modules %changelog %{autochangelog}