|
1 | | -#!/bin/sh |
2 | | -# Detects Haiku on BeFS partitions and FUSE mounted BeFS too. |
3 | | -# Discussion at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732696 |
4 | | -# From version 42 (dated 20150811) updated by Jeroen Oortwijn at https://bazaar.launchpad.net/~idefix/ubuntu/trusty/os-prober/HaikuPM/files/head:/os-probes/mounted/x86 |
| 1 | +#!/usr/bin/sh |
| 2 | +# Detects bootable Haiku OS on BeFS partitions and FUSE mounted BeFS too. |
| 3 | +# If it doesn't find anything, try mounting the BeFS volumes in Linux. |
| 4 | +# Discussion of improvements and development history at |
| 5 | +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732696 |
| 6 | +# Adapted from version 42 (dated 20150811) updated by Jeroen Oortwijn at |
| 7 | +# https://bazaar.launchpad.net/~idefix/ubuntu/trusty/os-prober/HaikuPM/files/head:/os-probes/mounted/x86 |
| 8 | +# Latest version now at https://git.haiku-os.org/haiku/tree/3rdparty/os_probe |
5 | 9 |
|
6 | 10 | . /usr/share/os-prober/common.sh |
7 | 11 |
|
8 | 12 | partition="$1" |
9 | 13 | mpoint="$2" |
10 | 14 | type="$3" |
11 | 15 |
|
12 | | -# Weed out stuff that doesn't apply to us |
| 16 | +# Weed out stuff that doesn't apply to us, needs to be a Be file system. |
13 | 17 | case "$type" in |
14 | | - bfs|befs) debug "$partition is a BeFS partition" ;; |
15 | | - fuse|fuseblk) debug "$partition is a FUSE partition" ; mpoint="$mpoint/myfs" ;; # might be befs-fuse |
16 | | - *) debug "$partition is not a BeFS partition: exiting"; exit 1 ;; |
| 18 | + bfs|befs) debug "$partition is a BeFS partition." ;; |
| 19 | + fuse|fuseblk) debug "$partition is a FUSE partition, maybe with BeFS on it." ; mpoint="$mpoint/myfs" ;; |
| 20 | + *) exit 1 ;; # Be quiet and just quit for irrelevant partitions. |
17 | 21 | esac |
18 | 22 |
|
19 | 23 | if head -c 512 "$partition" | grep -qs "haiku_loader"; then |
20 | | - debug "Haiku stage 1 bootloader found" |
| 24 | + debug "Haiku stage 1 bootloader found." |
21 | 25 | else |
22 | 26 | debug "Haiku stage 1 bootloader not found: exiting" |
23 | 27 | exit 1 |
24 | 28 | fi |
25 | 29 |
|
26 | 30 | if system="$(item_in_dir "system" "$mpoint")" && |
27 | 31 | packages="$(item_in_dir "packages" "$mpoint/$system")" && |
28 | | - item_in_dir -q "haiku_loader-.*\.hpkg" "$mpoint/$system/$packages" && |
29 | | - rev="$(item_in_dir "haiku-.*\.hpkg" "$mpoint/$system/$packages")" |
| 32 | + item_in_dir -q "haiku_loader-r[0-9].*\.hpkg" "$mpoint/$system/$packages" && |
| 33 | + rev="$(item_in_dir "haiku-r[0-9].*\.hpkg" "$mpoint/$system/$packages")" |
30 | 34 | then |
31 | | - debug "Haiku PM stage 2 bootloader and kernel found" |
| 35 | + debug "Haiku Package Manager stage 2 bootloader and kernel ($rev) found." |
32 | 36 | label="$(count_next_label Haiku)" |
33 | | - rev="$(echo "$rev" | sed 's/haiku-//;s/^\(r[0-9]\+\)./\U\1\E /;s/ \([a-z]\+[0-9]\+\)[_-]/ \1 /;s/ [a-z]*_\?\(hrev[0-9]\+\)\+-/ (\1) /;s/[^ ]\+.hpkg//;s/ $//')" |
| 37 | + # Convert kernel file name like haiku-r1~beta3_hrev55181_56-1-x86_64.hpkg |
| 38 | + # or haiku-r1~alpha4_pm_hrev49856-1-x86_gcc2.hpkg into a readable version, |
| 39 | + # like "Haiku R1 beta3 (hrev55181_56) 64". Seems to use a travelling space |
| 40 | + # technique in the sed stream editor. |
| 41 | + rev="$(echo "$rev" | sed 's/haiku-//;s/^\(r[0-9]\+\)./\U\1\E /;s/ \([a-z]\+[0-9]\+\)[_-]/ \1 /;s/ [a-z]*_\?\(hrev[0-9_]\+\)\+-/ (\1) /;s/) [^_]\+_\([a-z0-9]\+\)\.hpkg/) \1 /;s/[^ ]\+.hpkg//;s/ $//')" |
34 | 42 | long="Haiku $rev" |
35 | 43 | result "$partition:$long:$label:chain" |
36 | 44 | exit 0 |
37 | 45 | elif system="$(item_in_dir "system" "$mpoint")" && |
38 | 46 | item_in_dir -q "haiku_loader" "$mpoint/$system" && |
39 | 47 | item_in_dir -q "kernel_.*" "$mpoint/$system" |
40 | 48 | then |
41 | | - debug "Haiku non-PM stage 2 bootloader and kernel found" |
| 49 | + debug "Older non-package manager Haiku stage 2 bootloader and kernel found." |
42 | 50 | label="$(count_next_label Haiku)" |
43 | 51 | result "$partition:Haiku:$label:chain" |
44 | 52 | exit 0 |
|
0 commit comments