vlocity-vinstall-gambas / Vlocity / Step1.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
' 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 iCheckWarn AS Integer
' ' ' PUBLIC SUB _new() ' executed every time the form is instanciated.
' ' '   
' ' '       
' ' '       ' Find install media
' ' ' 
' ' '   
' ' ' ' ME.StartUp()
' ' ' ME.mvLooking.Visible = TRUE
' ' ' ME.mvLooking.Playing = TRUE
' ' ' 
' ' ' END

PUBLIC SUB Create_INstallation_Object()
  DIM image AS InstallSrc
  image = Main.InstallMedia[ME.ComboBox1.Index]
  Main.Install = NEW Installation
  Main.Install.Name = image.Name
  Main.Install.Version = image.Version
  Main.Install.SrcMnt = "/mnt/source"
  
  
END

PRIVATE FUNCTION Mount_Source() AS Integer
  
  DIM src AS String = Main.Install.Source
  DIM part AS String
  DIM sDump AS String
  
  TRY MKDIR "/mnt/source" 
  SHELL "umount -a 2> /dev/null" WAIT 
  SHELL "mount -a 2> /dev/null" WAIT
  SHELL "umount /mnt/source 2> /dev/null" WAIT 
    IF Main.SelectedSrc.IsISO = TRUE THEN 
      DEBUG "Installing " & Main.SelectedSrc.IsoName
      IF main.SelectedSrc.PathToISO THEN 
        Message.Info(main.SelectedSrc.PathToISO)
        SHELL "mount -o loop " & main.SelectedSrc.PathToISO & Space(1) & "/mnt/source" WAIT 
      ELSE 
        SHELL "mount | grep ^" & Main.SelectedSrc.HostDevice & " | cut -f 3 -d \' \'" TO sDump
          sDump = Trim(sDump)
            IF Len(sDump) = 0 THEN 
                 'SHELL "mkdir -p" & Space(1) & Replace(Main.SelectedSrc.HostDevice, "/dev/", "/mnt/") WAIT 
                 part = Replace(Main.SelectedSrc.HostDevice, "dev", "mnt")
                 SHELL "mkdir -p " & part
                 SHELL "mount -o ro " & Main.SelectedSrc.HostDevice & Space(1) & part WAIT 
                 
            ELSE 
              'SHELL "mount -o ro " & Main.SelectedSrc.HostDevice & Space(1) & Replace(Main.SelectedSrc.HostDevice, "/dev/", "/mnt/") WAIT 
              part = Trim(sDump)              
            END IF
      
      SHELL "mount -o loop " & part &/ Main.SelectedSrc.IsoName & Space(1) & "/mnt/source" WAIT 
      END IF
    ELSE 
      SHELL "mount -o ro " & Main.SelectedSrc.HostDevice & Space(1) & "/mnt/source" WAIT 
    END IF
    
    SHELL "mount | grep /mnt/source" TO sDump
      IF Len(Trim(sDump)) <= 0 THEN RETURN 1
    RETURN 0
  Main.Install.SrcMnt = "/mnt/source"
  Main.Install.TargetMount = "/mnt/target"
  
END

PUBLIC SUB OnExit()
  
    DEBUG "Creating installation profile"
  ME.Create_INstallation_Object()
  DEBUG "Mounting Selected Media source"
  IF Mount_Source() > 0 THEN 
    Main.bStopNav = TRUE
    Message.Error("Unable to mount source... Please stop the installer now.")
  ELSE 
    'Message.Info(Main.Install.SrcMnt)
    IF Exist(Main.Install.SrcMnt &/ "veclinux/VINSTALL.INI") THEN 
      Main.Install.Config = NEW Settings(Main.Install.SrcMnt &/ "veclinux/VINSTALL.INI")
      MdlMain.Set_App_Status(("Loading Install media") & " ...")
    END IF
  END IF

END




