acrn-hypervisor/misc/packaging/acrn-hypervisor.postinst
Junjie Mao adb047493c FIXME: packaging: generate a grub entry for shared scenario by default
The debian package created by misc/packaging today is supposed to add an
entry into grub.cfg for the installed hypervisor. Unfortunately, that is
done only when the given scenario XML is named shared, partitioned, hybrid
or hybrid_rt. In the rest of the cases, no entry is added while the default
boot option is still changed to ACRN_deb_multiboot2 which does not exist.

As a short-term workaround, this patch adjusts the branching structure of
the postinst script so that a grub entry is always generated. The entry for
shared scenario is chosen as the default if the scenario XML has a name
other than partitioned, hybrid or hybrid_rt.

This is a workaround only for release 3.0. In future releases we should
migrate to the dpkg-buildpackage using the scripts under debian/.

Tracked-On: #7778
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2022-06-17 16:44:45 +08:00

129 lines
3.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#* Copyright (c) 2020 Intel Corporation SPDX-License-Identifier: BSD-3-Clause
# postinst script for acrn-hypervisor
# please NOTE scenario_info/board_info changed by python scripts, so do not add content there!!!
# please NOTE scenario_info/board_info please add in release.json if needed !!!
set -e
#Build info Start
SCENARIO=(shared)
BOARD=(nuc11tnbi5)
#Build info End
ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin"
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})
filename="/etc/grub.d/40_custom"
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)
else
service_vm_kernel=$(ls /boot/vmlinuz-* | tail -1)
fi
kernelimg="module2 $service_vm_kernel Linux_bzImage"
if [ $SCENARIO == hybrid ];then
echo -e "\E[32m Please put zephyr64.elf in the /boot/ directory"
tput sgr0
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 $ACRNBIN root=PARTUUID=$partuuid
$kernelimg
module2 /boot/zephyr64.elf Zephyr_ElfImage
module2 /boot/ACPI_VM0.bin ACPI_VM0
}
EOF
elif [ $SCENARIO == hybrid_rt ];then
echo -e "\E[32m Please put bzImage_RT in the /boot/ directory"
tput sgr0
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 $ACRNBIN root=PARTUUID=$partuuid
$kernelimg
module2 /boot/bzImage_RT RT_bzImage
module2 /boot/ACPI_VM0.bin ACPI_VM0
}
EOF
elif [ $SCENARIO == partitioned ];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
echo 'loading ACRN...'
multiboot2 $ACRNBIN root=PARTUUID=$partuuid
$kernelimg
module2 /boot/ACPI_VM0.bin ACPI_VM0
module2 /boot/ACPI_VM1.bin ACPI_VM1
}
EOF
else
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 $ACRNBIN root=PARTUUID=$partuuid
$kernelimg
}
EOF
fi
filename='/etc/default/grub'
sed -i '/GRUB_DEFAULT=/d' ${filename}
sed -i '/GRUB_TIMEOUT=/d' ${filename}
sed -i '/GRUB_HIDDEN_TIMEOUT=/d' ${filename}
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT=/d' ${filename}
sed -i '/GRUB_CMDLINE_LINUX=/d' ${filename}
sed -i '/GRUB_TERMINAL=/d' ${filename}
sed -i '/GRUB_SERIAL_COMMAND=/d' ${filename}
sed -i '$a GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"' ${filename}
sed -i '$a GRUB_TERMINAL="console serial"' ${filename}
sed -i '$a GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' ${filename}
sed -i '$a GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"' ${filename}
sed -i '$a GRUB_DEFAULT=ACRN_deb_multiboot2' ${filename}
sed -i '$a GRUB_TIMEOUT=20' ${filename}
sync
update-grub
exit 0