opi5-efi/post.sh
2023-10-08 12:13:34 +05:30

32 lines
1.2 KiB
Bash

#!/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 "Initramfs not found... regenerating."
/sbin/installkernel "${UNAME_R}" "/boot/.vmlinuz-${UNAME_R}-rpm" "/boot/.System.map-${UNAME_R}-rpm"
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/setenvuname_r/setenv uname_r \"${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}"
mkimage -C none -A arm -T script -d "/boot/efi/boot.cmd-${FULL_VER}" "/boot/efi/boot.scr-${FULL_VER}"
cp "/boot/uInitrd-${UNAME_R}" "/boot/efi/uInitrd-${UNAME_R}"
cp "/boot/vmlinuz-${UNAME_R}" "/boot/efi/vmlinuz-${UNAME_R}"
cp -r "/boot/dtb-${UNAME_R}" "/boot/efi/dtb-${UNAME_R}"