vinstall-gambas / src / Step9.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
' 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/>.

PRIVATE $credits AS Process
PRIVATE $PkgNo AS Integer

PRIVATE SUB create_credit_labels()
  
  DIM dev AS String
  DIM name, list AS String[]
  DIM tl AS TextLabel
  DIM pb AS PictureBox
  DIM img AS Image
  
  list = Split(Trim(File.Load(main.install.SrcMnt &/ "CREDIT")), gb.NewLine)
  
  tl = NEW TextLabel(panel1)
  tl.Height = panel1.Height
  tl.Expand = TRUE
  
  tl = NEW TextLabel(Panel1)
  tl.Height = panel1.Height / 4
  tl.Expand = TRUE
  pb = NEW PictureBox(panel1)
  'pb.Expand = TRUE
  pb.Stretch = TRUE
  pb.Height = (Panel1.Height / 4)
  pb.Width = tl.Width
  img = Image.Load("images/installer.png")
  pb.Picture = img.Stretch(pb.Width, pb.Height / 2).Picture 'img.Picture
  pb.Expand = TRUE
  pb.Width = panel1.Width
  pb.Alignment = Align.Center
  
  tl = NEW TextLabel(panel1)
  tl.Height = (panel1.Height / 4) * 2
  tl.Expand = TRUE
  
  
  FOR EACH dev IN list
    tl = NEW TextLabel(panel1)
    tl.Height = 28
    tl.Expand = TRUE
    tl.Alignment = Align.Center
    IF InStr(dev, "(") THEN 
      name = Split(dev, "(")
      tl.Height = tl.Height * 2
      
      IF Trim(name[0]) = "M0E-lnx" THEN 
        name[1] = "GUI Installer, VASMCC, vpackager"
        'tl.Height = tl.Height * 2
        tl.Text = "<b>" & name[0] & "</b><br> [ " & name[1] & " ]"
      ELSE IF Trim(name[0]) = "Uelsk8s" THEN
         name[1] = "GUI Installer, ISO Master"
         'tl.Height = tl.Height * 1.75
        tl.Text = "<b>" & name[0] & "</b><br> [ " & name[1] & " ]"
      ELSE IF Trim(name[0]) = "Vector" THEN 
name[1] = "Founder"
        'tl.Height = tl.Height * 2
        tl.Text = "<b>" & name[0] & "</b><br> [ " & name[1] & " ]"
      ELSE 
        tl.Text = name[0] & "<br>" & "[ " & Replace(name[1], ")", "") & " ]"
      END IF
    ELSE 
      tl.Text = dev
    END IF
  NEXT 
  tl = NEW TextLabel(panel1)
  tl.Height = panel1.Height
  tl.Expand = TRUE
  
END


PUBLIC SUB Form_Open()
DIM pb AS PictureBox
 

  'ME.Refresh
    'Message("Welcome to the installation window")
    'MdlInstall.Create_Required_Bulks() ' create veclinux bulks
    ME.tlbanner.Text = "<h2>" & tlbanner.Text & "</h2>"
    ME.create_installation_process_layout()
    
    'ME.Resize(ClsGlobal.fRunningMainForm.pnlstack.Width, ClsGlobal.fRunningMainForm.pnlstack.height)
    'panel1.Move(frame2.x + 2, frame2.top + 24)
    panel1.Resize(frame2.Width - 12, frame2.Height - (panel1.top))
 
  
  ME.Resize(ClsGlobal.fRunningMainForm.pnlstack.Width - 1, ClsGlobal.fRunningMainForm.pnlstack.height)
ME.tmInstall.Enabled = TRUE  
     'ME.create_installation_process_layout()
     
END


