vlocity-vinstall-gambas / src / Conf0.class

   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
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
' Gambas class file
'    This file is part of vinstall-ng

'    vinstall-ng is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    vinstall-ng  is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with vinstall-ng.  If not, see <http://www.gnu.org/licenses/>.
'=====================================================================================

PUBLIC objIncludes AS NEW Object[]
PUBLIC objLabels AS NEW Object[]
PUBLIC objAppends AS NEW Object[]
PUBLIC objInitrds AS NEW Object[]

PUBLIC SUB POPULATE_MENU_TABSTRIP()
  
  DIM entry AS BootMenuEntry
  DIM i AS Integer
  DIM tl AS TextLabel
  DIM tb AS TextBox
  DIM chk AS CheckBox
  DIM cb AS ComboBox
  
  
  FOR EACH entry IN MdlBootMngr.objMenuEntries
    ME.TsOsList.Index = ME.TsOsList.Count - 1
    TsOsList.Text = entry.Root
    tl = NEW TextLabel(TsOsList)
      IF entry.osType LIKE "linux" THEN 
        tl.Text = entry.sGrubLabel & Space(1) & "(" & entry.kernel & ")" 
        TsOsList.Picture = Picture.Load("images/tux.png")
      ELSE IF InStr(entry.sGrubLabel, "Windows") OR InStr(entry.sGrubLabel, "windows") THEN 
        tl.Text = entry.sGrubLabel & Space(1) & ("Found on") & Space(1) & entry.Root
        TsOsList.Picture = Picture.Load("images/win32.png")
      ELSE ' & Space(1) & entry.Root
        tl.Text = entry.sGrubLabel & Space(1) & ("Found on") & Space(1) & entry.Root
        TsOsList.Picture = Picture.Load("images/unknown-os32.png")
      END IF
    tl.Height = 24
    tl.Expand = TRUE
    tl = NEW TextLabel(ME.TsOsList)
    tl.Text = ("Label")
    tl.Height = 24
    tl.Width = 150
    tl.Expand = FALSE
    tl.Alignment = Align.Left
      
      tb = NEW TextBox(ME.TsOsList) AS "NameBox"
      tb.Height = 24
      tb.Expand = TRUE
      tb.tag = entry.Root
      tb.Text = entry.sLIloLabel
      
        objLabels.Add(tb)
        IF entry.osType LIKE "linux" THEN 
      
      tl = NEW TextLabel(ME.TsOsList)
      tl.Height = 24
      tl.Width = 150
      tl.Expand = FALSE
      tl.Alignment = Align.Left
      tl.Visible = TRUE
      tl.Text = ("Initrd")
      
        cb = NEW ComboBox(ME.TsOsList) AS "InitrdPicker"
        cb.Height = 24
        cb.Width = 200
        cb.Expand = TRUE
        cb.ReadOnly = TRUE
        cb.List = entry.RamDisks
        'IF cb.List.Count > 0 THEN cb.Text = cb.List[0]
        'cb.ReadOnly = TRUE
        cb.Tag = entry.Root
        cb.Visible = TRUE
        cb.ReadOnly = TRUE
          objInitrds.Add(cb)
  END IF
      
      chk = NEW CheckBox(ME.TsOsList) AS "IncludeBox"
      chk.Height = 24
      chk.Value = TRUE
      entry.Enabled = chk.Value
      chk.Expand = TRUE
      chk.Tag = entry.Root
      chk.Text = ("Include this operating system in boot menu")
      objIncludes.Add(chk)

      
    INC ME.TsOsList.Count
      
  NEXT 
    TRY DEC ME.TsOsList.Count
  
END

PUBLIC SUB InitrdPicker_Click()
  
  DIM entry AS BootMenuEntry
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF LAST.tag = entry.Root THEN 
      DEBUG "Setting initrd for " & entry.Root
          entry.initrd = LAST.text
      END IF
    NEXT 
  
  
END


PUBLIC SUB IncludeBox_Click()
  
  DIM entry AS BootMenuEntry
  'DIM i AS Integer
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.root = LAST.tag THEN entry.Enabled = LAST.value
        ME.cbDefBoot.Clear()
        ME.List_Def_Boot_Options()
    NEXT 
  
END


PUBLIC SUB BootOptions_Change()
  
  DIM entry AS BootMenuEntry
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.Root = LAST.tag THEN 
        entry.StartupOptions = LAST.text
      END IF
    NEXT 
  
END



PUBLIC SUB NameBox_KeyRelease()
  
  DIM entry AS BootMenuEntry
  
  IF ME.rbLilo.Value = TRUE THEN 
    ' do nt allow spaces
    IF Key.Text = " " THEN LAST.text = Left(LAST.text, Len(LAST.text) - 1)
    
  END IF
  
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.root = LAST.tag THEN 
        entry.Label = LAST.text
      END IF
    NEXT 
    
    ME.cbDefBoot.Clear
    ME.List_Def_Boot_Options()
    
    
    
  
