@@ -268,25 +268,43 @@ function drivemap_to_hd0 {
268
268
else
269
269
set device =" ${1}"
270
270
fi
271
- if regexp -s disknum ' ^hd([0-9]+)' " $device" ; then
272
- if [ " $disknum" != " 0" ]; then
273
- drivemap -s (hd0) (hd${disknum})
274
- if [ -n " $2" ]; then
275
- set _var =" $2"
276
- probe -p -s hdscheme $device
277
- regexp -s partnum " ^hd${disknum},${hdscheme}([0-9]+)" " $device"
278
- regexp -s partnum " ([0-9]+).${partnum}" " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31"
279
- set $" ${_var}" =" (hd0,${partnum})"
280
- unset _var
281
- unset hdscheme
282
- unset partnum
283
- fi
284
- return 0
271
+ if ! regexp -s disknum ' ^hd([0-9]+)' " $device" ; then
272
+ esc 1 " Only hard disks are supported."
273
+ return 1
274
+ fi
275
+ if [ " $disknum" != " 0" ]; then
276
+ if [ " $disknum" == " 1" ]; then
277
+ drivemap -s (hd0) (hd1)
278
+ else
279
+ set arr =" 9 8 7 6 5 4 3 2 1"
280
+ # 10 disks is enough?
281
+ regexp -s arr " ${disknum} (.*)" " $arr"
282
+ drivemap -s (hd${disknum}) (hd0)
283
+ set _disknum =" $disknum"
284
+ for num in $arr; do
285
+ drivemap -s (hd${_disknum}) (hd${num})
286
+ set _disknum =${num}
287
+ done
288
+ drivemap (hd0) (hd1)
289
+ unset num
290
+ unset _disknum
291
+ unset arr
285
292
fi
286
- unset disknum
293
+ fi
294
+ unset disknum
295
+ if [ -n " $2" ]; then
296
+ # convert grub2 root to grub4dos root and set variable 2
297
+ set _var =" $2"
298
+ probe -p -s hdscheme $device
299
+ regexp -s partnum " ^hd${disknum},${hdscheme}([0-9]+)" " $device"
300
+ regexp -s partnum " ([0-9]+).${partnum}" " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31"
301
+ set $" ${_var}" =" (hd0,${partnum})"
302
+ unset _var
303
+ unset hdscheme
304
+ unset partnum
287
305
fi
288
306
unset device
289
- return 1
307
+ return 0
290
308
}
291
309
292
310
function partimgentry {
@@ -320,7 +338,7 @@ function partimgentry {
320
338
fi
321
339
elif [ " ${parttype}" == " jfs" ]; then fstype="0x35"
322
340
fi
323
- set opt =" debug off; root ${g4droot} > nul ; ${g4d_path}/partnew.g4b ${g4ddisk},${partnum} ${fstype} ${2} ${lang}"
341
+ set opt =" root ${g4droot}; ${g4d_path}/partnew.g4b ${g4ddisk},${partnum} ${fstype} ${2} ${lang}"
324
342
linux ${g4d_path}/grub.exe --config-file =${opt}
325
343
fi
326
344
fi
@@ -468,8 +486,7 @@ function WindowsDetect {
468
486
' (' -f ($device)/NTLDR -a -e ($device)/NTDETECT.COM -a -f ($device)/BOOT.INI ' )' \
469
487
; then
470
488
set root =" $device"
471
- regexp -s devnum ' hd([0-9]+)' $root
472
- if test " $devnum" != " 0" ; then drivemap -s hd0 $root; fi
489
+ drivemap_to_hd0 " $root"
473
490
ntldr /ntldr
474
491
boot
475
492
fi
@@ -595,20 +612,18 @@ function FileProcessing {
595
612
fi
596
613
elif [ -e (isoloop)/I386/TXTSETUP.SIF ] -o [ -e (isoloop)/AMD64/TXTSETUP.SIF ]; then
597
614
menuentry " ${installxp} - ${stepmsg} 1" {
598
- if ! drivemap_to_hd0 " ${root}" " g4droot" ; then
599
- grub4dosroot
615
+ if drivemap_to_hd0 " ${root}" " g4droot" ; then
616
+ set g4d_cmd =" root ${g4droot};${g4d_path}/INSTALLXP cd $path" ;
617
+ linux ${g4d_path}/grub.exe --config-file =${g4d_cmd};
618
+ initrd ${g4d_path}/winvblk.img;
600
619
fi
601
- set g4d_cmd =" root ${g4droot};${g4d_path}/INSTALLXP cd $path" ;
602
- linux ${g4d_path}/grub.exe --config-file =${g4d_cmd};
603
- initrd ${g4d_path}/winvblk.img;
604
620
}
605
621
menuentry " ${installxp} - ${stepmsg} 2" {
606
- if ! drivemap_to_hd0 " ${root}" " g4droot" ; then
607
- grub4dosroot
622
+ if drivemap_to_hd0 " ${root}" " g4droot" ; then
623
+ set g4d_cmd =" root ${g4droot};${g4d_path}/INSTALLXP hd $path" ;
624
+ linux ${g4d_path}/grub.exe --config-file =${g4d_cmd};
625
+ initrd ${g4d_path}/winvblk.img;
608
626
fi
609
- set g4d_cmd =" root ${g4droot};${g4d_path}/INSTALLXP hd $path" ;
610
- linux ${g4d_path}/grub.exe --config-file =${g4d_cmd};
611
- initrd ${g4d_path}/winvblk.img;
612
627
}
613
628
elif test -e (isoloop)/boot/grub/loopback.cfg -o -e (isoloop)/efi/boot/loopback.cfg -o -e (isoloop)/boot/grub/loopback.cfg; then
614
629
for cfg in /boot/grub/loopback.cfg /efi/boot/loopback.cfg /EFI/BOOT/loopback.cfg; do
@@ -847,7 +862,7 @@ function FileProcessing {
847
862
elif [ wimtools --exist " ${file}" \\I386\\System32\\cmd.exe ] -a [ -n " $pc" ]; then
848
863
grub4dosroot
849
864
set fullpath =" ${g4droot}${path}"
850
- set opt =" debug off; ${g4d_path}/bootvhd.g4b PE1 ${fullpath}"
865
+ set opt =" ${g4d_path}/bootvhd.g4b PE1 ${fullpath}"
851
866
linux ${g4d_path}/grub.exe --config-file =${opt}
852
867
fi
853
868
elif [ " $file_ext" == " vhd" ] -o [ " $file_ext" == " vhdx" ]; then
@@ -860,7 +875,7 @@ function FileProcessing {
860
875
menuentry " [2] Windows XP/2003 (NT5)" " ${path}" --hotkey =" 2" {
861
876
grub4dosroot
862
877
set fullpath =" ${g4droot}${2}"
863
- set opt =" debug off; ${g4d_path}/bootvhd.g4b NT5 ${fullpath}"
878
+ set opt =" ${g4d_path}/bootvhd.g4b NT5 ${fullpath}"
864
879
linux ${g4d_path}/grub.exe --config-file =${opt}
865
880
}
866
881
fi
@@ -873,7 +888,7 @@ function FileProcessing {
873
888
if [ " $3" == " iso" ]; then set boottype="bootiso"; else set boottype="bootraw"; fi
874
889
grub4dosroot
875
890
set fullpath =" ${g4droot}${path}"
876
- set opt =" debug off; ${g4d_path}/${boottype}.g4b ${fullpath}"
891
+ set opt =" ${g4d_path}/${boottype}.g4b ${fullpath}"
877
892
linux ${g4d_path}/grub.exe --config-file =${opt}
878
893
}
879
894
unset timeout
0 commit comments