2021-09-26 22:42:40 +08:00
|
|
|
#!/bin/bash
|
2022-04-05 18:59:24 +08:00
|
|
|
#* Copyright (c) 2020 Intel Corporation.
|
2021-09-26 22:42:40 +08:00
|
|
|
# postinst script for acrn kernel
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
|
|
|
|
. /usr/lib/grub/grub-mkconfig_lib
|
|
|
|
LX=linux16
|
|
|
|
elif [ -f /usr/lib/grub/update-grub_lib ]; then
|
|
|
|
. /usr/lib/grub/update-grub_lib
|
|
|
|
LX=linux
|
|
|
|
else
|
|
|
|
# no grub file, so we notify and exit gracefully
|
|
|
|
echo "Cannot find grub config file, exiting." >&2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
filename="/etc/grub.d/40_custom"
|
|
|
|
menu=$(grep ACRN_deb_multiboot2 ${filename}) || true
|
|
|
|
|
|
|
|
type=$(lsblk -l |awk '$NF == "/" {print $1}')
|
|
|
|
pattern='^/dev/.* UUID="([^"]+)".* PARTUUID="([^"]+)"'
|
|
|
|
while IFS= read -r line; do
|
|
|
|
if [[ $line =~ $pattern ]]; then
|
|
|
|
uuid="${BASH_REMATCH[1]}"
|
|
|
|
partuuid="${BASH_REMATCH[2]}"
|
|
|
|
fi
|
|
|
|
done < <(blkid |grep ext4 |grep ${type})
|
|
|
|
|
2022-01-04 10:39:41 +08:00
|
|
|
if ls /boot/vmlinuz*acrn-service-vm* 1> /dev/null 2>&1;then
|
|
|
|
service_vm_kernel=$(ls -tr /boot/vmlinuz-*acrn-service-vm* | tail -1)
|
2021-09-26 22:42:40 +08:00
|
|
|
else
|
2022-01-04 10:39:41 +08:00
|
|
|
service_vm_kernel=$(ls /boot/vmlinuz-* | tail -1)
|
2021-09-26 22:42:40 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$menu" ];then
|
|
|
|
cat>"${filename}"<<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
exec tail -n +3 \$0
|
|
|
|
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
|
|
|
|
load_video
|
|
|
|
insmod gzio
|
|
|
|
insmod part_gpt
|
|
|
|
insmod ext2
|
|
|
|
search --no-floppy --fs-uuid --set $uuid
|
|
|
|
multiboot2 /boot/acrn.bin root=PARTUUID=$partuuid
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i '/Linux_bzImage/d' ${filename} || true
|
2022-01-04 10:39:41 +08:00
|
|
|
sed -i '/multiboot2 \/boot/a\module2 '$service_vm_kernel' Linux_bzImage' ${filename}
|
2021-09-26 22:42:40 +08:00
|
|
|
|
|
|
|
sync
|