Source

vlocity-vinstall-gambas / Vlocity / MdlMain.module

Full commit
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
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
' Gambas module 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 $pkgtotal AS Integer
PRIVATE $currpkg AS Integer
PUBLIC $objPboxes AS NEW Object[]
PUBLIC $objUsrGroups AS NEW Object[]
PUBLIC iUID AS Integer
PRIVATE $hproc AS Process
PUBLIC $hBgConfig AS Process
PUBLIC uuidList AS NEW String[]


PUBLIC SUB Set_App_Status(Status AS String, OPTIONAL iTimeout AS Integer)
  
  DIM i AS Integer
  
  IF ClsGlobal.fRunningMainForm.timer1.enabled = TRUE THEN ClsGlobal.fRunningMainForm.timer1.enabled = FALSE
  IF NOT (iTimeout) THEN iTimeout = 5
  IF Len(Status) > 0 THEN 
    'ClsGlobal.fRunningMainForm.AppStatus.backcolor = Color.DarkRed
    ClsGlobal.fRunningMainForm.AppStatus.forecolor = Color.DarkRed
  ELSE 
    'ClsGlobal.fRunningMainForm.AppStatus.backcolor = Color.Default
    ClsGlobal.fRunningMainForm.AppStatus.forecolor = Color.ButtonForeground
  END IF
  
  ClsGlobal.fRunningMainForm.timer1.delay = (iTimeout * 1000)  
  ClsGlobal.fRunningMainForm.AppStatus.text = Status
  ClsGlobal.fRunningMainForm.timer1.enabled = TRUE
  

END 

PUBLIC SUB RECREATE_PARTITION_OBJECTS()

DIM sOutput, sPart, sISoName, sFile AS String
  DIM sName, sVersion AS String
  DIM i AS Integer
  DIM sPartList AS String[]
  DIM Inst AS InstallSrc
  DIM PartInfo AS String
  DIM sPartInfo AS String[]
  DIM p AS Partition

  main.Partitions_In_Host.Clear()

  SHELL "/sbin/probepart | grep \"^/dev\" | grep -v -i \"linux swap\" | tr -s \' \'\"\" | cut -f 1 -d \' \'" TO sOutput
    sOutput = Trim(sOutput)
      IF Len(sOutput) < 1 THEN RETURN 
  sPartList = Split(sOutput, "\n")
    FOR i = 0 TO sPartList.Count - 1
      sPart = Trim(Right(Trim(sPartList[i]), Len(Trim(sPartList[i])) - RInStr(Trim(sPartList[i]), "/")))
          EXEC ["mkdir", "/mnt" &/ Trim(sPart)] WAIT 
          EXEC ["mount", "/dev" &/ Trim(sPart), "/mnt" &/ Trim(sPart)] WAIT 
          
          ''''''''''''''''''''''''''''''''''''''''''''''''''
          ''' TAKE A SPLIT SECOND HERE TO CREATE AN OBJECT AND SAVE THE PARTITION INFORMATION TO AN ARRAY
          ''' THIS WILL HELP US AVOID HAVING TO PROBE THE SAME PARTITIONS OVER AGAIN IN THE PARTITION
          ''' SELECTION STEP
          ''''''''''''''''''''''''''''''''''''''''
          
            SHELL "df -hT | tr -s \' \',\"\" | grep ^" & Trim(sPartList[i]) TO PartInfo
            IF Len(Trim(PartInfo)) > 0 THEN 
              sPartInfo = Split(Trim(PartInfo), " ")
                p = NEW Partition
                p.BlockDevice = sPartInfo[0]
                p.CurrentFileSystem = sPartInfo[1]
                p.RawSize = sPartInfo[2]
                main.Partitions_In_Host.Add(p)
            END IF
                
              
        
            
          EXEC ["umount", "/mnt" &/ Trim(sPart)] WAIT 
          EXEC ["sync"] WAIT 
          'TRY RMDIR "/mnt" &/ Trim(sPart)
NEXT


END


PUBLIC SUB write_background_config_scripts()
  
  DIM sOut AS String
  
  'We will run the commands neccesary to setup the newly installed system here
 EXEC ["mkdir", "-p", main.Install.TargetMount &/ "var" &/ "log" &/ "setup"] WAIT  
 EXEC ["chmod", "700", main.Install.TargetMount &/ "var" &/ "log" &/ "setup"] WAIT 
 sOut = "#!/bin/bash \n" &
 "for i in /usr/share/icons/*;do cd $i 2>/dev/null && if [ -e convert.sh ];then sh convert.sh & 2>/dev/null;fi;done" & gb.NewLine &
 "DISPLAY=" & gb.NewLine &
 "chmod +x /etc/rc.d/rc.udev" & gb.NewLine &
 "/etc/rc.d/rc.udev restart" & gb.NewLine &
 "/etc/rc.d/rc.modules" & gb.NewLine &
 "sleep 2" & gb.NewLine &
 "/sbin/vlsetup" & gb.NewLine &
 "/sbin/vhwconf-quiet" & gb.NewLine &
 "cd /usr/lib && ln -sf preloadable_libintl.so libgnuintl.so.8 && rm libintl.so 2>/dev/null; ln -s preloadable_libintl.so libintl.so" & gb.NewLine &
 "/sbin/valsaconf-quiet" & gb.NewLine &
 "cd / && for i in /var/log/scripts/x11-fonts*;do sh $i &>/dev/null;done" & gb.NewLine &
 "rm -r /root/.mc 2>/dev/null" & gb.NewLine &
 "gconftool-2 --install-schema-file /etc/gconf/schemas/firestarter.schemas > /dev/null 2>&1" & gb.NewLine &
 "cd / && sh /var/log/scripts/gsb-desktop* 2>/dev/null" & gb.NewLine &
 "update-mime-database /usr/share/mime/" & gb.NewLine &
 "echo Done > /tmp/status" & gb.NewLine &
 "#sleep 20"
  '"echo done >/tmp/status" & gb.NewLine
  
  
 File.Save(main.Install.TargetMount &/ "var/log/setup/config-vinstall-ng", sOut)
  
  EXEC ["chmod", "+x", main.Install.TargetMount &/ "var" &/ "log" &/ "setup" &/ "config-vinstall-ng"] WAIT 
  
  
  '''''''''''''''''''''''''''''''''''''''''
  'this is the script that runs after reboot.
 sOut = "#!/bin/bash \n" &
 ". /sbin/vasm-functions \n" &
 "TEXT=\" \n" &
 "VLocity Linux Has been Installed. " &
 "We will finalize video settings on the next few screens. " &
 "Any other system fine tuning can be done via VASM. \n" &
 "$DCMD --backtitle \"$BACKTITLE\" --title \"CONGRATULATIONS\" " &
 "--msgbox \"$TEXT\" 0 0 2>/dev/NULL  \n" &
 "#cd / && sh /var/log/scripts/x11-fonts* \n " &
 "#alsaconf \n " &
 "alsactl store \n " &
 "/sbin/vxconf \n" &
 "echo \"updating database\" \n" &
 "updatedb & \n" &
 "sleep 10 \n" &
 "#cd / && sh /var/log/scripts/gsb-desktop* & 2>/dev/null" & gb.NewLine &
 "#/sbin/vsrvset \n" &
 "#/sbin/config-stage1 gui-installer" & gb.NewLine
   
 EXEC ["mkdir", "-p", main.Install.TargetMount &/ "var" &/ "log" &/ "setup" &/ "init"] WAIT 
 EXEC ["chmod", "700", main.Install.TargetMount &/ "var" &/ "log" &/ "setup" &/ "init"] WAIT 
 EXEC ["touch", main.Install.TargetMount &/ "var" &/ "log" &/ "setup" &/ "init" &/ "config-stage2"] WAIT 
   
   
 File.Save(main.Install.TargetMount &/ "var/log/setup/init/config-stage2", sOut)
   
 EXEC ["chmod", "+x", main.Install.TargetMount &/ "var" &/ "log" &/ "setup" &/ "init" &/ "config-stage2"] WAIT 
   
 IF Exist(main.Install.TargetMount &/ "tmp" &/ "status") THEN KILL main.Install.TargetMount &/ "tmp" &/ "status"
 IF Exist("/tmp/status") THEN KILL "/tmp/status"
  
  ' The process is triggered here.
  DEBUG "Start background configuration now ..."
  $hBgConfig = SHELL "chroot /mnt/target /var/log/setup/config-vinstall-ng &" ' FOR READ"
  
  
  
END


PUBLIC SUB FIND_CD_INSTALL_MEDIA()
  
  DIM sDump, sDrive, sOutput, sShortDrive AS String
  DIM sName, sVersion, snames, multisingle AS String
  DIM i AS Integer
  DIM Multi, MedID AS String
  DIM ReleaseID, bdate AS String
  DIM sDriveList AS String[]
  DIM Install AS InstallSrc
  
  
'  ME.mvLooking.Playing = TRUE
  WAIT 1
  
  ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = FALSE
  
  Step1.tlStatus.Text = ("Scanning for CD Media ... Please wait")
  DEBUG "Scanning for CD Media ... Please wait"
  
 
    SHELL "cat /proc/sys/dev/cdrom/info | grep \'^drive name\' | cut -f2 -d: | xargs -n 2" TO sOutput
    'SHELL "cat /proc/sys/dev/cdrom/info | grep \'^drive name:\' | awk \'{ print $3 }\'" TO sOutput
    IF Len(Trim(sOutput)) > 0 THEN snames = Trim(soutput)
    
  IF Len(Trim(sOutput)) <= 0 THEN RETURN  ' give up if the kernel cant see cdroms
  'Message("scanning cds")
  sDriveList = Split(sOutput, " ")
  
    FOR i = 0 TO sDriveList.max
      sShortDrive = Trim(sDriveList[i]) 'Right(Trim(sDriveList[i]), Len(Trim(sDriveList[i])) - RInStr(Trim(sDriveList[i]), "/"))
        EXEC ["mkdir", "-p", "/mnt" &/ sShortDrive] WAIT 
        PRINT ("Scanning") & Space(1) & "/dev/" &/ sDriveList[i]
        SHELL "umount -f /dev/" &/ Trim(sDriveList[i] & " 2>/dev/null") WAIT 
        SHELL "mount /dev" &/ Trim(sDriveList[i]) & Space(1) & "/mnt" &/ sShortDrive & " 2>/dev/null" WAIT 
        'WAIT 0.25
        IF Exist("/mnt" &/ sShortDrive &/ "veclinux/VINSTALL.INI") THEN 
          install = NEW InstallSrc
          install.Config = NEW Settings("/mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.INI")
          install.id = main.InstallMediaID
          install.Name = install.Config["general/distro"]
          install.Version = install.Config["general/version"]
          install.BuildDate = install.Config["general/build_date"]
          install.HostDevice = "/dev" &/ sShortDrive
          install.Type = "cdrom"
          install.IsISO = FALSE
          install.ReleaseID = install.Config["general/release_id"]
          install.MediaID = install.Config["general/media_id"]
          IF install.Config["general/multi_cd"] = "1" THEN install.MultiDisk = TRUE
          IF install.Config["general/multi_single"] = "1" THEN install.MultiSingle = TRUE
          INC main.InstallMediaID
          main.InstallMedia.Push(install)
        
        ELSE 
          IF Exist("/mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF") THEN 
              SHELL "grep \"^DISTRO=\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f 2 -d \'=\'" TO sName
              SHELL "grep \"^VERSION=\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f 2 -d \'=\'" TO sVersion
              SHELL "grep \"^MULTI_CD=\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d \'=\'" TO Multi
              SHELL "grep \"builddate\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d \'=\'" TO bdate
              SHELL "grep -i \"^multi_single\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d \'=\'" TO multisingle
              bdate = Replace(bdate, "\"", "")
              bdate = Replace(bdate, "\'", "")
                  ' SHELL "cat /mnt/source/veclinux/VINSTALL.CONF | grep ^builddate" TO builddate
    ' IF builddate THEN builddate = Right(builddate, Len(builddate) - InStr(builddate, "="))
    ' IF builddate THEN builddate = Replace(builddate, "\"", "")
    ' IF builddate THEN builddate = Replace(builddate, "\'", "")
                IF Trim(Multi) = "1" THEN 
                  SHELL "grep \"^RELEASE_ID=\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d \'=\'" TO ReleaseID
                  SHELL "grep \"^Media_ID=\" /mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d \'=\'" TO MedID
                END IF
                
              ClsGlobal.sDistroName = sName
              ClsGlobal.sDistroVer = sVersion
                sName = Trim(Replace(sName, "\'", ""))
                sVersion = Trim(Replace(sVersion, "\'", ""))
                'File.Save(Temp(sShortDrive), File.Load("/mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF"))
                      ' create object
                        Install = NEW InstallSrc
                          Install.Name = sName
                          Install.Version = sVersion
                          install.BuildDate = bdate
                          Install.Configuration = File.Load("/mnt" &/ sShortDrive &/ "veclinux" &/ "VINSTALL.CONF")
                          Install.Type = "cdrom"
                          Install.HostDevice = "/dev" &/ Trim(sDriveList[i])
                          Install.ID = Main.InstallMediaID
                          IF Trim(multisingle) = "1" THEN Install.MultiSingle = TRUE
                          IF Trim(Multi) = "1" THEN install.MultiDisk = TRUE
                          IF ReleaseID THEN install.ReleaseID = Trim(ReleaseID)
                          IF MedID THEN install.MediaID = Trim(MedID)
                          INC Main.InstallMediaID
                          Main.InstallMedia.Add(Install)   

                  PRINT " \\__" & Space(1) & ("Found") & Space(1) & sName & "-" & sVersion & Space(1) & ("in") & Space(1) & Trim(sShortDrive) 'sDriveList[i]         
          END IF
          END IF
        'EXEC ["umount", "/mnt" &/ sShortDrive, " 2>/dev/null"] WAIT 
        SHELL "umount /mnt" &/ Trim(sShortDrive) & " 2>/dev/null" WAIT 
        
        'Message(sShortDrive)
    NEXT 
      
Step1.tlStatus.Text = ""
  
  'ComboBox1.ReadOnly = TRUE
  
  
END

PUBLIC SUB scan_partitions() ' useful when installing from a USB stick or preloaded partition
  
  DIM sOutput, sPart, sIsoname, sFIle, sName, sVersion, sKeypath, multisingle, multi, ReleaseID, bdate, mntpoint, configpath AS String
  DIM i AS Integer
  DIM inst AS InstallSrc
  DIM PartList AS String[]
  DIM p AS Partition
  
  FOR EACH p IN main.Partitions_In_Host
    mntpoint = Replace(p.BlockDevice, "dev", "mnt")
      IF IsDir(mntpoint) = FALSE THEN TRY MKDIR mntpoint
      SHELL "umount " & mntpoint & " 2> /dev/null" WAIT 
      SHELL "mount " & p.BlockDevice & Space(1) & mntpoint & " 2>/dev/null" WAIT 
        IF Exist(mntpoint &/ "veclinux/VINSTALL.INI") = FALSE THEN 
          SHELL "umount -f " & mntpoint & " 2>/dev/null" WAIT 
          CONTINUE 
        END IF
        inst = NEW InstallSrc
        inst.Type = "partition"
        inst.HostDevice = p.BlockDevice
        inst.Config = NEW Settings(mntpoint &/ "veclinux/VINSTALL.INI")
        inst.Name = inst.Config["general/distro"]
        inst.Version = inst.Config["general/version"]
        inst.BuildDate = inst.Config["general/build_date"]
        inst.IsISO = FALSE
        inst.ID = main.InstallMediaID
        inst.MediaID = inst.Config["general/media_id"]
        IF inst.Config["general/multi_cd"] = "1" THEN inst.MultiDisk = TRUE
        IF inst.Config["general/multi_single"] = "1" THEN inst.MultiSingle = TRUE
        inst.ReleaseID = inst.Config["general/release_id"]
        INC main.InstallMediaID
        main.InstallMedia.Push(inst)
    SHELL "umount " & mntpoint & " 2>/dev/null" WAIT 
  NEXT 
 
  
END

PUBLIC SUB probe_system_partitions()
  
  DIM sPartNo, sOutPut, sdev, spart, sfs, sSize, sdump, sdisc, sLine AS String
  DIM spre AS String
  DIM slist, partinfo, sdisks, discinfo AS string[]
  DIM p AS Partition
  
  main.Partitions_In_Host.Clear()
  SHELL "cat /proc/partitions | grep -v \"name\" | grep -v \'loop\' |grep -v \"^$\" | awk \'{print \"/dev/\"$4}' | grep -v \"[0-9]\"" TO sDump
  
  'SHELL "parted -l | grep ^Disk | cut -f2 -d \' \' | cut -f1 -d \':\'" TO sdump
  IF Len(Trim(sdump)) <= 0 THEN 
    PRINT "No hard disks found on this system .... Cannot install"
    RETURN 
  END IF
  
  sdisks = Split(Trim(sdump), gb.NewLine).Sort(gb.Ascent)
  FOR EACH sdisc IN sdisks
    SHELL "parted " & sdisc & " -s \'print\' | grep -i \'partition table:\' | cut -f2 -d \':\'" TO sdump
    IF Left(sdump, Len("Error:")) = "Error:" THEN 
      sdisks.Remove(sdisks.Find(sdisc)) ' remove empty card reader entry from disks array
      CONTINUE 
    END IF
    IF Trim(sdump) LIKE "gpt" THEN 
      SHELL "parted " & sdisc & " -s \'unit gb print\'|grep -vi swap | grep -vi \'extended\' | tr -s \' \',\"\"" TO sdump
      IF Len(Trim(sdump)) <= 0 THEN CONTINUE ' no partitions on this disc
      discinfo = Split(Trim(sdump), gb.NewLine)
        FOR EACH sLine IN discinfo
          IF Len(Trim(sLine)) <= 0 THEN CONTINUE 
          IF IsDigit(Left(Trim(sLine))) = TRUE THEN 
            partinfo = Split(Trim(sline), " ")
            p = NEW Partition
            p.BlockDevice = sdisc & PartInfo[0]
            p.RawSize = Trim(partinfo[3])
            IF partinfo.Count = 4 THEN ''' Avoid a crash because of an unformatted partition.
              p.CurrentFileSystem = "Unformatted"
            ELSE 
              p.CurrentFileSystem = Trim(partinfo[4])
            END IF
            main.Partitions_In_Host.Push(p)
          ENDIF 
        NEXT 
    ELSE ' not gpt
    SHELL "parted " & sdisc & " -s \'unit gb print\' | grep -vi swap | grep -vi \'extended\' | tr -s \' \',\"\"" TO sdump
      IF Len(Trim(sdump)) <= 0 THEN CONTINUE ' no useable partitions
    discinfo = Split(Trim(sdump), gb.NewLine)
    FOR EACH sLine IN discinfo
      IF IsDigit(Left(Trim(sline))) = TRUE THEN 
        partinfo = Split(Trim(sline), " ")
        p = NEW Partition
        p.BlockDevice = sdisc & Trim(partinfo[0])
        p.RawSize = Trim(partinfo[3])
        '''
        ' Avoid a crash when an unformatted partition is found. Achieve this by counting the number
        ' of elements in the resulting array. 
        '''
        IF partinfo.Count = 5 THEN 
        IF partinfo[partinfo.Max] LIKE "logical" OR partinfo[partinfo.Max] LIKE "primary" THEN 
          p.CurrentFileSystem = "Unformatted"
        END IF
        ELSE
        p.CurrentFileSystem = Trim(partinfo[5])
        END IF
        
        main.Partitions_In_Host.Push(p)
      END IF
    NEXT 
  END IF
  NEXT 
      
  
  