END

PUBLIC SUB Resize_Labels()
  
  DIM tl AS TextLabel
  DIM l, i AS Integer
  DIM sdump AS String
  
    IF Len(ME.TextLabel1.Text) > l THEN l = Len(ME.TextLabel1.Text)
    IF Len(ME.TextLabel2.Text) > l THEN l = Len(ME.TextLabel2.Text)
    IF Len(ME.lbTarget.Text) > l THEN l = Len(ME.lbTarget.Text)
    IF Len(ME.TextLabel4.Text) > l THEN l = Len(ME.TextLabel4.Text)
  FOR i = 0 TO l 
    sdump = sdump & "a" ' I need a dummy string
  NEXT 
    ME.TextLabel1.Width = MdlObjSizer.get_object_width(sdump)
    ME.TextLabel2.Width = MdlObjSizer.get_object_width(sdump)
    ME.lbTarget.Width = MdlObjSizer.get_object_width(sdump)
    ME.TextLabel4.Width = MdlObjSizer.get_object_width(sdump)
    
END

PRIVATE SUB List_target_options(sBootloader AS String)
  
  DIM sList, sTarget, sDump AS String
  DIM sListArr, entry AS String[]
  DIM i AS Integer
  DIM cb, cbl AS ComboBox
  DIM p AS Partition
  DIM bsector AS Boolean
  DIM root, spart, sfs, smnt AS String
  
  SHELL "probedisk | grep -vi cdrom | cut -f 1 -d \'|\'" TO sList
  sList = Trim(sList)
  
  sListArr = Split(sList, "\n").Sort(gb.Ascent)
    FOR i = 0 TO sListArr.Max
    sTarget = ("MBR of") & Space(1) & Trim(sListArr[i])    
      'objCB.Add(Trim(sTarget))
      ME.cbTarget.Add(Trim(sTarget))
    NEXT 
  ' determine how the root partition was formatted
  
  FOR i = 0 TO Main.Install.Partitions.Max
    IF InStr(LCase(Trim(Main.Install.Partitions[i])), "swap") THEN CONTINUE 
    entry = Split(Trim(Main.Install.Partitions[i]), "-")
      spart = Trim(entry[0])
      sfs = Trim(entry[entry.Max])
      smnt = Trim(entry[2])
      ' slot 1 has the partition size
      IF smnt = "/" THEN 
        root = spart
        IF sfs LIKE "xfs" THEN 
          bsector = FALSE
            ELSE 
          bsector = TRUE
          BREAK 
        END IF
      ELSE 
        CONTINUE  ' we only want the "/"
      END IF
    NEXT 
  IF sBootloader LIKE "lilo" THEN 
    IF bsector = TRUE THEN ME.cbTarget.Add(("Bootsector of") & Space(1) & spart)
  END IF
      
END

PRIVATE SUB Install_emergency_bootloader(selection AS String)
  
  DIM target AS String
  DIM liloline AS String
  SHELL "probedisk | grep -vi rom | grep a | cut -f 1 -d \'|\'" TO target
  
  SELECT CASE selection
    
    CASE "Lilo", "lilo", "LILO"
    liloline = "/sbin/vliloquiet MBR " & target & " bootsplash-high YES"
      SHELL "chroot " & main.Install.TargetMount & Space(1) & liloline WAIT 
    CASE "Grub", "grub", "GRUB"
      SHELL "chroot " & main.Install.TargetMount & " grub-mkdevicemap --no-floppy" WAIT 
      SHELL "chroot " & main.Install.TargetMount & " grub-install --no-floppy " & target WAIT 
      SHELL "chroot " & main.Install.TargetMount & " grub-mkconfig -o /boot/grub/grub.cfg" WAIT 
  END SELECT 
    
  DEBUG "Installed " & selection & " as emergency bootloader on " & target
  Message.Info(selection & Space(1) & ("has been installed to") & Space(1) & target & "<br>" &
  ("You may now click") & Space(1) & ClsGlobal.fRunningMainForm.btnext.text & Space(1) & ("to continue."))
  
END