PUBLIC SUB Form_Open()
  DIM media AS InstallSrc
  DIM i AS Integer
  
  MdlMain.Set_App_Status(("Searching for install media"))
  ClsGlobal.fRunningMainForm.maximized = TRUE
  ClsGlobal.fRunningMainForm.FullScreen = TRUE
  ME.TextLabel1.Text = "<h2>" & TextLabel1.text & "</h2>"
  ME.mvLooking.path = "images/throbber.gif"
  ME.gvDistDetails.Rows.Count = 4
  ME.gvDistDetails.Columns.Count = 2
  ME.gvDistDetails[0, 0].Text = ("Distribution")
  ME.gvDistDetails[1, 0].Text = ("Version")
  ME.gvDistDetails[2, 0].Text = ("Location")
  ME.gvDistDetails[3, 0].Text = ("Media type")
  ME.gvDistDetails.Columns[0].Width = MdlObjSizer.get_object_width(gvdistdetails[0, 0].Text) * 1.5
  ME.gvDistDetails.Visible = FALSE
  ME.mvLooking.Playing = TRUE
  MdlMain.Resize_Object(ME.btRescan)
  MdlMain.Resize_Object(ME.button1)
  ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
  MdlMain.ADVANCE_STATUS_TREE("Step0", "Step1")
  timer1.Enabled = TRUE

END

PUBLIC FUNCTION GetNext() AS String
  
    MdlMain.ADVANCE_STATUS_TREE("Step0", "Step1")

    IF FMain.bConfMode = TRUE THEN 
      RETURN "Step6"
    ELSE 
      RETURN "Step3"  
    END IF
 
  
END

PUBLIC SUB StartUp() ' Executed every time the Next button is pressed

    ME.Resize(ClsGlobal.fRunningMainForm.Pnlstack.Width, ClsGlobal.fRunningMainForm.PnlStack.Height)

  
END


PUBLIC SUB DESCRIBE_PARTITION_INSTALL_MEDIA(sTempFileName AS String)
  
  DIM sDump AS String[]
  DIM sDistro, sVer, sLine AS String
  DIM i AS Integer
  
    sTempFileName = Replace(sTempFileName, "/dev/", "")
    sTempFileName = Replace(sTempFileName, Space(1) & ("on") & Space(1), "-")
  
   ' ME.mvLooking.Playing = TRUE
  'WAIT 1
  sDump = Split(File.Load(Temp(sTempFileName)), "\n")
    FOR i = 0 TO sDump.Count - 1
      sLine = Trim(sDump[i])
        IF Left(sLine, Len("DISTRO=")) = "DISTRO=" THEN 
          sDistro = Right(sLine, Len(sLine) - InStr(sLine, "\'"))
        ELSE IF Left(sLine, Len("VERSION=")) = "VERSION=" THEN 
          sVer = Right(sLine, Len(sLine) - InStr(sLine, "\'"))
        END IF
    NEXT 
      sDistro = Trim(Replace(sDistro, "\'", ""))
      sver = Trim(Replace(sver, "\'", ""))
    gvdistdetails[0, 0].Text = ("DISTRIBUTION")
    gvdistdetails.Columns[0].Width = 150
    gvdistdetails[0, 1].Text = sDistro
    gvdistdetails[1, 0].Text = ("VERSION")
    gvdistdetails[1, 1].Text = sVer
  
END


PUBLIC SUB DESCRIBE_ISO_INSTALL_MEDIA(sTempFileName AS String)
DIM sDump AS String[]
DIM sDistro, sVer, sLine AS String
DIM i AS Integer

sTempFileName = Replace(sTempFileName, "/dev/", "")
  sDump = Split(File.Load(Trim(Temp(sTempFileName))), "\n")
    FOR i = 0 TO sDump.Count - 1
      sLine = Trim(sDump[i])
        IF Left(sLine, Len("DISTRO=")) = "DISTRO=" THEN 
          sDistro = Right(sLine, Len(sLine) - InStr(sLine, "\'"))
        ELSE IF Left(sLine, Len("VERSION=")) = "VERSION=" THEN 
          sVer = Right(sLine, Len(sLine) - InStr(sLine, "\'"))
        END IF
    NEXT 
    sDistro = Trim(Replace(sDistro, "\'", ""))
    sVer = Trim(Replace(sver, "\'", ""))
    'Message(sDistro & "\n" & sVer)
    
    gvdistdetails[0, 0].Text = ("DISTRIBUTION")
    gvdistdetails.Columns[0].Width = 150
    gvdistdetails[0, 1].Text = sDistro
    gvdistdetails[1, 0].Text = ("VERSION")
    gvdistdetails[1, 1].Text = sVer
  
  
