From 02354704729d38c3b078c696adc1bbbd33cbcf72 Mon Sep 17 00:00:00 2001 From: "Alexander G. M. Smith" Date: Tue, 21 Sep 2021 15:40:33 -0400 Subject: [PATCH] 3rdparty/os_probe: Original 83haiku GRUB auto detect Haiku. Original version of 83haiku as seen in Debian Linux, for detecting pre-package based Haiku OS and automatically setting up a GRUB boot menu item for bootable Haiku partitions. Change-Id: I0d1fe4c9b395e7912b2398ab6bac5c25d92aa64a Reviewed-on: https://review.haiku-os.org/c/haiku/+/4495 Tested-by: Commit checker robot Reviewed-by: Alexander G. M. Smith Reviewed-by: Adrien Destugues --- 3rdparty/os_probe/83haiku | 35 +++++++++++++++++++++++++++++++++++ 3rdparty/os_probe/README.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 3rdparty/os_probe/83haiku create mode 100644 3rdparty/os_probe/README.md diff --git a/3rdparty/os_probe/83haiku b/3rdparty/os_probe/83haiku new file mode 100755 index 0000000000..1fcd4b8535 --- /dev/null +++ b/3rdparty/os_probe/83haiku @@ -0,0 +1,35 @@ +#!/usr/bin/sh +# Detects Haiku on BeFS partitions. + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + befs|befs_be) debug "$partition is a BeFS partition" ;; + *) debug "$partition is not a BeFS partition: exiting"; exit 1 ;; +esac + +if head -c 512 "$partition" | grep -aqs "system.haiku_loader"; then + debug "Stage 1 bootloader found" +else + debug "Stage 1 bootloader not found: exiting" + exit 1 +fi + +if system="$(item_in_dir "system" "$mpoint")" && + item_in_dir -q "haiku_loader" "$mpoint/$system" && + (item_in_dir -q "kernel_x86" "$mpoint/$system" || + item_in_dir -q "kernel_x86_64" "$mpoint/$system") +then + debug "Stage 2 bootloader and kernel found" + label="$(count_next_label Haiku)" + result "$partition:Haiku:$label:chain" + exit 0 +else + debug "Stage 2 bootloader and kernel not found: exiting" + exit 1 +fi diff --git a/3rdparty/os_probe/README.md b/3rdparty/os_probe/README.md new file mode 100644 index 0000000000..cc4804815d --- /dev/null +++ b/3rdparty/os_probe/README.md @@ -0,0 +1,30 @@ +# os-probe for the Haiku Computer Operating System + +This is the Linux "os-probes" file to detect Haiku OS and to automatically add +it to the GRUB boot menu. + +First make sure the Haiku volumes you want to boot are mounted in Linux +(otherwise nothing gets detected). Then copy the 83haiku file to your Linux +system in the os-probes subdirectory, usually (in Fedora at least) it will be +/usr/libexec/os-probes/mounted/83haiku You can find older 83haiku versions in +the repository history, though the latest should be able to detect older +(pre-package manager) Haiku too. + +Then regenerate the GRUB boot configuration file. This will happen +automatically the next time your kernel is updated. To do it manually, +for old school MBR BIOS boot computers, the command is +`grub2-mkconfig --output /boot/grub2/grub.cfg` + +Computers using the newer UEFI boot system have a EFI/HAIKU/BOOTX64.EFI file +that you manually install to your EFI partition, and booting is done +differently, so you don't need this 83Haiku file for them. See +[UEFI Booting Haiku](https://www.haiku-os.org/guides/uefi_booting/) instead. + +The original seems to have come from Debian and was written by François Revol. +It's in the +[Debian os-prober package](https://packages.debian.org/search?keywords=os-prober). +There's also a big discussion about updating it in +[Debian Bug Report #732696](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732696). + +_AGMS20210921_ +