PUBLIC SUB Form_Open()
  DIM ent AS BootMenuEntry
  
  Main.BootLoader = NEW BootMenuSettings
  main.BootLoader.TimeOut = sbTimeOut.Value
  ME.tlbanner.Text = "<h2>" & tlbanner.Text & "</h2>"
  ME.Resize_Labels()
  ME.sbTimeOut.Value = 5
  MdlMain.ADVANCE_STATUS_TREE("Step5", "Step6")
  ME.cbVidRes.List = [("Standard"), ("Bootsplash Med"), ("Bootsplash High"), ("Bootsplash Extra High")]
  'MdlBootMngr.Display_Bootmanager_Target_Options(ME.cbTarget)
  'List_target_options("lilo")
  hbox4.Visible = MdlBootMngr.objMenuEntries.Count > 0
  ME.List_Def_Boot_Options()
  IF MdlBootMngr.objMenuEntries.Count <= 0 THEN 
    REPEAT 
      IF MdlBootMngr.bMenuRan <> TRUE THEN WAIT 
    UNTIL MdlBootMngr.bMenuRan = TRUE
  
  END IF
  hbox4.Visible = MdlBootMngr.objMenuEntries.Count > 0
    IF MdlBootMngr.objMenuEntries.Count > 0 THEN 
      
      ME.POPULATE_MENU_TABSTRIP()
      ME.HPFailSafe.Visible = FALSE
  ME.rbGrub_Click()
  cbTarget.clear()
  List_target_options("grub")
  ClsGlobal.fRunningMainForm.$aPrev.Clear()
  ME.cbTarget.ReadOnly = TRUE
  'ME.cbTarget_Click()
  'Main.BootLoader.Target = Trim(ME.cbTarget.Text)
  ME.Set_Bootloader_Target(ME.cbTarget.Text)
 Main.BootLoader.DefaultOS = Trim(ME.cbDefBoot.Text)
 ClsGlobal.fRunningMainForm.btback.enabled = FALSE
 
 ELSE 
  DEBUG "Display failsafe boot options"
  WITH ME
    .btlilo.Width = MdlObjSizer.get_object_width(btlilo.Text) + 24
    .btgrub.Width = MdlObjSizer.get_object_width(btgrub.Text) + 24
    .btskip.Width = MdlObjSizer.get_object_width(btskip.Text) + 24
    .TLoSlIST.BackColor = Color.DarkRed
    .TLoSlIST.ForeColor = Color.Yellow
    .TLoSlIST.Font.Bold = TRUE
    .sbTimeOut.Enabled = FALSE
    .rbLilo.Enabled = FALSE
    .rbGrub.Enabled = FALSE
    .rbNone.Enabled = FALSE
    .cbDefBoot.Enabled = FALSE
    .cbTarget.Enabled = FALSE
    .cbVidRes.Enabled = FALSE
    .TLoSlIST.Text = UCase("failsafe bootloader selection")
    .tlFailWarning.Text = Main.Install.Name & Space(1) & ("was unable to probe for any other operating systems on your computer.") & Space(1)&
      ("We will attempt a failsafe boot option to allow you to start your computer. If you have any issues after that, you may use") & Space(1)&
      ("the control center to resolve them. You may also boot your computer using the first installation disc and by typing the following at the prompt") & "<br><br>" &
      "\"" & "linux root=" & Main.Install.Root & " ro" & "\" (without quotes)<br><br> " &
      ("Choose which bootmanager you would like to use in failsafe mode by click one of the buttons below.")
    .HBox4.Visible = FALSE
    .HpFailsafe.Visible = TRUE
    .HPFailSafe.Height = .ClientHeight - .HPFailSafe.Top - 12
  END WITH 
 END IF
 IF Application.Args[1] = "-C" THEN MdlMain.Mount_Target_Partitions()
    
 ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
 ME.rbGrub.Value = TRUE
    
END

PUBLIC SUB List_Def_Boot_Options()

DIM entry AS BootMenuEntry
  FOR EACH entry IN MdlBootMngr.objMenuEntries
    ME.cbDefBoot.Add(entry.Label)
  NEXT 
  
END


PUBLIC FUNCTION GetNext() AS String
  

  RETURN "Conf1"
  
END
PRIVATE SUB Lock_Form()
  
  TLoSlIST.Text = "<b>" & ("Saving Configuration") & "..." & Space(1) & ("Please wait") & "</b>"
  TLoSlIST.BackColor = color.SelectedBackground
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btquit.enabled = FALSE
  TsOsList.Enabled = FALSE
  
END
PUBLIC SUB Revert_Form()
  
  IF MdlBootMngr.objMenuEntries.Count > 0 THEN 
    TLoSlIST.Text = "<b>" & UCase(("DETECTED OPERATING SYSTEMS")) & "</b>"
    TLoSlIST.BackColor = tlbanner.BackColor
  ELSE 
    WITH ME
      .btgrub.Enabled = TRUE
      .btlilo.Enabled = TRUE
    END WITH 
  END IF
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btquit.enabled = TRUE
  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
  TsOsList.Enabled = TRUE
  
END