END



PUBLIC SUB FIND_ISO_INSTALL_MEDIA()
  
  DIM sOutput, sPart, sISoName, sFile, multisingle, mntpoint AS String
  DIM sName, sVersion AS String
  DIM i AS Integer
  DIM sPartList AS String[]
  DIM Inst AS InstallSrc
  DIM Multi, MedID, ReleaseID AS String
  DIM sdump, PartInfo, bdate AS String
  DIM sPartInfo AS String[]
  DIM p AS Partition
  
  MdlMain.Set_App_Status("Scanning system for ISO images")
  WAIT 0.25
  SHELL "mkdir /mnt/loop 2> /dev/null" WAIT 

  FOR EACH p IN main.Partitions_In_Host
  IF Len(p.BlockDevice) <= 0 THEN CONTINUE   
  SHELL "mount | grep ^" & p.BlockDevice & " | tr -s \' \',\'\' | cut -f3 -d \' \'" TO mntpoint
    mntpoint = Trim(mntpoint)
    IF Len(Trim(mntpoint)) <= 0 THEN mntpoint = Replace(p.BlockDevice, "dev", "mnt")
    SHELL "umount /mnt/loop 2> /dev/null" WAIT 
    SHELL "umount " & mntpoint & " 2> /dev/null" WAIT 
    SHELL "mkdir -p " & mntpoint WAIT 
    SHELL "mount -o ro " & p.BlockDevice & Space(1) & mntpoint & " 2> /dev/null " WAIT 
    MdlMain.Set_App_Status("Scanning " & p.BlockDevice) '& Space(1) & mntpoint)
    WAIT 0.125
    SHELL "mount | grep ^ " & p.BlockDevice & " |tr -s \' \',\'\' | cut -f3 -d\' \'" TO sdump
      IF Len(Trim(sdump)) <= 0 THEN 
        PRINT "WARNING: Unable to mount " & p.BlockDevice & " .. Install media from this location WILL NOT be detected."
      CONTINUE 
      END IF
    SHELL "ls " & mntpoint & " | grep .iso" TO sdump
    IF Len(Trim(sdump)) <= 0 THEN CONTINUE 
      FOR EACH sfile IN Dir(mntpoint, "*.iso")
         WAIT 0.25
         SHELL "umount /mnt/loop 2> /dev/null" WAIT
        IF Right(File.BaseName(mntpoint &/ sfile), Len("-cd2")) = "-CD2" THEN CONTINUE 
        SHELL "mount -o loop " & mntpoint &/ Trim(sfile) & Space(1) & "/mnt/loop" WAIT 
        'IF Len(Trim(sfile)) <= 0 THEN CONTINUE   
        IF Exist("/mnt/loop/veclinux/VINSTALL.INI") = FALSE THEN 
          DEBUG "No VINSTALL.INI found in " & sfile
          CONTINUE 
        END IF
        
        inst = NEW InstallSrc
        inst.Config = NEW Settings("/mnt/loop/veclinux/VINSTALL.INI")
        inst.Name = inst.Config["general/distro"]
        inst.Version = inst.Config["general/version"]
        inst.ReleaseID = inst.Config["general/release_id"]
        inst.ID = main.InstallMediaID
        inst.IsISO = TRUE
        inst.Type = "iso"
        inst.IsoName = sfile
        inst.HostDevice = p.BlockDevice
        inst.MediaID = inst.Config["general/media_id"]
        IF inst.Config["general/multi_single"] = "1" THEN inst.MultiSingle = TRUE
        IF inst.Config["general/multi_cd"] = "1" THEN inst.MultiDisk = TRUE
        inst.BuildDate = inst.Config["general/build_date"]
        INC main.InstallMediaID
        main.InstallMedia.Add(inst)
      SHELL "umount /mnt/loop 2> /dev/null" WAIT 
    NEXT 
    SHELL "umount " & mntpoint WAIT 
  NEXT 
  
END



PUBLIC FUNCTION FORMAT_THIS_PARTITION(sPartition AS String, sFilesystem AS String) AS Integer
  
  DIM hproc AS Process
  DIM sFlags AS String
  
  SELECT CASE sFilesystem
    CASE "reiserfs"
    sFlags = "-f"
  END SELECT 
  
  WAIT 1
  PRINT " --+ Formatting " & sPartition & " to " & sFilesystem
  SHELL "umount -f " & sPartition
  hproc = SHELL "mkfs." & LCase(sFilesystem) & Space(1) & sFlags & Space(1) & sPartition WAIT 
    IF hproc.Value > 0 THEN Message.Error(("Unable to format") & Space(1) & sPartition & Space(1) & ("to") & Space(1) & sFilesystem)
  RETURN hproc.Value
  
END




PUBLIC SUB NAVIGATION_LOCKDOWN()
  
    WITH FMain
      .btNext.Enabled = FALSE
      .btBack.Enabled = FALSE
      .btQuit.Enabled = FALSE
    END WITH 
    WITH FMain0
      .btNext.Enabled = FALSE
      .btBack.Enabled = FALSE
      .btQuit.Enabled = FALSE
    END WITH 
    
  
END

PUBLIC SUB NAVIGATION_RESTORE()
  
      WITH FMain
      .btNext.Enabled = TRUE
      .btBack.Enabled = TRUE
      .btQuit.Enabled = TRUE
    END WITH 
    WITH FMain0
      .btNext.Enabled = TRUE
      .btBack.Enabled = TRUE
      .btQuit.Enabled = TRUE
    END WITH 
  
END

PUBLIC SUB DISPLAY_TIME_ZONES(objLb AS ListView)
  
  DIM sList AS String
  DIM stz AS String[]
  DIM i AS Integer
  
  sList = "US/Alaska,US/Aleutian,US/Arizona,US/Central,US/East-Indiana,US/Eastern,US/Hawaii,US/Indiana-Starke, US/Michigan, US/Mountain, US/Pacific, US/Samoa, Africa/Abidjan, Africa/Accra, Africa/Addis_Ababa, Africa/Algiers, Africa/Asmera, Africa/Bamako, Africa/Bangui, Africa/Banjul, Africa/Bissau, Africa/Blantyre, Africa/Brazzaville, Africa/Bujumbura, Africa/Cairo, Africa/Casablanca, Africa/Ceuta, Africa/Conakry, Africa/Dakar, Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Douala, Africa/El_Aaiun, Africa/Freetown, Africa/Gaborone, Africa/Harare, Africa/Johannesburg, Africa/Kampala, Africa/Khartoum, Africa/Kigali, Africa/Kinshasa, Africa/Lagos, Africa/Libreville, Africa/Lome, Africa/Luanda, Africa/Lubumbashi, Africa/Lusaka, Africa/Malabo, Africa/Maputo, Africa/Maseru, Africa/Mbabane, Africa/Mogadishu, Africa/Monrovia, Africa/Nairobi, Africa/Ndjamena, Africa/Niamey, Africa/Nouakchott, Africa/Ouagadougou, Africa/Porto-Novo, Africa/Sao_Tome, Africa/Timbuktu, Africa/Tripoli, Africa/Tunis, Africa/Windhoek, America/Adak, America/Anchorage, America/Anguilla, America/Antigua, America/Araguaina, America/Aruba, America/Asuncion, America/Atka, America/Barbados, America/Belem, America/Belize, America/Boa_Vista, America/Bogota, America/Boise, America/Buenos_Aires, America/Cambridge_Bay, America/Cancun, America/Caracas, America/Catamarca, America/Cayenne, America/Cayman, America/Chicago, America/Chihuahua, America/Cordoba, America/Costa_Rica, America/Cuiaba, America/Curacao, America/Dawson, America/Dawson_Creek, America/Denver, America/Detroit, America/Dominica, America/Edmonton, America/Eirunepe, America/El_Salvador, America/Ensenada, America/Fort_Wayne, America/Fortaleza, America/Glace_Bay, America/Godthab, America/Goose_Bay, America/Grand_Turk, America/Grenada, America/Guadeloupe, America/Guatemala, America/Guayaquil, America/Guyana, America/Halifax, America/Havana, America/Hermosillo, America/Indiana/Indianapolis, America/Indiana/Knox, America/Indiana/Marengo, America/Indiana/Vevay, America/Indianapolis, America/Inuvik, America/Iqaluit, America/Jamaica, America/Jujuy, America/Juneau, America/Kentucky/Louisville, America/Kentucky/Monticello, America/Knox_IN, America/La_Paz, America/Lima, America/Los_Angeles, America/Louisville, America/Maceio, America/Managua, America/Manaus, America/Martinique, America/Mazatlan, America/Mendoza, America/Menominee, America/Merida, America/Mexico_City, America/Miquelon, America/Monterrey, America/Montevideo, America/Montreal, America/Montserrat, America/Nassau, America/New_York, America/Nipigon, America/Nome, America/Noronha, America/Panama, America/Pangnirtung, America/Paramaribo, America/Phoenix, America/Port-au-Prince, America/Port_of_Spain, America/Porto_Acre, America/Porto_Velho, America/Puerto_Rico, America/Rainy_River, America/Rankin_Inlet, America/Recife, America/Regina, America/Rosario, America/Santiago, America/Santo_Domingo, America/Sao_Paulo, America/Scoresbysund, America/Shiprock, America/St_Johns, America/St_Kitts, America/St_Lucia, America/St_Thomas, America/St_Vincent, America/Swift_Current, America/Tegucigalpa, America/Thule, America/Thunder_Bay, America/Tijuana, America/Tortola, America/Vancouver, America/Virgin, America/Whitehorse, America/Winnipeg, America/Yakutat, America/Yellowknife, Antarctica/Casey, Antarctica/Davis, Antarctica/DumontDUrville, Antarctica/Mawson, Antarctica/McMurdo, Antarctica/Palmer, Antarctica/South_Pole, Antarctica/Syowa, Arctic/Longyearbyen," &
