improve %post
This commit is contained in:
parent
c3887a24ee
commit
5339e5a06d
@ -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/.uname)
|
||||
BOOT_PART=$(grep '/ ' /etc/fstab | awk '{print $1}')
|
||||
|
||||
echo "rootdev=${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."
|
||||
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/*
|
||||
|
33
post.sh
Normal file
33
post.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xeuf -o pipefail
|
||||
|
||||
UNAME_R="$(</boot/.uname)"
|
||||
BOOT_PART="$(grep '/ ' /etc/fstab | awk '{print $1}')"
|
||||
replacewithfullver
|
||||
|
||||
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
|
||||
echo "ERROR: No /boot/.uname found to extract 'uname -r' from."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "/boot/initramfs-${UNAME_R}" ]; then
|
||||
echo "ERROR: No initramfs found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "rootdev=${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}"
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user