PUBLIC SUB OnExit()
  DIM entry AS BootMenuEntry
  DIM cb AS ComboBox
  DIM target AS String
  
    main.BootLoader.TimeOut = sbTimeOut.Value
  MdlMain.Set_App_Status(("Saving bootloader configuration ... Please wait"), 30)
  IF MdlBootMngr.objMenuEntries.Count <= 0 THEN RETURN 
  
   TLoSlIST.Text = "<b>" & ("Saving configuration") & "..." & Space(1) & ("Please wait") & "</b>"
   TLoSlIST.BackColor = Color.SelectedBackground
   ClsGlobal.fRunningMainForm.btback.enabled = FALSE
   ClsGlobal.fRunningMainForm.btquit.enabled = FALSE
  Lock_Form()
  WAIT 0.25
  
  target = Right(Trim(ME.cbTarget.Text), Len(ME.cbTarget.Text) - InStr(ME.cbTarget.Text, "/") + 1)
  
  'RETURN 
  Main.BootLoader.DefaultOS = Trim(ME.cbDefBoot.Text)
  'Main.BootLoader.Target = Trim(ME.cbTarget.Text)
  'ME.Set_Bootloader_Target(ME.cbTarget.Text)
  Main.BootLoader.Target = target
  Main.BootLoader.TimeOut = ME.sbTimeOut.Value
  Main.BootLoader.VideoResolution = Trim(ME.cbVidRes.Text)
  
  IF rbNone.Value = TRUE THEN RETURN 
    
    IF ME.rbGrub.Value = TRUE THEN 
      'MdlBootMngr.UPDATE_GRUB_TIMEOUT(ME.sbTimeOut.Value)
      Set_Grub_DEFAULTS()
        IF MdlBootMngr.RUN_GRUB_INSTALL() > 0 THEN 
        Main.bStopNav = TRUE
          SELECT CASE Message.Question(("The bootloader did not install correctly. You may continue without it and") & gb.NewLine &
             ("use your installation media to boot your system, or click") & Space(1) & "\"" & ("No") & "\"" & Space(1) & ("to try and correct the problem.") & gb.newline &
            gb.NewLine & ("Would you like to continue without setting up the booloader?"), ("Yes"), ("No"))
            CASE 1
            Main.bStopNav = FALSE
            ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
            CASE ELSE 
              ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
              Main.bStopNav = TRUE
          END SELECT 
          
          'Message.Error("Failed to save configuration. You may need to use your installation media for the initial boot")
          'ClsGlobal.fRunningMainForm.$ocurrent = Conf0 ' Try this to make it stay in Conf0
          RETURN 
        END IF
        Main.bStopNav = FALSE
        'Message.Info(("Grub configuration saved successfully"))
        MdlMain.Set_App_Status(("Bootloader was successfully configured"))
    DEBUG "Saved grub configuration"

  ELSE 

    ' set initrds
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.Enabled = TRUE THEN 
      IF entry.Root <> Main.Install.Root THEN 
        FOR EACH cb IN objInitrds
          IF cb.Tag = entry.Root THEN 
            entry.initrd = cb.Text
          END IF
        NEXT 
      END IF
      END IF
    NEXT 
      
GENERATE_LILO_HEADER(ME.sbTimeOut.Value)
  ' after that's done, we need to run lilo. The config file has already been saved to /mnt/target/etc/lilo.conf
    IF Exist(Main.Install.TargetMount &/ "etc" &/ "lilo.conf") THEN 
        IF MdlBootMngr.SETUP_LILO_BOOT_MANAGER() > 0 THEN 
        Main.bStopNav = TRUE
          DEBUG "Error in lilo setup. Please check lilo.conf"
          ' Message.Error(("Unable to successfully install LILO on") & Space(1) & Main.BootLoader.Target & gb.NewLine &
          ' ("You may click") & Space(1) & ClsGlobal.fRunningMainForm.btback.text & Space(1) & ("to go back and correct the problem") & gb.NewLine &
          ' ("You may also choose to continue and use your installation media to boot your installed system."))
          
          SELECT CASE Message.Question(("The bootloader did not install correctly. You may continue without it and") & gb.NewLine &
          ("use your installation media to boot your system, or click") & Space(1) & "\"" & ("No") & "\"" & Space(1) & ("to try and correct the problem.") & gb.newline &
            gb.NewLine & ("Would you like to continue without setting up the booloader?"), ("Yes"), ("No"))
            CASE 1
            Main.bStopNav = FALSE
          CASE ELSE 
          'Message("As you wish")
            Main.bStopNav = TRUE
              'FMain.bclear = FALSE

          END SELECT 
          
          ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
          'Message.Error("Failed to save configuration. You may need to use your installation media for the initial boot")
          'ClsGlobal.fRunningMainForm.$ocurrent = Conf0
          STOP EVENT 
          RETURN 
        ELSE 
        'MdlBootMngr.SETUP_LILO_BOOT_MANAGER()
        Main.bStopNav = FALSE
          DEBUG "Booloader succcessfully setup."
          MdlMain.Set_App_Status(("Bootloader was successfully configured"))
        END IF
      'PRINT " \\ --> Lilo boot manager installed successfully."
    ELSE 
      DEBUG Main.Install.Root &/ "etc/lilo.conf not found...cannot install lilo."
      STOP EVENT 
      RETURN 
    END IF
  
  Revert_Form()
END IF