PRIVATE FUNCTION install_kernels() AS Integer
  
  DIM sdump, sKern, sver, isostr, hdstr, krnldir AS String
  DIM sarr, sList, sLine AS NEW String[]
  DIM i, n AS Integer
  
  DEBUG "Copying kernels from initrd"
  
  krnldir = main.Install.SrcMnt &/ "isolinux/kernel"
  
  IF Exist(main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.INI") THEN 
      FOR EACH sKern IN main.Install.Config.Keys["kernels"]
      sver = main.Install.Config["kernels" &/ sKern]
      IF Exist(krnldir &/ sKern) THEN 
      DEBUG "Installing " & krnldir &/ sKern & " as " & main.Install.TargetMount &/ "vmlinuz-" & sver
        SHELL "cp " & krnldir &/ sKern & Space(1) & main.Install.TargetMount &/ "boot/vmlinuz-" & sver WAIT 
        sList.Push(sKern)
      ELSE 
        
      END IF
      NEXT 
  ELSE 
  SHELL "grep ^ISO_KERNEL " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF" TO sdump
  IF Len(Trim(sdump)) <= 0 THEN RETURN 1
  
  sarr = Split(Trim(sdump), gb.NewLine)
  FOR i = 0 TO sarr.Max
    sLine = Split(Trim(sarr[i]), "=")
      isostr = Trim(sLine[0])
      sKern = Trim(sLine[1])
      sKern = Replace(sKern, "\'", "")
      sKern = Replace(sKern, "\"", "")
      IF Exist(krnldir &/ sKern) THEN 
      SHELL "grep " & Replace(Trim(isostr), "ISO", "HD") & Space(1) & main.Install.SrcMnt &/ "veclinux/VINSTALL.CONF | cut -f 2 -d=" TO sdump
      IF Len(Trim(sdump)) <= 0 THEN CONTINUE 
      sver = Replace(sdump, "\'", "")
        sver = Replace(sver, "\"", "")
      DEBUG "copying kernel " & sKern & " to target as vmlinuz-" & sver
        SHELL "cp " & krnldir &/ sKern & Space(1) & main.Install.TargetMount &/ "boot/vmlinuz-" & sver WAIT 
        sList.Push(sKern)
      END IF
      
      
      
  NEXT 
  END IF
  
  IF sList.Count <= 0 THEN RETURN 1
  RETURN 0

END



PUBLIC SUB Perform_Installation()
  DIM b AS Bulk
  DIM pb AS PictureBox
  DIM sdump, sd, iso2 AS String
  DIM i, n AS Integer
  
  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btquit.enabled = FALSE
  
  

  Install_Bulk_Objects(TRUE) 'install veclinux
  FOR EACH pb IN MdlMain.$objPboxes
      IF pb.Tag = 1 THEN pb.Picture = MdlStartUp.pDone
      IF pb.Tag = 2 THEN pb.Picture = MdlStartUp.pCategory
     NEXT 
  main.Install.BulkObjects.Sort(gb.Descent)
  Install_Bulk_Objects(FALSE) ' install non-vital packages
    
    
      
  install_kernels() ' Install kernels before switching cd.
    ' TRANSITION TO CD2 IF NECESSARY
  IF Main.Install.CD2BulkObjects.Count > 0 OR IF main.LangPacks.Count > 0 THEN 
  'IF Main.SelectedSrc.MultiSingle <> TRUE THEN   
  MdlMain.Store_vlconfig_temporarily() ' Save vlconfig to the target /tmp for later access.
  
    SELECT CASE UCase(Main.SelectedSrc.Type)
      CASE "ISO"
        ME.umount_source()
        sd = find_iso2(main.SelectedSrc.IsoName)
        IF Len(Trim(sd)) <= 0 THEN 
          REPEAT             
            ME.umount_source()
                Dialog.Title = ("Select second image to continue with installation")
                Dialog.Path = Replace(main.SelectedSrc.HostDevice, "dev", "mnt")
                Dialog.filter = [("*.iso"), ("Compresed Image")]
                IF Dialog.OpenFile() THEN 
                  SELECT CASE Message.Question(("Continue without installing bonus software?"), ("Yes"), ("No"))
                  CASE 1
                    Message.Warning(("Installation will continue without installing bonus software"))
                    RETURN 
                  END SELECT 
                END IF
                sd = Dialog.Path
                SHELL "umount /mnt/source " WAIT 
           mount_new_source(sd)
            IF match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = FALSE THEN 
                DEBUG "Media does not match"
            END IF
           UNTIL match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = TRUE
        ELSE 
          mount_new_source(sd)
          IF match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = FALSE THEN 
            REPEAT 
            DEBUG "Media does not match."
              ME.umount_source()
               Dialog.Title = ("Select second image to continue with installation")
                Dialog.filter = [("*.iso"), ("Compresed Image")]
                IF Dialog.OpenFile() THEN 
                  SELECT CASE Message.Question(("Continue without installing bonus software?"), ("Yes"), ("No"))
                  CASE 1
                    Message.Warning(("Installation will continue without installing bonus software"))
                    RETURN 
                  END SELECT 
                END IF
                sd = Dialog.Path
                mount_new_source(sd)
              UNTIL match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = TRUE
            END IF
        
         END IF
  
      CASE "CDROM"
        IF main.SelectedSrc.MultiSingle <> TRUE THEN 
        DEBUG "CDROM install... moving to CD 2"
          REPEAT 
              umount_source()
              WAIT 1
              SHELL "eject " & main.SelectedSrc.HostDevice
              SELECT CASE Message.Question(("Please insert the second installation disc.") & gb.NewLine &
              ("You should insert it to the same drive used for the first CD"), ("OK"), ("I dont have it"))
                CASE 2
                  Message.Warning(("The bonus software will not be installed"))
                  RETURN 
              END SELECT 
              mount_new_source(main.SelectedSrc.HostDevice)
              IF match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = FALSE THEN 
                DEBUG "Media mismatch error... Trying again."
                Message.Error(("You have inserted an incorrect disc. Please try again"))
              END IF
          UNTIL match_installation_media(main.Install.SrcMnt, main.SelectedSrc.ReleaseID) = TRUE
        END IF
    
    END SELECT 
    
  ME.install_cd2_bulk_objects()
  ELSE  ' it's 2 cd's in one !!!!! merged ISO
  ME.install_cd2_bulk_objects()
  END IF
  ' ELSE  ' if there is no need to switch cd's, then install kernels now
  ' install_kernels() ' Install kernels
  ' END IF

  IF main.LangPacks.Count > 0 THEN INSTALL_LANGUAGE_PACKS()

' INSTALL VLCONFIG
INSTALL_VL_CONFIG()

FOR EACH pb IN MdlMain.$objPboxes
  IF pb.Tag = 2 THEN pb.Picture = MdlStartUp.pCategory
NEXT 



END

PRIVATE FUNCTION INSTALL_LANGUAGE_PACKS() AS Integer
  
DIM slang, spath AS String
DIM i AS Integer
DIM hproc AS Process
DIM basepkgpath AS String = main.Install.SrcMnt &/ "packages"

ME.tlInstallWarn.Text = ("Installing language packs")

IF main.LangPacks.Count <= 0 THEN 
DEBUG "No language packs selected for installation... Continue"
  RETURN 
END IF
DEBUG "Installing language packs"
  FOR EACH slang IN main.LangPacks
    spath = MdlMain.Get_FULL_TLZ_PACKAGE(slang)
      IF (spath) THEN 
        ME.tlCurrPkg.Text = ("Installing") & Space(1) & slang
        hproc = EXEC ["installpkg", "-q", "--root=" & main.Install.TargetMount, basepkgpath &/ Trim(spath)] 
          IF hproc.State <> Process.Stopped THEN 
            REPEAT 
              WAIT 
            UNTIL hproc.State = Process.Stopped
          END IF
          
          pbInstall.Value = $PkgNo / MdlMain.$pkgtotal
          INC $PkgNo
            
      'ME.INSTALL_THIS_PACKAGE(main.Install.SrcMnt &/ "packages" &/ spath)
        
      END IF
  NEXT 
END


PUBLIC FUNCTION INSTALL_VL_CONFIG() AS Integer
  
  DIM conf AS String
  DIM hproc AS Process
  
  'Message(conf)
  IF main.Install.InstalledPkgLog.Find("vlconfig2") > -1 THEN 
    PRINT "vlconfig2 is already installed in the target.... bypassing attempt to re-install"
    RETURN 0
  END IF
  
  IF Main.Install.CD2BulkObjects.Count > 0 OR main.LangPacks.Count > 0 THEN 
  DEBUG "vlconfig2 has been previously moved to the target"
    hproc = SHELL "installpkg -q --root=" & main.Install.TargetMount & Space(1) & main.Install.TargetMount &/ "tmp" &/ "vlconfig*.t?z"
    WAIT 0.25
    IF hproc.State <> Process.Stopped THEN 
      REPEAT 
        WAIT 0.125
      UNTIL hproc.State = Process.Stopped
    END IF
    main.Install.InstalledPkgLog.Push("vlconfig2")
  ELSE 
  conf = MdlMain.Get_FULL_TLZ_PACKAGE("vlconfig2") 'ME.Get_FULL_TLZ_PACKAGE("vlconfig2")
  IF Len(Trim(conf)) <= 0 THEN 
   'IF Exist(main.Install.SrcMnt &/ "packages" &/ conf) = FALSE THEN   'vlconfig is not there... look for it in the target directory
   
    IF main.SelectedSrc.MultiDisk = TRUE THEN 'most likely in the target /tmp dir
    hproc = SHELL "installpkg -q --root=" & main.Install.TargetMount & Space(1) & main.Install.TargetMount &/ "tmp" &/ "vlconfig*.t?z"
      WAIT 0.25
        IF hproc.State <> Process.Stopped THEN 
          REPEAT 
            WAIT 
          UNTIL hproc.State = Process.Stopped
        END IF
        main.Install.InstalledPkgLog.Push("vlconfig2")
      '   IF hproc.Value > 0 THEN RETURN hproc.Value
      '     SHELL "rm " & main.Install.TargetMount &/ "tmp/vlconfig*.tlz" WAIT 
      ' END IF
     END IF
  ELSE 
    IF Exist(main.Install.SrcMnt &/ "packages" &/ conf) THEN 
'     DEBUG "Cant find vlconfig2"
'   END IF
' '  ELSE 
    hproc = SHELL "installpkg --root=" & main.Install.TargetMount & Space(1) & main.Install.SrcMnt &/ "packages" &/ conf
      WAIT 0.25
      main.Install.InstalledPkgLog.Push("vlconfig2")
        IF hproc.State <> Process.Stopped THEN 
          REPEAT 
            WAIT 
          UNTIL hproc.State = Process.Stopped
        END IF
      IF hproc.Value > 0 THEN RETURN hproc.Value
  END IF
  END IF
END IF
  RETURN 0
END


PUBLIC FUNCTION umount_source() AS Integer
  
    DIM sdump AS String
    DIM i, n AS Integer
    REPEAT 
      SHELL "mount | grep " & Main.Install.SrcMnt TO sdump
        IF Len(Trim(sdump)) > 0 THEN 
          SHELL "umount --force " & Main.Install.SrcMnt WAIT 
          WAIT 2
        END IF
      INC n
    UNTIL Len(Trim(sdump)) = 0 OR n = 5
    IF Len(Trim(sdump)) = 0 THEN RETURN 0
    RETURN 0
END

PUBLIC FUNCTION mount_new_source(src AS String) AS Integer
  DIM sdump, smntcmd AS String
  DIM i AS Integer
  
  DEBUG "attempting to mount " & src
  IF ME.umount_source() > 0 THEN RETURN 
    IF Len(File.Ext(src)) > 0 THEN 
      smntcmd = "mount -o loop "
    ELSE 
      smntcmd = "mount "
    END IF
    
    REPEAT 
      SHELL Trim(smntcmd) & Space(1) & src & Space(1) & Main.Install.SrcMnt WAIT 
      DEBUG smntcmd & Space(1) & src & Space(1) & Main.Install.SrcMnt
      'SHELL smntcmd & " /mnt/target " WAIT 
      WAIT 2
      SHELL "mount | grep " & Main.Install.SrcMnt TO sdump
      INC i
    UNTIL Len(Trim(sdump)) > 0 OR i = 10
    'Message(Trim(sdump))
    
    IF Len(Trim(sdump)) <= 0 THEN 
      DEBUG "Unable to mount new source... Bailing"
      RETURN 1
    END IF
    RETURN 0
    
  
END

PUBLIC FUNCTION find_iso2(iso1name AS String) AS String
  
  DIM filename AS String = File.BaseName(iso1name) & "-CD2.iso"
  DIM sdump AS String
  
  SHELL "mount | grep " & Main.SelectedSrc.HostDevice & " | cut -f3 -d \' \'" TO sdump
  IF Len(Trim(sdump)) > 0 THEN 
  DEBUG "Looking for " & Trim(sdump) &/ filename
    IF Exist(Trim(sdump) &/ filename) THEN 
      DEBUG "Found second image in " & Trim(sdump) &/ filename & " No need for user intervention"
    RETURN Trim(sdump) &/ filename
    END IF
  END IF
      
    'RETURN Dialog.Path
  
  
END


PRIVATE FUNCTION match_installation_media(MntPoint AS String, sReleaseID AS String) AS Boolean
  
  DIM mi_d, sdump, relid AS String
  DIM tmps AS Settings
  
  DEBUG "Matching install media"
  IF Exist(MntPoint &/ "veclinux/VINSTALL.INI") = FALSE THEN RETURN FALSE
    tmps = NEW Settings(MntPoint &/ "veclinux/VINSTALL.INI")
    relid = tmps["general/release_id"]
    mi_d = tmps["general/media_id"]
      IF relid <> sReleaseID THEN 
        PRINT "Matching media .... Failed"
        RETURN FALSE
      ELSE 
        IF mi_d = "1" THEN 
          PRINT "Installation media is the same as first... Point me to the correct one"
          RETURN FALSE
        END IF
        PRINT "Matching media ... Match found!..."
      END IF
      
      RETURN TRUE
  
  ' ' '  SHELL "cat " & MntPoint &/ "veclinux" &/ "VINSTALL.CONF | grep ^RELEASE_ID= | cut -f2 -d=" TO relid
  ' ' '    IF Len(Trim(relid)) <= 0 THEN 
  ' ' '     DEBUG "Cannot read RELEASE_ID from new install media"
  ' ' '       RETURN FALSE
  ' ' '    END IF
  ' ' '    IF Trim(relid) <> Trim(sReleaseID) THEN 
  ' ' '     DEBUG "Release IDs do not match for these media objects"
  ' ' '     RETURN FALSE
  ' ' '    END IF
  ' ' ' IF Exist(MntPoint &/ "veclinux/VINSTALL.CONF") = FALSE THEN 
  ' ' '     DEBUG "Missing VINSTALL.CONF in new media"
  ' ' '     RETURN FALSE
  ' ' ' END IF
  ' ' ' SHELL "cat " & MntPoint &/ "veclinux" &/ "VINSTALL.CONF | grep ^Media_ID |cut -f2 -d=" TO sdump
  ' ' ' ' Message("release ID search: " & sdump & GB.NewLine &
  ' ' ' ' Main.SelectedSrc.MediaID)
  ' ' ' IF Len(Trim(sdump)) <= 0 THEN 
  ' ' '   DEBUG "Cant find Media_ID on new media"
  ' ' '     RETURN FALSE
  ' ' ' ELSE 
  ' ' '     IF Trim(sdump) = Trim(main.SelectedSrc.MediaID) THEN 
  ' ' '   DEBUG "Same installation media inserted ... invalid"
  ' ' '   RETURN FALSE '
  ' ' ' END IF  
  ' ' ' END IF
  ' ' ' 
  ' ' ' 
  ' ' ' IF Trim(sdump) = Trim(sReleaseID) THEN 
  ' ' '   DEBUG "Media ID is the same as previously used... Need the second cd.. not the first one again"
  ' ' '   RETURN FALSE
  ' ' ' END IF
  ' ' ' 
  ' ' ' DEBUG "Media matched correctly"
  ' ' ' RETURN TRUE
  
END


PUBLIC FUNCTION switch_installation_media(sReleaseID AS String) AS Integer
  
  DIM nextiso, src, sdump AS String
  
  SHELL "umount " & Main.Install.SrcMnt
  SELECT CASE Main.SelectedSrc.Type
    CASE "ISO" 
      nextiso = Replace(File.Name(Main.SelectedSrc.IsoName), File.Ext(Main.SelectedSrc.IsoName), "") & "-CD2." & File.Ext(Main.SelectedSrc.IsoName)
        ' see if the host device is mounted
        SHELL "mount | grep " & Main.SelectedSrc.HostDevice & " | cut -f3 -d \' \'" TO sdump
          IF Len(Trim(sdump)) > 0 THEN 
            Dialog.Path = Trim(sdump)
          ELSE ' host device is not mounted ( this should never happen )
            SHELL "mkdir -p " & Replace(Main.SelectedSrc.HostDevice, "dev", "mnt") WAIT 
            SHELL "mount " & Main.SelectedSrc.HostDevice & Space(1) & Replace(Main.SelectedSrc.HostDevice, "dev", "mnt") WAIT 
            Dialog.Path = Replace(Main.SelectedSrc.HostDevice, "dev", "mnt")
          END IF
              
            Dialog.Title = "Select second ISO for installation"
            Dialog.Filter = (nextiso)
            IF Dialog.OpenFile() THEN 
            Message.Warning(("Software from the second cd image will not be installed"))
              RETURN 1
            END IF
            src = Dialog.Path
            REPEAT 
            SHELL "mount -o loop " & src & Space(1) & Main.Install.SrcMnt WAIT 
              IF ME.match_installation_media(Main.Install.SrcMnt, sReleaseID) = FALSE THEN 
                ' media does not match...
                SHELL "umount " & Space(1) & Main.Install.SrcMnt WAIT 
                SELECT CASE Message.Question(("Selected ISO does not match the first one. Continue without insalling additional software?"), ("Yes"), ("No"))
                  CASE 1
                  Message.Error(("Additional software will not be installed"))
                  RETURN 1
                END SELECT 
                
              END IF
            UNTIL ME.Main(Main.Install.SrcMnt, sReleaseID) = TRUE
            
    CASE "CDROM"
    Message("Switching cd media")
      SHELL "umount " & Main.SelectedSrc.HostDevice WAIT 
      SHELL "eject " & Main.SelectedSrc.HostDevice WAIT 
        Message.Info(("Please insert the second installation CD. If the cd tray has not ejected, please eject it manually"))
      SHELL "mount " & Main.SelectedSrc.HostDevice & Space(1) & Main.Install.SrcMnt WAIT 
      REPEAT 
        IF ME.match_installation_media(Main.Install.SrcMnt, sReleaseID) = FALSE THEN 
          ' media does not match
          SHELL "umount " & Main.SelectedSrc.HostDevice WAIT 
          SHELL "eject " & Main.SelectedSrc.HostDevice WAIT 
          SELECT CASE Message.Question(("The cd media you inserted is incorrect.") & gb.NewLine &
          ("Would you like to continue without installing the additional software?"), ("Yes"), ("No"))
          CASE 1
            RETURN 1
          END SELECT 
        END IF
      UNTIL ME.match_installation_media(Main.Install.SrcMnt, sReleaseID) = TRUE
      src = Main.Install.SrcMnt
        
  END SELECT 
    
  RETURN 0
END


PUBLIC FUNCTION Install_Bulk_Objects(Reqd AS Boolean) AS Integer
  
  DIM Item AS Bulk
  DIM Pkg, pkgpath, basepkgpath, Bulk AS String
  DIM hproc AS Process
  DIM sList AS NEW String[]
  
  FOR EACH item IN main.Install.BulkObjects
    sList.Push(item.Name)
  NEXT 
  sList.Sort(gb.Descent)
  
  basepkgpath = Main.Install.SrcMnt &/ "packages"
  
  
  'FOR EACH item IN Main.Install.BulkObjects
  FOR EACH Bulk IN sList
  FOR EACH item IN main.Install.BulkObjects
    IF item.Name <> Bulk THEN CONTINUE 
    IF item.Required <> Reqd THEN CONTINUE ' Dont do the required packages
      IF Reqd = TRUE THEN 
        item.Description = main.Install.Config["bulks/required" &/ item.Name]
      ELSE 
        item.Description = main.Install.Config["bulks/optional" &/ item.name]
      END IF
      ME.tlInstallWarn.Text = "Processing " & item.Description
      FOR EACH pkg IN item.Contents
        pkgpath = MdlMain.Get_FULL_TLZ_PACKAGE(pkg)
          IF Len(pkgpath) <= 0 THEN 
            INC $PkgNo
            CONTINUE 
          END IF
          IF Main.Install.InstalledPkgLog.Find(pkg) = -1 THEN 
          main.Install.InstalledPkgLog.Push(pkg)
          ME.Refresh()
          ME.Raise()
              tlCurrPkg.Text = ("Installing") & Space(1) & LCase(item.Name) & " [ " & File.Name(pkgpath) & " ]"
              'INC $PkgNo
              'hproc = SHELL "installpkg -q --root=" & Main.Install.TargetMount & Space(1) & basepkgpath &/ pkgpath 
              hproc = EXEC ["installpkg", "-q", "--root=" & main.Install.TargetMount, basepkgpath &/ pkgpath] 
              
            pbInstall.Value = $PkgNo / MdlMain.$pkgtotal
            INC $PkgNo
            
               'WAIT 0.25
                IF hproc.State = Process.Running THEN 
                  REPEAT 
                    WAIT 0.0125
                        UNTIL 
                    hproc.State = Process.Stopped
                    ' IF hproc.Value > 0 THEN 
                    '   Message.Error(("Unable to install package:") & Space(1) & File.Name(pkgpath))
                    '   RETURN 1
                    ' END IF
                END IF
          END IF

      NEXT 
  NEXT 
  NEXT 
  RETURN 0
END

PUBLIC FUNCTION install_cd2_bulk_objects() AS Integer
  
  DIM Item AS Bulk
  DIM Pkg, pkgpath, basepkgpath, sdump AS String
  DIM hproc AS Process
  
  
  basepkgpath = Main.Install.SrcMnt &/ "packages"
  DEBUG "Installing packages from second media"
  ' refresh the md5sum listings
  SHELL "cat " & basepkgpath &/ "CHECKSUMS.md5 | cut -f2-10 -d/" TO sdump
  TRY KILL Temp("pkgpaths")
  TRY File.Save(Temp("pkgpaths"), Trim(sdump))
  
  
  FOR EACH item IN Main.Install.CD2BulkObjects
      FOR EACH pkg IN item.Contents
      ME.tlInstallWarn.Text = "Processing " & item.Description
        pkgpath = MdlMain.Get_FULL_TLZ_PACKAGE(pkg)
          IF Len(pkgpath) <= 0 THEN 
            INC $PkgNo
            CONTINUE 
          END IF
          IF Main.Install.InstalledPkgLog.Find(pkg) = -1 THEN 
          main.Install.InstalledPkgLog.Push(pkg)
          ME.Refresh()
          ME.Raise()
              tlCurrPkg.Text = ("Installing") & Space(1) & LCase(item.Name) & " [ " & File.Name(pkgpath) & " ] ( CD2 )"
            'hproc = SHELL "installpkg -q --root=" & Main.Install.TargetMount & Space(1) & basepkgpath &/ pkgpath 
            hproc = EXEC ["installpkg", "-q", "--root=" & main.Install.TargetMount, basepkgpath &/ pkgpath]
            
            pbInstall.Value = $PkgNo / MdlMain.$pkgtotal
            INC $PkgNo
              'WAIT 0.25
                IF hproc.State = Process.Running THEN 
                  REPEAT 
                    WAIT 0.0125
                  UNTIL 
                    hproc.State = Process.Stopped

                END IF
          END IF

      NEXT 
  NEXT 
  RETURN 0
  
END




PUBLIC FUNCTION GetNExt() AS String
  

  RETURN "Conf0"
  
END

PUBLIC SUB OnExit()

    'IF $credits.State <> Process.Stopped THEN $credits.Kill()
    
END

PUBLIC SUB Mount_Home()
  
  DIM spart, smntpnt AS String
  DIM i AS Integer
  DIM sentry AS String[]
  
          'blank end means "not formmated"
        ' /dev/sdb5-20.0GB-/-
        ' /dev/sdc4-15.1GB-Swap-linux-swap
  
  FOR i = 0 TO Main.Install.Partitions.Max
    sentry = Split(Main.Install.Packages[i], "-")
    spart = Trim(sentry[0])
    smntpnt = Trim(sentry[2])
      IF smntpnt LIKE "home" THEN 
        SHELL "mount " & spart & Space(1) & Main.Install.TargetMount &/ "home" WAIT 
      ELSE 
        CONTINUE 
      END IF
  NEXT 
    
    
  
END


PUBLIC SUB Create_New_install_menu_entry()
  
  DIM entry AS BootMenuEntry
  DIM target AS BootMenuEntry
  DIM bFound AS Boolean
  DIM sDUmp AS String
  
    FOR EACH entry IN MdlBootMngr.objMenuEntries
      IF entry.Root = Main.Install.Root THEN ' I found an existing object for this
        target = entry
        bFound = TRUE
      ELSE 
        target = NEW BootMenuEntry
                
      END IF
    NEXT 
    
      target.Root = Main.Install.RootPartition
      IF Exist(Main.Install.TargetMount &/ "boot" &/ "initrd") THEN target.initrd = "/boot/initrd"
      IF Exist(Main.Install.TargetMount &/ "boot" &/ "initrd") THEN target.RamDisks.Push("initrd")
      IF Exist(Main.Install.TargetMount &/ "boot" &/ "vmlinuz") THEN target.kernel = "/boot/vmlinuz"
      target.sGrubLabel = Main.install.Name & Space(1) & Main.Install.Version 'ClsGlobal.sDistroName & Space(1) & ClsGlobal.sDistroVer
      target.sLIloLabel = Replace(Main.install.Name, " ", "") '& "-" & Main.Install.Root 'ClsGlobal.sDistroName
      target.Label = target.sLIloLabel
      target.osType = "linux"
      target.StartupOptions = "4 vga=791 ro"
      target.Enabled = TRUE
      target.IsDefault = TRUE
      
      ' SHELL "ls " & Main.Install.TargetMount &/ "/boot | grep ^initrd" TO sDUmp
      '   sDUmp = Trim(sDUmp)
      '     IF Len(sDUmp) > 0 THEN target.RamDisks = Split(sDUmp, gb.NewLine)
          
      IF bFound = FALSE THEN 
        MdlBootMngr.objMenuEntries.Add(target)
      END IF
    
  
END


PUBLIC SUB StartUp()

  
  MdlMain.ADVANCE_STATUS_TREE("Step4", "Step5")
  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE

  
  
END




PUBLIC SUB create_installation_process_layout()
  
  DIM tl AS TextLabel
  DIM pb AS PictureBox
  DIM i AS Integer
  DIM sStages AS String[] = [("Prepare Partitions"), ("Install Base System (required)"), ("Install User-Selected Software")]
  
  MdlMain.ADVANCE_STATUS_TREE("Step4", "Step5")
  ClsGlobal.fRunningMainForm.Refresh()
    FOR i = 0 TO sStages.Max
      pb = NEW PictureBox(ME.svInstallProc)
        WITH pb
          .Expand = FALSE
          .Resize(28, (28 * 2))
          .Picture = Picture.Load("images/square.png")
          .Tag = i
          .Alignment = Align.Center
          '.Stretch = TRUE
        END WITH 
        MdlMain.$objPboxes.Add(pb)
      tl = NEW TextLabel(ME.svInstallProc)
        WITH tl
          .Text = Trim(sStages[i])
          .Height = 28 * 2
          .Width = MdlObjSizer.get_object_width(.Text) + 24
          .Alignment = Align.Left
          .Expand = TRUE
          .Visible = TRUE
        END WITH 
  NEXT 
  
  'WAIT 1
  FOR EACH pb IN MdlMain.$objPboxes
    IF pb.Tag = 0 THEN pb.Picture = MdlStartUp.pCategory
  NEXT 
  
  
  
  
END



PUBLIC SUB Form_Resize()

  ME.hbBottomPanel.Height = (ME.ClientH - (ME.hbBottomPanel.top + 24)) '/ 1.5
  ME.hbox7.Height = ME.ClientH - ME.HBox7.Top - ME.Separator3.Height - 4
  ME.svInstallProc.Width = svinstallproc.Parent.Width - (svinstallproc.left * 2)
  ME.svInstallProc.Height = svinstallproc.Parent.Height - (svinstallproc.top * 1.25)
  'ME.ScrlCredits.Move(4, 36, ScrlCredits.Parent.Width - (ScrlCredits.x * 2), ScrlCredits.Parent.Height - (ScrlCredits.Top * 1.5))
'  ME.wsScroll.Move(4, 36, wsScroll.Parent.Width - (wsscroll.x * 2), wsscroll.Parent.Height - (wsscroll.top + 12))
  'ME.Panel1.Move(4, 36, Panel1.Parent.Width - (Panel1.x * 2), Panel1.Parent.Height - (Panel1.Top + 24))
  panel1.Resize(frame2.Width - 12, frame2.Height - (panel1.top + 8))
  
  'ME.Embedder1.Move(4, 36, Embedder1.Parent.Width - (Embedder1.x * 2), Embedder1.Parent.Height - (Embedder1.Top + 24))

END



' ' ' PUBLIC SUB tmScroll_Timer()
' ' ' 
' ' ' DIM i AS Integer
' ' ' tmScroll.Enabled = FALSE ' fist kill this so that the process doesn't run all over again
' ' ' WAIT 5 ' wait 5 seconds.
' ' ' DEBUG ("Starting installation process")
' ' '   ' perform partitioning as requested.
' ' ' 
' ' '   
' ' '     i = MdlMain.INSTALL_PACKAGES(tlcurrpkg, pbInstall, ClsGlobal.iInstallMethod) 
' ' '   
' ' '   IF i > 0 THEN 
' ' '     Message.Error(("Something went wrong during installation. Please try again"))
' ' '   ELSE 
' ' '     RETURN 
' ' '   END IF
' ' '   
' ' ' 
' ' ' END




PUBLIC SUB tmScroll_Timer()

  
    INC Panel1.ScrollY
  'PRINT ScrollView1.scrolly & " |" & ScrollView1.ScrollH & " | " & ScrollView1.Height
    IF Panel1.ScrollY = Panel1.scrollh - Panel1.Height THEN Panel1.Scroll(0, 0)

END

PUBLIC SUB tmInstall_Timer()

  DIM pb AS PictureBox
  DIM i AS Integer
  
  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
  tmInstall.Enabled = FALSE
  
  
  create_credit_labels()
  panel1.Scroll(0, panel1.Height)
  i = 5
  REPEAT 
    MdlMain.Set_App_Status(("Installation will start in") & Space(1) & i)
    DEC i
    WAIT 1
  UNTIL i = 0
  
  MdlMain.Set_App_Status(("Preparing host for installation"))
  ME.tlInstallWarn.Text = ("Preparing system") & "..."
    WITH ClsGlobal.fRunningMainForm
      .btnext.enabled = FALSE
      .btquit.enabled = FALSE
      .btback.enabled = FALSE
    END WITH 
  ME.Refresh()
  
  ME.tlInstallWarn.Text = ("Formatting partitions") & "..."
     
     WAIT 0.25
     MdlMain.PERFORM_PARTITIONING()
     ME.tlInstallWarn.Text = ("Mounting target partitions")
     
     WAIT 0.25
      IF MdlMain.Mount_Target_Partitions() > 0 THEN 
        Message.Error("Unable to mount target partition")
        RETURN 
        STOP EVENT 
      ELSE 
        'Message("Done mounting partitions")
      END IF
    FOR EACH pb IN MdlMain.$objPboxes
      IF pb.Tag = 0 THEN pb.Picture = MdlStartUp.pDone
      IF pb.Tag = 1 THEN pb.Picture = MdlStartUp.pCategory
     NEXT 
     
    WAIT 0.25
    MdlMain.Set_App_Status("")
    
    
    tmScroll.Enabled = TRUE
    Perform_Installation() ' INSTALL PACKAGES


IF ME.INSTALL_VL_CONFIG() > 0 THEN 
  Message.Error("Error installing default system configuration. This installation is useless.")
END IF

    pbInstall.Value = 1
ME.tlInstallWarn.Text = ("Installation complete")
ME.tlInstallWarn.Refresh
WAIT 0.25
MdlMain.WRITE_ETC_VECTOR_VERSION()
main.Install.write_fstab()

tlCurrPkg.Text = ("Preparing new installation ...")
tlCurrPkg.Refresh
WAIT 0.25

MdlBootMngr.DO_BIND_MOUNTING()

tlCurrPkg.Text = ("Preparing boot menu ... This may take a few minutes.")
tlCurrPkg.Refresh
WAIT 0.25
MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS()
MdlMain.write_background_config_scripts() ' write scripts for background configuration.
ME.tlCurrPkg.Text = ("Click") & Space(1) & ClsGlobal.fRunningMainForm.btnext.text & Space(1) & ("to continue")

ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
ClsGlobal.fRunningMainForm.btquit.enabled = TRUE

main.bInstallDone = TRUE
FOR EACH pb IN MdlMain.$objPboxes
  IF pb.Tag = 2 THEN pb.Picture = MdlStartUp.pDone
NEXT 

ClsGlobal.fRunningMainForm.btnext.enabled = TRUE
Message.Info(("Installation complete. Ready to begin configuring the system"))
tmScroll.Enabled = FALSE

'panel1.Scroll(0, 0)
panel1.Scroll(0, panel1.Height)
'ClsGlobal.fRunningMainForm.btnext.enabled = main.bInstallDone

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.