"Asia/Aden, Asia/Almaty, Asia/Amman, Asia/Anadyr, Asia/Aqtau, Asia/Aqtobe, Asia/Ashgabat, Asia/Ashkhabad, Asia/Baghdad, Asia/Bahrain, Asia/Baku, Asia/Bangkok, Asia/Beirut, Asia/Bishkek, Asia/Brunei,Asia/Calcutta,Asia/Chungking,Asia/Colombo,Asia/Dacca,Asia/Damascus,Asia/Dhaka,Asia/Dili,Asia/Dubai,Asia/Dushanbe,Asia/Gaza,Asia/Harbin,Asia/Hong_Kong,Asia/Hovd,Asia/Irkutsk,Asia/Istanbul,Asia/Jakarta,Asia/Jayapura,Asia/Jerusalem,Asia/Kabul,Asia/Kamchatka,Asia/Karachi,Asia/Kashgar,Asia/Katmandu,Asia/Krasnoyarsk,Asia/Kuala_Lumpur,Asia/Kuching,Asia/Kuwait,Asia/Macao,Asia/Macau,Asia/Magadan,Asia/Makassar,Asia/Manila,Asia/Muscat,Asia/Nicosia,Asia/Novosibirsk,Asia/Omsk,Asia/Oral,Asia/Phnom_Penh,Asia/Pyongyang,Asia/Qatar,Asia/Qyzylorda,Asia/Rangoon,Asia/Riyadh,Asia/Riyadh87,Asia/Riyadh88,Asia/Riyadh89,Asia/Saigon,Asia/Samarkand,Asia/Seoul,Asia/Shanghai,Asia/Singapore,Asia/Taipei,Asia/Tashkent,Asia/Tbilisi,Asia/Tehran,Asia/Tel_Aviv,Asia/Thimbu,Asia/Thimphu,Asia/Tokyo,Asia/Ujung_Pandang,Asia/Ulaanbaatar,Asia/Ulan_Bator,Asia/Urumqi,Asia/Vientiane,Asia/Vladivostok,Asia/Yakutsk,Asia/Yekaterinburg,Asia/Yerevan,Atlantic/Azores,Atlantic/Bermuda,Atlantic/Canary,Atlantic/Cape_Verde,Atlantic/Faeroe,Atlantic/Jan_Mayen,Atlantic/Madeira,Atlantic/Reykjavik,Atlantic/South_Georgia,Atlantic/St_Helena,Atlantic/Stanley,Australia/ACT,Australia/Adelaide,Australia/Brisbane,Australia/Broken_Hill,Australia/Canberra,Australia/Darwin,Australia/Hobart,Australia/LHI,Australia/Lindeman,Australia/Lord_Howe,Australia/Melbourne,Australia/NSW,Australia/North,Australia/Perth,Australia/Queensland,Australia/South,Australia/Sydney,Australia/Tasmania,Australia/Victoria,Australia/West,Australia/Yancowinna,Brazil/Acre,Brazil/DeNoronha,Brazil/East,Brazil/West,CET,CST6CDT,Canada/Atlantic,Canada/Central,Canada/East-Saskatchewan,Canada/Eastern,Canada/Mountain,Canada/Newfoundland,Canada/Pacific,Canada/Saskatchewan,Canada/Yukon,Chile/Continental,Chile/EasterIsland,Cuba,EET,EST,EST5EDT,Egypt,Eire,Etc/GMT,Etc/GMT+0,Etc/GMT+1,Etc/GMT+10,Etc/GMT+11,Etc/GMT+12,Etc/GMT+2,Etc/GMT+3,Etc/GMT+4,Etc/GMT+5,Etc/GMT+6,Etc/GMT+7,Etc/GMT+8,Etc/GMT+9,Etc/GMT-0,Etc/GMT-1,Etc/GMT-10,Etc/GMT-11,Etc/GMT-12,Etc/GMT-13,Etc/GMT-14,Etc/GMT-2,Etc/GMT-3,Etc/GMT-4,Etc/GMT-5,Etc/GMT-6,Etc/GMT-7,Etc/GMT-8,Etc/GMT-9,Etc/GMT0,Etc/Greenwich,Etc/UCT,Etc/UTC,Etc/Universal,Etc/Zulu,Europe/Amsterdam,Europe/Andorra,Europe/Athens,Europe/Belfast,Europe/Belgrade,Europe/Berlin,Europe/Bratislava,Europe/Brussels,Europe/Bucharest,Europe/Budapest,Europe/Chisinau,Europe/Copenhagen,Europe/Dublin,Europe/Gibraltar,Europe/Helsinki,Europe/Istanbul,Europe/Kaliningrad,Europe/Kiev,Europe/Lisbon,Europe/Ljubljana,Europe/London,Europe/Luxembourg,Europe/Madrid,Europe/Malta,Europe/Minsk,Europe/Monaco,Europe/Moscow,Europe/Nicosia,Europe/Oslo,Europe/Paris,Europe/Prague,Europe/Riga,Europe/Rome,Europe/Samara,Europe/San_Marino,Europe/Sarajevo,Europe/Simferopol,Europe/Skopje,Europe/Sofia,Europe/Stockholm,Europe/Tallinn,Europe/Tirane,Europe/Tiraspol,Europe/Uzhgorod,Europe/Vaduz,Europe/Vatican,Europe/Vienna,Europe/Vilnius,Europe/Warsaw,Europe/Zagreb,Europe/Zaporozhye,Europe/Zurich,Factory,GB,GB-Eire,GMT,GMT+0,GMT-0,GMT0,Greenwich,HST,Hongkong,Iceland,Indian/Antananarivo,Indian/Chagos,Indian/Christmas,Indian/Cocos,Indian/Comoro,Indian/Kerguelen,Indian/Mahe,Indian/Maldives,Indian/Mauritius,Indian/Mayotte,Indian/Reunion," &
"Iran,Israel,Jamaica,Japan,Kwajalein,Libya,MET,MST,MST7MDT,Mexico/BajaNorte,Mexico/BajaSur,Mexico/General,Mideast/Riyadh87,Mideast/Riyadh88,Mideast/Riyadh89,NZ,NZ-CHAT,Navajo,PRC,PST8PDT,Pacific/Apia,Pacific/Auckland,Pacific/Chatham,Pacific/Easter,Pacific/Efate,Pacific/Enderbury,Pacific/Fakaofo,Pacific/Fiji,Pacific/Funafuti,Pacific/Galapagos,Pacific/Gambier,Pacific/Guadalcanal,Pacific/Guam,Pacific/Honolulu,Pacific/Johnston,Pacific/Kiritimati,Pacific/Kosrae,Pacific/Kwajalein,Pacific/Majuro,Pacific/Marquesas,Pacific/Midway,Pacific/Nauru,Pacific/Niue,Pacific/Norfolk,Pacific/Noumea,Pacific/Pago_Pago,Pacific/Palau,Pacific/Pitcairn,Pacific/Ponape,Pacific/Port_Moresby,Pacific/Rarotonga,Pacific/Saipan,Pacific/Samoa,Pacific/Tahiti,Pacific/Tarawa,Pacific/Tongatapu,Pacific/Truk,Pacific/Wake,Pacific/Wallis,Pacific/Yap,Poland,Portugal,ROC,ROK,Singapore,SystemV/AST4,SystemV/AST4ADT,SystemV/CST6,SystemV/CST6CDT,SystemV/EST5,SystemV/EST5EDT,SystemV/HST10,SystemV/MST7,SystemV/MST7MDT,SystemV/PST8,SystemV/PST8PDT,SystemV/YST9,SystemV/YST9YDT,Turkey,UCT,UTC,Universal,W-SU,WET,Zulu,posix/Africa/Abidjan,posix/Africa/Accra,posix/Africa/Addis_Ababa,posix/Africa/Algiers,posix/Africa/Asmera,posix/Africa/Bamako,posix/Africa/Bangui,posix/Africa/Banjul,posix/Africa/Bissau,posix/Africa/Blantyre,posix/Africa/Brazzaville,posix/Africa/Bujumbura,posix/Africa/Cairo,posix/Africa/Casablanca,posix/Africa/Ceuta,posix/Africa/Conakry,posix/Africa/Dakar,posix/Africa/Dar_es_Salaam,posix/Africa/Djibouti,posix/Africa/Douala,posix/Africa/El_Aaiun,posix/Africa/Freetown,posix/Africa/Gaborone,posix/Africa/Harare,posix/Africa/Johannesburg,posix/Africa/Kampala,posix/Africa/Khartoum,posix/Africa/Kigali,posix/Africa/Kinshasa,posix/Africa/Lagos,posix/Africa/Libreville,posix/Africa/Lome,posix/Africa/Luanda,posix/Africa/Lubumbashi,posix/Africa/Lusaka,posix/Africa/Malabo,posix/Africa/Maputo,posix/Africa/Maseru,posix/Africa/Mbabane,posix/Africa/Mogadishu,posix/Africa/Monrovia,posix/Africa/Nairobi,posix/Africa/Ndjamena,posix/Africa/Niamey,posix/Africa/Nouakchott,posix/Africa/Ouagadougou,posix/Africa/Porto-Novo,posix/Africa/Sao_Tome,posix/Africa/Timbuktu,posix/Africa/Tripoli,posix/Africa/Tunis,posix/Africa/Windhoek,posix/America/Adak,posix/America/Anchorage,posix/America/Anguilla,posix/America/Antigua,posix/America/Araguaina,posix/America/Aruba,posix/America/Asuncion,posix/America/Atka,posix/America/Barbados,posix/America/Belem,posix/America/Belize,posix/America/Boa_Vista,posix/America/Bogota,posix/America/Boise,posix/America/Buenos_Aires,posix/America/Cambridge_Bay,posix/America/Cancun,posix/America/Caracas,posix/America/Catamarca,posix/America/Cayenne,posix/America/Cayman,posix/America/Chicago,posix/America/Chihuahua,posix/America/Cordoba,posix/America/Costa_Rica,posix/America/Cuiaba,posix/America/Curacao,posix/America/Dawson,posix/America/Dawson_Creek,posix/America/Denver,posix/America/Detroit,posix/America/Dominica,posix/America/Edmonton,posix/America/Eirunepe,posix/America/El_Salvador,posix/America/Ensenada,posix/America/Fort_Wayne,posix/America/Fortaleza,posix/America/Glace_Bay,posix/America/Godthab,posix/America/Goose_Bay,posix/America/Grand_Turk,posix/America/Grenada,posix/America/Guadeloupe,posix/America/Guatemala,posix/America/Guayaquil,posix/America/Guyana,posix/America/Halifax,posix/America/Havana,posix/America/Hermosillo,posix/America/Indiana/Indianapolis,posix/America/Indiana/Knox," &
"posix/America/Indiana/Marengo,posix/America/Indiana/Vevay,posix/America/Indianapolis,posix/America/Inuvik,posix/America/Iqaluit,posix/America/Jamaica,posix/America/Jujuy,posix/America/Juneau,posix/America/Kentucky/Louisville,posix/America/Kentucky/Monticello,posix/America/Knox_IN,posix/America/La_Paz,posix/America/Lima,posix/America/Los_Angeles,posix/America/Louisville,posix/America/Maceio,posix/America/Managua,posix/America/Manaus,posix/America/Martinique,posix/America/Mazatlan,posix/America/Mendoza,posix/America/Menominee,posix/America/Merida,posix/America/Mexico_City,posix/America/Miquelon,posix/America/Monterrey,posix/America/Montevideo,posix/America/Montreal,posix/America/Montserrat,posix/America/Nassau,posix/America/New_York,posix/America/Nipigon,posix/America/Nome,posix/America/Noronha,posix/America/Panama,posix/America/Pangnirtung,posix/America/Paramaribo,posix/America/Phoenix,posix/America/Port-au-Prince,posix/America/Port_of_Spain,posix/America/Porto_Acre,posix/America/Porto_Velho,posix/America/Puerto_Rico,posix/America/Rainy_River,posix/America/Rankin_Inlet,posix/America/Recife,posix/America/Regina,posix/America/Rosario,posix/America/Santiago,posix/America/Santo_Domingo,posix/America/Sao_Paulo,posix/America/Scoresbysund,posix/America/Shiprock,posix/America/St_Johns,posix/America/St_Kitts,posix/America/St_Lucia,posix/America/St_Thomas,posix/America/St_Vincent,posix/America/Swift_Current,posix/America/Tegucigalpa,posix/America/Thule,posix/America/Thunder_Bay,posix/America/Tijuana,posix/America/Tortola,posix/America/Vancouver,posix/America/Virgin,posix/America/Whitehorse,posix/America/Winnipeg,posix/America/Yakutat,posix/America/Yellowknife,posix/Antarctica/Casey,posix/Antarctica/Davis,posix/Antarctica/DumontDUrville,posix/Antarctica/Mawson,posix/Antarctica/McMurdo,posix/Antarctica/Palmer,posix/Antarctica/South_Pole,posix/Antarctica/Syowa,posix/Arctic/Longyearbyen,posix/Asia/Aden,posix/Asia/Almaty,posix/Asia/Amman,posix/Asia/Anadyr,posix/Asia/Aqtau,posix/Asia/Aqtobe,posix/Asia/Ashgabat,posix/Asia/Ashkhabad,posix/Asia/Baghdad,posix/Asia/Bahrain,posix/Asia/Baku,posix/Asia/Bangkok,posix/Asia/Beirut,posix/Asia/Bishkek,posix/Asia/Brunei,posix/Asia/Calcutta,posix/Asia/Chungking,posix/Asia/Colombo,posix/Asia/Dacca,posix/Asia/Damascus,posix/Asia/Dhaka,posix/Asia/Dili,posix/Asia/Dubai,posix/Asia/Dushanbe,posix/Asia/Gaza,posix/Asia/Harbin,posix/Asia/Hong_Kong,posix/Asia/Hovd,posix/Asia/Irkutsk,posix/Asia/Istanbul,posix/Asia/Jakarta,posix/Asia/Jayapura,posix/Asia/Jerusalem,posix/Asia/Kabul,posix/Asia/Kamchatka,posix/Asia/Karachi,posix/Asia/Kashgar,posix/Asia/Katmandu,posix/Asia/Krasnoyarsk,posix/Asia/Kuala_Lumpur,posix/Asia/Kuching,posix/Asia/Kuwait,posix/Asia/Macao,posix/Asia/Macau,posix/Asia/Magadan,posix/Asia/Makassar,posix/Asia/Manila,posix/Asia/Muscat,posix/Asia/Nicosia,posix/Asia/Novosibirsk,posix/Asia/Omsk,posix/Asia/Oral,posix/Asia/Phnom_Penh,posix/Asia/Pyongyang,posix/Asia/Qatar,posix/Asia/Qyzylorda,posix/Asia/Rangoon,posix/Asia/Riyadh,posix/Asia/Riyadh87,posix/Asia/Riyadh88,posix/Asia/Riyadh89,posix/Asia/Saigon,posix/Asia/Samarkand,posix/Asia/Seoul,posix/Asia/Shanghai,posix/Asia/Singapore,posix/Asia/Taipei,posix/Asia/Tashkent,posix/Asia/Tbilisi,posix/Asia/Tehran,posix/Asia/Tel_Aviv,posix/Asia/Thimbu,posix/Asia/Thimphu,posix/Asia/Tokyo,posix/Asia/Ujung_Pandang,posix/Asia/Ulaanbaatar,posix/Asia/Ulan_Bator,posix/Asia/Urumqi,posix/Asia/Vientiane," &
"posix/Asia/Vladivostok,posix/Asia/Yakutsk,posix/Asia/Yekaterinburg,posix/Asia/Yerevan,posix/Atlantic/Azores,posix/Atlantic/Bermuda,posix/Atlantic/Canary,posix/Atlantic/Cape_Verde,posix/Atlantic/Faeroe,posix/Atlantic/Jan_Mayen,posix/Atlantic/Madeira,posix/Atlantic/Reykjavik,posix/Atlantic/South_Georgia,posix/Atlantic/St_Helena,posix/Atlantic/Stanley,posix/Australia/ACT,posix/Australia/Adelaide,posix/Australia/Brisbane,posix/Australia/Broken_Hill,posix/Australia/Canberra,posix/Australia/Darwin,posix/Australia/Hobart,posix/Australia/LHI,posix/Australia/Lindeman,posix/Australia/Lord_Howe,posix/Australia/Melbourne,posix/Australia/NSW,posix/Australia/North,posix/Australia/Perth,posix/Australia/Queensland,posix/Australia/South,posix/Australia/Sydney,posix/Australia/Tasmania,posix/Australia/Victoria,posix/Australia/West,posix/Australia/Yancowinna,posix/Brazil/Acre,posix/Brazil/DeNoronha,posix/Brazil/East,posix/Brazil/West,posix/CET,posix/CST6CDT,posix/Canada/Atlantic,posix/Canada/Central,posix/Canada/East-Saskatchewan,posix/Canada/Eastern,posix/Canada/Mountain,posix/Canada/Newfoundland,posix/Canada/Pacific,posix/Canada/Saskatchewan,posix/Canada/Yukon,posix/Chile/Continental,posix/Chile/EasterIsland,posix/Cuba,posix/EET,posix/EST,posix/EST5EDT,posix/Egypt,posix/Eire,posix/Etc/GMT,posix/Etc/GMT+0,posix/Etc/GMT+1,posix/Etc/GMT+10,posix/Etc/GMT+11,posix/Etc/GMT+12,posix/Etc/GMT+2,posix/Etc/GMT+3,posix/Etc/GMT+4,posix/Etc/GMT+5,posix/Etc/GMT+6,posix/Etc/GMT+7,posix/Etc/GMT+8,posix/Etc/GMT+9,posix/Etc/GMT-0,posix/Etc/GMT-1,posix/Etc/GMT-10,posix/Etc/GMT-11,posix/Etc/GMT-12,posix/Etc/GMT-13,posix/Etc/GMT-14,posix/Etc/GMT-2,posix/Etc/GMT-3,posix/Etc/GMT-4,posix/Etc/GMT-5,posix/Etc/GMT-6,posix/Etc/GMT-7,posix/Etc/GMT-8,posix/Etc/GMT-9,posix/Etc/GMT0,posix/Etc/Greenwich,posix/Etc/UCT,posix/Etc/UTC,posix/Etc/Universal,posix/Etc/Zulu,posix/Europe/Amsterdam,posix/Europe/Andorra,posix/Europe/Athens,posix/Europe/Belfast,posix/Europe/Belgrade,posix/Europe/Berlin,posix/Europe/Bratislava,posix/Europe/Brussels,posix/Europe/Bucharest,posix/Europe/Budapest,posix/Europe/Chisinau,posix/Europe/Copenhagen,posix/Europe/Dublin,posix/Europe/Gibraltar,posix/Europe/Helsinki,posix/Europe/Istanbul,posix/Europe/Kaliningrad,posix/Europe/Kiev,posix/Europe/Lisbon,posix/Europe/Ljubljana,posix/Europe/London,posix/Europe/Luxembourg,posix/Europe/Madrid,posix/Europe/Malta,posix/Europe/Minsk,posix/Europe/Monaco,posix/Europe/Moscow,posix/Europe/Nicosia,posix/Europe/Oslo,posix/Europe/Paris,posix/Europe/Prague,posix/Europe/Riga,posix/Europe/Rome,posix/Europe/Samara,posix/Europe/San_Marino,posix/Europe/Sarajevo,posix/Europe/Simferopol,posix/Europe/Skopje,posix/Europe/Sofia,posix/Europe/Stockholm,posix/Europe/Tallinn,posix/Europe/Tirane,posix/Europe/Tiraspol,posix/Europe/Uzhgorod,posix/Europe/Vaduz,posix/Europe/Vatican,posix/Europe/Vienna,posix/Europe/Vilnius,posix/Europe/Warsaw,posix/Europe/Zagreb,posix/Europe/Zaporozhye,posix/Europe/Zurich,posix/Factory,posix/GB,posix/GB-Eire,posix/GMT,posix/GMT+0,posix/GMT-0,posix/GMT0,posix/Greenwich,posix/HST,posix/Hongkong,posix/Iceland,posix/Indian/Antananarivo,posix/Indian/Chagos,posix/Indian/Christmas,posix/Indian/Cocos,posix/Indian/Comoro,posix/Indian/Kerguelen,posix/Indian/Mahe,posix/Indian/Maldives,posix/Indian/Mauritius,posix/Indian/Mayotte,posix/Indian/Reunion,posix/Iran,posix/Israel,posix/Jamaica,posix/Japan,posix/Kwajalein,posix/Libya,posix/MET,posix/MST,posix/MST7MDT," &
"posix/Mexico/BajaNorte,posix/Mexico/BajaSur,posix/Mexico/General,posix/Mideast/Riyadh87,posix/Mideast/Riyadh88,posix/Mideast/Riyadh89,posix/NZ,posix/NZ-CHAT,posix/Navajo,posix/PRC,posix/PST8PDT,posix/Pacific/Apia,posix/Pacific/Auckland,posix/Pacific/Chatham,posix/Pacific/Easter,posix/Pacific/Efate,posix/Pacific/Enderbury,posix/Pacific/Fakaofo,posix/Pacific/Fiji,posix/Pacific/Funafuti,posix/Pacific/Galapagos,posix/Pacific/Gambier,posix/Pacific/Guadalcanal,posix/Pacific/Guam,posix/Pacific/Honolulu,posix/Pacific/Johnston,posix/Pacific/Kiritimati,posix/Pacific/Kosrae,posix/Pacific/Kwajalein,posix/Pacific/Majuro,posix/Pacific/Marquesas,posix/Pacific/Midway,posix/Pacific/Nauru,posix/Pacific/Niue,posix/Pacific/Norfolk,posix/Pacific/Noumea,posix/Pacific/Pago_Pago,posix/Pacific/Palau,posix/Pacific/Pitcairn,posix/Pacific/Ponape,posix/Pacific/Port_Moresby,posix/Pacific/Rarotonga,posix/Pacific/Saipan,posix/Pacific/Samoa,posix/Pacific/Tahiti,posix/Pacific/Tarawa,posix/Pacific/Tongatapu,posix/Pacific/Truk,posix/Pacific/Wake,posix/Pacific/Wallis,posix/Pacific/Yap,posix/Poland,posix/Portugal,posix/ROC,posix/ROK,posix/Singapore,posix/SystemV/AST4,posix/SystemV/AST4ADT,posix/SystemV/CST6,posix/SystemV/CST6CDT,posix/SystemV/EST5,posix/SystemV/EST5EDT,posix/SystemV/HST10,posix/SystemV/MST7,posix/SystemV/MST7MDT,posix/SystemV/PST8,posix/SystemV/PST8PDT,posix/SystemV/YST9,posix/SystemV/YST9YDT,posix/Turkey,posix/UCT,posix/US/Alaska,posix/US/Aleutian,posix/US/Arizona,posix/US/Central,posix/US/East-Indiana,posix/US/Eastern,posix/US/Hawaii,posix/US/Indiana-Starke,posix/US/Michigan,posix/US/Mountain,posix/US/Pacific,posix/US/Samoa,posix/UTC,posix/Universal,posix/W-SU,posix/WET,posix/Zulu,posixrules,right/Africa/Abidjan,right/Africa/Accra,right/Africa/Addis_Ababa,right/Africa/Algiers,right/Africa/Asmera,right/Africa/Bamako,right/Africa/Bangui,right/Africa/Banjul,right/Africa/Bissau,right/Africa/Blantyre,right/Africa/Brazzaville,right/Africa/Bujumbura,right/Africa/Cairo,right/Africa/Casablanca,right/Africa/Ceuta,right/Africa/Conakry,right/Africa/Dakar,right/Africa/Dar_es_Salaam,right/Africa/Djibouti,right/Africa/Douala,right/Africa/El_Aaiun,right/Africa/Freetown,right/Africa/Gaborone,right/Africa/Harare,right/Africa/Johannesburg,right/Africa/Kampala,right/Africa/Khartoum,right/Africa/Kigali,right/Africa/Kinshasa,right/Africa/Lagos,right/Africa/Libreville,right/Africa/Lome,right/Africa/Luanda,right/Africa/Lubumbashi,right/Africa/Lusaka,right/Africa/Malabo,right/Africa/Maputo,right/Africa/Maseru,right/Africa/Mbabane,right/Africa/Mogadishu,right/Africa/Monrovia,right/Africa/Nairobi,right/Africa/Ndjamena,right/Africa/Niamey,right/Africa/Nouakchott,right/Africa/Ouagadougou,right/Africa/Porto-Novo,right/Africa/Sao_Tome,right/Africa/Timbuktu,right/Africa/Tripoli,right/Africa/Tunis,right/Africa/Windhoek,right/America/Adak,right/America/Anchorage,right/America/Anguilla,right/America/Antigua,right/America/Araguaina,right/America/Aruba,right/America/Asuncion,right/America/Atka,right/America/Barbados,right/America/Belem,right/America/Belize,right/America/Boa_Vista,right/America/Bogota,right/America/Boise,right/America/Buenos_Aires,right/America/Cambridge_Bay,right/America/Cancun,right/America/Caracas,right/America/Catamarca,right/America/Cayenne,right/America/Cayman,right/America/Chicago,right/America/Chihuahua,right/America/Cordoba,right/America/Costa_Rica,right/America/Cuiaba,right/America/Curacao,right/America/Dawson,right/America/Dawson_Creek,right/America/Denver,right/America/Detroit," &
"right/America/Dominica,right/America/Edmonton,right/America/Eirunepe,right/America/El_Salvador,right/America/Ensenada,right/America/Fort_Wayne,right/America/Fortaleza,right/America/Glace_Bay,right/America/Godthab,right/America/Goose_Bay,right/America/Grand_Turk,right/America/Grenada,right/America/Guadeloupe,right/America/Guatemala,right/America/Guayaquil,right/America/Guyana,right/America/Halifax,right/America/Havana,right/America/Hermosillo,right/America/Indiana/Indianapolis,right/America/Indiana/Knox,right/America/Indiana/Marengo,right/America/Indiana/Vevay,right/America/Indianapolis,right/America/Inuvik,right/America/Iqaluit,right/America/Jamaica,right/America/Jujuy,right/America/Juneau,right/America/Kentucky/Louisville,right/America/Kentucky/Monticello,right/America/Knox_IN,right/America/La_Paz,right/America/Lima,right/America/Los_Angeles,right/America/Louisville,right/America/Maceio,right/America/Managua,right/America/Manaus,right/America/Martinique,right/America/Mazatlan,right/America/Mendoza,right/America/Menominee,right/America/Merida,right/America/Mexico_City,right/America/Miquelon,right/America/Monterrey,right/America/Montevideo,right/America/Montreal,right/America/Montserrat,right/America/Nassau,right/America/New_York,right/America/Nipigon,right/America/Nome,right/America/Noronha,right/America/Panama,right/America/Pangnirtung,right/America/Paramaribo,right/America/Phoenix,right/America/Port-au-Prince,right/America/Port_of_Spain,right/America/Porto_Acre,right/America/Porto_Velho,right/America/Puerto_Rico,right/America/Rainy_River,right/America/Rankin_Inlet,right/America/Recife,right/America/Regina,right/America/Rosario,right/America/Santiago,right/America/Santo_Domingo,right/America/Sao_Paulo,right/America/Scoresbysund,right/America/Shiprock,right/America/St_Johns,right/America/St_Kitts,right/America/St_Lucia,right/America/St_Thomas,right/America/St_Vincent,right/America/Swift_Current,right/America/Tegucigalpa,right/America/Thule,right/America/Thunder_Bay,right/America/Tijuana,right/America/Tortola,right/America/Vancouver,right/America/Virgin,right/America/Whitehorse,right/America/Winnipeg,right/America/Yakutat,right/America/Yellowknife,right/Antarctica/Casey,right/Antarctica/Davis,right/Antarctica/DumontDUrville,right/Antarctica/Mawson,right/Antarctica/McMurdo,right/Antarctica/Palmer,right/Antarctica/South_Pole,right/Antarctica/Syowa,right/Arctic/Longyearbyen,right/Asia/Aden,right/Asia/Almaty,right/Asia/Amman,right/Asia/Anadyr,right/Asia/Aqtau,right/Asia/Aqtobe,right/Asia/Ashgabat,right/Asia/Ashkhabad,right/Asia/Baghdad,right/Asia/Bahrain,right/Asia/Baku,right/Asia/Bangkok,right/Asia/Beirut,right/Asia/Bishkek,right/Asia/Brunei,right/Asia/Calcutta,right/Asia/Chungking,right/Asia/Colombo,right/Asia/Dacca,right/Asia/Damascus,right/Asia/Dhaka,right/Asia/Dili,right/Asia/Dubai,right/Asia/Dushanbe,right/Asia/Gaza,right/Asia/Harbin,right/Asia/Hong_Kong,right/Asia/Hovd,right/Asia/Irkutsk,right/Asia/Istanbul,right/Asia/Jakarta,right/Asia/Jayapura,right/Asia/Jerusalem,right/Asia/Kabul,right/Asia/Kamchatka,right/Asia/Karachi,right/Asia/Kashgar,right/Asia/Katmandu,right/Asia/Krasnoyarsk,right/Asia/Kuala_Lumpur,right/Asia/Kuching,right/Asia/Kuwait,right/Asia/Macao,right/Asia/Macau,right/Asia/Magadan,right/Asia/Makassar,right/Asia/Manila,right/Asia/Muscat,right/Asia/Nicosia,right/Asia/Novosibirsk,right/Asia/Omsk,right/Asia/Oral,right/Asia/Phnom_Penh,right/Asia/Pyongyang,right/Asia/Qatar,right/Asia/Qyzylorda,right/Asia/Rangoon,right/Asia/Riyadh,right/Asia/Riyadh87," &
"right/Asia/Riyadh88,right/Asia/Riyadh89,right/Asia/Saigon,right/Asia/Samarkand,right/Asia/Seoul,right/Asia/Shanghai,right/Asia/Singapore,right/Asia/Taipei,right/Asia/Tashkent,right/Asia/Tbilisi,right/Asia/Tehran,right/Asia/Tel_Aviv,right/Asia/Thimbu,right/Asia/Thimphu,right/Asia/Tokyo,right/Asia/Ujung_Pandang,right/Asia/Ulaanbaatar,right/Asia/Ulan_Bator,right/Asia/Urumqi,right/Asia/Vientiane,right/Asia/Vladivostok,right/Asia/Yakutsk,right/Asia/Yekaterinburg,right/Asia/Yerevan,right/Atlantic/Azores,right/Atlantic/Bermuda,right/Atlantic/Canary,right/Atlantic/Cape_Verde,right/Atlantic/Faeroe,right/Atlantic/Jan_Mayen,right/Atlantic/Madeira,right/Atlantic/Reykjavik,right/Atlantic/South_Georgia,right/Atlantic/St_Helena,right/Atlantic/Stanley,right/Australia/ACT,right/Australia/Adelaide,right/Australia/Brisbane,right/Australia/Broken_Hill,right/Australia/Canberra,right/Australia/Darwin,right/Australia/Hobart,right/Australia/LHI,right/Australia/Lindeman,right/Australia/Lord_Howe,right/Australia/Melbourne,right/Australia/NSW,right/Australia/North,right/Australia/Perth,right/Australia/Queensland,right/Australia/South,right/Australia/Sydney,right/Australia/Tasmania,right/Australia/Victoria,right/Australia/West,right/Australia/Yancowinna,right/Brazil/Acre,right/Brazil/DeNoronha,right/Brazil/East,right/Brazil/West,right/CET,right/CST6CDT,right/Canada/Atlantic,right/Canada/Central,right/Canada/East-Saskatchewan,right/Canada/Eastern,right/Canada/Mountain,right/Canada/Newfoundland,right/Canada/Pacific,right/Canada/Saskatchewan,right/Canada/Yukon,right/Chile/Continental,right/Chile/EasterIsland,right/Cuba,right/EET,right/EST,right/EST5EDT,right/Egypt,right/Eire,right/Etc/GMT,right/Etc/GMT+0,right/Etc/GMT+1,right/Etc/GMT+10,right/Etc/GMT+11,right/Etc/GMT+12,right/Etc/GMT+2,right/Etc/GMT+3,right/Etc/GMT+4,right/Etc/GMT+5,right/Etc/GMT+6,right/Etc/GMT+7,right/Etc/GMT+8,right/Etc/GMT+9,right/Etc/GMT-0,right/Etc/GMT-1,right/Etc/GMT-10,right/Etc/GMT-11,right/Etc/GMT-12,right/Etc/GMT-13,right/Etc/GMT-14,right/Etc/GMT-2,right/Etc/GMT-3,right/Etc/GMT-4,right/Etc/GMT-5,right/Etc/GMT-6,right/Etc/GMT-7,right/Etc/GMT-8,right/Etc/GMT-9,right/Etc/GMT0,right/Etc/Greenwich,right/Etc/UCT,right/Etc/UTC,right/Etc/Universal,right/Etc/Zulu,right/Europe/Amsterdam,right/Europe/Andorra,right/Europe/Athens,right/Europe/Belfast,right/Europe/Belgrade,right/Europe/Berlin,right/Europe/Bratislava,right/Europe/Brussels,right/Europe/Bucharest,right/Europe/Budapest,right/Europe/Chisinau,right/Europe/Copenhagen,right/Europe/Dublin,right/Europe/Gibraltar,right/Europe/Helsinki,right/Europe/Istanbul,right/Europe/Kaliningrad,right/Europe/Kiev,right/Europe/Lisbon,right/Europe/Ljubljana,right/Europe/London,right/Europe/Luxembourg,right/Europe/Madrid,right/Europe/Malta,right/Europe/Minsk,right/Europe/Monaco,right/Europe/Moscow,right/Europe/Nicosia,right/Europe/Oslo,right/Europe/Paris,right/Europe/Prague,right/Europe/Riga,right/Europe/Rome,right/Europe/Samara,right/Europe/San_Marino,right/Europe/Sarajevo,right/Europe/Simferopol,right/Europe/Skopje,right/Europe/Sofia,right/Europe/Stockholm,right/Europe/Tallinn,right/Europe/Tirane,right/Europe/Tiraspol,right/Europe/Uzhgorod,right/Europe/Vaduz,right/Europe/Vatican,right/Europe/Vienna,right/Europe/Vilnius,right/Europe/Warsaw,right/Europe/Zagreb,right/Europe/Zaporozhye,right/Europe/Zurich,right/Factory,right/GB,right/GB-Eire,right/GMT,right/GMT+0,right/GMT-0,right/GMT0,right/Greenwich,right/HST,right/Hongkong,right/Iceland,right/Indian/Antananarivo,right/Indian/Chagos,right/Indian/Christmas,right/Indian/Cocos,right/Indian/Comoro,right/Indian/Kerguelen," &
"right/Indian/Mahe,right/Indian/Maldives,right/Indian/Mauritius,right/Indian/Mayotte,right/Indian/Reunion,right/Iran,right/Israel,right/Jamaica,right/Japan,right/Kwajalein,right/Libya,right/MET,right/MST,right/MST7MDT,right/Mexico/BajaNorte,right/Mexico/BajaSur,right/Mexico/General,right/Mideast/Riyadh87,right/Mideast/Riyadh88,right/Mideast/Riyadh89,right/NZ,right/NZ-CHAT,right/Navajo,right/PRC,right/PST8PDT,right/Pacific/Apia,right/Pacific/Auckland,right/Pacific/Chatham,right/Pacific/Easter,right/Pacific/Efate,right/Pacific/Enderbury,right/Pacific/Fakaofo,right/Pacific/Fiji,right/Pacific/Funafuti,right/Pacific/Galapagos,right/Pacific/Gambier,right/Pacific/Guadalcanal,right/Pacific/Guam,right/Pacific/Honolulu,right/Pacific/Johnston,right/Pacific/Kiritimati,right/Pacific/Kosrae,right/Pacific/Kwajalein,right/Pacific/Majuro,right/Pacific/Marquesas,right/Pacific/Midway,right/Pacific/Nauru,right/Pacific/Niue,right/Pacific/Norfolk,right/Pacific/Noumea,right/Pacific/Pago_Pago,right/Pacific/Palau,right/Pacific/Pitcairn,right/Pacific/Ponape,right/Pacific/Port_Moresby,right/Pacific/Rarotonga,right/Pacific/Saipan,right/Pacific/Samoa,right/Pacific/Tahiti,right/Pacific/Tarawa,right/Pacific/Tongatapu,right/Pacific/Truk,right/Pacific/Wake,right/Pacific/Wallis,right/Pacific/Yap,right/Poland,right/Portugal,right/ROC,right/ROK,right/Singapore,right/SystemV/AST4,right/SystemV/AST4ADT,right/SystemV/CST6,right/SystemV/CST6CDT,right/SystemV/EST5,right/SystemV/EST5EDT,right/SystemV/HST10,right/SystemV/MST7,right/SystemV/MST7MDT,right/SystemV/PST8,right/SystemV/PST8PDT,right/SystemV/YST9,right/SystemV/YST9YDT,right/Turkey,right/UCT,right/US/Alaska,right/US/Aleutian,right/US/Arizona,right/US/Central,right/US/East-Indiana,right/US/Eastern,right/US/Hawaii,right/US/Indiana-Starke,right/US/Michigan,right/US/Mountain,right/US/Pacific,right/US/Samoa,right/UTC,right/Universal,right/W-SU,right/WET,right/Zulu"



  stz = Split(Trim(sList), ",")

  FOR i = 0 TO stz.Max
    'objLb.Add(Trim(stz[i]))