END



PUBLIC SUB DESCRIBE_CD_INSTALL_MEDIA(sAddress AS String)
  
  DIM sDistro, sVersion, sLine AS String
  DIM sSetup AS String[]
  DIM sFile AS String = File.Load(Temp(sAddress))
  DIM i, ir AS Integer
  
  
  sSetup = Split(sFile, "\n")
    FOR i = 0 TO sSetup.count - 1
      sLine = Trim(sSetup[i])
        IF Left(sLine, Len("DISTRO=")) = "DISTRO=" THEN 
          sDistro = Right(sLine, Len(sLine) - InStr(sline, "\'"))
          sDistro = Replace(sDistro, "\'", "")
          sDistro = Trim(sDistro)
        ELSE IF Left(sline, Len("VERSION=")) = "VERSION=" THEN 
          sVersion = Right(sLine, Len(sLine) - InStr(sline, "\'"))
          sVersion = Replace(sVersion, "\'", "")
          sVersion = Trim(sVersion)
        END IF
      
  
    NEXT 


    gvdistdetails[0, 0].Text = ("DISTRIBUTION")
    gvdistdetails.Columns[0].Width = 150
    gvdistdetails[0, 1].Text = sDistro
    gvdistdetails[1, 0].Text = ("VERSION")
    gvdistdetails[1, 1].Text = sVersion
  
END




PUBLIC SUB bCheckMedia_Click()

  IF iCheckWarn < 1 THEN 
    IF LAST.value = TRUE THEN 
      Message.Warning(("This feature can help you avoid an unsuccesful installation.") & "<br>" &
      "<b><br>" & ("WARNING:") & "</b><br>" & Space(1) & ("This process can take a long time to complete."))
      INC iCheckWarn
    END IF
  END IF

END

PUBLIC SUB btRescan_Click()
DIM entry AS InstallSrc

'IF Main.Partitions_In_Host.Count > 0 THEN Main.Partitions_In_Host.Clear()
textlabel2.Text = ("Scanning system for installable media. Please wait")
ME.gvDistDetails.Visible = FALSE

ME.ComboBox1.Clear
Main.InstallMedia.Clear
Main.InstallMediaID = 0
'ME.mvLooking.Visible = TRUE
'ME.mvLooking.Playing = TRUE
MdlMain.FIND_CD_INSTALL_MEDIA()
'ME.mvLooking.Playing = TRUE
MdlMain.FIND_ISO_INSTALL_MEDIA()
'ME.mvLooking.Playing = TRUE
'MdlMain.FIND_PARTITION_INSTALL_MEDIA()
MdlMain.scan_partitions()
'ME.mvLooking.Playing = TRUE

  FOR EACH entry IN Main.InstallMedia
    ME.ComboBox1.Add(entry.Name & Space(1) & entry.Version & Space(1) & ("on") & Space(1) & entry.HostDevice, entry.ID)
  NEXT 

'ME.mvLooking.Playing = FALSE
ME.mvLooking.Visible = FALSE
ClsGlobal.fRunningMainForm.btquit.enabled = TRUE
ClsGlobal.fRunningMainForm.btNext.enabled = Main.InstallMedia.Count > 0
ME.gvDistDetails.Visible = Main.InstallMedia.Count > 0
IF Main.InstallMedia.Count <= 0 THEN 
  textlabel2.Text = ("Unable to find any installation media on your system. Please insert your installation CD.") & "<br><br>" &
  ("You may also install from a compressed ISO image by placing the ISO on the top directory of any partition in your system.")
ELSE IF Main.InstallMedia.Count = 1 THEN 
  textlabel2.Text = ("Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to begin installing") & Space(1) & Trim(combobox1.text)
ELSE 
  textlabel2.Text = ("Multiple installation sources were found on your system. Select which one to install from the list below.")
END IF

END