TLoSlIST.Text = UCase(("Detected operating systems"))
ME.TsOsList.Enabled = TRUE
TLoSlIST.BackColor = Color.SelectedBackground
  ClsGlobal.fRunningMainForm.btback.enabled = TRUE
  ClsGlobal.fRunningMainForm.btquit.enabled = TRUE
  TLoSlIST.BackColor = TsOsList.BackColor
  
  'Start the background configuration scripts
'  MdlMain.write_background_config_scripts()

END

PRIVATE SUB GENERATE_LILO_HEADER(iTimeOut AS Integer)
  
  DIM sTmp AS String
  DIM sVGA, sVidImput, sDefBoot, sVidText, sOutput, sTarget AS String
  DIM sOsList AS String
  DIM entry AS BootMenuEntry
  
  
  sVidImput = Trim(ME.cbVidRes.Text)
  sDefBoot = Trim(ME.cbDefBoot.Text)
  sTarget = Main.BootLoader.Target
  iTimeOut = ME.sbTimeOut.Value
  'iTimeout = Main.BootLoader.TimeOut
  'Message(sVidImput)
    'IF iTimeout = 0 OR NOT (iTimeout) THEN iTimeout = 5 ' set default timeout value to 5 seconds.

    SELECT CASE sVidImput
      CASE ("Standard")
        svga = "normal"
      CASE ("Bootsplash Med")
        svga = "788"
      CASE ("Bootsplash High")
        svga = "791"
      CASE ("Bootsplash Extra High")
        svga = "794"
      END SELECT 
      
    sVidText = "# VESA framebuffer console @ 1024x768x64k \n" &
"vga = " & svga & "\n" &
"# Normal VGA console \n" &
"#vga = normal \n" &
"#VESA framebuffer console @ 1024 x768x64k \n" &
"#vga = 791 \n" &
"#VESA framebuffer console @ 1024 x768x32k \n" &
"#vga = 790 \n" &
"#VESA framebuffer console @ 1024 x768x256 \n" &
"#vga = 773 \n" &
"#VESA framebuffer console @ 800 x600x64k \n" &
"#vga = 788 \n" &
"#VESA framebuffer console @ 800 x600x32k \n" &
"#vga = 787 \n" &
"#VESA framebuffer console @ 800 x600x256 \n" &
"#vga = 771 \n" &
"#VESA framebuffer console @ 640 x480x64k \n" &
"#vga = 785 \n" &
"#VESA framebuffer console @ 640 x480x32k \n" &
"#vga = 784 \n" &
"#VESA framebuffer console @ 640 x480x256 \n" &
"#vga = 769 \n" &
"# Begin listing OS Choices \n"

    IF Conf0.rbLilo.Value = TRUE THEN 
      sOsList = MdlBootMngr.GENERATE_LILO_OS_LIST("lilo")
    ELSE 
      'sOsList = ME.GENERATE_LILO_OS_LIST("grub")
    END IF
    'sDefBoot = 
  ' FOR EACH entry IN MdlBootMngr.objMenuEntries
  '   IF entry.IsDefault = TRUE THEN 
  '     sDefBoot = entry.Label
  '   END IF
  ' NEXT 
  iTimeOut = iTimeOut * 10
  
  sOutput = "# LILO Configuration File \n" &
  "# Generated by the " & Main.Install.Name & " Installer \n \n" &
  "# Begin lilo global configuration \n \n" &
  "boot = " & sTarget & "\n" &
  "default = " & sDefBoot & "\n" &
  "prompt \n" &
  "compact \n" &
  "timeout = " & iTimeOut & "\n" &
  "#\n#\n#\n" &
  "# Override dangerous defaults that require the partition table: \n" &
  "change-rules \n" &
  "reset \n"
  IF Exist(Main.Install.TargetMount &/ "boot" &/ "bitmap" &/ "boot.bmp") THEN 
   sOutput = sOutput & "bitmap = /boot/bitmap/boot.bmp \n \n"
  END IF

  sOutput = sOutput & sVidText & gb.NewLine & sOsList & gb.NewLine
  
  
  
  File.Save(Temp("lilo.in"), sOutput)
  
  'Message(sOutput)
  File.Save(Main.Install.TargetMount &/ "etc" &/ "lilo.conf", sOutput)
  
  
  'Message(File.Load(Temp("lilo.in")))

END


PUBLIC SUB StartUp()
  
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  
  
END



PUBLIC SUB Names_Change()
  

  
  TsOsList.Current.Text = LAST.text
  ME.Update_Default_boot_choices()
  
  
END

PUBLIC SUB tbOsLabel_Change()
  
  LAST.text = Replace(LAST.text, " ", "")  
  IF Len(LAST.text) > 15 THEN 
    RETURN 
  END IF
    
  TsOsList.Current.Text = LAST.text
  ME.Update_Default_boot_choices()
  
END




