Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
	- Functions.module: Created the MkPart function that uses fdisk
		to create new partitions on a given drive.
		Receives drive name, partition number and partition size
		and returns true if the partition was created and false
		if the creation failed.
  • Loading branch information
easuter committed Jan 7, 2008
1 parent 35599f2 commit 1f92eba
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 69 deletions.
8 changes: 6 additions & 2 deletions .lang/.pot
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,15 @@ msgstr ""
msgid "Click on a row to select..."
msgstr ""

#: frmGO.class:117
#: frmGO.class:116
msgid "Ready to install!"
msgstr ""

#: frmGO.class:132
#: frmGO.class:130
msgid "TextLabel1"
msgstr ""

#: frmGO.class:136
msgid "Begin installation"
msgstr ""

Expand Down
8 changes: 6 additions & 2 deletions .lang/frmGO.pot
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: frmGO.class:117
#: frmGO.class:116
msgid "Ready to install!"
msgstr ""

#: frmGO.class:132
#: frmGO.class:130
msgid "TextLabel1"
msgstr ""

#: frmGO.class:136
msgid "Begin installation"
msgstr ""

2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Title=VL-gui-installer
Startup=Main
Icon=vl_logo_icon2.png
Version=0.0.317
Version=0.0.322
Library=gb.qt
Library=gb.qt.ext
TabSize=3
Expand Down
55 changes: 55 additions & 0 deletions Functions.module
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,61 @@ ENDIF

END

PUBLIC FUNCTION ErasePartTable(device AS String) AS Boolean
'Dangerous stuff....this will erase the partition table on a given device, and create a new MSDOS table. Return true if all goes well
DIM sBuffer AS String

'And here goes one of the ugliest and dirtiest ways of process management:
SHELL "parted -s " & device & " mklabel msdos" TO sBuffer

IF Trim(sBuffer) = "" THEN
RETURN TRUE
ELSE IF InStr(sBuffer, "Err") THEN
RETURN FALSE
ENDIF

END

PUBLIC FUNCTION MkPart(device AS String, partnum AS Integer, size AS Long) AS Boolean
'Create a partition using fdisk. use size=0 to use fdisk's defaults (fill unfartitioned space with new partition)

DIM $fdisk_proc AS Process
DIM partsize AS String


'Check is the partition already exists:
IF Exist(global.installDrive & partnum) THEN
RETURN FALSE
ENDIF

IF size = 0 THEN
partsize = ""
ELSE
partsize = "+" & (size * 1024) & "K"
ENDIF

SHELL "fdisk " & device FOR WRITE AS "$fdisk_proc"

PRINT #$fdisk_proc, "n";
PRINT #$fdisk_proc, "p";
PRINT #$fdisk_proc, partnum;
PRINT #$fdisk_proc, "";
PRINT #$fdisk_proc, partsize;
WAIT 0.5
PRINT #$fdisk_proc, "w";

'Make sure it was created
IF Exist(global.installDrive & partnum) = FALSE THEN
RETURN FALSE
ELSE
RETURN TRUE
ENDIF


END




' PUBLIC SUB BootMngrSet()
' ' This must determine:
Expand Down
3 changes: 3 additions & 0 deletions Global.class
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ STATIC PUBLIC enumLILOMODE AS Long 'Boot manager installation.
' 1 = VL Boot Sector
' 2 = Floppy diskette
' 3 = Do not install
STATIC PUBLIC enumSTAGE AS Integer 'Installation stage
'0 = First stage (partitioning, package installation)
'1 = Second stage (hardware config, user management)

'System memory declarations:
STATIC PUBLIC SysMemory AS Integer
Expand Down
58 changes: 32 additions & 26 deletions Utils.module
Original file line number Diff line number Diff line change
Expand Up @@ -222,33 +222,39 @@ OPEN Global.SOURCE & "veclinux/SETUP.CONF" FOR READ AS #hConfFile
' CONF1='required/vlconfig2.tlz:17613:Base system (config Files)'