PUBLIC SUB ComboBox1_Click()

  DIM sel AS InstallSrc
  ' Describe Installation.
  FOR EACH sel IN Main.InstallMedia
    IF sel.ID = combobox1.index THEN 
 '     ME.gvDistDetails[0, 0].Text = ("DISTRO")
      ME.gvDistDetails[0, 0].Font.Bold = TRUE
      ME.gvDistDetails[1, 0].Font.Bold = TRUE
      ME.gvDistDetails[2, 0].Font.Bold = TRUE
      ME.gvDistDetails[3, 0].Font.Bold = TRUE
'      ME.gvDistDetails[4, 0].Font.Bold = TRUE
'      ME.gvDistDetails[1, 0].Text = ("VERSION")
      ME.gvDistDetails[0, 1].Text = sel.Name
      ME.gvDistDetails[1, 1].Text = sel.Version
      ME.gvDistDetails[2, 1].Text = sel.HostDevice
      IF sel.IsISO = TRUE THEN 
        ME.gvDistDetails[3, 1].Text = UCase(sel.Type) & Space(1) & "[ " & sel.IsoName & " ]"
        ELSE 
          ME.gvDistDetails[3, 1].Text = UCase(sel.Type)
      END IF
    END IF
    
  NEXT 
  
    Main.SelectedSrc = Main.InstallMedia[ME.ComboBox1.index]
  
  
  IF Main.SelectedSrc.MultiDisk = TRUE THEN 
    IF gvdistdetails.Rows.Count = 4 THEN 
      INC gvdistdetails.Rows.Count
        gvdistdetails[4, 0].Text = ("Notes")
        gvdistdetails[4, 1].Text = ("Bonus software is available for this installation") & "\n" & 
        ("on a second install media")
        gvdistdetails.Rows[4].Height = gvdistdetails.Rows[4].Height * 3  '("Bonus software is available for this installation on a second install media")

    END IF
  ELSE 
    IF gvdistdetails.Rows.Count = 5 THEN DEC gvdistdetails.Rows.Count
  END IF
  gvdistdetails.Refresh
END

PUBLIC SUB Form_Resize()

'  ME.Panel1.Height = ME.ClientH - ME.Panel1.top - ClsGlobal.fRunningMainForm.btNext.Height

END


PUBLIC SUB Form_Enter()

  ClsGlobal.fRunningMainForm.btNext.enabled = Main.InstallMedia.Count > 0

END


PUBLIC SUB Timer1_Timer()

  DIM media AS InstallSrc
  DIM i AS Integer
  
  timer1.Enabled = FALSE
  MdlMain.probe_system_partitions() ' create partition objects
  MdlMain.FIND_CD_INSTALL_MEDIA()
  MdlMain.FIND_ISO_INSTALL_MEDIA()
  MdlMain.scan_partitions() ' Find installation files on a partition (USB DRIVES)
  
  'MdlMain.FIND_PARTITION_INSTALL_MEDIA()
  
  
    FOR EACH media IN Main.InstallMedia
      ComboBox1.Add(media.Name & Space(1) & media.Version & Space(1) & ("on") & Space(1) & media.HostDevice, media.ID)
    NEXT 
  ME.gvDistDetails.Visible = Main.InstallMedia.Count > 0
  'WAIT 0.25 ' a small wait time to avoid a solid blank form
  
  ClsGlobal.fRunningMainForm.btNext.enabled = Main.InstallMedia.Count > 0
  'ME.mvLooking.Playing = FALSE
  ME.mvLooking.Visible = FALSE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  'ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
  ClsGlobal.fRunningMainForm.btNext.enabled = FALSE 'Main.InstallMedia.Count > 0
  ClsGlobal.fRunningMainForm.btquit.enabled = TRUE
  
  IF Main.InstallMedia.Count = 0
    ME.HBox4.Visible = TRUE
    ME.gvDistDetails.Visible = FALSE
      ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
    Message.Error(("No installable media was found on your system. Please insert an installation CD") & gb.NewLine & 
    ("or move your installation images (ISO) to the top of your partitions, then click") & Space(1) & "\"" & btrescan.text & "\"")
    ME.TextLabel2.Text = ("No installable media found on your system.") & "<br><br>" &
    ("Click") & Space(1) & "\'" & btrescan.Text & "\'" & Space(1)&
    ("to search again or click") & Space(1) & "\'" & button1.text & "\'" & Space(1)&
    ("to locate an installation image (iso) yourself. Click on") & Space(1) & "\'" & ClsGlobal.fRunningMainForm.bthelp.text & "\'" & Space(1)&
    ("for details.")
    'ME.tlNext.Text = "<i>" & ("Insert installation CD or move Installable (iso) images to the top directory on your partitions and click") & Space(1) & "\"" & ME.btrescan.text & "\"" & ("to search for media again") & "</i>"
    
  ELSE IF Main.InstallMedia.Count = 1 THEN 
    ME.TextLabel2.Text = ("Click") & Space(1) & "\"" & ClsGlobal.fRunningMainForm.btNext.text & "\"" & Space(1) & ("to begin installing") & Space(1)&
    Main.InstallMedia[0].Name & Space(1) & Main.InstallMedia[0].Version
    'ME.tlNext.Text = ""
  ELSE 
    'ME.TextLabel2.Text = ("Select Installation source from the list below")
    ME.textlabel2.Text = ("Click") & Space(1) & "\"" & ClsGlobal.fRunningMainForm.btNext.text & "\"" & Space(1)&
    ("to continue or click") & Space(1) & "\"" & ME.btRescan.Text & "\"" & Space(1) & ("to search for installation media again or click")&
    Space(1) & "\'" & ME.Button1.text & "\'" & Space(1) & ("to find the install media yourself.")
    
  END IF

