opi5-efi/opi5-efi.spec
2023-10-05 09:54:08 +05:30

67 lines
1.9 KiB
RPMSpec

# disable the '-debug{info,source}' pkgs
%define debug_package %{nil}
# also disable packaging files in '/usr/lib/.build-id/'
%define _build_id_links none
Name: opi5-efi
Version: 0.0.1
Release: 2%{?dist}
Summary: Necessary files for booting from vendor U-Boot on Orange Pi 5
License: GPL
Provides: %{name}-%{version}
Requires: uboot-tools
%global full_ver %{version}-%{release}
Source0: boot.cmd
Source1: uEnv.txt
%description
This is a hack to get the kernel booting on the Oragne Pi 5
%prep
echo "Nothing to prepare"
%build
echo "Nothing to build"
%install
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
%clean
rm -rf $RPM_BUILD_ROOT
%post
set -xeuf -o pipefail
cp /opt/opi5-efi/boot.cmd $RPM_BUILD_ROOT/boot/efi/boot.cmd
cp /opt/opi5-efi/uEnv.txt $RPM_BUILD_ROOT/boot/efi/uEnv.txt
cp /boot/efi/boot.cmd /boot/efi/boot.cmd-%{full_ver}
cp /boot/efi/uEnv.txt /boot/efi/uEnv.txt-%{full_ver}
if [ -f /boot/.uname ]; then
UNAME_R=$(</boot/.uname)
BOOT_PART=$(grep '/ ' /etc/fstab | awk '{print $1}')
echo "${BOOT_PART}" >> /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."
fi
mkimage -C none -A arm -T script -d /boot/efi/boot.cmd-%{full_ver} /boot/efi/boot.scr-%{full_ver}
cp /boot/boot.scr-%{full_ver} /boot/efi/boot.scr
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
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
%files
/opt/opi5-efi/*