summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2020-08-19 17:14:30 -0400
committerDavid P <megver83@parabola.nu>2020-08-19 18:21:51 -0400
commit72ad84dfbc2593a5c143df6a3976ac5359167483 (patch)
treed603f598562f8bc88963eae54a6ad47c64852b2c /scripts
parentd51ab687e642ab1c44f0843d4fe4b024819762ed (diff)
sync with archiso, add timeout for i686 syslinux menus
imported the following changes: 13b8c7d (HEAD -> master, origin/master, origin/HEAD) archiso/mkarchiso: correct the path of airootfs/etc/machine-id 41d3d7d Add Joliet file system to the ISO e6455b8 archiso/mkarchiso: create an empty /etc/machine-id ba3e834 scripts/run_archiso.sh: support booting the image as a hard disk or an optical disc 55d9d1f scripts/run_archiso.sh: disable PXE ROM 1e0ffd0 scripts/run_archiso.sh: don't duplicate qemu commands for each boot mode e9f209e Deprecate build.sh scripts and old mkarchiso commands 31b1dfd archiso/mkarchiso: delete all files in /boot not just the kernel and initramfs 7c2247f archiso/mkarchiso: allow choosing boot modes from profiledef.sh 41b9b89 archiso/mkarchiso: copy make_* functions from configs/releng/build.sh 1cc7375 archiso/mkarchiso: start preparing a build_profile command 0387b25 archiso/mkarchiso: general bash improvements
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run_parabolaiso.sh116
1 files changed, 56 insertions, 60 deletions
diff --git a/scripts/run_parabolaiso.sh b/scripts/run_parabolaiso.sh
index 01f0a7d..cc75d24 100755
--- a/scripts/run_parabolaiso.sh
+++ b/scripts/run_parabolaiso.sh
@@ -15,117 +15,113 @@
set -eu
print_help() {
- cat << EOF
+ local usagetext
+ IFS='' read -r -d '' usagetext <<EOF || true
Usage:
run_parabolaiso [options]
Options:
- -b set boot type to 'bios' (default)
+ -b set boot type to 'BIOS' (default)
+ -d set image type to hard disk instead of optical disc
-h print help
-i [image] image to boot into
- -s use secure boot (only relevant when using UEFI)
- -u set boot type to 'uefi'
+ -s use Secure Boot (only relevant when using UEFI)
+ -u set boot type to 'UEFI'
Example:
Run an image using UEFI:
$ run_parabolaiso -u -i parabolaiso-2020.05.23-x86_64.iso
EOF
+ printf '%s' "${usagetext}"
}
cleanup_working_dir() {
- if [ -d "${working_dir}" ]; then
- rm -rf "${working_dir}"
+ if [[ -d "${working_dir}" ]]; then
+ rm -rf -- "${working_dir}"
fi
}
copy_ovmf_vars() {
- if [ ! -f /usr/share/edk2-ovmf/x64/OVMF_VARS.fd ]; then
- echo "ERROR: OVMF_VARS.fd not found. Install edk2-ovmf."
+ if [[ ! -f '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' ]]; then
+ printf 'ERROR: %s\n' "OVMF_VARS.fd not found. Install edk2-ovmf."
exit 1
fi
- cp -av /usr/share/edk2-ovmf/x64/OVMF_VARS.fd "${working_dir}"
+ cp -av -- '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' "${working_dir}/"
}
check_image() {
- if [ -z "$image" ]; then
- echo "ERROR: Image name can not be empty."
+ if [[ -z "$image" ]]; then
+ printf 'ERROR: %s\n' "Image name can not be empty."
exit 1
fi
- if [ ! -f "$image" ]; then
- echo "ERROR: Image file ($image) does not exist."
+ if [[ ! -f "$image" ]]; then
+ printf 'ERROR: %s\n' "Image file (${image}) does not exist."
exit 1
fi
}
run_image() {
- [ "$boot_type" == "bios" ] && run_image_using_bios
- [ "$boot_type" == "uefi" ] && run_image_using_uefi
-}
+ if [[ "$boot_type" == 'uefi' ]]; then
+ copy_ovmf_vars
+ if [[ "${secure_boot}" == 'on' ]]; then
+ printf '%s\n' 'Using Secure Boot'
+ local ovmf_code='/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd'
+ else
+ local ovmf_code='/usr/share/edk2-ovmf/x64/OVMF_CODE.fd'
+ fi
+ qemu_options+=(
+ '-drive' "if=pflash,format=raw,unit=0,file=${ovmf_code},readonly"
+ '-drive' "if=pflash,format=raw,unit=1,file=${working_dir}/OVMF_VARS.fd"
+ '-global' "driver=cfi.pflash01,property=secure,value=${secure_boot}"
+ )
+ fi
-run_image_using_bios() {
qemu-system-x86_64 \
-boot order=d,menu=on,reboot-timeout=5000 \
- -m size=3072,slots=0,maxmem=$((3072*1024*1024)) \
+ -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \
-k en \
-name parabolaiso,process=parabolaiso_0 \
- -drive file="${image}",media=cdrom,readonly=on,if=virtio \
+ -device virtio-scsi-pci,id=scsi0 \
+ -device "scsi-${mediatype%rom},bus=scsi0.0,drive=${mediatype}0" \
+ -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \
-display sdl \
-vga virtio \
- -device virtio-net-pci,netdev=net0 -netdev user,id=net0 \
- -enable-kvm \
- -no-reboot
-}
-
-run_image_using_uefi() {
- local ovmf_code=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd
- local secure_boot_state=off
- copy_ovmf_vars
- if [ "${secure_boot}" == "yes" ]; then
- echo "Using Secure Boot"
- ovmf_code=/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd
- secure_boot_state=on
- fi
- qemu-system-x86_64 \
- -boot order=d,menu=on,reboot-timeout=5000 \
- -m size=3072,slots=0,maxmem=$((3072*1024*1024)) \
- -k en \
- -name parabolaiso,process=parabolaiso_0 \
- -drive file="${image}",media=cdrom,readonly=on,if=virtio \
- -drive if=pflash,format=raw,unit=0,file="${ovmf_code}",readonly \
- -drive if=pflash,format=raw,unit=1,file="${working_dir}/OVMF_VARS.fd" \
+ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \
-machine type=q35,smm=on,accel=kvm \
- -global driver=cfi.pflash01,property=secure,value="${secure_boot_state}" \
-global ICH9-LPC.disable_s3=1 \
- -display sdl \
- -vga virtio \
- -device virtio-net-pci,netdev=net0 -netdev user,id=net0 \
-enable-kvm \
+ "${qemu_options[@]}" \
-no-reboot
}
set_image() {
- if [ -z "$image" ]; then
- echo "ERROR: Image name can not be empty."
+ if [[ -z "$image" ]]; then
+ printf 'ERROR: %s\n' "Image name can not be empty."
exit 1
fi
- if [ ! -f "$image" ]; then
- echo "ERROR: Image ($image) does not exist."
+ if [[ ! -f "$image" ]]; then
+ printf 'ERROR: %s\n' "Image (${image}) does not exist."
exit 1
fi
image="$1"
}
-image=""
-boot_type="bios"
-secure_boot="no"
-working_dir="$(mktemp -d)"
+image=''
+boot_type='bios'
+mediatype='cdrom'
+secure_boot='off'
+qemu_options=()
+working_dir="$(mktemp -dt run_parabolaiso.XXXXXXXXXX)"
trap cleanup_working_dir EXIT
-if [ ${#@} -gt 0 ]; then
- while getopts 'bhi:su' flag; do
- case "${flag}" in
+if (( ${#@} > 0 )); then
+ while getopts 'bdhi:su' flag; do
+ case "$flag" in
b)
- boot_type=bios
+ boot_type='bios'
+ ;;
+ d)
+ mediatype='hd'
;;
h)
print_help
@@ -135,13 +131,13 @@ if [ ${#@} -gt 0 ]; then
image="$OPTARG"
;;
u)
- boot_type=uefi
+ boot_type='uefi'
;;
s)
- secure_boot=yes
+ secure_boot='on'
;;
*)
- echo "Error: Wrong option. Try 'run_parabolaiso -h'."
+ printf '%s\n' "Error: Wrong option. Try 'run_parabolaiso -h'."
exit 1
;;
esac