# Maintainer: Azkali Manad Name: l4s-bsp-kernel Version: 32.3.1 Release: %{autorelease} License: GPL-3.0-only Summary: L4S custom BSP # Sources SOURCE0: https://gitlab.com/l4t-community/gnu-linux/switchroot-pipeline/-/jobs/artifacts/master/raw/switchroot-fedora-boot.zip?job=bootstack_full_fedora#/switchroot-fedora-boot.zip SOURCE1: https://gitlab.com/l4t-community/kernel/l4t-initramfs/-/jobs/artifacts/master/raw/initramfs?job=build#/initramfs SOURCE2: https://gitlab.com/api/v4/projects/58434590/jobs/artifacts/master/download?job=32.3.1#/artifacts.zip # Build dependencies BuildRequires: systemd-rpm-macros %prep unzip %{SOURCE0} unzip %{SOURCE2} # Custom packges defines %define kernel switch-kernel %define kernel_ver 4.9.140 # RPMLint defines %undefine __brp_mangle_shebangs %global __brp_check_rpaths %{nil} %undefine _missing_build_ids_terminate_build %define _build_id_links none %description %{summary}. # Bootfiles package %package -n switch-bootfiles Version: 5.1 Release: %{release} Summary: Nintendo Switch bootstack Requires: libnotify %description -n switch-bootfiles %{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}. %package -n %{kernel}-switch-initramfs Version: %{kernel_ver} Release: %{release} Summary: Switch Initramfs %description -n %{kernel}-switch-initramfs %{summary}. %install cd %{buildroot} mkdir -p %{buildroot}/.boot/bootloader/ %{buildroot}/boot/switchroot/ %{buildroot}%{_exec_prefix}/lib %{buildroot}%{_usrsrc} %{buildroot}%{_exec_prefix}/lib/aarch64-linux-gnu/tegra/ %{buildroot}/etc/ld.so.conf.d/ # Bootstack find %{_builddir}/switchroot/fedora/ -type f -exec install -m 644 "{}" "%{buildroot}/boot/switchroot/" \; cp -r %{_builddir}/bootloader/ini/ %{buildroot}/.boot/bootloader/ # Kernel install -m 755 %{_builddir}/uImage %{buildroot}/boot/switchroot/ install -m 644 %{_builddir}/nx-plat.dtimg %{buildroot}/boot/switchroot/ install -m 644 %{SOURCE1} %{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 # Post scriptlets %pre -n switch-bootfiles if [[ ! $(ls /dev/mmcblk0*) ]]; then echo "Running in OBS 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 if [ -e "/.boot/bootloader/ini/L4T-fedora.ini" ]; then cp /.boot/bootloader/ini/L4T-fedora.ini /.boot/bootloader/ini/L4T-fedora.ini.bak fi %pre -n %{kernel}-switch-initramfs if [[ ! $(ls /dev/mmcblk0* 2> /dev/null) ]]; then echo "Running in OBS 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}-core if [[ ! $(ls /dev/mmcblk0* 2> /dev/null) ]]; then echo "Running in OBS 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* 2> /dev/null) ]]; then echo "Running in OBS 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 %posttrans -n %{kernel}-devel ln -sfn kernel-4.9 %{_usrsrc}linux %posttrans -n switch-bootfiles if [ -e "/.boot/bootloader/ini/L4T-fedora.ini.bak" ]; then cp /.boot/bootloader/ini/L4T-fedora.ini.bak /.boot/bootloader/ini/L4T-fedora.ini rm -f /.boot/bootloader/ini/L4T-fedora.ini.bak fi # Bootstack %files -n switch-bootfiles /boot/switchroot/boot.scr /boot/switchroot/logo_fedora.bmp /boot/switchroot/icon_fedora_hue.bmp /boot/switchroot/bl31.bin /boot/switchroot/bl33.bin /.boot/bootloader/ini/* # Kernel %files -n %{kernel}-core /boot/switchroot/uImage %files -n %{kernel}-switch-device-tree /boot/switchroot/nx-plat.dtimg %files -n %{kernel}-switch-initramfs /boot/switchroot/initramfs %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}