PUBLIC SUB Form_Resize()

  hbox4.Height = ME.ClientH - (hbox4.top + 30)
  HPFailSafe.Height = ME.ClientH - HpFailsafe.Top - 12
  hbox1.Width = hbox1.Parent.Width - (hbox1.Left * 2)
  hbox2.Width = hbox2.Parent.Width - (hbox2.Left * 2)
  hbox3.Width = hbox3.Parent.Width - (hbox3.Left * 2)

END

PUBLIC SUB Toggle_window_controls(bval AS Boolean)
  
  DIM obj AS Object
  'DIM rb AS RadioButton
  
  FOR EACH obj IN ME.Children
    IF obj.Name <> "HPanel2" THEN 
     TRY obj.enabled = bval
    END IF
  NEXT 
  'FOR EACH obj IN ME.HPanel2.Children
  '  TRY obj.enabled = TRUE
  'NEXT 
END


PUBLIC SUB rbNone_Click()


    IF LAST.value = TRUE THEN 
   Message.Warning("<b>" & ("WARNING:") & "</b><br>" &
    ("Selecting this option will bypass your boot manager configuration.") & "<br>" &
    ("You may not be able to start your") & Space(1) & ClsGlobal.sDistroName & Space(1) & ("installation. Do not choose this option") & "<br>" &
    ("unless you are fully aware of what you are doing."))
  END IF
  Timer1.Enabled = FALSE
  ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
  ME.Toggle_window_controls(FALSE)
  Main.bStopNav = FALSE

END

PUBLIC SUB Toggle_Grub_Objects(bEnabled AS Boolean)
  
  WITH ME
    '.sbTimeOut.Enabled = bEnabled
    .cbDefBoot.Enabled = bEnabled
    '.cbVidRes.Enabled = bEnabled
  END WITH 
      
  
END

PRIVATE SUB Set_Grub_DEFAULTS()
  
  DIM sOut AS String
  
  sOut = "# Default grub settings for" & Space(1) & Main.Install.Name & Space(1) & Main.Install.Version & gb.NewLine &
  "#" & gb.NewLine &
  "# Default settings provided by GUI Installer" & gb.NewLine &
  "export GRUB_DISABLE_LINUX_UUID=true" & gb.NewLine &
  "export GRUB_TERMINAL=gfxterm" & gb.NewLine &
  "export GRUB_TIMEOUT=" & ME.sbTimeOut.Value & gb.NewLine &
  "export GRUB_GFXMODE=" & ME.cbVidRes.Text & gb.NewLine & 
  "export GRUB_DISTRIBUTOR=\"" & Replace(main.Install.Name, " ", "") & "\"" & gb.NewLine &
  "if [ \"$GRUB_GFXMODE\" = \"1024x768x16\" ]; then " & gb.NewLine &
  "VGA=791" & gb.NewLine &
  "elif [ \"$GRUB_GFXMODE\" = \"800x600x16\" ]; then" & gb.NewLine &
  "VGA=788" & gb.NewLine & 
  "elif [ \"$GRUB_GFXMODE\" = \"1280x1024x16\" ]; then" & gb.NewLine &
  "VGA=794" & gb.NewLine &
  "else" & gb.NewLine &
  "VGA=normal" & gb.NewLine &
  "fi" & gb.NewLine
  
    
  
  IF Exist(Main.Install.TargetMount &/ "etc" &/ "default" &/ "grub") THEN TRY KILL Main.Install.TargetMount &/ "etc/default/grub"
  IF Exist("/etc/default/grub") THEN TRY KILL "/etc/default/grub"
  
  TRY File.Save(Main.Install.TargetMount &/ "etc" &/ "default" &/ "grub", sOut)
  TRY File.Save("/etc/default/grub", sOut)
  
  
END


PUBLIC SUB rbGrub_Click()
 
  DIM entry AS BootMenuEntry
  DIM tb AS TextBox
  DIM cb AS CheckBox
  DIM Modes AS String[]
  
  ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
  cbTarget.Clear()
  ME.Toggle_window_controls(TRUE)
  ME.Toggle_Grub_Objects(FALSE)
  IF MdlBootMngr.objMenuEntries THEN 
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      entry.Label = entry.sGrubLabel
      FOR EACH cb IN objIncludes
        IF cb.Tag = entry.Root THEN cb.Enabled = FALSE
      NEXT 
      FOR EACH tb IN objLabels
        IF tb.Tag = entry.Root THEN 
        tb.MaxLength = 100
          tb.Text = entry.Label
          tb.ReadOnly = TRUE ' Edits to the label are not allowed here, since grub depends on os-prober to get the labels.
          
        END IF
      NEXT 
      
    NEXT 
    
    ME.cbDefBoot.Clear
    ME.List_Def_Boot_Options()
    List_target_options(LCase(LAST.text))
  END IF
  
  ' LIST GRUB_GFXMODES
  Modes = ["640x480x16", "800x600x16", "1024x768x16", "1280x1024x16"]
  ME.cbVidRes.List = Modes
  ME.cbVidRes.text = "1024x768x16"
  