TRY objLb.Add(Trim(stz[i]), Trim(stz[i]))
  NEXT 
  
END

PUBLIC SUB SET_TIME_ZONE(sTimeZone AS String, hwclock AS String)
  DIM sTarget AS String = main.Install.TargetMount
  DIM sCfg AS String
  
  EXEC ["rm", sTarget &/ "etc" &/ "localtime-copied-from"] WAIT 
  'EXEC ["ln", "-s", sTarget &/ "usr/share/zoneinfo" &/ Trim(sTimeZone), sTarget &/ "etc/localtime-copied-from"] WAIT 
  SHELL "chroot " & main.Install.TargetMount & " ln -s /usr/share/zoneinfo" &/ Trim(sTimeZone) & " /etc/localtime-copied-from" WAIT 
  EXEC ["rm", sTarget &/ "/etc/localtime"] WAIT 
  EXEC ["cp", sTarget &/ "/usr/share/zoneinfo" &/ Trim(sTimeZone), sTarget &/ "/etc/localtime"] WAIT 
  
  ' write the hadwareclock configure script
  
  sCfg = "# /etc/hardwareclock \n" &
  "# \n" &
  "# Tells how hardware clock is stored. \n" &
  "# You should run vzoneset rather than editing this file manually \n" &
  "\n\n" & hwclock & gb.NewLine
  
  TRY File.Save(sTarget &/ "etc" &/ "hardwareclock", Trim(sCfg))
  DEBUG "Timezone set to " & sTimeZone
  DEBUG "Clock settings: " & hwclock
  
