move "%post" steps from boot.cmd into the spec file itself

This commit is contained in:
Pratham Patel 2023-10-15 09:09:07 +05:30
parent 9b2a3788ab
commit 9ae05da3ba
No known key found for this signature in database
2 changed files with 15 additions and 21 deletions

View File

@ -16,7 +16,6 @@ Requires: uboot-tools bash
Source0: boot.cmd Source0: boot.cmd
Source1: uEnv.txt Source1: uEnv.txt
Source2: post.sh
%description %description
This is a hack to get the kernel booting on the Oragne Pi 5 This is a hack to get the kernel booting on the Oragne Pi 5
@ -38,7 +37,21 @@ cp %{SOURCE2} $RPM_BUILD_ROOT/opt/opi5-efi/post.sh
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%post %post
bash /opt/opi5-efi/post.sh BOOT_PART="$(grep '/ ' /etc/fstab | awk '{print $1}')"
cp /opt/opi5-efi/boot.cmd boot/efi/boot.cmd
cp /opt/opi5-efi/uEnv.txt boot/efi/uEnv.txt
if [ ! -f /boot/initramfs.img ]; then
echo "Initramfs not found."
exit 1
fi
echo "rootdev=${BOOT_PART}" >> /boot/efi/uEnv.txt
sed -i "s/setenvrootdev/setenv rootdev \"${BOOT_PART}\"/" /boot/efi/boot.cmd
mkimage -A arm -T ramdisk -C none -n uInitrd -d /boot/initramfs.img /boot/uInitrd
mkimage -C none -A arm -T script -d /boot/efi/boot.cmd /boot/efi/boot.scr
%files %files
/opt/opi5-efi/* /opt/opi5-efi/*

19
post.sh
View File

@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -xeuf -o pipefail
BOOT_PART="$(grep '/ ' /etc/fstab | awk '{print $1}')"
cp /opt/opi5-efi/boot.cmd boot/efi/boot.cmd
cp /opt/opi5-efi/uEnv.txt boot/efi/uEnv.txt
if [ ! -f "/boot/initramfs.img" ]; then
echo "Initramfs not found."
exit 1
fi
echo "rootdev=${BOOT_PART}" >> "/boot/efi/uEnv.txt"
sed -i "s/setenvrootdev/setenv rootdev \"${BOOT_PART}\"/" "/boot/efi/boot.cmd"
mkimage -A arm -T ramdisk -C none -n uInitrd -d /boot/initramfs.img /boot/uInitrd
mkimage -C none -A arm -T script -d /boot/efi/boot.cmd /boot/efi/boot.scr