From 1f92ebab0563c65b1f336ad2a2470aa91f07dad2 Mon Sep 17 00:00:00 2001 From: easuter Date: Mon, 7 Jan 2008 00:43:46 +0000 Subject: [PATCH] Changes: - 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. --- .lang/.pot | 8 +++++-- .lang/frmGO.pot | 8 +++++-- .project | 2 +- Functions.module | 55 +++++++++++++++++++++++++++++++++++++++++++ Global.class | 3 +++ Utils.module | 58 +++++++++++++++++++++++++--------------------- cPackageInfo.class | 13 +++++------ frmConfig.class | 6 +++++ frmGO.class | 51 ++++++++++++++++++++-------------------- frmGO.form | 14 +++++++---- 10 files changed, 149 insertions(+), 69 deletions(-) diff --git a/.lang/.pot b/.lang/.pot index 8a50cfe..3273f52 100644 --- a/.lang/.pot +++ b/.lang/.pot @@ -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 "" diff --git a/.lang/frmGO.pot b/.lang/frmGO.pot index 9f78c26..29a3e98 100644 --- a/.lang/frmGO.pot +++ b/.lang/frmGO.pot @@ -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 "" diff --git a/.project b/.project index aa58dd9..955ecf1 100644 --- a/.project +++ b/.project @@ -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 diff --git a/Functions.module b/Functions.module index 498991e..afa83f3 100644 --- a/Functions.module +++ b/Functions.module @@ -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: diff --git a/Global.class b/Global.class index 18fea53..87022cb 100644 --- a/Global.class +++ b/Global.class @@ -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 diff --git a/Utils.module b/Utils.module index 172fb15..cecbb25 100644 --- a/Utils.module +++ b/Utils.module @@ -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 @@ -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 &= "
Erasing partition table on " & global.installDrive & "..." +IF Functions.ErasePartTable(global.installDrive) = TRUE THEN + txtlabel.Text &= "OK" +ELSE + txtlabel.Text &= "FAILED" + RETURN +ENDIF -FOR iPart = 1 TO Global.PartInfo.Length - SHELL "parted " & dev & " rm " & iPart -NEXT + END diff --git a/cPackageInfo.class b/cPackageInfo.class index a2b20b6..a59769b 100644 --- a/cPackageInfo.class +++ b/cPackageInfo.class @@ -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 diff --git a/frmConfig.class b/frmConfig.class index b4d2a28..a912753 100644 --- a/frmConfig.class +++ b/frmConfig.class @@ -73,3 +73,9 @@ PUBLIC SUB Button6_Click() 'Config 2: END + +PUBLIC SUB TextLabel1_MouseDown() + + + +END diff --git a/frmGO.class b/frmGO.class index 6edfce6..a2c1c70 100644 --- a/frmGO.class +++ b/frmGO.class @@ -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 @@ -17,8 +17,8 @@ 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 @@ -26,33 +26,32 @@ ProgressBar1.Value = 0.31 END -PUBLIC SUB btnStartStop_Click() +PUBLIC SUB btnStart_Click() +goTxtLabel.Text = "

Starting phase one

" -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 + + diff --git a/frmGO.form b/frmGO.form index 5d3380c..b6ab50c 100644 --- a/frmGO.form +++ b/frmGO.form @@ -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 = ("") @@ -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 @@ -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") }