END

PUBLIC SUB Display_User_Group_Choices(lbCont AS Container)
  
  DIM cb AS CheckBox
  DIM sList AS String[] = ["plugdev", "disk", "cdrom", "floppy", "lp", "scanner", "audio", "video", "games", "slocate", "adm", "sys", "wheel", "power", "netdev"]
  DIM sDesc AS String[] = ["User can un/mount pendrives", "User can un/mount removable HD", "User can access CD/CDW/DVD devices", "User can access floppy disks", "User can access printers", "User can access scanners", "User can access audio devices", "User can access video devices", "User can play restricted games", "User can use the system\'s locate database", "Restricted System Administrator", "Unlimited system administrator", "elite users", "User can shut the system down", "User is allowed to access network devices and services"]
  
  
  DIM i AS Integer
  
    FOR i = 0 TO sList.Max
      cb = NEW CheckBox(lbCont) AS "GroupBoxes"
        WITH cb
          .Text = sList[i]
          .Height = 28
          .ToolTip = sDesc[i]
          IF i <= 9 OR i = 13 OR i = 14 THEN 
            .Value = TRUE
          ELSE 
            .Value = FALSE
          END IF
          .Expand = TRUE
        END WITH 
        $objUsrGroups.Add(cb)
    NEXT 
END

PUBLIC FUNCTION CHECK_EXISTING_USER(sName AS String) AS Boolean
  
  DIM sDump AS String
  
  SHELL "grep ^\"" & sName & "\"" & Space(1) & Main.Install.TargetMount &/ "etc/group" TO sDump
  sDump = Trim(sDump)
  IF Len(sDump) > 0 THEN 
    RETURN TRUE
  END IF
    RETURN FALSE
  
  
END

PRIVATE FUNCTION import_uuid(user_name AS String) AS String
  
  DIM sname, uuid, sLine AS String
  DIM entry AS String[]
  FOR EACH sLine IN uuidList
    entry = Split(Trim(sLine), " ")
    IF Trim(entry[1]) = Trim(user_name) THEN RETURN Trim(entry[0])
  NEXT 
  
END

PUBLIC SUB WRITE_USER_AUTOSTART(sUser AS String, OPTIONAL sfilename AS String)
  
  DIM filepath AS String 
  DIM script AS String
  IF NOT sfilename THEN sfilename = "vlstartup.sh"
  filepath = main.Install.TargetMount &/ "home" &/ sUser &/ sfilename
  
  IF Exist(filepath) THEN 
    SHELL "mv " & filepath & " " & filepath & ".bak" WAIT 
    SHELL "chmod -x " & filepath & ".bak" WAIT 
  END IF
  
  script = "#!/usr/bin/bash \n" &
  "/usr/bin/slapt-update-notifier \n\n"
    IF IsDir(File.Dir(filepath)) = FALSE THEN MKDIR File.Dir(filepath)
  TRY File.Save(filepath, script)
  SHELL "chmod 755 " & filepath WAIT 
  SHELL "chmod +x " & filepath WAIT 
  
  
  
  
END


PUBLIC FUNCTION Import_Account(sAccntName AS String, sRealName AS String, sPasswd AS String, OPTIONAL sPicPath AS String) AS Integer
  ' will return
  ' 0 = operation successful
  ' 1 = operation failed
  DIM cb AS CheckBox
  DIM sGrpLst, sDump AS String
  DIM ob AS Object
  DIM sOldSetting, skel AS String
  DIM i AS Integer
  DIM uuid AS String
  'ME.$objUsrGroups.Clear

' Import the uuid for this user
uuid = 1000 + MdlMain.iUID
  uuid = import_uuid(Trim(sAccntName))
  IF Len(Trim(uuid)) <= 0 THEN 
    Message.Error(("Unable to import UUID for user") & Space(1) & sAccntName & ". " & ("This account cannot be imported at this time."))
    RETURN 1
  ELSE 
    PRINT " -Importing account " & sAccntName & " with UUID " & uuid
  END IF

  ' -= Get the list of groups this user belongs to =-
    FOR EACH cb IN $objUsrGroups
      IF cb.Value = TRUE THEN 
        sGrpLst = sGrpLst & Space(1) & cb.Text
      END IF
    NEXT 
    sGrpLst = Trim(sGrpLst)
    sGrpLst = Replace(sGrpLst, " ", ",")
    
     
   
  '-== Just to be safe, make sure the group user does not exist before trying to create a new user ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/groupdel " & sAccntName & " > /dev/null " WAIT 
  '-== Create new group for user ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/groupadd -g " & uuid & Space(1) & sAccntName & " > /dev/null" WAIT 
  '-== Create new user account ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/useradd -m -c \'" & sRealName & "\' -g " & sAccntName &
        " -p " & Trim(sPasswd) & " -u " & uuid & " -G \'" & "users," & sGrpLst & "\' -s /bin/bash " &
        Trim(sAccntName) & " || echo FAILED" TO sDump
          ' [Quick error check]
            sDump = Trim(sDump)
              IF InStr(sDump, "FAILED") THEN 
                Message.Error(("Failed to create user account. See error below.") & "<br><br>" & sDump)
                RETURN 1
              END IF
  ' -== Just to be sure... re-run the password to make sure it's set ==-'
  SHELL "chroot " & Main.Install.TargetMount & " /sbin/passwdx " & sAccntName & Space(1) & sPasswd WAIT 
  
  ' Handle the settings.
  
  
              FOR EACH skel IN Dir(main.Install.TargetMount &/ "etc" &/ "skel")
                'IF main.ImportSettings.Find(skel) = -1 THEN 
                IF main.ImportSettings.Exist(skel) THEN 
                  SHELL "rm -rf " & main.Install.TargetMount &/ "home" &/ sAccntName &/ skel WAIT 
                  SHELL "cp -arp " & main.Install.TargetMount &/ "etc" &/ "skel" &/ skel & Space(1) & main.Install.TargetMount &/ "home" &/ sAccntName &/ skel WAIT 
                  DEBUG "resetting " & skel
                ELSE 
                  DEBUG "Keeping " & skel & " for " & sAccntName
                END IF
              NEXT 

' ' ' ' ' ' ' ' ' ' '             SHELL "chroot " & main.Install.TargetMount & " chown -R " & sAccntName & ":" & sAccntName & " /home" &/ sAccntName &/ "*" WAIT 
  
  
  ' -== Set the face icon ==-
        IF sPicPath THEN 
          ' -= fix for KDM login (KDE3) =-
            TRY LINK Main.Install.TargetMount &/ "usr/share/apps/kdm/pics/users" &/ sAccntName & ".face.icon" TO sPicPath
        
'              CATCH  
'                SHELL "ln -s " & sPicPath & Space(1) & "/mnt/target/usr/share/apps/kdm/pics/users" &/ sUsrLogIn &/ ".face.icon" 
          ' -= fix for GDM login =-
            TRY COPY sPicPath TO Main.Install.TargetMount &/ "home" &/ sAccntName &/ ".face"
            SHELL "chmod 664 " & Main.Install.TargetMount &/ "home" &/ sAccntName &/ ".face 2>/dev/null" WAIT 
            SHELL "chroot " & Main.Install.TargetMount & " /bin/chown " & sAccntName & Space(1) & "/home/" &/ sAccntName &/ ".face 2> /dev/null" WAIT 
            SHELL "chroot " & Main.Install.TargetMount & " /bin/chgrp " & sAccntName & Space(1) & "/home" &/ sAccntName &/ ".face 2> /dev/null" WAIT 
            'SHELL "cp -ar " & Main.Install.TargetMount &/ "etc" &/ "skel/*" & Space(1) & Main.Install.TargetMount &/ "home" &/ sUsrLogIn WAIT 
            'SHELL "chroot " & main.Install.TargetMount & Space(1) & " cp -ar /etc/skel/* /home" &/ Trim(sAccntName) WAIT ' Some of these will be over-written
            ' ' ' ' ' ' ' ' ' ' ' ' SHELL "chroot " & main.Install.TargetMount & " chown -R " & sAccntName & ":" & "users" & " /home" &/ sAccntName WAIT 
            ' ' ' ' ' ' ' ' ' ' ' ' SHELL "chroot " & main.Install.TargetMount & " chmod 755 /home" &/ sAccntName WAIT 
            ' ' ' ' ' ' ' ' ' ' ' ' SHELL "chroot " & main.Install.TargetMount & " cd /home" &/ sAccntName WAIT 
            
            ' Now, bring the old settings in.
              ' FOR EACH sOldSetting IN main.ImportSettings
              '   SHELL "cp -arp " & main.Install.TargetMount &/ "etc" &/ "skel" &/ sOldSetting & Space(1) & main.Install.TargetMount &/ "home" &/ sAccntName &/ sOldSetting WAIT 
              ' NEXT 
              
            'shell "chroot
            
      END IF
  
' Fix permissions for existing stuff
SHELL "chroot " & main.Install.TargetMount & " chown -R " & sAccntName & ":" & sAccntName & "/home" &/ sAccntName WAIT 

  
  ' USER ACCOUNT HAS BEEN CREATED      
  '-= increase the iUID number every time this sub runs =-
  DEBUG "User account created for " & sAccntName & " and seetings recovered "
  'Message.Info(("Imported account for") & Space(1) & sAccntName)
  MdlMain.Set_App_Status(("Imported account for user") & Space(1) & "<b>" & sAccntName & "</b>", 8)
  'INC iUID
  
  ' clear the name and settings arrays
  main.ImportUserName = ""
  main.ImportSettings.Clear
  i = main.ImportUsers.Find(Trim(sAccntName))
    IF i >= 0 THEN main.ImportUsers.Delete(i)
  DEBUG "Imported account: " & sAccntName
  INC MdlMain.iUID
  'Message.Info(("User account successfully imported.") & gb.NewLine & sAccntName)
  RETURN 0
  
  
  
END

PRIVATE FUNCTION clear_iuid(uid_in AS String) AS Integer
  
  DIM sdump AS String
  'SHELL "ls -n " & main.Install.TargetMount &/ "home | grep -v ftp | grep -v lost+found | tr -s \' \',\"\" | cut -f3,8 -d \' \'" TO sdump
  ' Fix by uelsk8s
  SHELL "ls -n" & main.Install.TargetMount &/ "home |grep -v ftp |grep -v lost+found |tr -s \' \',\"\"|cut -f3,9 -d\' \'" TO sDump
  IF InStr(Trim(sdump), uid_in) THEN RETURN 1
  RETURN 0
  
END

PRIVATE FUNCTION find_next_uid_value() AS Integer
  
  DIM lst AS String
  DIM data AS NEW String[]
  DIM i AS Integer
  DIM _line AS NEW String[]
  DIM _pos AS String
  DIM _conv AS Integer
  DIM _values AS NEW Integer[]
  
  
  IF Exist(main.Install.TargetMount &/ "etc" &/ "passwd") THEN 
    lst = File.Load(main.Install.TargetMount &/ "etc/passwd")
    
    data = Split(Trim(lst), "\n")
    FOR i = 0 TO data.Max
      _line = Split(Trim(data[i]), ":")
      _conv = Trim(_line[2])
      IF _conv >= 1000 THEN 
        'Message.Info(_conv)
        _values.Add(_conv)
      END IF
    NEXT 
  ELSE 
    RETURN 1000
  END IF
  
  IF _values.Count = 0 THEN RETURN 1000
  _values.Sort()
  RETURN (_values[_values.Max] + 1)
  
  
END


PUBLIC FUNCTION CREATE_NEW_USER_ACCOUNT(sUsrLogIn AS String, sUsrRlName AS String, sPass AS String, OPTIONAL sPicPath AS String) AS Integer
  
  ' will return
  ' 0 = operation successful
  ' 1 = operation failed
  
  DIM cb AS CheckBox
  DIM sGrpLst, sDump AS String
  DIM ob AS Object
  DIM uid AS Integer
  
  'ME.$objUsrGroups.Clear

  ' -= Get the list of groups this user belongs to =-
    FOR EACH cb IN $objUsrGroups
      IF cb.Value = TRUE THEN 
        sGrpLst = sGrpLst & Space(1) & cb.Text
      END IF
    NEXT 
    sGrpLst = Trim(sGrpLst)
    sGrpLst = Replace(sGrpLst, " ", ",")
   
    'uid = 1000 + MdlMain.iUID
    uid = find_next_uid_value()
    
  '-== Just to be safe, make sure the group user does not exist before trying to create a new user ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/groupdel " & sUsrLogIn & " > /dev/null " WAIT 
  '-== Create new group for user ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/groupadd -g " & uid & Space(1) & sUsrLogIn & " > /dev/null" WAIT 
  '-== Create new user account ==-
  SHELL "chroot " & Main.Install.TargetMount & " /usr/sbin/useradd -m -c \'" & sUsrRlName & "\' -g " & sUsrLogIn &
        " -p " & Trim(sPass) & " -u " & uid & " -G \'" & "users," & sGrpLst & "\' -s /bin/bash " &
        Trim(sUsrLogIn) & " || echo FAILED" TO sDump
          ' [Quick error check]
            sDump = Trim(sDump)
              IF InStr(sDump, "FAILED") THEN 
                Message.Error(("Failed to create user account. See error below.") & "<br><br>" & sDump)
                RETURN 1
              END IF
  ' -== Just to be sure... re-run the password to make sure it's set ==-'
  SHELL "chroot " & Main.Install.TargetMount & " /sbin/passwdx " & sUsrLogIn & Space(1) & sPass WAIT 
  ' -== Set the face icon ==-
        IF sPicPath THEN 
          ' -= fix for KDM login (KDE3) =-
            'TRY LINK Main.Install.TargetMount &/ "usr/share/apps/kdm/pics/users" &/ sUsrLogIn & ".face.icon" TO sPicPath
            SHELL "ln -s /mnt/target" &/ sPicPath & Space(1) & "/mnt/target/apps/kdm/pics/users" &/ sUsrLogIn & ".face.icon" WAIT 
            
'              CATCH  
'                SHELL "ln -s " & sPicPath & Space(1) & "/mnt/target/usr/share/apps/kdm/pics/users" &/ sUsrLogIn &/ ".face.icon" 
          ' -= fix for GDM login =-
            TRY COPY sPicPath TO Main.Install.TargetMount &/ "home" &/ sUsrLogIn &/ ".face"
            SHELL "chmod 664 " & Main.Install.TargetMount &/ "home" &/ sUsrLogIn &/ ".face 2>/dev/null" WAIT 
            SHELL "chroot " & Main.Install.TargetMount & " /bin/chown " & sUsrLogIn & Space(1) & "/home/" &/ sUsrLogIn &/ ".face 2> /dev/null" WAIT 
            SHELL "chroot " & Main.Install.TargetMount & " /bin/chgrp " & sUsrLogIn & Space(1) & "/home" &/ sUsrLogIn &/ ".face 2> /dev/null" WAIT 
            'SHELL "cp -ar " & Main.Install.TargetMount &/ "etc" &/ "skel/*" & Space(1) & Main.Install.TargetMount &/ "home" &/ sUsrLogIn WAIT 
            SHELL "chroot " & main.Install.TargetMount & Space(1) & " cp -ar /etc/skel/* /home" &/ Trim(sUsrLogIn) WAIT 
            SHELL "chroot " & main.Install.TargetMount & " chown -R " & sUsrLogIn & ":" & "users" & " /home" &/ sUsrLogIn WAIT 
            SHELL "chroot " & main.Install.TargetMount & " chmod 755 /home" &/ sUsrLogIn WAIT 

            'shell "chroot
            
      END IF
  
  ' USER ACCOUNT HAS BEEN CREATED      
  '-= increase the iUID number every time this sub runs =-
  DEBUG "User account created for " & sUsrLogIn
  'INC iUID
  'Message.Info(("New user account created successfully.") & gb.NewLine & sUsrLogIn)
  INC MdlMain.iUID
  MdlMain.Set_App_Status(("New user account created for") & Space(1) & "<b>" & sUsrLogIn & "</b>", 8)
  
  RETURN 0
  
  