IF InStr(sLine, "BULK") OR InStr(sLine, "CONF") THEN
vPKG.PkgName = Mid(Left(sLine, InStr(sLine, ":") - 1), InStr(sLine, "/") + 1)
vPKG.PkgCategory = Mid(Left(sLine, InStr(sLine, "/") - 1), InStr(sLine, "'") + 1)
vPKG.PkgComment = Mid(Left(sLine, RInStr(sLine, "'") - 1), RInStr(sLine, ":") + 1)
vPKG.PkgPath = Global.SOURCE & "veclinux/" & vPKG.PkgCategory & "/" & vPKG.PkgName
vPKG.PkgSize = Val(Mid(Left(sLine, RInStr(sLine, ":") - 1), InStr(sLine, ":") + 1)) * 1024
Global.PkgTotalSize = Global.PkgTotalSize + vPKG.PkgSize
vPKG.Selected = TRUE
vPKG.Name = Mid(Left(sLine, InStr(sLine, ":") - 1), InStr(sLine, "/") + 1)
vPKG.Category = Mid(Left(sLine, InStr(sLine, "/") - 1), InStr(sLine, "'") + 1)
vPKG.Comment = Mid(Left(sLine, RInStr(sLine, "'") - 1), RInStr(sLine, ":") + 1)
vPKG.Path = Global.SOURCE & "veclinux/" & vPKG.Category & "/" & vPKG.Name
vPKG.UncompSize = Val(Mid(Left(sLine, RInStr(sLine, ":") - 1), InStr(sLine, ":") + 1)) * 1024
Global.PkgTotalSize = Global.PkgTotalSize + vPKG.UncompSize
Global.PackageInfo.Push(vPKG)
ENDIF
WEND
CLOSE #hConfFile

'Parse the "extra" packages
'To see what the PACKAGES.TXT file looks like, visit one of the
'VL repositories (eg: http://vectorlinux.osuosl.org/veclinux-5.8/packages)
'or mount a VL installation CD and take a look inside.

OPEN Global.SOURCE & "packages/PACKAGES.TXT" FOR READ AS #hConfFile
vPKG = NEW cPackageInfo
WHILE NOT Eof(hConfFile)
LINE INPUT #hConfFile, sLine

vPKG.PkgCategory = "extra"
vPKG.PkgComment = ""
vPKG.Selected = TRUE
vPKG.Category = "extra"
vPKG.Comment = ""

IF InStr(sLine, "PACKAGE NAME") THEN
vPKG.PkgName = Trim(Mid(sLine, InStr(sLine, ":") + 1))
vPKG.Name = Trim(Mid(sLine, InStr(sLine, ":") + 1))
ELSE IF InStr(sLine, "LOCATION") THEN
vPKG.PkgPath = Global.SOURCE & "packages/" & Trim(Mid(sLine, InStr(sLine, "/") + 1)) & "/" & vPKG.PkgName
vPKG.Path = Global.SOURCE & "packages/" & Trim(Mid(sLine, InStr(sLine, "/") + 1)) & "/" & vPKG.Name
ELSE IF InStr(sLine, "SIZE (uncompressed)") THEN
vPKG.PkgSize = Val(Trim$(Mid(Left(sLine, RInStr(sLine, "K") - 1), InStr(sLine, ":") + 1))) * 1024
Global.PkgTotalSize = Global.PkgTotalSize + vPKG.PkgSize
vPKG.UncompSize = Val(Trim$(Mid(Left(sLine, RInStr(sLine, "K") - 1), InStr(sLine, ":") + 1))) * 1024
Global.PkgTotalSize = Global.PkgTotalSize + vPKG.UncompSize
ELSE IF Trim(sLine) = "" THEN 'An empty line marks the end of the package info, so push the data before moving on
Global.PackageInfo.Push(vPKG)
vPKG = NEW cPackageInfo
Expand All @@ -259,28 +265,28 @@ CLOSE #hConfFile

'For debugging
' FOR i = 0 TO Global.PackageInfo.Max
' PRINT Global.PackageInfo[i].PkgName
' PRINT Global.PackageInfo[i].PkgCategory
' PRINT Global.PackageInfo[i].PkgComment
' PRINT Global.PackageInfo[i].PkgPath
' PRINT Global.PackageInfo[i].PkgSize
' PRINT Global.PackageInfo[i].Name
' PRINT Global.PackageInfo[i].Category
' PRINT Global.PackageInfo[i].Comment
' PRINT Global.PackageInfo[i].Path
' PRINT Global.PackageInfo[i].Size
' PRINT "-----"
' NEXT




END

PUBLIC SUB DoAutoInstall(txtlabel AS TextLabel) 'the textlabel indicates where information needs to be written to


PUBLIC SUB DestroyAllPartitions(dev AS String)
'THIS WILL DELETE ALL THE PARTITIONS ON A SELECTED DRIVE!
DIM iPart AS Integer
txtlabel.Text &= "<br>Erasing partition table on " & global.installDrive & "..."
IF Functions.ErasePartTable(global.installDrive) = TRUE THEN
txtlabel.Text &= "<b><font color=00CC00>OK</font></b>"
ELSE
txtlabel.Text &= "<b><font color=FF0000>FAILED</font></b>"
RETURN
ENDIF

FOR iPart = 1 TO Global.PartInfo.Length
SHELL "parted " & dev & " rm " & iPart
NEXT


END

Expand Down
13 changes: 6 additions & 7 deletions cPackageInfo.class
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
' Gambas class file