ClsGlobal.fRunningMainForm.btNext.enabled = Main.InstallMedia.Count > 0
MdlMain.Set_App_Status("")

  IF ME.ComboBox1.count > 0 THEN 
    ME.ComboBox1_Click()
  END IF


END

PUBLIC SUB Button1_Click()

  Dialog.title = "Select installation source"
  Dialog.filter = ["*.iso", ("Compressedn Image")]
  Dialog.path = "/"
  IF Dialog.OpenFile() THEN RETURN 
  textbox1.text = Dialog.Path
  inspect_image(Dialog.Path)
  
  

END

PRIVATE FUNCTION inspect_image(path AS String) AS Boolean
  DIM msg AS String
  
  EXEC ["umount", "/mnt/loop"] WAIT 
  SHELL "mount -o loop " & path & Space(1) & "/mnt/loop" WAIT 
  
  IF Exist("/mnt/loop/veclinux/VINSTALL.INI")
    create_new_iso_image(path)
    ClsGlobal.fRunningMainForm.btNext.enabled = main.InstallMedia.Count > 0
    msg = ("Click") & Space(1) & "\'" & ClsGlobal.fRunningMainForm.btNext.text & "\'" & Space(1) & ("to begin the installation process or")&
    Space(1) & ("click") & Space(1) & "\'" & button1.text & "\'" & Space(1) & ("to locate another installation image.")
    textlabel2.Text = msg
  ELSE 
    Message.Error(("The selected disc image does not contain suitable installation files"))
    Dialog.path = "/"
    textbox1.Clear()
  END IF
  EXEC ["umount", "/mnt/loop"] WAIT 
  
END
PRIVATE SUB create_new_iso_image(path AS String)
  
  DIM src AS InstallSrc
  src = NEW InstallSrc
  src.Config = NEW Settings("/mnt/loop/veclinux/VINSTALL.INI")
  src.Name = src.Config["general/distro"]
  src.Version = src.Config["general/version"]
  src.ID = main.InstallMediaID
  src.IsISO = TRUE
  src.Type = "iso"
  src.IsoName = File.Name(path)
  src.HostDevice = File.Dir(path)
  src.PathToISO = path
  src.MediaID = src.Config["general/media_id"]
  IF src.Config["general/multi_single"] = "1" THEN src.MultiSingle = TRUE
  IF src.Config["general/multi_cd"] = "1" THEN src.MultiDisk = TRUE
  src.BuildDate = src.Config["general/build_date"]
  INC main.InstallMediaID
  main.InstallMedia.Add(src)
  combobox1.Add(src.name & Space(1) & src.Version & Space(1) & ("on") & Space(1) & src.HostDevice, src.ID)
  gvDistDetails.Visible = TRUE
  
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.