END

PUBLIC SUB ADVANCE_STATUS_TREE(sPrev AS String, sNow AS String)
  
  ClsGlobal.fRunningMainForm.listview1[sPrev].picture = MdlStartUp.pDone
  ClsGlobal.fRunningMainForm.listview1[sNow].picture = MdlStartUp.pNow
  
END

PUBLIC FUNCTION PERFORM_PARTITIONING() AS Integer
  
  DIM i, iretval AS Integer
  DIM sPart, sFmt, scommand AS String
  DIM entry AS String[]
  
  
  DEBUG "Formatting partitions ... Please wait"
  ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = FALSE
    FOR i = 0 TO Main.Install.Partitions.Max
        'blank end means "not formmated"
        ' /dev/sdb5-20.0GB-/-
        ' /dev/sdc4-15.1GB-Swap-linux-swap
        entry = Split(Main.Install.Partitions[i], "-")
        spart = entry[0]
        IF entry.Count > 2 THEN 
          sFmt = entry[3]
        ELSE  
          CONTINUE 
        END IF
        
          IF (entry[3]) AND entry[3] LIKE "swap" THEN 
            ' Activate swap while we're at it
            DEBUG "Activating swap space on " & spart
            SHELL "mkswap " & spart WAIT 
            SHELL "swapon -a" WAIT 
          ELSE 
            SHELL "umount " & spart WAIT 
            SELECT CASE sFmt
              CASE "ext2"
                sCommand = "mke2fs -q " & sPart
             CASE "ext3"
                'sCommand = "mke2fs -q -j " & saddr
                scommand = "mkfs.ext3 -q -j " & sPart
             CASE "ext4"
                sCommand = "mkfs.ext4 " & spart
             CASE "reiserfs"
                sCommand = "mkreiserfs --format 3.6 -q " & sPart
             CASE "xfs"    
                sCommand = "mkfs.xfs -f " & sPart
             CASE "jfs"
                sCommand = "mkfs.jfs -q " & sPart  
             CASE "swap"
              sCommand = "mkswap -L swap-space " & sPart
          END SELECT 
          IF Len(Trim(sFmt)) <= 0 THEN CONTINUE ' partition is not to be formatted.
          IF Trim(sFmt) LIKE "linux" THEN CONTINUE ' "linux swap" detected
          MdlMain.Set_App_Status("Formatting " & spart & " (" & sFmt & ")")
                      DEBUG "Formatting " & sPart & " with " & sFmt
              Step9.tlCurrPkg.Text = ("Formatting") & Space(1) & sPart & Space(1) & ("with") & Space(1) & sFmt
            $hproc = SHELL scommand WAIT 
              IF $hproc.Value > 1 THEN 
                DEBUG sPart & " failed to format to " & sFmt
                iretval = 1
                BREAK 
              ELSE 
                DEBUG "Success!"
                iretval = 0
              END IF
      END IF
    NEXT 
    
    RETURN iretval

END

PUBLIC FUNCTION Mount_Target_Partitions() AS Integer
  
  DIM sDump AS String
  DIM item AS string[]
  DIM entry, spart, smntpnt AS String
  DIM i AS Integer
  
  IF main.Install.TargetMount = "" THEN main.Install.TargetMount = "/mnt/target"
  IF Exist(main.Install.TargetMount) = FALSE THEN TRY MKDIR main.Install.TargetMount
  SHELL "mount | grep " & Main.Install.TargetMount TO sDump
  sdump = Trim(sdump)
  IF Len(sdump) > 0 THEN 
    SHELL "umount " & Main.Install.TargetMount WAIT 
  END IF
    
    FOR i = 0 TO main.Install.Partitions.Max
      item = Split(main.Install.Partitions[i], "-")
      spart = Trim(item[0])
      smntpnt = Trim(item[2])
        IF smntpnt = "/" THEN 
          DEBUG "Mounting target root " & spart
          SHELL "mount " & spart & Space(1) & main.Install.TargetMount &/ smntpnt WAIT 
          'Message("mounted / partition")
        ELSE 
          CONTINUE 
        END IF
    NEXT 
        
    'WAIT 2
    
  FOR i = 0 TO main.install.Partitions.Max
    item = Split(main.Install.Partitions[i], "-")
    spart = Trim(item[0])
    smntpnt = Trim(item[2])
    IF smntpnt = "/" THEN CONTINUE 
    
            'blank end means "not formmated"
        ' /dev/sdb5-20.0GB-/-
        ' /dev/sdc4-15.1GB-Swap-linux-swap
        IF Len(Trim(smntpnt)) = 1 THEN 
          main.Install.Root = Trim(spart)
          main.Install.RootPartition = Trim(spart)
          DEBUG "Setting Main.Install.Rootpartition to " & spart
        END IF
        
    IF smntpnt LIKE "swap" THEN 
      SHELL "mkswap " & Trim(spart) WAIT 
      SHELL "swapon " & Trim(spart) WAIT 
        
    ELSE 
      'IF smntpnt LIKE "home" THEN CONTINUE ' exclude the home dir for now
        DEBUG "Mounting " & spart & " to " & Main.Install.TargetMount &/ smntpnt
        'IF IsDir(main.Install.TargetMount &/ smntpnt) = FALSE THEN TRY MKDIR main.Install.TargetMount &/ smntpnt
        SHELL "mkdir -p " & main.Install.TargetMount &/ "home"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "var"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "tmp"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "opt"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "sys"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "boot"
        SHELL "mkdir -p " & main.Install.TargetMount &/ "usr"
        SHELL "mount " & spart & Space(1) & Main.Install.TargetMount &/ smntpnt WAIT 
        'Message("mounted " & spart & " to " & smntpnt)
    END IF
   NEXT      
   SHELL " mount | grep " & main.Install.TargetMount TO sdump
   IF Len(Trim(sdump)) <= 0 THEN RETURN 1
   RETURN 0
  
END

PUBLIC SUB doublecheck_home_mount()
  
  DIM entry, part, sdump AS String
  DIM $line AS String[]
  
  
  FOR EACH entry IN main.Install.Partitions
    IF InStr(entry, "/home") THEN 
      $line = Split(entry, "-")
      part = $line[0]
        SHELL "mount | grep ^" & part TO sdump
          IF Len(Trim(sdump)) <= 0 THEN ' partition is not mounted
            'Message("Re-mounting /mnt/target/home")
            DEBUG "Re-mounting /mnt/target/home"
            SHELL "mkdir -p " & main.Install.TargetMount &/ "home" WAIT 
            SHELL "mount " & part & Space(1) & main.Install.TargetMount &/ "home" WAIT 
          END IF
    END IF
  NEXT 
            
    
  
  
END


PUBLIC SUB COUNT_PACKAGES_TO_BE_INSTALLED()
  DIM sLine, sDump AS String
  DIM sLinearr, sdumparr, temparr AS String[]
  DIM i, ii, iBulkCnt, itotal AS Integer
  DIM cb AS CheckBox
  
  ' count required packages.
    SHELL "cat /mnt/source/veclinux/VINSTALL.CONF | grep REQ: | cut -f 2 -d :" TO sDump
      sdump = Trim(sDump)
        sdumparr = Split(sdump, gb.NewLine)
          FOR i = 0 TO sdumparr.Max
            PRINT sdumparr[i]
            temparr = Split(Trim(File.Load("/mnt/source/veclinux" &/ Trim(sdumparr[i]))), gb.NewLine)
            itotal = (itotal + temparr.Count) + 1 ' add one for vlconfig2
          NEXT 
  SELECT CASE ClsGlobal.iInstallMethod
    CASE 0 ' full installation round up all the packages.
      'reset total because this will get counted again.
      ' Maybe this would be easier if we just count the number of packages that have been md5summed?
      itotal = 0
      'FOR EACH sLine IN Dir("/mnt/source/veclinux")
        'IF sLine <> "VINSTALL.CONF" THEN 
        SHELL "cat " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | cut -f2 -d:" TO sdump
        sdumparr = Split(Trim(sdump), gb.NewLine)
        FOR i = 0 TO sdumparr.Max
          'temparr = Split(Trim(File.Load("/mnt/source/veclinux" &/ Trim(sLine))), gb.NewLine)
          temparr = Split(Trim(File.Load(main.Install.SrcMnt &/ "veclinux" &/ Trim(sdumparr[i]))), gb.NewLine)
          itotal = (itotal + temparr.Count)
      NEXT 
        IF main.SelectedSrc.MultiDisk = TRUE THEN 
          main.Install.CD2Bulks.Clear()
          FOR EACH sLine IN Dir("/mnt/source/veclinux/CD2")
          main.Install.CD2Bulks.Add(Trim(sLine))
            temparr = Split(Trim(File.Load("/mnt/source/veclinux/CD2" &/ sLine)), gb.NewLine)
            itotal = itotal + (temparr.Count - 1) 'remember to remove one line here because line 1 is comment on cd2 bulks
          NEXT 
        END IF
    CASE 1 'customized install
      ' do not reset the required for this.
      'sdumparr = Split(ClsGlobal.sBulkListToInstall, ",")
      
      FOR EACH sLine IN main.Install.Bulks
        temparr = Split(Trim(File.Load("/mnt/source/veclinux" &/ Trim(sLine))), gb.NewLine)
          itotal = (itotal + temparr.Count)
      NEXT 
      
      ' Count packages from 2nd cd if necessary
        IF main.SelectedSrc.MultiDisk = TRUE THEN 
      FOR EACH sLine IN main.Install.CD2Bulks
      IF InStr(sLine, "l10n") THEN CONTINUE 
'        Message("Searcing for  " & sLine)
        temparr = Split(Trim(File.Load(main.Install.SrcMnt &/ "veclinux" &/ "CD2" &/ Trim(sLine))), gb.NewLine)
          itotal = (itotal + (temparr.Count - 1))
      NEXT 
      END IF
        ' now count the selected packages from optional.
        'sdumparr = Split(ClsGlobal.sPkgListToInstall, ",")
        itotal = (itotal + main.Install.Packages.Count)
        IF main.LangPacks.Count > 0 THEN 
          itotal = (itotal + main.LangPacks.Count)
        END IF
    CASE 2 ' minimal installation
        ' the minimal is already counted, so we just need to find out if anything is being installed on top of it, ie, x11 or dev
        ' this is done by counting the checkboxes with values from the installation window.
        FOR EACH cb IN ClsGlobal.objMinComponents
          IF cb.Value = TRUE THEN 
            temparr = Split(Trim(File.Load("/mnt/source/veclinux" &/ Trim(cb.Tag))), gb.NewLine)
            itotal = (itotal + temparr.Count)
          END IF
        NEXT 
  END SELECT 
  
  DEBUG "Total packages to be installed : " & itotal
  $pkgtotal = itotal
    

END



PUBLIC FUNCTION INSTALL_INITIAL_PACKAGES(tlStatus AS TextLabel, pbProg AS ProgressBar) AS Integer
  
  ' This function will install the initial packages necessary for installation before anything else.
  DIM sList AS String[] = ["/x/fontconfig-*.tlz"]
  DIM sRes, sLine, $listarr AS String[]
  DIM i, ii, iret, ires AS Integer
  DIM hproc AS Process
  DIM sDump, $path, $line, sPkg, MajorDesc, sFileList AS String

  
  ' this part will isntall the bulks defined as REQUIRED
    SHELL "cat /mnt/source/veclinux/VINSTALL.CONF | grep REQ:" TO sdump
      sDump = Trim(sdump)
      sRes = Split(sDump, gb.NewLine)
        FOR i = 0 TO sRes.Max
        $line = Right(sRes[i], Len(sRes[i]) - InStr(sRes[i], "-"))
          $line = Replace($line, "\'", "")
          sLine = Split($line, ":")
          MajorDesc = sLine[3]
          sPkg = sLine[1]
            IF ME.INSTALL_THIS_BULK(tlStatus, pbProg, sPkg) > 0 THEN RETURN 1

        NEXT 
  
END


PUBLIC SUB ADVANCE_INSTALL_PROGRESS(iStep AS Integer)
  
  DIM pb AS PictureBox
  DIM pb1 AS PictureBox
    
  FOR EACH pb IN $objPboxes
    IF pb.Tag = iStep THEN pb.Picture = Picture.Load("images/16px-check.png")
      FOR EACH pb1 IN $objPboxes
        IF pb1.Tag = (iStep + 1) THEN 
          pb1.Picture = picture.Load("images/category.png")
        END IF
      NEXT 
    'WAIT 5
  NEXT 
  
    
  
END


PUBLIC FUNCTION INSTALL_KERNEL_AND_INITRD() AS Integer
  
  DIM sfile, sdump, sname, sversion AS String
  DIM sList, sdumparr, sVersArr, sLinearr AS String[]
  DIM i AS Integer
  DIM sverstring, sKernString AS String
  DIM $hproc AS Process
  
  DEBUG "Copying kernels and intrd now ..."
  EXEC ["mkdir", "-p", Main.Install.TargetMount &/ "boot"] WAIT 
    SHELL "grep ^\'ISO_KERNEL_\' /mnt/source/veclinux/VINSTALL.CONF" TO sdump
      sdump = Replace(sdump, "\'", "")
      sdump = Replace(sdump, "\"", "")
      sdump = Replace(sdump, "(", "")
      sdump = Replace(sdump, ")", "")
      sList = Split(Trim(sdump), gb.NewLine)
      FOR i = 0 TO sList.Max
        sLinearr = Split(sList[i], "=")
        sKernString = sLinearr[0]
        sname = sLinearr[1]
          ' check to see if the kernel is included and then copy it
          IF Exist("/mnt/source/isolinux/kernel" &/ Trim(sname)) THEN 
            ' now find the version, so we have a complete file name to save it
            sverstring = Replace(sKernString, "ISO", "HD")
              SHELL "grep ^\'" & sverstring & "\' /mnt/source/veclinux/VINSTALL.CONF | cut -f 2 -d \'=\'" TO sdump
                sdump = Trim(sdump)
                  IF sdump THEN 
                    sversion = Replace(sdump, "\'", "")
                    sversion = Replace(sversion, "\"", "")
                    sversion = Replace(sversion, "(", "")
                    sversion = Replace(sversion, ")", "")
                  END IF
                IF sversion THEN 'TRY COPY "/mnt/source/isolinux/kernel" &/ Trim(sname) TO ClsGlobal.sTargetPath &/ "boot" &/ "veclinux-" & Trim(sversion)
                  $hproc = SHELL "cp /mnt/source/isolinux/kernel" &/ Trim(sname) & Space(1) & Main.Install.TargetMount &/ "boot" &/ "vmlinuz-" & Trim(sversion) WAIT 
                  'SHELL "ln -s " & ClsGlobal.sTargetPath &/ "boot" &/ "vmlinuz-" & Trim(sversion) & Space(1) & ClsGlobal.sTargetPath &/ "boot" &/ "vmlinuz" WAIT 
                  SHELL "cd " & Main.Install.TargetMount &/ "boot" & "&& ln -s vmlinuz-" & Trim(sversion) & Space(1) & "vmlinuz" WAIT 
                  
                    IF $hproc.value > 0 THEN 
                      DEBUG "Error copying " & sname & Space(1) & "to" & Space(1) & Main.Install.TargetMount &/ "boot" &/ "vmlinuz-" & sversion
                      Message.Error("Error while trying to copy veclinux-" & sversion) '&/ "boot" &/ "veclinux-" & sversion)
                      RETURN 1
                    END IF
                END IF
                
          END IF
      NEXT        
      
     
  RETURN 0
END

PUBLIC SUB Store_vlconfig_temporarily()
  DIM conf AS String
  DIM sdump AS String
  conf = ME.Get_FULL_TLZ_PACKAGE("vlconfig2")
  IF Exist("/mnt/source" &/ "packages" &/ conf) THEN 
      SHELL "cp " & main.Install.SrcMnt &/ "packages" &/ conf & Space(1) & main.Install.TargetMount &/ "tmp" WAIT 
  ELSE 
    DEBUG "No config pacakge found (vlconfig2)... Default configuration cannot be provided (looked in " & main.Install.SrcMnt &/ "packages" &/ conf & ")"
  END IF 
  
  SHELL "ls " & main.Install.TargetMount &/ "tmp | grep vlconfig" TO sdump
  IF Len(Trim(sdump)) <= 0 THEN 
    ' no vlfonfig in place in the target.
    SHELL "cp " & main.Install.SrcMnt &/ "packages/*/vlconfig*.t?z " & main.Install.TargetMount &/ "tmp" WAIT 
    
  END IF
  