END



PUBLIC SUB rbLilo_Click()
 DIM entry AS BootMenuEntry
 DIM tb AS TextBox
 DIM cb AS CheckBox
  
 ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
 ME.Toggle_window_controls(TRUE)
 ME.Toggle_Grub_Objects(TRUE)
 cbTarget.Clear()
 
  IF MdlBootMngr.objMenuEntries THEN 
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      entry.Label = Replace(entry.Label, " ", "")
      entry.Label = Replace(entry.Label, "(", "_")
        IF Right(entry.Label) = "_" THEN 
          REPEAT 
          entry.Label = Left(entry.Label, Len(entry.Label) - 1)
          UNTIL Right(entry.Label) <> "_"
        END IF
          
      IF InStr(entry.sGrubLabel, "VectorLinux") THEN entry.Label = "Vector-" & Replace(entry.Root, "/dev/", "")
      entry.Label = Trim(entry.Label)
      entry.Label = Left(entry.Label, 15)
      FOR EACH cb IN objIncludes
        IF cb.Tag = entry.Root THEN cb.Enabled = TRUE
      NEXT 
        FOR EACH tb IN objLabels
          IF tb.tag = entry.root THEN 
            IF InStr(tb.Text, "VectorLinux") THEN 
              tb.Text = "Vector-" & Replace(entry.Root, "/dev/", "")
            ELSE IF InStr(entry.sGrubLabel, "Windows") THEN 
              tb.Text = "Windows-" & Replace(entry.Root, "/dev/", "")
            ELSE 
              tb.Text = entry.Label
            END IF
            tb.MaxLength = 15
            tb.ReadOnly = FALSE
          END IF
        NEXT 
    NEXT 
    
    FOR EACH tb IN objLabels
      tb.Text = Replace(tb.Text, " ", "")
    NEXT 
  END IF
  
  ME.cbDefBoot.Clear
  ME.List_Def_Boot_Options()
  List_target_options(LCase(LAST.text))
  ME.cbVidRes.List = [("Standard"), ("Bootsplash Med"), ("Bootsplash High"), ("Bootsplash Extra High")]
  'ME.cbVidRes.Selection = cbVidRes.Find(("Bootsplash High"))
  ME.cbVidRes.Text = ("Bootsplash High")

END




PUBLIC FUNCTION determine_boot_parameters(sRoot AS String) AS String
  
  ' needs to return a string[] containing the kernel, initrd, and append lines for an OS
  DIM sShortPart AS String = Right(sRoot, Len(sRoot) - Len("/dev/"))
  DIM sBootPath AS String
  DIM skernel, sinitrd, sAppend AS String
  DIM sDump AS String
  DIM sDumparr AS String[]
    TRY MKDIR "/mnt/hd"
    SHELL "mount " & sRoot & " /mnt/hd 2>/dev/null" WAIT 
    
      IF Exist("/mnt/hd/vmlinuz") THEN 
        sBootPath = "/"
      ELSE IF Exist("/mnt/hd/boot/vmlinuz") THEN 
        sBootPath = "/boot"
      END IF
      
      IF NOT (sBootPath) THEN ' the above lines did not find anything
        SHELL "ls -B /mnt/hd | grep vmlinuz" TO sDump
          sDump = Trim(sDump)
            IF sDump THEN 
              sBootPath = "/"
            ELSE ' not found in the roots dir of the distro, look in /boot
              SHELL "ls -B /mnt/hd/boot | grep vmlinuz" TO sDump
                sDump = Trim(sDump)
                  IF sDump THEN sBootPath = "/boot"
            END IF
      END IF
                  
        ' now get the real path
        
        sdump = Trim(sdump)
        'Message(sdump)
          IF sdump THEN sDumparr = Split(Trim(sDump), gb.NewLine) ' found something
               ' this will either pick up the link to the default kernel, or the first kernel that comes up from that partition.
        IF sDumparr THEN 
          skernel = Trim(Replace(sDumparr[0], "@", ""))
            IF skernel THEN PRINT "Found kernel " & skernel & " for " & sRoot
      ' now get the initrd
      SHELL "ls -B " & sBootPath & " | grep initrd" TO sDump
        sDump = Trim(sDump)
          IF sDump THEN 
            sDumparr = Split(Trim(sdump), gb.NewLine) ' found something for initrd
              sinitrd = Trim(Replace(sDumparr[0], "@", ""))
              IF sinitrd THEN PRINT "Found initrd " & sinitrd & " for " & sRoot
          END IF
      
      TRY MKDIR Main.Install.TargetMount &/ "boot" &/ "tamu"
      TRY COPY "/mnt/hd" &/ sBootPath &/ skernel TO Main.Install.TargetMount &/ "boot" &/ "tamu" &/ skernel & "-" & sShortPart
      TRY COPY "/mnt/hd" &/ sBootPath &/ sinitrd TO Main.Install.TargetMount &/ "boot" &/ "tamu" &/ sinitrd & "-" & sShortPart
      
    SHELL "umount -f /mnt/hd >/dev/null" WAIT 
    
    skernel = "/boot/tamu" &/ skernel & "-" & sShortPart
    sinitrd = "/boot/tamu" &/ sinitrd & "-" & sShortPart
        
      
      ' IF Exist(sBootPath &/ "initrd") THEN 
      '   sinitrd = sBootPath &/ "initrd"
      ' END IF
       sAppend = "splash=silent" 'generic kernel arguments.
      
      RETURN skernel & "," & sinitrd & "," & sAppend
    'END IF
    ELSE 
      RETURN 
    END IF
  
