diff --git a/opi5-efi.spec b/opi5-efi.spec index d5a0ea6..fdae83a 100644 --- a/opi5-efi.spec +++ b/opi5-efi.spec @@ -5,16 +5,17 @@ Name: opi5-efi Version: 0.0.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Necessary files for booting from vendor U-Boot on Orange Pi 5 License: GPL Provides: %{name}-%{version} -Requires: kernel-opi5-tfg uboot-tools +Requires: kernel-opi5-tfg uboot-tools bash %global full_ver %{version}-%{release} Source0: boot.cmd Source1: uEnv.txt +Source2: post.sh %description This is a hack to get the kernel booting on the Oragne Pi 5 @@ -30,36 +31,14 @@ rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/opt/opi5-efi cp %{SOURCE0} $RPM_BUILD_ROOT/opt/opi5-efi/boot.cmd cp %{SOURCE1} $RPM_BUILD_ROOT/opt/opi5-efi/uEnv.txt +cp %{SOURCE2} $RPM_BUILD_ROOT/opt/opi5-efi/post.sh +sed -i "s/replacewithfullver/FULL_VER=%{full_ver}/" $RPM_BUILD_ROOT/opt/opi5-efi/post.sh %clean rm -rf $RPM_BUILD_ROOT -%posttrans -set -xeuf -o pipefail - -cp /opt/opi5-efi/boot.cmd /boot/efi/boot.cmd-%{full_ver} -cp /opt/opi5-efi/uEnv.txt /boot/efi/uEnv.txt-%{full_ver} - -if [ -f /boot/.uname ]; then - UNAME_R=$(> /boot/efi/uEnv.txt-%{full_ver} - sed -i "s/setenvrootdev/setenv rootdev \"${BOOT_PART}\"/" /boot/efi/boot.cmd-%{full_ver} - sed -i "s/setenvunamer/setenv unamer \"${UNAME_R}\"/" /boot/efi/boot.cmd-%{full_ver} -else - echo "ERROR: No /boot/.uname found to extract 'uname -r' from." - exit 1 -fi - -mkimage -A arm -T ramdisk -C none -n uInitrd -d /boot/initramfs-${UNAME_R}.img /boot/uInitrd-${UNAME_R} -cp /boot/uInitrd-${UNAME_R} /boot/uInitrd - -mkimage -C none -A arm -T script -d /boot/efi/boot.cmd-%{full_ver} /boot/efi/boot.scr-%{full_ver} -cp /boot/efi/boot.scr-%{full_ver} /boot/efi/boot.scr - -diff /boot/efi/boot.cmd /boot/efi/boot.cmd-%{full_ver} > /boot/diff_boot_cmd -diff /boot/efi/uEnv.txt /boot/efi/uEnv.txt-%{full_ver} > /boot/diff_uenv_txt +%post +bash /opt/opi5-efi/post.sh %files /opt/opi5-efi/* diff --git a/post.sh b/post.sh new file mode 100644 index 0000000..14c0616 --- /dev/null +++ b/post.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -xeuf -o pipefail + +UNAME_R="$(> "/boot/efi/uEnv.txt-${FULL_VER}" +sed -i "s/setenvrootdev/setenv rootdev \"${BOOT_PART}\"/" "/boot/efi/boot.cmd-${FULL_VER}" +sed -i "s/setenvunamer/setenv unamer \"${UNAME_R}\"/" "/boot/efi/boot.cmd-${FULL_VER}" + +mkimage -A arm -T ramdisk -C none -n uInitrd -d "/boot/initramfs-${UNAME_R}.img" "/boot/uInitrd-${UNAME_R}" +cp "/boot/uInitrd-${UNAME_R}" /boot/uInitrd + +mkimage -C none -A arm -T script -d "/boot/efi/boot.cmd-${FULL_VER}" "/boot/efi/boot.scr-${FULL_VER}" +cp "/boot/efi/boot.scr-${FULL_VER}" /boot/efi/boot.scr + +diff /boot/efi/boot.cmd "/boot/efi/boot.cmd-${FULL_VER}" > /boot/diff_boot_cmd +diff /boot/efi/uEnv.txt "/boot/efi/uEnv.txt-${FULL_VER}" > /boot/diff_uenv_txt