PUBLIC PkgName AS String
PUBLIC PkgCategory AS String 'catagories can be required, optional, and extra
PUBLIC PkgComment AS String 'A comment on the package
PUBLIC PkgPath AS String ' the install path for the package
PUBLIC PkgSize AS Long 'Individual package size
PUBLIC Name AS String
PUBLIC Category AS String 'catagories can be required, optional, and extra
PUBLIC Comment AS String 'A comment on the package
PUBLIC Path AS String ' the install path for the package
PUBLIC UncompSize AS Long 'Individual package size, uncompressed!
PUBLIC Selected AS Boolean 'This indicates if the package [i] was marked for installation. The value is always TRUE unless manually changed to FALSE

'This is in the wrong place?! moved to Global for now....
'PUBLIC TotalSize AS Long 'Total size of all the packages when uncompressed
6 changes: 6 additions & 0 deletions frmConfig.class
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ PUBLIC SUB Button6_Click() 'Config 2:

END


PUBLIC SUB TextLabel1_MouseDown()



END
51 changes: 25 additions & 26 deletions frmGO.class
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PUBLIC SUB Form_Show()
frmMain.btnMain6.SetFocus

' set some background colours:
TextLabel1.BackColor = Global.HTMLBG
goTxtLabel.BackColor = Global.HTMLBG
lblSubTitle.BackColor = Global.LogoBG
Panel1.BackColor = Global.LogoBG

Expand All @@ -17,42 +17,41 @@ END
PUBLIC SUB Form_Resize()

' Resize the html message:
TextLabel1.Width = ScrollView1.ClientWidth
TextLabel1.Adjust
goTxtLabel.Width = ScrollView1.ClientWidth
goTxtLabel.Adjust

' 4 debug:
ProgressBar1.Value = 0.31

END


PUBLIC SUB btnStartStop_Click()
PUBLIC SUB btnStart_Click()

goTxtLabel.Text = "<center><h3><b>Starting phase one</b></h3></center>"

SELECT btnStartStop.Text
IF Global.enumINSTMODE = 0 THEN 'Do whatever is necessary for the automatic installation

CASE "Begin installation"
SELECT CASE Message.Warning("All partitions on " & Global.installDrive & " will be destroyed!" & gb.NewLine & "Are you sure you want to continue?", "Yes", "No")
CASE 1
btnStart.Hide
Form_Resize()
lblSubTitle.Text = "Installing"
Utils.DoAutoInstall(frmGO.goTxtLabel)
CASE 2
frmMain.btnMain1_Click()
END SELECT
ENDIF

IF Global.enumINSTMODE = 0 THEN 'Do whatever is necessary for the automatic installation

SELECT CASE Message.Warning("All partitions on " & Global.installDrive & " will be destroyed!" & gb.NewLine & "Are you sure you want to continue?", "Yes", "No")
CASE 1
btnStartStop.Text = "Cancel"
Form_Resize()
lblSubTitle.Text = "Installing"
CASE 2
frmMain.btnMain1_Click()

END SELECT
ENDIF

CASE "Cancel"
SELECT CASE Message.Question("Are you sure you want to abort the installtion?", "Yes", "No")
CASE 1
QUIT
END SELECT

END SELECT
' CASE "Cancel"
' SELECT CASE Message.Question("Are you sure you want to abort the installtion?", "Yes", "No")
' CASE 1
' QUIT
' END SELECT
'
' END SELECT


END


14 changes: 9 additions & 5 deletions frmGO.form
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Gambas Form File 2.0

{ Form Form
MoveScaled(29,25.3333,90.5,64.3333)
MoveScaled(29,25.1667,90.5,64.1667)
Font = Font["Luxi Sans"]
Background = &HFFFFFF&
Text = ("")
Expand All @@ -12,13 +12,13 @@
Font = Font["Luxi Sans"]
Expand = True
{ ScrollView1 ScrollView
MoveScaled(2,2,58,50)
MoveScaled(0,0,58,50)
Font = Font["Luxi Sans,16"]
Background = &HDFFFFF&
Expand = True
ScrollBar = Scroll.Vertical
{ TextLabel1 TextLabel
MoveScaled(0,0,58,39)
{ goTxtLabel TextLabel
MoveScaled(2,1,58,39)
Font = Font["Luxi Sans,14"]
Background = &HDFFFFF&
Padding = 10
Expand Down Expand Up @@ -48,8 +48,12 @@
Background = &H0055FF&
Expand = True
Border = Border.Etched
{ tasksTxtLabel TextLabel
MoveScaled(1,3,27,40)
Text = ("\n")
}
}
{ btnStartStop Button
{ btnStart Button
MoveScaled(4,54,21,4)
Text = ("Begin installation")
}
Expand Down

0 comments on commit 1f92eba

Please sign in to comment.