END



PUBLIC SUB INSTALL_VL_CONFIG()
  
  DIM conf AS String
  conf = ME.Get_FULL_TLZ_PACKAGE("vlconfig2")
  IF Exist("/mnt/source" &/ "packages" &/ conf) THEN 
    IF main.Install.InstalledPkgLog.Find(File.Name(conf)) = -1 THEN 
    DEBUG "Installing default " & main.Install.Name & Space(1) & "configuration" & Space(1) & File.Name(conf) & Space(1) & "..." & Space(1) & "Installing"
    ME.INSTALL_THIS_PACKAGE(main.Install.SrcMnt &/ "packages" &/ conf)
      ELSE 
        DEBUG conf & " is already installed"
    END IF
  ELSE 
    DEBUG "No config package found (vlconfig2)... Default configuration cannot be provided (looked in " & main.Install.SrcMnt &/ "packages" &/ conf & ")"
  END IF
  ' quick trick to enable /etc/vector-version
  'SHELL "echo \"" & main.Install.Name & Space(1) & main.Install.Version & "\" >" & main.Install.TargetMount &/ "etc" &/ "vector-version" WAIT 
  
  ' TRIGGER BIND MOUNTING FROM HERE
  DEBUG "Triggering bind mounts."
  MdlBootMngr.DO_BIND_MOUNTING()
  
END

PUBLIC SUB trigger_cd2_install(pbProg AS ProgressBar, tlStatus AS TextLabel)
  DIM RelID AS String
  DIM sItem, MedID AS String
  DIM i AS Integer
  DIM sDump, sBasePath AS String
  DIM ISO AS String
              ''''' HERE IS THE CODE FOR THE INSTALLATION OF THE STUFF ON THE 2ND CD '''''
              
              
  ' begin by copying the CD2 dir to /mnt/target/CD2 because this will be unavailable after the CD is ejected.
  SHELL "cp -ar /mnt/source/veclinux/CD2 /mnt/target/tmp" WAIT 
  
  ' merged 2cd install into 1 location.

              IF main.SelectedSrc.MultiDisk = TRUE AND IF main.Install.CD2Bulks.Count > 0 THEN 
                  ' Begin by temporarily copying VLCONFIG2 to the target
                    Store_vlconfig_temporarily() ' This moves the vlconfig2 package to /mnt/target/tmp
                    MdlMain.WRITE_ETC_VECTOR_VERSION()
                  ' Prompt the user to insert the next cd
            IF UCase(main.SelectedSrc.Type) = "CDROM" THEN 
              SHELL "grep ^MULTI_SINGLE= " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d=" TO sdump
                IF Trim(sdump) = "1" THEN 
                  main.Install.SrcMnt = "/mnt/source/CD2"
              ELSE 
               SHELL "umount " & main.SelectedSrc.HostDevice WAIT 
               SHELL "umount -f /mnt/source" WAIT 
                   REPEAT 
                      SHELL "mount | grep /mnt/source" TO sDump
                       IF Len(Trim(sdump)) > 0 THEN 
                         SHELL "umount /mnt/source" WAIT
                         INC i
                       END IF
                   UNTIL Len(Trim(sdump)) = 0 OR i = 10
               SHELL "umount /mnt/source && eject " & main.SelectedSrc.HostDevice WAIT 
               SHELL "eject -r " & main.SelectedSrc.HostDevice WAIT ' Just to be sure.
               SHELL "eject -r " & main.SelectedSrc.HostDevice WAIT ' Yet again.
                        
                  REPEAT 
                  SHELL "umount -ndifl" & main.SelectedSrc.HostDevice WAIT 
                        SHELL "umount -ndif /mnt/source" WAIT 
                        SHELL "umount -ndif" & main.SelectedSrc.HostDevice WAIT 
                        SHELL "eject -rm " & main.SelectedSrc.HostDevice WAIT 
                        SHELL "mount | grep ^" & main.SelectedSrc.HostDevice TO sdump
                          IF Len(Trim(sdump)) > 0 THEN 
                            SHELL "umount -ndifl " & main.SelectedSrc.HostDevice WAIT 
                              SHELL "mount | grep ^" & main.SelectedSrc.HostDevice TO sdump
                                IF Len(Trim(sdump)) > 0 THEN 
                                  DEBUG "Im having trouble releasing the inserted cd...."
                                  Message(("End of installation of the software included in the first CD"))
                                ELSE 
                                  SHELL "eject -rm" & main.SelectedSrc.HostDevice WAIT 
                                END IF
                            END IF
                         SELECT CASE Message.Question(("Please insert the second disk provided with your") & Space(1) & main.Install.Name & Space(1) & ("package"), ("OK"), ("I dont have it"))
                            CASE 1
                              SHELL "eject -t " & main.SelectedSrc.HostDevice WAIT 
                              SHELL "mount " & main.SelectedSrc.HostDevice & Space(1) & "/mnt/source" WAIT 
                            CASE 2
                              Message.Warning(("The bonus software will not be installed."))
                              RETURN 
                          END SELECT 
                        SHELL "grep ^RELEASE_ID= /mnt/source/veclinux/VINSTALL.CONF | cut -f2 -d=" TO RelID
                        SHELL "grep ^Media_ID= /mnt/source/veclinux/VINSTALL.CONF | cut -f2 -d=" TO MedID
                                IF Trim(RelID) <> Trim(main.SelectedSrc.ReleaseID) OR IF Trim(MedID) = main.SelectedSrc.MediaID THEN 
                                  SHELL "umount /mnt/source" WAIT 
                                END IF
                            UNTIL Trim(RelID) = Trim(main.SelectedSrc.ReleaseID) AND Trim(MedID) <> main.SelectedSrc.MediaID
                         main.Install.SrcMnt = "/mnt/source/"
                        END IF
              ELSE IF UCase(main.SelectedSrc.Type) = "ISO" THEN 
              
                 SHELL "grep ^MULTI_SINGLE= " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d=" TO sdump
                IF Trim(sdump) = "1" THEN 
                  main.Install.SrcMnt = "/mnt/source/CD2"
              ELSE           
                'SHELL "cp -ar /mnt/source/veclinux/CD2 /mnt/target/tmp" WAIT 
                        ' search for the 2nd ISO
                          SHELL "mount | grep " & main.SelectedSrc.IsoName & " | cut -f1 -d \' \'" TO sdump
                            sdump = Trim(Replace(sdump, main.SelectedSrc.IsoName, ""))
                              IF Len(Trim(sdump)) > 0 THEN sBasePath = Trim(sdump)

                            REPEAT 
                              SHELL "umount /mnt/source" WAIT 
                                WAIT 1
                              SHELL "mount | grep /mnt/source" TO sdump
                              INC i
                            UNTIL Len(Trim(sdump)) = 0 OR i = 10
                          IF NOT (sBasePath) THEN 
                            SHELL "mount | grep ^" & main.SelectedSrc.HostDevice TO sdump
                              IF Len(Trim(sdump)) <= 0 THEN 
                                SHELL "mkdir -p " & Replace(main.SelectedSrc.HostDevice, "dev", "mnt") WAIT 
                                SHELL "mount " & main.SelectedSrc.HostDevice & Space(1) & Replace(main.SelectedSrc.HostDevice, "dev", "mnt") WAIT 
                                sBasePath = Replace(main.SelectedSrc.HostDevice, "dev", "mnt")
                              ELSE 
                                sBasePath = Trim(sdump)
                              END IF
                          END IF
                          'IF Exist(sBasePath &/ File.BaseName(main.SelectedSrc.IsoName) & "-CD2.iso") THEN 
                          iso = Left(main.SelectedSrc.IsoName, Len(main.SelectedSrc.IsoName) - Len(".iso")) & "-CD2.iso"
                          IF Exist(sBasePath &/ iso) THEN 
                            'Message.Info("Found " & sBasePath &/ iso)
                            SHELL "mkdir -p /mnt/hd"
                            SHELL "mount -o loop " & sBasePath &/ iso & Space(1) & "/mnt/hd" WAIT 
                            main.Install.SrcMnt = "/mnt/hd"
                          ELSE 
                            REPEAT 
                              Dialog.Title = ("Select next ISO image")
                              Dialog.Path = Replace(main.SelectedSrc.HostDevice, "dev", "mnt")
                              'Dialog.Filter = ["*.iso", ("Installable Image")]
                              Dialog.Filter = [Left(main.SelectedSrc.IsoName, Len(main.SelectedSrc.IsoName) - Len(".iso")) & "-CD2.iso", ("ISO Image")]
                                SELECT CASE Message.Question(("Continue without installing additional bonus software?"), ("Yes"), ("No"))
                                  CASE 1
                                    RETURN 
                                END SELECT 
                              Dialog.OpenFile()
                                SHELL "mount -o loop " & Dialog.Path & Space(1) & "/mnt/source" WAIT 
                                  SHELL "grep ^RELEASE_ID= /mnt/source/veclinux/VINSTALL.CONF | cut -f2 -d=" TO RelID
                                  SHELL "grep ^Media_ID= /mnt/source/veclinux/VINSTALL.CONF | cut -f2 -d=" TO MedID
                                IF Trim(RelID) <> Trim(main.SelectedSrc.ReleaseID) OR IF Trim(MedID) = Main.SelectedSrc.MediaID THEN 
                                  SHELL "umount /mnt/source" WAIT 
                                END IF
                            UNTIL Trim(RelID) = Trim(main.SelectedSrc.ReleaseID) AND Trim(MedID) <> main.SelectedSrc.MediaID
                              main.Install.SrcMnt = "/mnt/source"
                            DEBUG "Found ISO 2... Continue installation."
                          END IF
              END IF
            ELSE 
            
               SHELL "grep ^MULTI_SINGLE= " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d=" TO sdump
                IF Trim(sdump) = "1" THEN 
                  main.Install.SrcMnt = "/mnt/source/CD2"
              ELSE 
                'SHELL "cp -ar /mnt/source/veclinux/CD2 /mnt/target/tmp" WAIT 
            
                        ' this istall was done from a partition.
                        SHELL "umount /mnt/source" WAIT 
                          Message.Info(("Please select the directory containing the additional software to be installed"))
                          IF Dialog.SelectDirectory() THEN 
                            SELECT CASE Message.Question(("Would you like to continue without installing the additional software?"), ("Yes"), ("No"))
                              CASE 1
                                RETURN 
                            END SELECT 
                          END IF
                            Dialog.Path = "/mnt"
                            Dialog.Title = ("Select Directory with Additional Software")
                              REPEAT 
                                IF Exist(Dialog.Path &/ "veclinux" &/ "VINSTALL.CONF") = FALSE THEN 
                                  Message.Error(("This directory does not contain the software needed to complete the install.") & gb.NewLine &
                                  ("Please select the directory containing the additional software for") & main.Install.Name)
                                  Dialog.Title = ("Select Directory with Additional Software")
                                  Dialog.SelectDirectory()
                                ELSE 
                                  SHELL "grep ^RELEASE_ID= " & Dialog.Path &/ "veclinux" &/ "VINSTALL.CONF | cut -f2 -d=" TO RelID
                                  END IF
                                UNTIL Trim(RelID) = Trim(main.SelectedSrc.ReleaseID)
                                main.Install.SrcMnt = Dialog.Path                              

                              END IF
            END IF
            END IF

  ' refresh the new md5sum lists.
  KILL Temp("pkgpaths")
    DEBUG "Refreshing package path definitions."
    SHELL "cat " & main.Install.SrcMnt &/ "packages" &/ "CHECKSUMS.md5 | cut -f2-10 -d ." TO sdump
  File.Save(Temp("pkgpaths"), Trim(sDump))

  ' now, trigger the install process.
    FOR EACH sItem IN main.Install.CD2Bulks
      IF InStr(sItem, "l10n") THEN CONTINUE 
      ME.install_this_cd2_bulk(tlStatus, pbProg, sItem)
    NEXT 
  ' Now install languages, if any where chosen
  IF main.LangPacks.Count > 0 THEN 
    ME.INSTALL_LANGUAGE_PACKS(tlstatus, pbProg)
  END IF
  
  
END


PUBLIC FUNCTION INSTALL_PACKAGES(tlStatus AS TextLabel, pbProg AS ProgressBar, iInstallType AS Integer) AS Integer
  
  DIM $pkg, $bulk, $bulkfile, $file, $path AS String
  DIM $BulkArr, $PkgArr, $filearr AS String[]
  DIM $pkgcnt, i, ii, iii, ires AS Integer
  DIM sDump AS String
  DIM cb AS CheckBox ' for the minimal install options
  ' Load file that defines package paths into a temp file
  SHELL "cat /mnt/source/packages/CHECKSUMS.md5 | cut -f 2-10 -d \'.\'" TO sDump
  File.Save(Temp("pkgpaths"), Trim(sDump))
  
  ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = FALSE
  
     tlStatus.Text = ("Preparing system partitions")
   IF MdlMain.PERFORM_PARTITIONING() > 0 THEN 
    Message.Error(("An error occurred while preparing partitions. Unable to continue"))
    RETURN 
    'RETURN 1
   ELSE 
    ' Update Status and continue to next step
      MdlMain.ADVANCE_INSTALL_PROGRESS(0)
      MdlMain.Mount_Target_Partitions()
   END IF 
   
   ' Count number of packages to be installed.
  MdlMain.COUNT_PACKAGES_TO_BE_INSTALLED()
  
  
  
  ' Install initial directory structure for the target /
    IF ME.INSTALL_INITIAL_PACKAGES(tlStatus, pbProg) > 0 THEN 
