Codebase list os-prober / 3f48974
refactor windows version detection (adding ver 12) Philip Hands 1 year, 7 months ago
1 changed file(s) with 18 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
55 partition="$1"
66 mpoint="$2"
77 type="$3"
8
9 # this function interleaves a string with dots, thus:
10 # "Windows 11" --> "W.i.n.d.o.w.s. .1.1"
11 dotify() {
12 echo $1 | sed 's/./&./g;s/.$//'
13 }
814
915 # This script looks for legacy BIOS bootloaders only. Skip if running UEFI
1016 if [ -d /sys/firmware/efi ] && [ ! -f /var/lib/partman/ignore_uefi ]; then
3036 for boot in $(item_in_dir boot "$2"); do
3137 bcd=$(item_in_dir bcd "$2/$boot")
3238 if [ -n "$bcd" ]; then
33 if grep -aqs "W.i.n.d.o.w.s. .1.1" "$2/$boot/$bcd"; then
34 long="Windows 11"
35 elif grep -aqs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then
36 long="Windows 10"
37 elif grep -aqs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then
38 long="Windows 8"
39 elif grep -aqs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then
40 long="Windows 7"
41 elif grep -aqs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then
42 long="Windows Vista"
43 elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$2/$boot/$bcd"; then
44 long="Windows Server 2008 R2"
45 elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$2/$boot/$bcd"; then
46 long="Windows Server 2008"
47 elif grep -aqs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$2/$boot/$bcd"; then
48 long="Windows Recovery Environment"
49 elif grep -aqs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then
50 long="Windows Recovery Environment"
51 else
52 long="Windows Vista"
53 fi
39 found=true
5440 short=Windows
5541
56 found=true
57
42 for v in 12 11 10 8 7 Vista "Server 2008 R2" "Server 2008" "Recovery Environment" "Setup"; do
43 win_v="Windows $v"
44 if grep -aqs "$(dotify "$win_v")" "$2/$boot/$bcd"; then
45 long="$win_v"
46 # Windows Setup is a special case, rename it:
47 [ "$v" != "Setup" ] || long="Windows Recovery Environment"
48 break
49 fi
50 done
51 # if no match found, call it Vista
52 : ${long:="Windows Vista"}
5853 break
5954 fi
6055 done