END


PUBLIC SUB Timer1_Timer()

  ClsGlobal.fRunningMainForm.btnext.enabled = MdlBootMngr.CHECK_LILO_VALUES(TRUE) < 1
  'DEBUG "Timer tick"
  'PRINT MdlBootMngr.CHECK_LILO_VALUES(TRUE)
  
END

PUBLIC SUB Set_Bootloader_Target(sRawString AS String)
  
  DIM sRes AS String
    IF Len(Trim(sRawString)) <= 0 THEN 
      DEBUG "Empty parameter"
      RETURN 
    END IF
    'DEBUG "Raw string received as " & sRawString
    IF InStr(sRawString, ("Bootsector")) THEN 
      sRes = Main.Install.RootPartition
    ELSE IF InStr(sRawString, ("MBR")) THEN 
      sRes = Right(Trim(sRawString), Len("/dev/sda"))
    ELSE IF InStr(sRawString, ("Floppy")) THEN 
      sRes = "/dev/fd0"
    ELSE 
      sRes = ""
    END IF
    'DEBUG "Result: " & sRes
    Main.BootLoader.Target = sRes
  DEBUG "bootloader target changed to " & Main.BootLoader.Target
END


PUBLIC SUB cbTarget_Click()
' DIM sDump AS String[]
'   'ClsGlobal.BootMngrTarget = Trim(LAST.text)
'   IF InStr(LAST.text, ("Bootsector")) THEN 
'     'ClsGlobal.BootMngrTarget = Right(Trim(LAST.text), Len("/dev/sda1"))
'     sDump = Split(LAST.text, " ")
'     ClsGlobal.BootMngrTarget = sDump[sDump.Max]
'     'Main.BootLoader.Target = Trim(sdump[sdump.Max])
'     Main.BootLoader.Target = Main.Install.RootPartition
'   ELSE IF InStr(LAST.text, ("MBR Of")) THEN 
'     ClsGlobal.BootMngrTarget = Right(Trim(LAST.text), Len("/dev/sda"))
'     Main.BootLoader.Target = Right(Trim(LAST.text), Len("/dev/sda"))
'   ELSE IF InStr(LAST.text, ("Floppy")) THEN 
'     ClsGlobal.BootMngrTarget = "/dev/fd0"
'     Main.BootLoader.Target = "/dev/fd0"
'   END IF
'   
ME.Set_Bootloader_Target(LAST.text)
END



PUBLIC SUB TextLabel4_MouseDown()

  

END

PUBLIC SUB cbDefBoot_Click()

  DIM entry AS BootMenuEntry
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      entry.IsDefault = FALSE
    NEXT 
  
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.Label = Trim(LAST.text) THEN 
        entry.IsDefault = TRUE
        'PRINT "Default OS is now set to " & entry.Label
      END IF
    NEXT 
    
    Main.BootLoader.DefaultOS = LAST.text


END

PUBLIC SUB cbVidRes_Click()

  MdlBootMngr.sVidMode = Trim(LAST.text)
  Main.BootLoader.VideoResolution = Trim(LAST.text)

END

PUBLIC SUB sbTimeOut_Change()

  Main.BootLoader.TimeOut = sbTimeOut.Value

END




PUBLIC SUB btlilo_Click()
  btgrub.Enabled = FALSE
  btskip.Enabled = FALSE
  Install_emergency_bootloader(LAST.text)
  ClsGlobal.fRunningMainForm.btnext.enabled = TRUE

END

PUBLIC SUB btgrub_Click()

  btlilo.Enabled = FALSE
  btskip.Enabled = FALSE
  Install_emergency_bootloader(LAST.text)
  ClsGlobal.fRunningMainForm.btnext.enabled = TRUE

END

PUBLIC SUB btskip_Click()

  btlilo.Enabled = FALSE
  btgrub.Enabled = FALSE
  DEBUG "Bypassing emergency bootloader installation per user request."
  ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
  ClsGlobal.fRunningMainForm.btnext_click() ' emulate the click
  

END
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.