Source

vlocity-vinstall-gambas / Vlocity / MdlInstall.module

Full commit
' 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 Bulks AS NEW Object[]
PUBLIC tlzs AS NEW Object[]



PUBLIC SUB Create_Required_Bulks()
  
  DIM blk AS Bulk
  DIM ConfLst, BlkCont AS String[]
  DIM sDump, sDesc, sPkg AS String
  DIM i AS Integer
  
  
  IF Exist(main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.INI") THEN 
    FOR EACH sPkg IN main.Install.Config.Keys["bulks/required"]
    
      blk = NEW Bulk
      blk.Required = TRUE
      blk.Name = sPkg
      blk.Path = main.Install.SrcMnt &/ "veclinux" &/ blk.Name
      blk.Description = main.Install.Config["bulks/required" &/ sPkg]
      blk.Contents = Split(Trim(File.Load(blk.Path)), gb.NewLine)
      'BlkCont = Split(Trim(File.Load(blk.Path)), gb.NewLine)
      main.Install.BulkObjects.Push(blk)
    NEXT 
  ELSE 
  SHELL "cat " & Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep \"BULK\" | grep REQ| cut -f2 -d:" TO sDump
  
  ConfLst = Split(Trim(sDump), gb.NewLine)
    FOR i = 0 TO ConfLst.Max
      blk = NEW Bulk
        blk.Name = Trim(ConfLst[i])
        blk.Required = TRUE 
        blk.Path = Main.Install.SrcMnt &/ "veclinux" &/ blk.Name
          BlkCont = Split(Trim(File.Load(blk.Path)), gb.NewLine)
        blk.Contents = BlkCont
        SHELL "cat " & Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep " & blk.Name & " | cut -f4 -d:" TO blk.Description
        blk.Description = Replace(blk.Description, "\'", "")
        blk.Description = Replace(blk.Description, "\"", "")

        Main.Install.BulkObjects.Add(blk)
    NEXT 
END IF
  
END

PUBLIC SUB create_Optionals_Bulk(bFullInst AS Boolean)
  
  DIM b AS Bulk
  DIM sDump AS String
  DIM sarr, Contents AS String[]
  DIM i AS Integer
  
  
  IF Exist(Main.Install.SrcMnt &/ "veclinux" &/ "OPTIONAL") = FALSE THEN RETURN 
  b = NEW Bulk
    b.Name = "OPTIONAL"
    b.Path = Main.Install.SrcMnt &/ "veclinux" &/ b.Name
    b.Required = FALSE
    sarr = Split(Trim(File.Load(b.Path)), gb.NewLine)
    b.Description = "Individually packaged optional software."
IF bFullInst = TRUE THEN 
    'b.Contents = Split(Trim(File.Load(b.Path)), gb.NewLine)
      FOR i = 0 TO sarr.Max
        b.Contents.Push(Trim(sarr[i]))
      NEXT 
ELSE 
  FOR i = 0 TO Main.Install.Packages.Max
    b.Contents.Push(Trim(Main.Install.Packages[i]))
  NEXT 
END IF
  
  
  Main.Install.BulkObjects.Push(b)
    
  
END

PUBLIC SUB created_selected_bulk_objects()
  
  DIM item AS String
  DIM blk AS Bulk
  DIM cont AS String[]
  DIM i AS Integer
  
  IF Main.Install.Bulks.Count <= 0 THEN RETURN 
  FOR EACH item IN Main.Install.Bulks
    blk = NEW Bulk
    blk.Name = item
    blk.Path = Main.Install.SrcMnt &/ "veclinux" &/ blk.Name
      cont = Split(Trim(File.Load(blk.Path)), gb.NewLine)
      SHELL "cat " & Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | grep " & blk.Name & " | cut -f4 -d:" TO blk.Description
      blk.Description = Replace(blk.Description, "\'", "")
      blk.Description = Replace(blk.Description, "\"", "")
      'blk.Description = Trim(cont[0])
      blk.Required = FALSE
      FOR i = 0 TO cont.Max
      blk.Contents.Push(Trim(cont[i]))
      NEXT 
      Main.Install.BulkObjects.Push(blk)
  NEXT 
  
END


PUBLIC SUB create_CD2_Bulk_Objects()
  
  DIM item AS String
  DIM blk AS Bulk
  DIM Cont AS String[]
  DIM i AS Integer
  
  IF Main.Install.CD2Bulks.Count <= 0 THEN RETURN 
    FOR EACH item IN Main.Install.CD2Bulks
      IF item = "LANG" THEN CONTINUE 
      blk = NEW Bulk
      blk.Name = item
      blk.Path = Main.Install.SrcMnt &/ "veclinux" &/ "CD2" &/ blk.Name
        Cont = Split(Trim(File.Load(blk.Path)), gb.NewLine)
      blk.Required = FALSE
      blk.Description = Trim(Cont[0]) ' line 1 has the description
        FOR i = 1 TO Cont.Max
          blk.Contents.Push(Trim(Cont[i]))
        NEXT 
    Main.Install.CD2BulkObjects.Push(blk)
  NEXT 
       
END

PUBLIC SUB Create_Minimal_install_bulks()
  
  DIM b AS Bulk
  DIM bu AS String
  DIM arr AS String[]
  DIM i AS Integer
  
  IF ClsGlobal.MinOptions.Count <= 0 THEN RETURN 
  
  FOR EACH bu IN ClsGlobal.MinOptions
    b = NEW Bulk
    b.Name = bu
    b.Required = FALSE
    b.Path = Main.Install.SrcMnt &/ "veclinux" &/ Trim(b.Name)
    arr = Split(Trim(File.Load(b.Path)), gb.NewLine)
    b.Description = Trim(arr[0])
    FOR i = 0 TO arr.Max
      b.Contents.Push(Trim(arr[i]))
    NEXT 
    Main.Install.BulkObjects.Push(b)
  NEXT 
  
END

PUBLIC SUB make_bulks_for_full_install()
  
  DIM sarr, sr1 AS String[]
  DIM sdump, sdesc, item AS String
  DIM blk AS Bulk
  DIM i, n AS Integer
  
  IF Exist(main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.INI")
    FOR EACH item IN main.Install.Config.Keys["bulks/optional"]
      blk = NEW Bulk
      blk.Name = item
      blk.Description = main.Install.Config["bulks/optional" &/ blk.Name]
      blk.Required = FALSE
      blk.Path = main.Install.SrcMnt &/ "veclinux" &/ blk.Name
      blk.Contents = Split(Trim(File.Load(main.Install.SrcMnt &/ "veclinux" &/ blk.Name)), gb.NewLine)
      main.Install.BulkObjects.Push(blk)
    NEXT 
      
 ELSE  
  SHELL "cat " & Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | grep OPT | cut -f 2 -d:" TO sdump
  sarr = Split(Trim(sdump), gb.NewLine)
    FOR i = 0 TO sarr.Max
      SHELL "cat " & main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | grep " & Trim(sarr[i]) & " | cut -f4 -d:" TO sdesc
        sdesc = Replace(sdesc, "\'", "")
        sdesc = Replace(sdesc, "\"", "")
        
      blk = NEW Bulk
      blk.Name = Trim(sarr[i])
      blk.Required = FALSE
      blk.Path = Main.Install.SrcMnt &/ "veclinux" &/ blk.Name
        sr1 = Split(Trim(File.Load(blk.Path)), gb.NewLine)
        blk.Description = Trim(sdesc)
        FOR n = 0 TO sr1.Max
          blk.Contents.Push(Trim(sr1[n]))
        NEXT 
      Main.Install.BulkObjects.Push(blk)
    NEXT 
  END IF
  
  '================ FIXME: Add provisions for language options to be read from vinstall.ini =========
  
  IF Main.SelectedSrc.MultiDisk = FALSE THEN RETURN 
  FOR EACH item IN Dir(Main.Install.SrcMnt &/ "veclinux" &/ "CD2")
    IF ITEM = "LANG" THEN CONTINUE 
    blk = NEW Bulk
    blk.Name = item
    blk.Path = Main.Install.SrcMnt &/ "veclinux" &/ "CD2" &/ blk.Name
    blk.Required = FALSE
      sarr = Split(Trim(File.Load(blk.Path)), gb.NewLine)
      blk.Description = sarr[0]
      FOR n = 1 TO sarr.Max
      blk.Contents.Push(sarr[n])
      NEXT 
    Main.Install.CD2BulkObjects.Push(blk)
  NEXT 
  
  ' NOW CREATE THE LANGUAGE PACK SELECTION (INSTALL ALL OF THEM)
  IF Exist(main.Install.SrcMnt &/ "veclinux/CD2/LANG") = FALSE THEN RETURN 
  sarr = Split(Trim(File.Load(main.Install.SrcMnt &/ "veclinux/CD2/LANG")), gb.NewLine)
  FOR i = 1 TO sarr.Max 'line 0 is the bulk description
    main.LangPacks.Push(Trim(sarr[i]))
  NEXT 
  
END

PUBLIC FUNCTION Count_Package_Total() AS Integer
  
  DIM i AS Integer
  DIM b AS Bulk
  
  FOR EACH b IN Main.Install.BulkObjects
    i = (i + b.Contents.Count)
  NEXT 
    INC i ' for vlconfig2
  'IF Main.Install.CD2Bulks.Count <= 0 THEN RETURN i
  FOR EACH b IN Main.Install.CD2BulkObjects
    i = (i + b.Contents.Count)
  NEXT 
  
  i = (i + Main.LangPacks.Count)
  
  
  RETURN i
  
END


' PUBLIC SUB Create_BULLKS_FOR_CUSTOM_INSTALL()
'   
'   DIM item AS Bulk
'   DIM thing, sDUmp AS String
'   DIM i AS Integer
'   DIM arr AS String[]
'   
'   FOR EACH thing IN Main.Install.Bulks
'     item = NEW Bulk
'     item.Name = thing
'     item.Path = Main.Install.TargetMount &/ "veclinux" &/ Trim(thing)
'     arr = Split(Trim(File.Load(item.Path)), gb.NewLine)
'     item.Description = arr[0]
'       FOR i = 1 TO arr.Max
'         item.Contents.Push(Trim(arr[i]))
'       NEXT 
'     item.Required = FALSE
'     Main.Install.BulkObjects.Add(item)
'     NEXT 
'   
' '   IF Main.SelectedSrc.MultiDisk = FALSE THEN RETURN 
'   ' 
'   ' FOR EACH thing IN Main.Install.CD2Bulks
'   '   IF thing = "LANG" THEN CONTINUE 
'   '   item = NEW Bulk
'   '   item.Name = thing
'   '   item.Path = Main.Install.TargetMount &/ "veclinux" &/ "CD2" &/ Trim(thing)
'   '   arr = Split(Trim(File.Load(item.Path)), gb.NewLine)
'   '   item.Description = arr[0]
'   '   item.Required = FALSE
'   '   FOR i = 1 TO arr.Max
'   '     item.Contents.Push(Trim(arr[i]))
'   '   NEXT 
'   '   Main.Install.CD2BulkObjects.Push(item)
'   ' NEXT 
'   
' END