'IF ME.INSTALL_INITIAL_PACKAGES() > 0 THEN 
      Message.Error(("Error during installation of required software. Unable to continue"))
      RETURN 1
    ELSE 
      'uPDATE STATUS AND CONTINUE TO NEXT STEP
        ME.ADVANCE_INSTALL_PROGRESS(1)
    END IF
   
   WAIT 1 ' brace yourselves... installation is about to begin
   
   ' prepare boot menu entry objects for boot menu (this will only do existing OS's ... we will need to create a new object for the isntalled system after this process is done)
   
   'MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS()
   
    SELECT CASE iInstallType
      CASE 0
       GOTO FULL_INSTALL
      CASE 1
       GOTO CUSTOM_INSTALL
      CASE 2
        GOTO MINIMAL_INSTALL
    END SELECT 
  
  
  CUSTOM_INSTALL:
        FOR i = 0 TO main.Install.Bulks.Max
              IF Trim(main.Install.Bulks[i]) THEN 
                IF ME.INSTALL_THIS_BULK(tlStatus, pbProg, Trim(main.Install.Bulks[i])) > 0 THEN 
                  Message.Error(("Unable to install contents of") & Space(1) & Trim(main.install.Bulks[i]) & "." & Space(1) & ("Cannot continue"))
                  ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
                  RETURN 1
                  'BREAK 
          END IF
         
              END IF
            NEXT 
                
        ' and now we do the packages. (THESE ARE LISTED IN THE 'OPTIONAL' BULK DEF)
        DEBUG "  --- Installing optional individual packages"
        $filearr = Split(ClsGlobal.sPkgListToInstall, ",")
          FOR i = 0 TO main.Install.Packages.Max
            '$path = ME.GET_PACKAGE_FULL_PATH(Trim($filearr[i]))
            $path = ME.Get_FULL_TLZ_PACKAGE(Trim(main.Install.Packages[i]))
            INC $currpkg
              pbProg.Value = $currpkg / $pkgtotal
              IF $path THEN 
                IF Exist("/mnt/source/packages" &/ Trim($path)) THEN 
                  'WAIT 0.125
                  tlStatus.Text = ("Installing optional package") & Space(1) & File.Name($path)
                  ires = ME.INSTALL_THIS_PACKAGE("/mnt/source/packages" &/ Trim($path))
                    IF ires > 0 THEN 
                      ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
                      RETURN 1
                    END IF
                END IF
              END IF

          NEXT 


          IF ME.INSTALL_KERNEL_AND_INITRD() > 0 THEN 
            Message.Error(("Error while installing kernels and initrds"))
              DEBUG "Something wrong in the kernel installation module"
              ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
              RETURN 1
        END IF
        
        ' THIS IS IN CASE THIS IS A MULTI-CD INSTALL
        
          IF main.SelectedSrc.MultiDisk = TRUE AND main.Install.CD2Bulks.count > 0 THEN 
            DEBUG "Begin secondary media installation"
              Store_vlconfig_temporarily()
              trigger_cd2_install(pbProg, tlStatus)
                ' install vlconfig2 from /mnt/target/tmp
              SHELL "installpkg --root /mnt/target /mnt/target/tmp/vlconfig2-*.t?z" WAIT 
              SHELL "rm /mnt/target/tmp/vlconfig2-*.t?z" WAIT 
              
          ELSE 
            INSTALL_VL_CONFIG() ' install vl config
          END IF  
        '''''''''''''''''''''''''''''''''''''''''''''''''''''
          
          pbProg.Value = 1
          main.Install.write_fstab()
        'MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS()
          ME.ADVANCE_INSTALL_PROGRESS(2)
          MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS
          'MdlMain.write_background_config_scripts()
          pbProg.Value = 1
          Message.Info(("Installation is complete. Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue"))
          ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
          tlStatus.Text = ("Installation complete... Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue.")
            ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
  
  
        
          
    RETURN 0
  
  FULL_INSTALL:
    ' >>>>>>>>>>>> FULL INSTALLATION BEGINS HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
  
    SHELL "cat " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | grep OPT | cut -f2 -d:" TO sDump
    $BulkArr = Split(Trim(sDump), gb.NewLine)
    main.Install.Bulks = $BulkArr
    
    FOR EACH $bulk IN main.Install.Bulks
      IF $bulk = "VINSTALL.CONF" THEN CONTINUE ' skip the conf file
      IF $bulk = "VECLINUX" THEN CONTINUE ' we already did veclinux
        DEBUG "Processing " & $bulk
          IF ME.INSTALL_THIS_BULK(tlStatus, pbProg, $bulk) > 0 THEN 
            Message.Error(("Unable to install the components of") & Space(1) & $bulk & Space(1) & ("Unable to continue."))
            ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
            RETURN 1
            BREAK 
          END IF
    NEXT 
    
    ' Add cd2 bulks
    IF main.SelectedSrc.MultiDisk = TRUE THEN 
      FOR EACH $bulk IN Dir("/mnt/source/veclinux/CD2")
        main.Install.CD2Bulks.Add($bulk)
      NEXT 
    END IF
    
    IF ME.INSTALL_KERNEL_AND_INITRD() > 0 THEN 
    Message.Error(("Error while installing kernels and initrds"))
    DEBUG "Something wrong in the kernel installation module"
    ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
    RETURN 1
  END IF
    
    IF Main.SelectedSrc.MultiDisk = TRUE THEN 
      Store_vlconfig_temporarily()
      trigger_cd2_install(pbProg, tlStatus)
       SHELL "installpkg --root /mnt/target /mnt/target/tmp/vlconfig2-*.t?z" WAIT 
       SHELL "rm /mnt/target/tmp/vlconfig2-*.t?z" WAIT 
    ELSE 
    
        ME.INSTALL_VL_CONFIG()
    END IF
    
    main.Install.write_fstab()
    SHELL "rm /mnt/target/* 2>/dev/null"
    SHELL "rm /mnt/target/tmp/* 2>/dev/null"
    ME.ADVANCE_INSTALL_PROGRESS(2)
      
  'MdlMain.write_background_config_scripts()
  MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS
      pbProg.Value = 1
      Message.Info(("Installation is complete. Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue"))
          ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
          tlStatus.Text = ("Installation complete... Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue.")
      
      ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
  
      
    
    RETURN 0
  MINIMAL_INSTALL:
    
    ' >>>>>>>>>>>>>> MINIMAL INSTALLATION BEGINS HERE <<<<<<<<<<<<<<<<<<<<<<<<

    
      FOR EACH cb IN ClsGlobal.objMinComponents
        IF cb.Value = TRUE THEN 
          IF ME.INSTALL_THIS_BULK(tlStatus, pbProg, cb.Tag) > 0 THEN 
            Message.Error(("Unable to install the components of") & Space(1) & cb.Tag & Space(1) & ("Unable to continue."))
            RETURN 1
            BREAK 
          END IF
        END IF
      NEXT 
      ME.INSTALL_VL_CONFIG()
      main.Install.write_fstab()
      ME.ADVANCE_INSTALL_PROGRESS(2)
      IF ME.INSTALL_KERNEL_AND_INITRD() > 0 THEN 
      Message.Error(("Error while installing kernels and initrds"))
      DEBUG "Something wrong in the kernel installation module"
      ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
      RETURN 1
  END IF
  
  MdlBootMngr.CREATE_MENU_ENTRY_OBJECTS
  'MdlMain.write_background_config_scripts()
  pbProg.value = 1
      Message.Info(("Installation is complete. Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue"))
          ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
          tlStatus.Text = ("Installation complete... Click") & Space(1) & ClsGlobal.fRunningMainForm.btNext.text & Space(1) & ("to continue.")
      ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
  ClsGlobal.fRunningMainForm.btback.enabled = FALSE
  ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
  
    
              
    RETURN 0
  
END

PUBLIC FUNCTION Resize_Object(Item AS Object) AS Integer
  
  'RETURN MdlObjSizer.get_object_width(Item.text)
  item.width = MdlObjSizer.get_object_width(item.text) + 48
  
END


PUBLIC SUB WRITE_ETC_VECTOR_VERSION()

  DIM builddate AS String
  DIM sLine AS String
  
    
    sLine = main.Install.Name & Space(1) & main.Install.Version & Space(1) & "built on" & Space(1) & main.SelectedSrc.BuildDate
    'Message(sLine)
    'TRY File.Save("/mnt/target/etc/vector-version", sLine)
    DEBUG "Writing distro ID"
    SHELL "echo \"" & sLine & "\" > /mnt/target/etc/vector-version" WAIT 
    
  
END


PUBLIC FUNCTION install_this_cd2_bulk(tlStatus AS TextLabel, pbProg AS ProgressBar, sBulkName AS String) AS Integer
  DIM $list AS String[] '= Split(Trim(File.Load(ClsGlobal.sTargetPath &/ "tmp" &/ "CD2" &/ sBulkName)), gb.NewLine)
  DIM $BulkDesc, $pkg, $path AS String
  DIM i AS Integer
  
  DEBUG "Installing " & sBulkName & " from CD2"
    
    $list = Split(Trim(File.Load("/mnt/target/tmp/CD2" &/ Trim(sBulkName))), gb.NewLine)
    $BulkDesc = $list[0]
   FOR i = 1 TO $list.Max
      '$path = ME.GET_PACKAGE_FULL_PATH($list[i]) ' Old method using pkgname.
      $path = ME.Get_FULL_TLZ_PACKAGE($list[i]) ' New method not using pkgname
        IF $path THEN 
                 WAIT 0.125
          'INC $currpkg
            tlStatus.Text = ("Installing") & Space(1) & $BulkDesc
            pbProg.Value = $currpkg / $pkgtotal
              IF ME.INSTALL_THIS_PACKAGE(main.Install.SrcMnt &/ "packages" &/ $path) > 0 THEN 
                Message.Error(("Error installing") & Space(1) & $path)
                ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
                RETURN 1
              ELSE 
                'pbProg.Value = (i + 1) / $list.Max
                
              END IF
              tlStatus.Parent.Parent.Refresh()
              ClsGlobal.fRunningMainForm.Refresh()

              pbProg.Value = $currpkg / $pkgtotal
        END IF
        INC $currpkg
    NEXT 
    
  
END

PUBLIC FUNCTION INSTALL_LANGUAGE_PACKS(tlstatus AS TextLabel, Pbprog AS ProgressBar) AS Integer
  
DIM slang, spath AS String
DIM i AS Integer
IF main.LangPacks.Count <= 0 THEN RETURN 
DEBUG "Installing language packs"
  FOR EACH slang IN main.LangPacks
    spath = ME.Get_FULL_TLZ_PACKAGE(slang)
      IF (spath) THEN 
        tlstatus.Text = ("Installing language pack") & Space(1) & slang
      ME.INSTALL_THIS_PACKAGE(main.Install.SrcMnt &/ "packages" &/ spath)
        pbProg.Value = $currpkg / $pkgtotal
        INC $currpkg
      END IF
  NEXT 
END



PUBLIC FUNCTION INSTALL_THIS_BULK(tlStatus AS TextLabel, pbProg AS ProgressBar, sBulkName AS String) AS Integer
  
  DIM $list AS String[] = Split(Trim(File.Load(main.Install.SrcMnt &/ "veclinux" &/ sBulkName)), gb.NewLine)
  DIM $pkg, $path AS String
  DIM i AS Integer
  
    FOR i = 0 TO $list.Max
      '$path = ME.GET_PACKAGE_FULL_PATH($list[i]) ' Old method using pkgname.
      $path = ME.Get_FULL_TLZ_PACKAGE($list[i]) ' New method not using pkgname
        IF $path THEN 
                 WAIT 0.125
          'INC $currpkg
            tlStatus.Text = ("Installing") & Space(1) & $path '& Space(1) & "(" & ("Part of") & Space(1) & sBulkName & ")"
            pbProg.Value = $currpkg / $pkgtotal
              IF ME.INSTALL_THIS_PACKAGE(main.Install.SrcMnt &/ "packages" &/ $path) > 0 THEN 
                Message.Error(("Error installing") & Space(1) & $path)
                ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
                RETURN 1
              ELSE 
                'pbProg.Value = (i + 1) / $list.Max
                
              END IF
              tlStatus.Parent.Parent.Refresh()
              ClsGlobal.fRunningMainForm.Refresh()
              'WAIT 0.035
              'WAIT 0.05
              pbProg.Value = $currpkg / $pkgtotal
        END IF
        INC $currpkg
    NEXT 
          
            
        
  
  
END


PUBLIC FUNCTION INSTALL_THIS_PACKAGE(sFullPkgPath AS String) AS Integer
  
  'DIM $hproc AS Process
  DIM sBuff AS String
    
    '$hproc = EXEC ["/sbin/installpkg ", "-R", ClsGlobal.sTargetPath, sFullPkgPath] WAIT 
    '$hproc = SHELL "/sbin/installpkg -R " & ClsGlobal.sTargetPath & Space(1) & sFullPkgPath WAIT 'TO sBuff
    '$hproc = EXEC ["/sbin/installpkg", "-q", "-R", ClsGlobal.sTargetPath, sFullPkgPath] FOR READ 'WAIT 
    ''''$hproc = EXEC ["/sbin/installpkg", "-q", "-R", ClsGlobal.sTargetPath, sFullPkgPath] WAIT FOR OUTPUT ''''' THIS HAS CHANGED FOR NEW TXZ FORMAT
    '$hproc = EXEC ["ROOT=" & ClsGlobal.sTargetPath, "/sbin/installpkg", sFullPkgPath] WAIT FOR OUTPUT 
   $hproc = EXEC ["/sbin/installpkg", "--root", Main.Install.TargetMount, sFullPkgPath] WAIT FOR OUTPUT 
    '$hproc = EXEC ["/sbin/installpkg", "-q", "-R", main.install.TargetMount, sFullPkgPath] WAIT FOR OUTPUT 
    
      IF $hproc.Value > 0 THEN 
        DEBUG sFullPkgPath & Space(1) & "failed to install"
        'Message.Error($hproc.State)
        RETURN 1
      END IF
    RETURN 0
  
END

PUBLIC SUB Process_Read()
  
  DIM sLine AS String
  READ #LAST, sLine, -256
  PRINT sLine
  
END
PUBLIC SUB Process_Error(Errormessage AS String)
  
  PRINT Errormessage
  
END

PUBLIC SUB Get_FULL_TLZ_PACKAGE(sPkgname AS String) AS String
  
  DIM sNameArr, sList AS String[]
  DIM sPkg, sTlzName, sShortName, sParentDir AS String
  DIM sDump, sDump1, sRetval AS String
  DIM item AS String
  DIM i, ii AS Integer

  IF Exist(Temp("pkgpaths")) = FALSE THEN 
    SHELL "cat /mnt/source/packages/CHECKSUMS.md5 | cut -f2-10 -d/" TO sdump
    File.Save(Temp("pkgpaths"), Trim(sdump))
  END IF
  
  sDump1 = Trim(File.Load(Temp("pkgpaths")))
  sList = Split(Trim(sDump1), gb.NewLine)
  
    FOR i = 0 TO sList.Max
      IF InStr(sList[i], sPkgname) THEN ' only jack with the strings that actually contain the pkgname in them
        
        sParentDir = Left(sList[i], RInStr(sList[i], "/"))
        sPkg = Right(sList[i], Len(sList[i]) - Len(sParentDir))
        'PRINT "Found possibel match " & sPkg & " in " & sParentDir
          ' now find out if the left of the string is the same as the package name and it is a hit for what we are looking for.
          sNameArr = Split(sPkg, "-")
          sNameArr.Delete(sNameArr.Max) ' Take out the '1vl?0.t?z' part of the array
          sNameArr.Delete(sNameArr.Max) ' take out the arch part of the array (noarch)
          sNameArr.Delete(sNameArr.Max) ' take out the pkg version part of the array
          sTlzName = sNameArr.Join("-")
          'FOR ii = 0 TO (sNameArr.Count - 4)
          '  sTlzName = sTlzName & sNameArr[ii] & "-"
          'NEXT 
           ' sTlzName = Left(Trim(sTlzName), Len(Trim(sTlzName)) - 1)
            'PRINT sTlzName
            IF Trim(sTlzName) = sPkgname THEN
              sRetval = sList[i] 'sParentDir &/ sPkg 'Trim(sTlzName)
              RETURN sRetval
            
              ELSE 
                sTlzName = ""
            END IF
            
      END IF
    NEXT 
    
    DEBUG sPkgname & " not found in ISO"
    'Message("Looking for " & sPkgname)
    'sRetval = sTlzName
    'Message(sTlzName)
    
  
END




PUBLIC FUNCTION GET_PACKAGE_FULL_PATH(sPkgname AS String) AS String
  
  DIM sList AS String[]
  DIM sPkg, sShortname, sParentDir AS String
  DIM sDump1, sDump, sRetval AS String
  DIM i AS Integer
  
  sdump1 = Trim(File.Load(Temp("pkgpaths")))
  sList = Split(Trim(sdump1), gb.NewLine)
  
    FOR i = 0 TO sList.Max
     
      IF InStr(sList[i], sPkgname) THEN 
      sParentDir = Left(sList[i], RInStr(sList[i], "/"))
      sPkg = Right(sList[i], Len(sList[i]) - Len(sParentDir))
        'SHELL "pkgname " & sPkg TO sDump
        EXEC ["/sbin/pkgname", sPkg] TO sDump
          IF Trim(sdump) = Trim(sPkgname) THEN 
            'PRINT "looking for " & sPkgname & Space(5) & sDump
             sRetval = sList[i]
             BREAK ' I've found a match... no need to keep looking
          END IF
      END IF
    NEXT 
    
  IF Trim(sRetval) THEN 
    RETURN Trim(sRetval)
  ELSE 
    DEBUG sPkgname & " not found"
  END IF
END

PUBLIC SUB CREATE_CREDIT_LABELS(sHostScroll AS ScrollView)
  
  DIM hb AS HBox
  DIM tl AS TextLabel
  DIM sFile AS String
  DIM sCredits AS String[]
  DIM i AS Integer
  
  hb = NEW HBox(sHostScroll)
    hb.Height = sHostScroll.Height * 1.25
    hb.Expand = TRUE
  sFile = "/mnt/source/CREDIT" ' "/mnt/loop/CREDIT" '"/mnt/source/CREDIT"
  sCredits = Split(Trim(File.Load(sFile)), gb.NewLine)
    FOR i = 0 TO sCredits.Max
      tl = NEW TextLabel(sHostScroll)
        WITH tl
          .Alignment = Align.Center
          .Height = 28
          .Expand = TRUE
            IF InStr(Trim(sCredits[i]), "M0E-lnx") THEN 
              .Height = 28 * 2
              sCredits[i] = "<b>" & "M0E-lnx" & "</b>" & "<br>" & "[ GUI Installer, vpackager, vasmCC ]"
            ELSE IF InStr(Trim(sCredits[i]), "Uelsk8s") THEN 
              .Height = 28 * 2
              sCredits[i] = "<b>" & "Uelsk8s" & "</b><br>" & "[ ISO Master, GUI installer ]"
            ELSE IF InStr(Trim(sCredits[i]), "Vector") THEN 
              .Height = 28 * 2
              sCredits[i] = "<b>" & "Vector" & "</b><br>" & "[ Vectorlinux founder ]"
            ELSE IF InStr(Trim(sCredits[i]), "Tigger") THEN 
              .Height = 28 * 2
              sCredits[i] = "<b>" & "Tigger" & "</b><br>" & "[ SOHO Architect, GUI installer ]"
            ELSE IF InStr(Trim(sCredits[i]), "(") THEN 
              .Height = 28 * 2
              sCredits[i] = Left(sCredits[i], InStr(sCredits[i], "(") - 1) & "<br>" & Right(sCredits[i], Len(sCredits[i]) - InStr(sCredits[i], "(") + 1)              
              sCredits[i] = Replace(sCredits[i], "(", "[ ")
              sCredits[i] = Replace(sCredits[i], ")", " ]")
            
            END IF
          .Text = sCredits[i]
        END WITH 
      hb = NEW HBox(sHostScroll)
        hb.Height = 14
        hb.Expand = TRUE
  NEXT 
  
END